[postgis-users] contains function with complex polygons

Emily Gouge egouge at refractions.net
Wed Sep 27 14:50:33 PDT 2006


try making the nested hole a separate polygon:

MULTIPOLYGON (((-128.74153099999998 66.42965, -106.554262 32.849587, -130.846486 40.578899, 
-152.378198 61.006418999999994, -128.74153099999998 66.42965)), ((-64.841883 75.565074, -48.866971 
72.139282, -39.750806 62.662659999999995, -27.604758 32.297475999999996, -77.997723 
27.889585999999998, -96.791707 62.14741, -64.841883 75.565074), (-57.793946999999996 70.71189, 
-64.841883 72.710258, -85.985179 63.860305999999994, -70.11599 56.037586999999995, 
-54.035098999999995 59.578098, -57.793946999999996 70.71189), (-41.407126 47.204051, 
-49.688469999999995 39.474706999999995, -34.781974 36.162130999999995, -41.407126 47.204051)), 
((-65.311643 60.434546, -72.82933899999999 60.720017999999996, -76.11817099999999 65.28773, 
-71.419803 67.000626, -64.371867 68.428018, -61.552794999999996 64.431282, -65.311643 60.434546)))

----

select isvalid(geomfromtext('MULTIPOLYGON (((-128.74153099999998 66.42965, -106.554262 32.849587, 
-130.846486 40.578899, -152.378198 61.006418999999994, -128.74153099999998 66.42965)), ((-64.841883 
75.565074, -48.866971 72.139282, -39.750806 62.662659999999995, -27.604758 32.297475999999996, 
-77.997723 27.889585999999998, -96.791707 62.14741, -64.841883 75.565074), (-57.793946999999996 
70.71189, -64.841883 72.710258, -85.985179 63.860305999999994, -70.11599 56.037586999999995, 
-54.035098999999995 59.578098, -57.793946999999996 70.71189), (-41.407126 47.204051, 
-49.688469999999995 39.474706999999995, -34.781974 36.162130999999995, -41.407126 47.204051)), 
((-65.311643 60.434546, -72.82933899999999 60.720017999999996, -76.11817099999999 65.28773, -7
1.419803 67.000626, -64.371867 68.428018, -61.552794999999996 64.431282, -65.311643 60.434546)))'));
  isvalid
---------
  t
(1 row)

select contains(geomfromtext('MULTIPOLYGON (((-128.74153099999998 66.42965, -106.554262 32.849587, 
-130.846486 40.578899, -152.378198 61.006418999999994, -128.74153099999998 66.42965)), ((-64.841883 
75.565074, -48.866971 72.139282, -39.750806 62.662659999999995, -27.604758 32.297475999999996, 
-77.997723 27.889585999999998, -96.791707 62.14741, -64.841883 75.565074), (-57.793946999999996 
70.71189, -64.841883 72.710258, -85.985179 63.860305999999994, -70.11599 56.037586999999995, 
-54.035098999999995 59.578098, -57.793946999999996 70.71189), (-41.407126 47.204051, 
-49.688469999999995 39.474706999999995, -34.781974 36.162130999999995, -41.407126 47.204051)), 
((-65.311643 60.434546, -72.82933899999999 60.720017999999996, -76.11817099999999 65.28773, 
-71.419803 67.000626, -64.371867 68.428018, -61.552794999999996 64.431282, -65.311643 
60.434546)))'), geomfromtext('POINT (-68.5167 63.7500)'));
  contains
----------
  t
(1 row)

