[postgis-users] Bug dropping the Z coordinate?

Paragon Corporation lr at pcorp.us
Tue Jan 12 00:13:09 PST 2010


Abe,

Nothing to apologize for.  Your etiquette was fine I just wasn't clear if
you needed it represented or not.

You oould go with Paul's approach of doing the ST_ASbinary and the
ZXMax,...separately.

But do you absolutely need it as one geometry?  If you do then I was
thinking return a 3D line.  It wouldn't represent right but will encode all
the information in a geometry that you can then safely apply
ST_AsEWKB/ST_AsGeomFromWKB

So write an SQL function that takes an ST_Box3D and returns a 3D line


CREATE OR REPLACE FUNCTION zig_extentline(ext box3d)
  RETURNS geometry AS
$$
SELECT ST_MakeLine(ST_MakePoint(ST_Xmin($1), ST_YMin($1),
ST_Zmin($1)),ST_MakePoint(ST_XMAx($1), ST_YMax($1), ST_ZMax($1)) ) ;
$$
  LANGUAGE 'sql' IMMUTABLE
  COST 10;


--testing with this
SELECT ST_ZMax(ST_GeomFromEWKB(ST_AsEWKB(zig_extentline('BOX3D(0 0 0,0 0
1)'::box3d))));

Gives
1

Hope that helps,
Regina

 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Abram
Gillespie
Sent: Monday, January 11, 2010 12:46 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Bug dropping the Z coordinate?

I need to report back to ArcGIS what the bounds of the data is.  The way
zigGIS works is it parses all geometry data returned from PostGIS as WKB.
We're extending zigGIS to handle ZM coordinates.  I'll be happy to put in a
special case for the extents query where if I have to parse things manually
I will.  But I'm not even sure how to get a ST_Extent3d query into a from
that I can consume (note that going through Npgsql has its own challenges
with working with non-standard types).  I'd parse binary if ST_AsEWKB
worked, I'd parse text if ST_AsEWKT worked.

Regina, I'm a bit confused how you started your last response.  If I broke
list etiquette then I apologize.  I did the work to boil down my initial
question into an easily reproducible test case which I thought was
exercising a bug.  My apologies for not getting to the point immediately.

Thanks.

On Mon, Jan 11, 2010 at 12:14 PM, Paragon Corporation <lr at pcorp.us> wrote:
> Abe,
> One thought that comes to mind is store it as a multipolygon with each 
> polygon being a different edge of the box, but I'm not sure that would 
> be terribly useful for your use-case.
>
> Leo
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of 
> Abram Gillespie
> Sent: Monday, January 11, 2010 11:38 AM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Bug dropping the Z coordinate?
>
> OK, I'll ask this then.  What's the best way to get this:
>
> select ST_Extent3d(geometry_column) from my_table;
>
> Into EWKB w/o losing the Z (or M) coordinate?
>
> Doing:
>
> select ST_AsEWKB(ST_Extent3D(geometry_column)) from my_table;
>
> unfortunately falls prey to the issue we're discussing.
>
> Thanks.
> -Abe
>
> On Sun, Jan 10, 2010 at 10:53 PM, Paragon Corporation <lr at pcorp.us> wrote:
>> As a side note.  ST_Zmax doesn't exist for geometries.  It works 
>> because geometries can be autocast to boxes.
>>
>> See matrix
>> http://www.postgis.org/documentation/manual-svn/ch08.html#PostGIS_Typ
>> e
>> Functi
>> onMatrix
>>
>> -----Original Message-----
>> From: postgis-users-bounces at postgis.refractions.net
>> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of 
>> Paragon Corporation
>> Sent: Sunday, January 10, 2010 10:50 PM
>> To: 'PostGIS Users Discussion'
>> Subject: Re: [postgis-users] Bug dropping the Z coordinate?
>>
>> Abe,
>>
>> It seems we are flattening the box3d geometry in to a 2D polygon 
>> always instead of as a 3D/2.5D polygon.
>> I'm not sure it's a bug though, because I think a box3d is an invalid 
>> 2.5/3D polygon if you were to construct it.
>>
>> Can you envision it?
>>
>> Paul, Mark or Kevin might have a better clue, but I think it's at 
>> best an ambiguous 3D polygon and that is the problem. A box3d isn't 
>> really a 3D box, its more just a coordinate bounding thing.
>>
>> Hope that helps,
>> Regina
>>
>> -----Original Message-----
>> From: postgis-users-bounces at postgis.refractions.net
>> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of 
>> Abram Gillespie
>> Sent: Sunday, January 10, 2010 4:31 PM
>> To: PostGIS Users Discussion
>> Subject: [postgis-users] Bug dropping the Z coordinate?
>>
>> Is this a bug?
>>
>> select ST_ZMax('BOX3D(0 0 0,0 0 1)'::box3d);
>>
>> versus
>>
>> select ST_ZMax(ST_GeomFromEWKB(ST_AsEWKB('BOX3D(0 0 0,0 0 
>> 1)'::box3d)));
>>
>> The first query returns "1" as expected but the second returns "0" as 
>> unexpected.
>>
>> I'm trying to add Z/M support to zigGIS and this is show-stopping me.
>> Any work-arounds if this is a bug?  Also, I'll be happy to report the 
>> bug if so.
>>
>> Thanks.
>> -Abe
>> _______________________________________________
>> 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
>>
> _______________________________________________
> 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