Home > Net >  Geography/Geometry literal types?
Geography/Geometry literal types?

Time:08-31

It seems that most databases that support GIS encode the object as a string within a function, such as:

SELECT ST_GeomFromText('LINESTRING(110 40, 2 3, -10 80, -7 9)')

The one exception I've seen to this is from Postgres directly (and not PostGIS, which uses the above format), for things like:

SELECT POINT '1,1';

Are geo literals in databases essentially unused, and all 'standard' stuff has moved to within function calls (I suppose Postgres just maintains this feature for historical baggage?).

CodePudding user response:

PostGIS follows the OGC standard, while PostgreSQL's built-in geometry support doesn't. This is largely because it is older and it does not aim to model geography: it exclusively deals with the Euclidian plain.

While PostgreSQL's geometry features are useful for dealing with two-dimensional flat geometry, any real-world geographical application would use PostGIS.

CodePudding user response:

You're mixing geographic and geometric data types.

The point data type is a native PostgreSQL geometric data type designed for two-dimensional spatial objects only. I've never saw a GIS related project that uses geometric data types, as it is pretty limited and makes simple 2D GIS tasks quite hard to implement, e.g. transformation of spatial reference systems.

The LineString in your example is just a WKT (Well Known Text) representation of a spatial object, which comes with the extension PostGIS - WKT is a OGC (Open Geospatial Consortium) standard. If you're not familiar with OGC, consider it the W3C of GIS ;) If you're interested in the standards itself, take a look at the OGC specification for more details. PostGIS is imho the best GIS support for databases out there! It has loads of quite handy functions that make multidimensional spatial objects manipulation very easy, and most importantly: it has a very active community.

  • Related