<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><SPAN class=035315800-03022006><FONT face=Arial color=#0000ff size=2>Makes
sense to me, if that functionality is already there.</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV align=center><FONT face=Arial size=2><STRONG>Martin Davis, Senior Technical
Architect</STRONG><BR><STRONG><FONT color=#0000ff>Vivid Solutions
Inc.
<I>www.vividsolutions.com</I></FONT></STRONG><BR></FONT><EM><FONT face=Arial
size=2>Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5<BR>Phone: (250)
385 6040 - Local 308 Fax: (250) 385 6046</FONT></EM></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
geos-devel-bounces@geos.refractions.net
[mailto:geos-devel-bounces@geos.refractions.net] <B>On Behalf Of </B>Charlie
Savage<BR><B>Sent:</B> February 2, 2006 4:48 PM<BR><B>To:</B> GEOS Development
List<BR><B>Subject:</B> Re: [geos-devel] Re: GEOS / SRID /
WKB<BR><BR></FONT></DIV><BR>
<BLOCKQUOTE
cite=mid5A94289A9268514C8D6C0F1FF44BA0279C3ED1@venus.VividSolutions.com
type="cite"><PRE wrap="">But I agree with strk that starting to add support for reading and
writing SRIDs is fraught with peril, and should be carefully considered.
If a reader is needed to handle SRIDs coming out of a particular format,
perhaps that should be split out as an entirely separate reader class?
That would make it clear that it is tied to a particular extended
format.
</PRE></BLOCKQUOTE>Yes, I agree that it would be very important to have a
well-defined infrastructure for plugging in new readers/writers for different
formats.<BR><BR>For the short term, the Geos WKBReader already reads the SRID
value. Thus the only change I am proposing is that it takes the SRID
value it reads and calls setSRID(). Right now it just dumps the
SRID value into the ether (i.e., reads it into a variable and then ignores
it).<BR><BR>Thanks,<BR><BR>Charlie<BR>
<BLOCKQUOTE
cite=mid5A94289A9268514C8D6C0F1FF44BA0279C3ED1@venus.VividSolutions.com
type="cite"><PRE wrap="">Martin Davis, Senior Technical Architect
Vivid Solutions Inc. <A class=moz-txt-link-abbreviated href="http://www.vividsolutions.com">www.vividsolutions.com</A>
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">-----Original Message-----
From: <A class=moz-txt-link-abbreviated href="mailto:geos-devel-bounces@geos.refractions.net">geos-devel-bounces@geos.refractions.net</A>
[<A class=moz-txt-link-freetext href="mailto:geos-devel-bounces@geos.refractions.net">mailto:geos-devel-bounces@geos.refractions.net</A>] On Behalf Of
<A class=moz-txt-link-abbreviated href="mailto:strk@refractions.net">strk@refractions.net</A>
Sent: February 2, 2006 2:17 AM
To: <A class=moz-txt-link-abbreviated href="mailto:geos-devel@geos.refractions.net">geos-devel@geos.refractions.net</A>
Subject: Re: [geos-devel] Re: GEOS / SRID / WKB
On Thu, Feb 02, 2006 at 01:26:33AM -0700, Charlie Savage wrote:
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">Hi Strk,
Yes, that sounds like a good way of doing it. Is this
</PRE></BLOCKQUOTE><PRE wrap="">planned for the
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">near future, or should I put something together if I need it?
</PRE></BLOCKQUOTE><PRE wrap="">No plans for near future.
I think that should also include support for M, and
GEOS is not ready for that yet.
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">What do you think of saving the SRID on input (i.e., accepting
extensions)? That's the part that I need at the moment.
</PRE></BLOCKQUOTE><PRE wrap="">The Geometry class provides a setUserData/getUserData
mechanism for extended informations to be added to a Geometry.
Maybe that's a better way to handle this, as the
setSRID/getSRID methods have been marked as deprecated.
--strk;
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">Thanks,
Charlie
<A class=moz-txt-link-abbreviated href="mailto:strk@refractions.net">strk@refractions.net</A> wrote:
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">Charlie, we're playing dirty here, even for Z values.
One thing is accepting "extensions", another thing is
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">spitting them
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">out. Z,M and SRID flags are postgis-specific. The next
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">update on OGC
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">dox will define a different way to express Z and M for
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">example, and
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">won't say anything about SRID.
The most correct way to support multiple different specs
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">would be to
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">provide a method to specify which one to use.
For example:
        WKBWriter writer;
        writer.setFormat(DIALECT);
        writer.write(geom);
