Point in polygon

3 messages Options
Embed this post
Permalink
ezigoing

Point in polygon

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Guys, I have created a vector polygon as follows:

 

var parcel01 = new OpenLayers.Geometry.LinearRing(pointList);

polygonFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Polygon([parcel01]));

vectorLayer.addFeatures([polygonFeature]);

 

I then am parsing a list of external points to include only those that are inside the polygon on the map as vector markers.

 

I have tried the following with no success:

 

If (polygonFeature.intersects(new OpenLayers.Geometry.Point(p[0], p[1]))) {// include code…}

and

If (polygonFeature.containsPoint(new OpenLayers.Geometry.Point(p[0], p[1]))) {// include code…}

 

Where p[0] = x-coords in Sphericalmercator

And p[1] = y-coord in SphericalMercator.

 

The error returned is polygonFeature.intersects is not a function. I can verify that the polygon is being created.

 

Is there something I am missing here? I am using OL version 2.8.

 

Does anyone have a simple example of point-in-polygon working?

 

Cheers,

 

 

Brad Spencer

General Manager

NuMaps

tel: 02 9481 7024

mob: 0404 841 131

www.numaps.com.au

[hidden email]

 

 


_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
helmi03

Re: Point in polygon

Reply Threaded More More options
Print post
Permalink
>>The error returned is polygonFeature.intersects is not a function
have you tried polygonFeature.geometry.intersects() instead?

On Wed, Nov 4, 2009 at 1:45 PM, Brad Spencer <[hidden email]> wrote:

Guys, I have created a vector polygon as follows:

 

var parcel01 = new OpenLayers.Geometry.LinearRing(pointList);

polygonFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Polygon([parcel01]));

vectorLayer.addFeatures([polygonFeature]);

 

I then am parsing a list of external points to include only those that are inside the polygon on the map as vector markers.

 

I have tried the following with no success:

 

If (polygonFeature.intersects(new OpenLayers.Geometry.Point(p[0], p[1]))) {// include code…}

and

If (polygonFeature.containsPoint(new OpenLayers.Geometry.Point(p[0], p[1]))) {// include code…}

 

Where p[0] = x-coords in Sphericalmercator

And p[1] = y-coord in SphericalMercator.

 

The error returned is polygonFeature.intersects is not a function. I can verify that the polygon is being created.

 

Is there something I am missing here? I am using OL version 2.8.

 

Does anyone have a simple example of point-in-polygon working?

 

Cheers,

 

 

Brad Spencer

General Manager

NuMaps

tel: 02 9481 7024

mob: 0404 841 131

www.numaps.com.au

[hidden email]

 

 


_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Eric Lemoine-2-2

Re: Point in polygon

Reply Threaded More More options
Print post
Permalink
In reply to this post by ezigoing
On Wednesday, November 4, 2009, Brad Spencer <[hidden email]> wrote:

>
>
>
>
>
>
>
>
>
>
>
>
>
> Guys, I have created a vector polygon as follows:
>
>
>
> var parcel01 = new
> OpenLayers.Geometry.LinearRing(pointList);
>
> polygonFeature = new OpenLayers.Feature.Vector( new
> OpenLayers.Geometry.Polygon([parcel01]));
>
> vectorLayer.addFeatures([polygonFeature]);
>
>
>
> I then am parsing a list of external points to include only
> those that are inside the polygon on the map as vector markers.
>
>
>
> I have tried the following with no success:
>
>
>
> If (polygonFeature.intersects(new
> OpenLayers.Geometry.Point(p[0], p[1]))) {// include code…}

and polygonFeature.geometry.intersects()?

Cheers,


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users