我不太明白谷歌地图的google.maps.LatLngBounds.isEmpty功能如何运作.是什么定义LatLngBounds为空?难道LatLngBounds不知为什么在地图上所有的向量和点的记录和检查,看看是否有居住在边界框内?
我对此感到好奇,因为我正在开发OpenLayers和Google Maps之间的接口,并且没有对象的isEmpty方法OpenLayers.Bounds.
我正在编写一个从数字中提取小数的函数.忽略异常及其语法,我正在研究2.5.2(默认的Leopard版本).我的功能尚未处理0.我的问题是,该函数产生具有某些数字的随机错误,我不明白其中的原因.我将在代码后发布错误读数.
功能:
def extractDecimals(num):
try:
if(num > int(num)):
decimals = num - int(num)
while(decimals > int(decimals)):
print 'decimal: ' + str(decimals)
print 'int: ' + str(int(decimals))
decimals *= 10
decimals = int(decimals)
return decimals
else:
raise DecimalError(num)
except DecimalError, e:
e.printErrorMessage()
Run Code Online (Sandbox Code Playgroud)
例外类:
class DecimalError(Exception):
def __init__(self, value):
self.value = value
def printErrorMessage(self):
print 'The number, ' + str(self.value) + ', is not a decimal.'
Run Code Online (Sandbox Code Playgroud)
输入数字1.988时输出错误:
decimal: 0.988
int: 0
decimal: 9.88
int: 9
decimal: 98.8
int: 98
decimal: 988.0
int: …
我在C中编写了自己的链表实现,它可以很好地存储值,但每当我尝试运行列表时,我都会遇到分段错误.我不确定为什么会出现这个问题,而且我花了相当多的时间试图自己完成程序,但无济于事.你能帮我找一下错误的原因吗?这是我的代码:
#include <stdlib.h>
#include <stdio.h>
// A double linkd list node
struct list
{
struct list * prev;
int data;
struct list * next;
};
typedef struct list node;
node *head = NULL;
node *tail = NULL;
// Adds an item to the end of the list
void append(int item);
// Adds an item at the given index
int insert(int item, int index);
// Removes and returns an item at the specified index
int remove_node(int index);
// Gets an item …Run Code Online (Sandbox Code Playgroud) 对于Emacs CC模式,我试图使用"bsd"样式,但要使所有行默认为缩进,增量为4而不是8.在我的.emacs文件中,我已经放置:
(setq c-default-style "bsd"
c-basic-offset 4)
(setq c-indent-level 4)
Run Code Online (Sandbox Code Playgroud)
但所有行仍然缩进到8个空格.我无法真正找到问题所在.我正在运行GNU Emacs 23.3.1.
c ×1
cc-mode ×1
elisp ×1
emacs ×1
google-maps ×1
linked-list ×1
openlayers ×1
python ×1
python-2.5 ×1