问题列表 - 第32117页

将lat/lon转换为像素并返回

我在我的应用程序中使用谷歌地图,并且我有一个带有lat/lon值的数据库的网络服务器.我想在地图上标记它们,但如果它们在彼此的某个像素距离内,我也想将它们聚集在一起.

我想如果我从数据库中检索所有的点,我应该可以做这样的事情(伪代码):

clusters[];
while(count(points)) {
    cluster[];
    point = points.pop();
    boundingbox = pixelsToBB(point, pixeldistance, zoomlevel);
    query = "select * from database where lat > boundingbox.minlat 
             and lat < boundingbox.maxlat and lng > boundingbox.minlng
             and lng < boundingbox.maxlng";
    for (result in executedquery) {
        cluster[] += result;
        points.remove(result);
    }
    clusters[] += cluster;
}

pixelsToBB(point, distance, zoomlevel) {
    center = convertXY(point, zoomlevel);
    maxlng = convertToLng(center.X, distance, zoomlevel);
    minlng = convertToLng(center.X, -distance, zoomlevel);
    minlat = convertToLat(center.Y, -distance, zoomlevel);
    maxlat = convertToLat(center.Y, distance, zoomlevel);
    return boundingbox(maxlng, …
Run Code Online (Sandbox Code Playgroud)

google-maps zoom pixel coordinates

15
推荐指数
2
解决办法
2万
查看次数

如何最好地向管理部门提供单元测试?

我正准备向管理人员介绍单元测试.我的团队多年来一直在编写单元测试,但该公司的其他领域似乎很难采用它.我可以让开发人员对此感到兴奋,但如果没有管理层的支持,它就不会成为标准.

你们有什么建议如何最好地处理这方面的管理?你曾经尝试过哪些有用的东西?什么东西不起作用?

unit-testing presentation

10
推荐指数
1
解决办法
1965
查看次数

如何将.html附加到cakephp中的所有网址?

我在我的一个项目中使用cakephp,我的客户希望站点URL以.html而不是通常友好的URL结尾.我想知道在cakephp中是否可以通过它的任何路由技术来实现.请帮忙.

php routing cakephp url-rewriting

5
推荐指数
3
解决办法
4775
查看次数

检测/拦截<img>插入DOM

我们正在使用此分析公司提供的第三方分析报告脚本.它将1x1像素图像添加到DOM中,并在图像的URL中报告数据.

<img>在浏览器请求图像之前,有没有办法监视DOM并拦截此元素并更改其"src"属性?

我知道,这听起来真是个奇怪的事情,但我们想要破解这个报告脚本(脚本是封闭的).

javascript jquery dom

6
推荐指数
1
解决办法
2311
查看次数

帮助 - 使用PHP插入MySQL数据库

我正在尝试允许用户注册我正在创建的网站,但是我使用的代码不起作用,我需要你的帮助.

$registerquery = mysql_query("INSERT INTO users (Username, Password, EmailAddress) VALUES('".$username."', '".$password."', '".$email."'");
Run Code Online (Sandbox Code Playgroud)

数据库: alt text http://img248.imageshack.us/img248/2457/screenshot20100805at001.png

我只想在此阶段存储用户名,密码和电子邮件地址.

php mysql database

0
推荐指数
1
解决办法
819
查看次数

Apache POI:替换段落文本

我正在使用Apache POI从模板生成docx文件.似乎没有一种明显的方法来替换段落中的所有文本,文档很少.现在我能够通过循环遍历段落读取文档,然后循环遍历每个段落的运行,然后循环遍历每个运行的文本......这非常有效,我可以在运行中替换文本的内容,但是我的模板占位符(例如:<>)可能会分成几个运行,这使匹配和替换变得非常复杂.有没有办法设置XWPFParagraph的内容?或者至少是一种方法来消除段落中的所有运行并创建自己的运行?

这是我到目前为止:

    public static void main(String[] args) {

    InputStream fs = null;
    try {
        fs = new FileInputStream("C:\\sample1.docx");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    XWPFDocument doc = null;
    try {
        doc = new XWPFDocument(fs);
    } catch (IOException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < doc.getParagraphs().length; i++) {
        XWPFParagraph paragraph = doc.getParagraphs()[i];
        paragraph.getCTP().getRArray().

        // This will output the paragraph's contents.
        System.out.println(paragraph.getParagraphText());

        for (int j = 0; j < paragraph.getCTP().getRArray().length; j++) {
            CTR run = paragraph.getCTP().getRArray()[j]; …
Run Code Online (Sandbox Code Playgroud)

apache ms-word apache-poi

2
推荐指数
1
解决办法
9794
查看次数

相互递归的类

如何在C++中实现相互递归的类?就像是:

/*
 * Recursion.h
 *
 */

#ifndef RECURSION_H_
#define RECURSION_H_

class Class1
{
  Class2* Class2_ptr;
public:
  void Class1_method()
  {
      //...
      (*Class2_ptr).Class2_method();
      //...
  }
};

class Class2
{
    Class1* Class1_ptr;
public:
    void Class2_method()
    {
        //...
        (*Class1_ptr).Class1_method();
        //...
    };
};


#endif /* RECURSION_H_ */
Run Code Online (Sandbox Code Playgroud)

c++ recursion scope class mutual-recursion

7
推荐指数
1
解决办法
5293
查看次数

Python的join()不会加入我对象的字符串表示(__str__)

我不确定我在这里做错了什么:

>>> class Stringy(object):
...     def __str__(self):
...             return "taco"
...     def __repr__(self):
...             return "taco"
... 
>>> lunch = Stringy()
>>> lunch
taco
>>> str(lunch)
'taco'
>>> '-'.join(('carnitas',lunch))
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
TypeError: sequence item 1: expected string, Stringy found
Run Code Online (Sandbox Code Playgroud)

鉴于我__str__()在Stringy对象中包含了该方法,不应该join()将午餐看作字符串?

python

5
推荐指数
2
解决办法
2073
查看次数

如何将长度为m的n个数组转换为长度为n的m个数组?

我想转换这个:

[ [1, 2, 3, 4],
  [5, 6, 7, 8],
  [9, 10, 11, 12] ]
Run Code Online (Sandbox Code Playgroud)

进入这个:

[ [1, 5, 9],
  [2, 6, 10],
  [3, 7, 11],
  [4, 8, 12] ]
Run Code Online (Sandbox Code Playgroud)

是否有内置函数来执行此操作?如果不是,那么更短更清洁的方式是什么?

ruby

3
推荐指数
1
解决办法
79
查看次数

为什么以下程序会出错?

为什么以下程序会发出警告?

注意:很明显,向需要const指针的函数发送普通指针不会发出任何警告.

#include <stdio.h>
void sam(const char **p) { }
int main(int argc, char **argv)
{
    sam(argv);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误,

In function `int main(int, char **)':
passing `char **' as argument 1 of `sam(const char **)' 
adds cv-quals without intervening `const'
Run Code Online (Sandbox Code Playgroud)

c c++ pointers const command-line-arguments

3
推荐指数
1
解决办法
225
查看次数