[postgis-users] More details for errors

Denis Rouzaud denis.rouzaud at gmail.com
Tue Mar 27 07:09:27 PDT 2012


Hi Nicolas,

Thanks again.

Well, this working, but this not performant...

Based on your suggestion, I tried this:
in view1:
ST_Multi(ST_LineMerge(ST_Union(wkb_geometry)))::geometry(MultiLineString,21781) 
AS wkb_geometry

Then in view2:
ST_CollectionHomogenize(wkb_geometry)::geometry(LineString,21781) AS 
wkb_geometry
FROM view1
  WHERE ST_NumGeometries(wkb_geometry) = 1;

And I can detect problems by doing:
SELECT id FROM view1  WHERE ST_NumGeometries(wkb_geometry) != 1;


But this is slowing down a lot.
I think that the ST_CollectionHomogenize is not the right way. Is there 
a better function to transform multiline to line if I am sure I only 
have lines?

Greetings,

Denis


On 03/27/2012 02:29 PM, Nicolas Ribot wrote:
> On 27 March 2012 08:02, Denis Rouzaud<denis.rouzaud at gmail.com>  wrote:
>> Hi Nicolas, hi all,
>>
>> Thanks for your reply.
>>
>> The problem is:
>> - I cannot filter my view using where geometryType(wkb_geometry) =
>> 'LINESTRING' as it will still return the same error
>> - I cannot check the result of ST_LineMerge in the where clause since
>> aggragates are not allowed in wheres
>> - If I cast to a MULTI, I don't how to check that it is castable to a
>> LineString.
>>
>> So, I'll try to reformulate:
>> - Can I check if a MultiLineString is in fact a LineString ?
>> - Is there a way to test the result of LineMerge to see if it is a
>> LineString or MultiLineString?
>>
> Hi,
> The number of elements in the collection will tell you if it is a
> linestring (1 element): st_numGeometries(), or the geometry type
> (geometryType() ) will start by 'MULTI' in case of collection.
> You could add a rule on your view to disallow st_lineMerge results
> producing MULTI elements.
>
> Nicolas
> _______________________________________________
> 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