[OSM-dev] Osmosis Replication Statistics

Brett Henderson brett at bretth.com
Wed Aug 29 23:35:58 BST 2007


David Siegel wrote:
> On 29.08.2007, at 09:41, Martijn van Oosterhout wrote:
>
>   
>> On 8/29/07, Brett Henderson <brett at bretth.com> wrote:
>>     
>>> There is already a --bounding-box filter task.  Presumably you're
>>> looking for something more accurate than a square ...  If so, I have
>>> some research to do, I don't know how to figure out if a point fits
>>> inside a shape.  Hopefully the algorithm isn't too difficult.
>>>       
>> Don't write code you don't need to, see:
>> http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Polygon.html
>> You can create a Polygon object and then call the contains() function.
>>
>>     
>
> I agree with Martijn. Don't write it yourself. AFAIK finding points  
> in a general polygon (not convex and with holes) is absolutly non- 
> trivial. It becomes a lot easier for convex polygons without holes  
> but it still requires very clever data structures and algorithms to  
> get it efficient. If you find that awt/Polygon is too slow you might  
> want to take a look at the Java Topology Suite:
>
> http://www.jump-project.org/project.php?PID=JTS&SID=OVER
>   
Bugger, I was getting excited about writing this :-)  I was planning on 
drawing a line from a point to edge of the world and counting the number 
of edges crossed where odd=inside the polygon, even=outside.  But you're 
both right, why re-invent it and get it wrong.  Another guy from work 
with some background in geo-spatial apps suggested the java.awt.Polygon 
api as well.  The only issue is that a polygon is defined by integer 
coordinates, not doubles.  I guess I could fudge it by multiplying 
lat/lon by a fixed constant and losing some precision but it's not ideal ...

The above library at first glance also looks great, it's LGPL so 
presumably there's no issues there.  While I've been a bit slack on the 
licencing front, the intent is to licence osmosis under GPL (probably v3).






More information about the dev mailing list