[OSM-dev] Osmosis Replication Statistics
Dave Stubbs
osm.list at randomjunk.co.uk
Thu Aug 30 16:20:52 BST 2007
On 29/08/2007, Brett Henderson <brett at bretth.com> wrote:
>
> 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
> ...
You should be able to use the java.awt.geom.GeneralPath class which is ...
errm... more general (and uses floats). I don't know how this would impact
on performance though. The java.awt.geom.Area may also be of interest for
nice cag functionality.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070830/78ae6254/attachment.html>
More information about the dev
mailing list