Gilbert, Antoine wrote:
> How I can make this polygon valid?
> 
> It's a very simple one
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> Emily Gouge
> Sent: September 27, 2006 4:29 PM
> To: PostGIS Users Discussion
> Cc: Vachon, Patrick
> Subject: Re: [postgis-users] contains function with complex polygons
> 
> This may be a result of the polygon not being a valid PostGIS polygon.
> When I ran an isvalid() on 
> the polygon geometry it returned false with the notice "Holes are
> nested".
> 
> SELECT isvalid(geomfromtext('MULTIPOLYGON(...)'));
> NOTICE:  Holes are nested
>   isvalid
> ---------
>   f
> (1 row)
> 
> 
> Emily
> 
> 
> Gilbert, Antoine wrote:
>> Hi
>>
>>  
>>
>> I have special case problem with the contains SQL function if I use
>> polygons with "island in a hole"
>>
>>  
>>
>> For example I have a polygon, with a lake in it (hole) and an island
> in
>> the middle of the lake, all these as a whole polygon.
>>
>>  
>>
>> I have a point location standing on the island.
>>
>>  
>>
>> Why the contains SQL function contains(myPolygon,myPoint) dosen't
> return
>> true for my point
>>
>>  
>>
>> I verified my geometries using JUMP and everything seems ok
>>
>>  
>>
>> Here is the point: POINT (-68.5167 63.7500)
>>
>>  
>>
>> Here is my complex polygon (multipolygon in fact)
>>
>>  
>>
>> MULTIPOLYGON(((-128.74153099999998 66.42965, -106.554262 32.849587,
>> -130.846486 40.578899, -152.378198 61.006418999999994,
>> -128.74153099999998 66.42965)),((-64.841883 75.565074, -48.866971
>> 72.139282, -39.750806 62.662659999999995, -27.604758
> 32.297475999999996,
>> -77.997723 27.889585999999998, -96.791707 62.14741, -64.841883
>> 75.565074),(-57.793946999999996 70.71189, -64.841883 72.710258,
>> -85.985179 63.860305999999994, -70.11599 56.037586999999995,
>> -54.035098999999995 59.578098, -57.793946999999996
> 70.71189),(-41.407126
>> 47.204051, -49.688469999999995 39.474706999999995, -34.781974
>> 36.162130999999995, -41.407126 47.204051),(-65.311643 60.434546,
>> -72.82933899999999 60.720017999999996, -76.11817099999999 65.28773,
>> -71.419803 67.000626, -64.371867 68.428018, -61.552794999999996
>> 64.431282, -65.311643 60.434546)))
>>
>>  
>>
>> Formatted version:
>>
>>  
>>
>> MULTIPOLYGON (((
>>
>>             -128.74153099999998 66.42965, 
>>
>>             -106.554262 32.849587, 
>>
>>             -130.846486 40.578899, 
>>
>>             -152.378198 61.006418999999994, 
>>
>>             -128.74153099999998 66.42965
>>
>>         )), ((
>>
>>             -64.841883 75.565074, 
>>
>>             -48.866971 72.139282, 
>>
>>             -39.750806 62.662659999999995, 
>>
>>             -27.604758 32.297475999999996, 
>>
>>             -77.997723 27.889585999999998, 
>>
>>             -96.791707 62.14741, 
>>
>>             -64.841883 75.565074
>>
>>         ), (
>>
>>             -57.793946999999996 70.71189, 
>>
>>             -64.841883 72.710258, 
>>
>>             -85.985179 63.860305999999994, 
>>
>>             -70.11599 56.037586999999995, 
>>
>>             -54.035098999999995 59.578098, 
>>
>>             -57.793946999999996 70.71189
>>
>>         ), (
>>
>>             -41.407126 47.204051, 
>>
>>             -49.688469999999995 39.474706999999995, 
>>
>>             -34.781974 36.162130999999995, 
>>
>>             -41.407126 47.204051
>>
>>         ), (
>>
>>             -65.311643 60.434546, 
>>
>>             -72.82933899999999 60.720017999999996, 
>>
>>             -76.11817099999999 65.28773, 
>>
>>             -71.419803 67.000626, 
>>
>>             -64.371867 68.428018, 
>>
>>             -61.552794999999996 64.431282, 
>>
>>             -65.311643 60.434546
>>
>>         )))
>>
>>  
>>
>>  
>>
>>
>>
>>
>>
> ------------------------------------------------------------------------
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list