[geos-devel] Re: GEOS / SRID / WKB

Martin Davis mbdavis at VividSolutions.com
Thu Feb 2 19:58:54 EST 2006


Makes sense to me, if that functionality is already there.
 
 
Martin Davis, Senior Technical Architect
Vivid Solutions Inc.      www.vividsolutions.com
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046

	-----Original Message-----
	From: geos-devel-bounces at geos.refractions.net
[mailto:geos-devel-bounces at geos.refractions.net] On Behalf Of Charlie
Savage
	Sent: February 2, 2006 4:48 PM
	To: GEOS Development List
	Subject: Re: [geos-devel] Re: GEOS / SRID / WKB
	
	


		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.
		  

	Yes, I agree that it would be very important to have a
well-defined infrastructure for plugging in new readers/writers for
different formats.
	
	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).
	
	Thanks,
	
	Charlie
	

		Martin Davis, Senior Technical Architect
		Vivid Solutions Inc.      www.vividsolutions.com
		Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
		Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046
		
		
		  

			-----Original Message-----
			From: geos-devel-bounces at geos.refractions.net 
			[mailto:geos-devel-bounces at geos.refractions.net]
On Behalf Of 
			strk at refractions.net
			Sent: February 2, 2006 2:17 AM
			To: geos-devel at geos.refractions.net
			Subject: Re: [geos-devel] Re: GEOS / SRID / WKB
			
			
			On Thu, Feb 02, 2006 at 01:26:33AM -0700,
Charlie Savage wrote:
			    

				Hi Strk,
				
				Yes, that sounds like a good way of
doing it.  Is this 
				      

			planned for the
			    

				near future, or should I  put something
together if I need it?
				      

			No plans for near future.
			I think that should also include support for M,
and
			GEOS is not ready for that yet.
			
			    

				What do you think of saving the SRID on
input (i.e., accepting
				extensions)?  That's the part that I
need at the moment.
				      

			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;
			
			
			    

				Thanks,
				
				Charlie
				
				strk at refractions.net wrote:
				      

				Charlie, we're playing dirty here, even
for Z values.
				One thing is accepting "extensions",
another thing is 
				        

			spitting them 
			    

				out. Z,M and SRID flags are
postgis-specific. The next 
				        

			update on OGC 
			    

				dox will define a different way to
express Z and M for 
				        

			example, and 
			    

				won't say anything about SRID.
				
				The most correct way to support multiple
different specs 
				        

			would be to 
			    

				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:
				 
				        

				I'd like to be able to read/write SRID
information from 
				          

			GEOS using 
			    

				the
				WKB Reader/Writer.  Currently the
WKBReader reads the 
				          

			SRID value in an 
			    

				extended WKB format, but then tosses it
away.  Attached 
				          

			is a patch that 
			    

				saves the SRID value by calling setSRID
on the newly 
				          

			created geometry. 
			    

				It would also be nice if WKBWriter could
output SRID values.  
				Looking
				through the code, it would be easy
enough to write this 
				          

			information 
			    

				out.  However, if a geometry has an
SRID, the output WKB 
				          

			value would be 
			    

				one byte longer plus have an SRID flag
in the geomtype 
				          

			byte.  So this 
			    

				would break existing code that reads wkb
values if a 
				          

			geometry has an 
			    

				SRID.  I'm not sure if this is an issue
or not, since I 
				          

			see the SRID 
			    

				field on a geometry is not documented.
Is this a frequently used 
				feature?  An alternative of course would
be having a 
				          

			separate method, 
			    

				maybe called writeExtended or some such
thing.  
				
				Thanks,
				
				Charlie
				   
				          

				 
				        

				Index: source/io/WKBReader.cpp 
				          

	
===================================================================
				        

				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 
				          

			-0000	1.15
			    

				+++ 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 *
				
				   
				          

				
				
				 
				        

			
			    

	
_______________________________________________
				geos-devel mailing list
				geos-devel at geos.refractions.net 
	
http://geos.refractions.net/mailman/listinfo/geos-devel
				      

			-- 
			
			 +----------------------------------------+
			 | Fight against software patents in EU!  |
			 | www.ffii.org www.nosoftwarepatents.org |  
			+----------------------------------------+
			
			_______________________________________________
			geos-devel mailing list
			geos-devel at geos.refractions.net 
	
http://geos.refractions.net/mailman/listinfo/geos-devel
			
			    

		_______________________________________________
		geos-devel mailing list
		geos-devel at geos.refractions.net
		http://geos.refractions.net/mailman/listinfo/geos-devel
		
		
		  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20060202/3b64e199/attachment.html


More information about the geos-devel mailing list