[postgis-tickets] [PostGIS] #2825: ST_Intersection broken with Z coordinates

PostGIS trac at osgeo.org
Mon Jul 7 11:56:02 PDT 2014


#2825: ST_Intersection broken with Z coordinates
---------------------+------------------------------------------------------
 Reporter:  TBL      |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.1.4
Component:  postgis  |     Version:  2.1.x        
 Keywords:           |  
---------------------+------------------------------------------------------

Comment(by TBL):

 You mean something like this?

 Original query with a single line:
 {{{
 with linestring as (
   select st_makeline(
     st_geomfromtext('LINESTRING Z (-1 -1 0,-0.5 -0.5 1,0 0 2,0.5 0.5 3,1 1
 4,1.5 1.5 5)', 4326),
     st_geomfromtext('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5 9,0 0
 10)', 4326)
   ) as geom
 ),
 polygon as (select ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))',
 4326) as geom)
 select st_astext(st_intersection(linestring.geom, polygon.geom)) from
 linestring, polygon
 }}}

 Result
 {{{
 "MULTILINESTRING Z ((0 0 6,0.5 0.5 6),(0.5 0.5 6,1 1 6))"
 }}}

 Query with a multilinestring:

 {{{
 with linestring as (
   select st_collect(
     st_geomfromtext('LINESTRING Z (-1 -1 0,-0.5 -0.5 1,0 0 2,0.5 0.5 3,1 1
 4,1.5 1.5 5)', 4326),
     st_geomfromtext('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5 9,0 0
 10)', 4326)
   ) as geom
 ),
 polygon as (select ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))',
 4326) as geom)
 select st_astext(st_intersection(linestring.geom, polygon.geom)) from
 linestring, polygon
 }}}

 Result as above:
 {{{
 "MULTILINESTRING Z ((0 0 6,0.5 0.5 6),(0.5 0.5 6,1 1 6))"
 }}}

 And with two distinct linestrings:
 {{{
 with linestring as (
   select
     (select st_geomfromtext('LINESTRING Z (-1 -1 0,-0.5 -0.5 1,0 0 2,0.5
 0.5 3,1 1 4,1.5 1.5 5)', 4326)) as geom
   union all
     (select st_geomfromtext('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5
 9,0 0 10)', 4326))
 ),
 polygon as (select ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))',
 4326) as geom)
 select st_astext(st_intersection(linestring.geom, polygon.geom)) from
 linestring, polygon
 }}}

 Result is as expected:
 {{{
 "LINESTRING Z (0 0 2,0.5 0.5 3,1 1 4)"
 "LINESTRING Z (1 1 8,0.5 0.5 9,0 0 10)"
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2825#comment:6>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list