- 浏览: 96075 次
- 性别:
- 来自: HK
文章分类
最新评论
-
Mr.小裤裤:
谢谢,
我生日过的很快乐,
o(∩_∩)o...
system badimageformatexception and its partial solution
link: http://paulbourke.net/geometry/insidepoly/
here is the python code snippet:
def point_inside_polygon(cls, lon,lat, coors):
n = len(coors)
inside = False
p1x,p1y = coors[0]
for i in xrange(n+1):
p2x,p2y = coors[i % n]
if lat > min(p1y,p2y):
if lat <= max(p1y,p2y):
if lon <= max(p1x,p2x):
if p1y != p2y:
xinters = (lat-p1y)*(p2x-p1x)/(p2y-p1y)+p1x
if p1x == p2x or lon <= xinters:
inside = not inside
p1x,p1y = p2x,p2y
return inside
the following is a cython version:
cpdef point_inside_polygon(double x,double y,list poly):
cdef int n = len(poly)
inside = False
cdef int i
cdef double p1x,p1y,p2x,p2y,xinters
p1x,p1y = poly[0]
for i in xrange(n+1):
p2x,p2y = poly[i % n]
if y > min(p1y,p2y):
if y <= max(p1y,p2y):
if x <= max(p1x,p2x):
if p1y != p2y:
xinters = (y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x
if p1x == p2x or x <= xinters:
inside = not inside
p1x,p1y = p2x,p2y
return inside
the cython version is 10x faster that the first.
发表评论
-
static building lxml
2014-08-13 19:15 758well it is not really straig ... -
build pyrun/python from source
2014-08-01 19:39 539quite easy on ubuntu. 1: ... -
build apsw manually
2014-01-06 01:22 507download sqlite sources and co ... -
python, vs 2010 & manifest problem
2013-11-02 13:33 587It looks like python com ... -
numpy 1.7.0 fails with cx_freeze 4.3.1
2013-02-24 16:13 825It is a work around: find ... -
build psycopg2 on windows with mingw64
2013-01-03 20:36 932caution: version match problem. ... -
pypy的一个测试
2012-06-09 16:15 1574pypy-1.9 昨天已经发布,据称性能又有所提高。 ... -
a naive way to use dictcursor of psycopg2 with twisted adbapi
2012-05-03 03:14 1119make a new file called fakedb.p ... -
build psycopg2 on windows with vs
2012-05-02 02:16 832prerequisites: 1: postgresq ... -
twisted iocp reactor is still buggy---it was fixed on 23/10/2012
2012-03-19 14:53 1209I reported a bug on last wee ... -
One way to speed up Pb invoke.
2012-03-14 21:31 810Pb (stands for Perspecti ... -
change buffer size in order to send chunks data in ampoule
2011-12-03 16:08 762ampoule use name pipe to commun ... -
which one is thread safe?
2011-09-21 12:31 875quote: It's not so much tha ... -
cython的另类用途
2011-08-04 02:30 1514都知道py虽然方便但是却有个不是问题的问题:就是发布时的二进制 ... -
instructions for installing some python's pkgs on ubuntu
2011-07-23 00:54 755make sure python-dev, gcc and o ... -
a tedious way to build the latest pytables
2011-07-17 03:33 687pyTables is a great product. It ... -
再谈twisted
2011-06-29 17:03 1398现在我手头用的是11.0。 很好。没什么很大的问题,原来的版本 ... -
cython的效果
2011-06-29 00:29 769我有个用py写的 crc-ccitt的验证程序(实现效率并不高 ... -
the simplest way to use vs 2010 with python
2011-06-03 15:48 636edit py/Lib/distutils/msvc9comp ... -
speeding up python
2011-06-03 15:36 842python确实是十分慢的语 ...
相关推荐
Determining the required stack sizes for a software project is a crucial part of the development process. The developer aims to create a stable application, while not wasting resources. This ...
gmw 3205 Determining the Resistance to Odor Propagation of Interior Materials.pdf
Anyone using this document should rely on his or her own independent judgment or, as appropriate, seek the advice of a competent professional in determining the exercise of reasonable care in any ...
machine can be “reduced” to the problem of determining whether a given propositional formula is a tautology. Here “reduced” means, roughly speaking, that the first problem can be solved ...
discussed, concentrating on the problem of determining the parameters of the actuator modules e.g., the hydraulic valves. Some parts could not be used from existing Dymola R libraries, in those cases,...
If there is no clustered index, there is a sysindexes row for the table with an indid value of 0, and that row will keep track of the address of the first IAM for the table. The IAM is a giant bitmap...
based on a time of arrival analysis and the use of the sequential difference histogram (SDIF) for determining the pulse repetition interval (PRI). The optimal detection threshold in the SDIF histogram...
ganalysis - the analysis and classi¯cation method of determining if an audio medium is carrying hidden information. In this paper, we propose a novel distortion metric based on Hausdor® distance. ...
Watershed planners need a tool for determining width of filter strips that is accurate enough for developing cost-effective site designs and easy enough to use for making quick determinations on a ...
MBA投资课程的经典课本 外文版的,直接购买要好几百RMB
Although these are not questions that appear on the actual exam, they convey the principles and concepts that the exam emphasizes and are valuable in determining if you have mastered the information....
The text has been based in part on the designation reports of the New York City Landmarks Preservation Commission. Initially, my assistants and I systematically gathered and catalogued each report. ...
A system simulation model was used to create scene-dependent noise masks that reflect current performance of mobile phone cameras. Stimuli with different overall magnitudes of noise and with varying ...
Solving the process of hysteresis without determining the optimal thresholds
The third edition has three new chapters on unusual topics related to Kalman filtering and other filtering techniques based on the method of least squares.Chapter 17 presents a type of filter known ...
where the method of the field-orientated control has been successfully established in the practice, and on the use of the grid voltage orientated controlled DFIM in the wind power plants. After a ...
described by a 3x3 singular matrix called the essential matrix if images’ internal parameters are known, or the fundamental matrix otherwise. It captures all geometric information contained in two ...
一类混杂系统关于具有分片光滑边界的区域的生存域判别,韩艳丽,高岩,该文研究了一类混杂系统关于由分片光滑函数表示的不等式构成的区域的生存性问题。首先,基于非光滑分析,讨论了连续动态系统的生存�
Determining the length of a string 49 Comparing strings 50 Comparing a string of characters 51 Locating the first instance of a character 52 Locating the index of a character 53 Determining the class ...
For more and more new standards containing patents, the licensing policy of these patents has become the key factor determining whether a standard will be adopted by industry. RAND—the principle of ...