[postgis-users] Intersection of point and linestring. Error?

strk at refractions.net strk at refractions.net
Fri Nov 26 01:20:20 PST 2004


On Fri, Nov 26, 2004 at 11:05:09AM +0300, ksa wrote:
> Hi, List.
> 
> I have a table that contains two multilinestrings (where numgeometries = 1);
> And I have some problem.
> 
> search=# select gid, geom from t_table_46;
>  gid |
> geom
> -----+----------------------------------------------------------------------
> ----------------------------------------------------------------------------
> ----------------------------------------------------------------------------
> ------------------
>    1 |
> SRID=2000;MULTILINESTRING((-346.39495192 -32.22278924,-346.39495192 -32.2227
> 8924,-347.01462094 37.18014143,-261.50029565 23.54742291,-271.41500003
> 93.5700226,-187.14001279 74.36028286,-195.1957101 155.53692498,-118.97642017
> 141.90420646))
>    2 | SRID=2000;MULTILINESTRING((-268.94877508 161.46993124,-268.94877508
> 161.46993124,-236.16352798 88.61382659,-238.34921112 24.5004545))
> (2 rows)
> 
> This multilinestrings have intersection.
> search=# select geometryfromtext(astext(intersection(t1.geom, t2.geom)),
> 2000) from t_table_46 t1, t_table_46 t2 where t1.gid = 1 and t2.gid = 2;
>                   geometryfromtext
> ----------------------------------------------------
>  SRID=2000;POINT(-236.267686750346 85.558502660642)
> (1 row)
> 
> So, there is a point that lays on one multilinestring and on second
> multilinestring. And I think that intersection of this point and
> multilinestring *must* be point (same point). But I havebad result after
> executing next query...
> 
> search=# select intersection(geom, (select
> geometryfromtext(astext(intersection(t1.geom, t2.geom)), 2000) from
> t_table_46 t1, t_table_46 t2 where t1.gid = 1 and t2.gid = 2)) from
> t_table_46;
>            intersection
> -----------------------------------
>  SRID=-1;GEOMETRYCOLLECTION(EMPTY)
>  SRID=-1;GEOMETRYCOLLECTION(EMPTY)
> (2 rows)
> 
> Why? I think the result must be:
>                   geometryfromtext
> ----------------------------------------------------
>  SRID=2000;POINT(-236.267686750346 85.558502660642)
>  SRID=2000;POINT(-236.267686750346 85.558502660642)
> (2 row)
> 
> 
> Sergey Karin

Have you tried manually intersecting the POINT and the MULTILINEs ?
It would be easier to debug.
Anyway, since you convert the geometry to text and back you're probably
loosing precision... your query should look like this instead:

  search=# select intersection(geom,
	(select setSRID(intersection(t1.geom, t2.geom), 2000) from
  	 t_table_46 t1, t_table_46 t2 where t1.gid = 1 and t2.gid = 2)
  ) from t_table_46;

--strk;

> 
> _______________________________________________
> 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