Re: [OpenMap Users] OMPoly and getShape woes

From: Carsten Ø. Madsen <com_at_navicon.dk>
Date: Tue, 20 Dec 2005 07:13:35 +0100

Hi

You have to convert the lat,lon to x,y via the forward method as
contains operates in x,y space. Something like the following:

LatLonPoint currentPos = new LatLonPoint(points[0], points[1], true);
Mercator proj = new Mercator(currentPos, 65000f, 1024, 768);
Point xyTargetPos = proj.forward(ll);
// prep for spatial analysis
OMPoly polyCopy = new OMPoly();
polyCopy.setLineType(OMGraphicConstants.LINETYPE_GREATCIRCLE);
polyCopy.setLocation(poly.getLatLonArray(), OMGraphic.RADIANS);
polyCopy.setDoShapes(true);
polyCopy.generate(proj);
if (polyCopy.getShape().contains(xyTargetPos)) {...


regards
/carsten


Lepkowski, Thomas M., CTR, OSD-PA&E wrote:

> */Classification: UNCLASSIFIED/*
>
> Hello all,
>
> I have two things:
>
> 1) a valid and displayed OMGraphic with LatLonPoint (of course).
> 2) a valid and displayed OMPoly ( in the form of ESRIPolygon ).
>
> The OMGraphic point is inside the OMPoly. It's like a town inside a
> state. The state is represented by the OMPoly and the town is a
> simple OMGraphic. I want to show programmatically that the town is
> inside the state.
>
> My following code is not printing "true":
>
> <CODE>
>
> // some code bringing me here
> // OMPoly is on map
>
> EsriPolygon ep = (EsriPolygon) omg;
>
> ep.setDoShapes( true );
> ep.generate( projection );
>
> GeneralPath gp = ep.getShape();
>
>
> // latLonPoint is inside the polygon
> // THIS PRINTS "false" EXPECT IT TO PRINT "true"
> System.out.println( "Inside polygon: " + gp.contains(
> latLonPoint.getLongitude(), latLonPoint.getLatitude() );
>
> </CODE>
>
> I expect gp.contains( ) wants another representation of x,y but I
> don't know what.
>
> Any help is greatly appreciated.
>
>
> -Tom
>


--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Dec 20 2005 - 01:14:40 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT