Ticket #180 (closed defect: wontfix)

Opened 4 years ago

Last modified 3 years ago

getting bad Intersect, contains with polygon vs. linearring

Reported by: zstauber Owned by: pramsey
Priority: minor Milestone: 3.2.0
Component: C API Version: 3.0.0
Severity: Unassigned Keywords:
Cc:

Description

I'm doing a spatial query between two rectangles and getting the same answer for GEOSIntersects as GEOSDisjoint, which have to be opposites. Also, GEOSContains is returning an incorrect value. It only happens when one is a linearring (geometry below). If I make both polygons, they work, but it takes about 20 times as long to do the GEOSContains query that way.

I'm writing a C++ program against FWTools 2.1.0 with GDAL 1.6.0dev on Windows 32 bit. It's GEOS 3.0.0 I believe.

I load up the following rectangular polygon from a shapefile into a GEOSGeom:

geom1 =

coord 1=344128.12322340254 3859266.871856628

coord 2=344129.10421630088 3859266.871856628

coord 3=344129.12308154907 3859263.8439843189

coord 4=344128.08549290895 3859263.8628495652

coord 5=344128.12322340254 3859266.871856628

Then I construct this rectangle by making a 5 point coordseq, which I turn into a linearring

geom2 =

coord 1=344075.605 3859277.36

coord 2=344138.605 3859277.36

coord 3=344138.605 3859250.36

coord 4=344075.605 3859250.36

coord 5=344075.605 3859277.36

So geom1 is a GEOSGeom polygon and geom2 is a GEOSGeom linearring.

If I do:

GEOSIntersects(geom1, geom2) I get 0.

But if I do:

GEOSDisjoint(geom1, geom2) I also get 0, which is supposed to be the opposite of intersect.

If I do:

GEOSContains(geom1, geom2) it returns 1 which is also wrong (geom2 actually contains geom1).

I believe the disjoint is correct and intersects and contains are wrong.

If I make them BOTH into polygons, then it all comes out right:

GEOSContains(geom1, geom2) returns 0

GEOSDisjoint(geom1, geom2) returns 0

GEOSIntersects(geom1, geom2) returns 1

and these are all correct.

Like I said though GEOSContains with the poly on poly takes about 20 times as long, and since a polygon can contain a closed linearring without trouble (just not the other way around) I was hoping to use it this way.

Change History

Changed 3 years ago by pramsey

  • milestone changed from 3.0.1 to 3.2.0

Changed 3 years ago by pramsey

  • owner set to pramsey

Will attempt to reproduce.

Changed 3 years ago by pramsey

You talk about linearring, which is not something GEOS expects to instantiate. Do you mean linestring? What happens when you use linestring?

Changed 3 years ago by pramsey

  • status changed from new to closed
  • resolution set to wontfix

Some example code would be good, re-open at that point.

Note: See TracTickets for help on using tickets.