Same would apply to WKBReader and to WKT reader/writer.
--strk;
On Wed, Feb 01, 2006 at 06:50:07PM -0700, Charlie Savage wrote:
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">I'd like to be able to read/write SRID information from
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">GEOS using
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">the
WKB Reader/Writer. Currently the WKBReader reads the
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">SRID value in an
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">extended WKB format, but then tosses it away. Attached
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">is a patch that
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">saves the SRID value by calling setSRID on the newly
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">created geometry.
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">It would also be nice if WKBWriter could output SRID values.
Looking
through the code, it would be easy enough to write this
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">information
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">out. However, if a geometry has an SRID, the output WKB
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">value would be
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">one byte longer plus have an SRID flag in the geomtype
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">byte. So this
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">would break existing code that reads wkb values if a
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">geometry has an
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">SRID. I'm not sure if this is an issue or not, since I
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">see the SRID
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">field on a geometry is not documented. Is this a frequently used
feature? An alternative of course would be having a
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">separate method,
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">maybe called writeExtended or some such thing.
Thanks,
Charlie
</PRE></BLOCKQUOTE><PRE wrap="">
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">Index: source/io/WKBReader.cpp
</PRE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE type="cite"><PRE wrap="">===================================================================
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">RCS file: /home/cvs/postgis/geos/source/io/WKBReader.cpp,v
retrieving revision 1.15
diff -u -r1.15 WKBReader.cpp
--- source/io/WKBReader.cpp        20 Jan 2006 00:59:55
</PRE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">-0000        1.15
</PRE>
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite">
<BLOCKQUOTE type="cite"><PRE wrap="">+++ source/io/WKBReader.cpp        2 Feb 2006 01:44:16 -0000
@@ -230,31 +230,43 @@
        cout<<"WKB hasSRID: "<<hasZ<<endl;
#endif
-        if (hasSRID) dis.readInt(); // skip SRID
-
+        int srid = -1;
+        if (hasSRID) srid = dis.readInt(); // read SRID
        // allocate space for ordValues
        if ( ordValues.size() < inputDimension )
                ordValues.resize(inputDimension);
+        Geometry * result;
        switch (geometryType) {
                case WKBConstants::wkbPoint :
-                        return readPoint();
+                        result = readPoint();
+                        break;
                case WKBConstants::wkbLineString :
-                        return readLineString();
+                        result = readLineString();
+                        break;
                case WKBConstants::wkbPolygon :
-                        return readPolygon();
+                        result = readPolygon();
+                        break;
                case WKBConstants::wkbMultiPoint :
-                        return readMultiPoint();
+                        result = readMultiPoint();
+                        break;
                case WKBConstants::wkbMultiLineString :
-                        return readMultiLineString();
+                        result = readMultiLineString();
+                        break;
                case WKBConstants::wkbMultiPolygon :
-                        return readMultiPolygon();
+                        result = readMultiPolygon();
+                        break;
                case WKBConstants::wkbGeometryCollection :
-                        return readGeometryCollection();
+                        result = readGeometryCollection();
+                        break;
+                default:
+                        throw new ParseException("Unknown WKB type " +
geometryType);
        }
-        throw new ParseException("Unknown WKB type " + geometryType);
+
+        result->setSRID(srid);
+        return result;
}
Point *
</PRE></BLOCKQUOTE><PRE wrap="">
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap="">
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">_______________________________________________
geos-devel mailing list
<A class=moz-txt-link-abbreviated href="mailto:geos-devel@geos.refractions.net">geos-devel@geos.refractions.net</A>
<A class=moz-txt-link-freetext href="http://geos.refractions.net/mailman/listinfo/geos-devel">http://geos.refractions.net/mailman/listinfo/geos-devel</A>
</PRE></BLOCKQUOTE><PRE wrap="">--
+----------------------------------------+
| Fight against software patents in EU! |
| <A class=moz-txt-link-abbreviated href="http://www.ffii.org">www.ffii.org</A> <A class=moz-txt-link-abbreviated href="http://www.nosoftwarepatents.org">www.nosoftwarepatents.org</A> |
+----------------------------------------+
_______________________________________________
geos-devel mailing list
<A class=moz-txt-link-abbreviated href="mailto:geos-devel@geos.refractions.net">geos-devel@geos.refractions.net</A>
<A class=moz-txt-link-freetext href="http://geos.refractions.net/mailman/listinfo/geos-devel">http://geos.refractions.net/mailman/listinfo/geos-devel</A>
</PRE></BLOCKQUOTE><PRE wrap=""><!---->_______________________________________________
geos-devel mailing list
<A class=moz-txt-link-abbreviated href="mailto:geos-devel@geos.refractions.net">geos-devel@geos.refractions.net</A>
<A class=moz-txt-link-freetext href="http://geos.refractions.net/mailman/listinfo/geos-devel">http://geos.refractions.net/mailman/listinfo/geos-devel</A>
</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>