[postgis-users] How to instanziate the Geometry class from the geometry string?

Markus Schaber schabi at logix-tt.com
Wed Sep 20 04:28:10 PDT 2006


Hi, Francesco,

martinelli at pi.ingv.it wrote:

> looking at the same package (org.postgis.binary) I also tried for the
> "derializer" the following snippet:
>     BinaryParser parser = new BinaryParser();
>     Geometry geom = parser.parse((String)source);
> and (at least "apparently") it worked without the need of looking for
> SQLException, which is required for:
>     Geometry geom = PGgeometry.geomFromString((String) source);
> requires a try-catch.
> 
> Is there a reson for preferring the second one?

The second one can also parse Text Representations (like "POINT(23
42)"). If you don't need it, use the first one.

Btw, BinaryParser is reusable, so you can reuse the same instance for
several geometries.

HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org



More information about the postgis-users mailing list