Hello Jason,

If the points are guaranteed to form a closed polygon, as assuming
they are in correct vertex order, you can do something like this...

double[] x = ...
double[] y = ...

GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null);
Coodinate[] coords = new Coordinate[ x.length + 1 ];
for (int i = 0; i < x.length; i++) {
    coords[i] = new Coordinate(x[i], y[i]);
}
// repeat starting coord to close the linear ring
coords[ x.length - 1 ] = new Coordinate(x[0], y[0]);

Polygon poly = gf.createPolygon(coords, null);

If you have a lot of features to test, you can do a quick first pass
by testing them against the bounding rectangle of the polygon, and
then just testing the resulting subset against for inclusion in the
polygon.

If your input points form a cloud rather than polygon vertices you
could create a convex or concave hull of the cloud. Let me know if
that case applies to your data.

Hope this helps.

Michael

On 4 June 2011 01:21, Jason Ferguson <[email protected]> wrote:
> I'm sure this is a FAQ, but for some reason my proxy has blocked
> docs.geotools.org and I can't get it fixed immediately.
>
> I have a class called BorderPoint, which has latitude and longitude fields
> stored as doubles (would rather use BigDecimal, but thats not an option). I
> also have a List of Feature objects, which I need to check to see if they
> are in the polygon defined by the coordinates in BorderPoint.
>
> I think what I need to do is create a Geometry or Polygon from the
> coordinates defined in a List of BorderPoints, the use the contains method
> to check the coordinates in Feature against that Geometry or Polygon.
> However, I don't know how to create that Geometry or Polygon from simple
> doubles.
>
> Like I said, I can't get to the docs at the moment, so any help would be
> appreciated.
>
> Jason
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Discover what all the cheering's about.
> Get your free trial download today.
> http://p.sf.net/sfu/quest-dev2dev2
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to