Re: [postgis-users] More details for errors

2012-03-28 Thread Denis Rouzaud

Hi again!

Well, this is always the same problem, if I do linemerge(union()), I 
have to force multi to prevent errors. Then, simplifying to linestring 
seems to consume resources.


On way, would to do a view which determine if the union would lead to a 
multi or a linestring.

But I don't know how to achieve this.
I have no idea either if this would also be greedy on resources.

Denis

On 03/27/2012 05:43 PM, Nicolas Ribot wrote:

Yes, it is 2.0
http://postgis.refractions.net/documentation/manual-svn/ST_CollectionHomogenize.html

Well, I am turning around the problem...
I have to do a cast, as I used
ST_Multi(ST_LineMerge(ST_Union(wkb_geometry)))::geometry(MultiLineString,xxx)
in the first view to prevent errors of unconnected lines.

Right now the best solution I have is to let the view being unusable, and
another view to report errors.
This is not very satisfying as if a problem occurs, I cannot use my view
until I fix the geometric errors.

Basically, I need to compute a view with a LineMerge returning LineString
(i.e. leaving away features leading to MultiLineString) and another view
returning IDs of features leading to MULTI.

I thought about using ST_Touches but it only uses two geometries and I can
have more in the LineMerge. No idea what to look for...

Thanks for your help. I could go deeper in the problem!

Greetings


I would then create 3 views:
One doing the actual computation (linemerge(Union)), then one view
where st_numgeometries(the_geom) = 1, and one view where
st_numgeometries(the_geom)  1.

nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-27 Thread Denis Rouzaud

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?


Thanks

Denis

On 03/26/2012 02:00 PM, Nicolas Ribot wrote:

Hi all,

I have a view which does this
ST_LineMerge(ST_Union(wkb_geometry))::geometry(LineString,21781)

In case of the lines are not juxtaposed, I have this error
ERROR:  Geometry type (MultiLineString) does not match column type
(LineString)

Is there a way of getting the line ID which leads to the error???



Hi,
you could execute the SQL query defining the view and filter features
where geometryType(wkb_geometry) = 'LINESTRING' to identify only
problematic features.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-27 Thread Denis Rouzaud

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 Rouzauddenis.rouz...@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@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-27 Thread Nicolas Ribot
On 27 March 2012 16:09, Denis Rouzaud denis.rouz...@gmail.com wrote:
 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?


I did not know this function. 2.0 ?
You can simply do:

st_setsrid(ST_geometryN(wkb_geometry), 21781) AS
wkb_geometry
FROM view1
 WHERE ST_NumGeometries(wkb_geometry) = 1;

If geoms come from linemerge, no need to cast to a linestring. It is
already one.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-27 Thread Denis Rouzaud

Yes, it is 2.0
http://postgis.refractions.net/documentation/manual-svn/ST_CollectionHomogenize.html

Well, I am turning around the problem...
I have to do a cast, as I used 
ST_Multi(ST_LineMerge(ST_Union(wkb_geometry)))::geometry(MultiLineString,xxx) 
in the first view to prevent errors of unconnected lines.


Right now the best solution I have is to let the view being unusable, 
and another view to report errors.
This is not very satisfying as if a problem occurs, I cannot use my view 
until I fix the geometric errors.


Basically, I need to compute a view with a LineMerge returning 
LineString (i.e. leaving away features leading to MultiLineString) and 
another view returning IDs of features leading to MULTI.


I thought about using ST_Touches but it only uses two geometries and I 
can have more in the LineMerge. No idea what to look for...


Thanks for your help. I could go deeper in the problem!

Greetings

Denis





On 03/27/2012 04:39 PM, Nicolas Ribot wrote:

On 27 March 2012 16:09, Denis Rouzauddenis.rouz...@gmail.com  wrote:

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?


I did not know this function. 2.0 ?
You can simply do:

st_setsrid(ST_geometryN(wkb_geometry), 21781) AS
wkb_geometry
FROM view1
  WHERE ST_NumGeometries(wkb_geometry) = 1;

If geoms come from linemerge, no need to cast to a linestring. It is
already one.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-27 Thread Nicolas Ribot
 Yes, it is 2.0
 http://postgis.refractions.net/documentation/manual-svn/ST_CollectionHomogenize.html

 Well, I am turning around the problem...
 I have to do a cast, as I used
 ST_Multi(ST_LineMerge(ST_Union(wkb_geometry)))::geometry(MultiLineString,xxx)
 in the first view to prevent errors of unconnected lines.

 Right now the best solution I have is to let the view being unusable, and
 another view to report errors.
 This is not very satisfying as if a problem occurs, I cannot use my view
 until I fix the geometric errors.

 Basically, I need to compute a view with a LineMerge returning LineString
 (i.e. leaving away features leading to MultiLineString) and another view
 returning IDs of features leading to MULTI.

 I thought about using ST_Touches but it only uses two geometries and I can
 have more in the LineMerge. No idea what to look for...

 Thanks for your help. I could go deeper in the problem!

 Greetings


I would then create 3 views:
One doing the actual computation (linemerge(Union)), then one view
where st_numgeometries(the_geom) = 1, and one view where
st_numgeometries(the_geom)  1.

nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] More details for errors

2012-03-26 Thread Denis Rouzaud

Hi all,

I have a view which does this
ST_LineMerge(ST_Union(wkb_geometry))::geometry(LineString,21781)

In case of the lines are not juxtaposed, I have this error
ERROR:  Geometry type (MultiLineString) does not match column type 
(LineString)


Is there a way of getting the line ID which leads to the error???


Thanks!

Denis
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] More details for errors

2012-03-26 Thread Nicolas Ribot
 Hi all,

 I have a view which does this
 ST_LineMerge(ST_Union(wkb_geometry))::geometry(LineString,21781)

 In case of the lines are not juxtaposed, I have this error
 ERROR:  Geometry type (MultiLineString) does not match column type
 (LineString)

 Is there a way of getting the line ID which leads to the error???



Hi,
you could execute the SQL query defining the view and filter features
where geometryType(wkb_geometry) = 'LINESTRING' to identify only
problematic features.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users