HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How can I store latitude and longitude without PostGIS?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
canwithoutstorepostgislatitudehowandlongitude

Problem

I know there are similar questions on here that have been answered but unfortunately none of them work for me. I am hacking my way through creating a page which will display multiple locations on a map. I am using HTML 5 mapping plus Google maps. I have converted the addresses I have, into long/lat and they are stored in a CSV file along with other attributes.

I have tried storing as point, character varying and number as well as trying to create my own definition but have had no success. The table already exists and I just need to add these additional columns. I would rather not use PostGIS since that feels like adding in an additional level of complexity which I could well do without.

So what do you suggest?

Solution

The simplest solution without PostGIS would be to store lat/long as two number columns.

numeric for exact precision.

double precision or even just real if you don't need the precision.

I see no reason why the data type point shouldn't work as well. Per documentation:


Points are the fundamental two-dimensional building block for
geometric types. Values of type point are specified using either of
the following syntaxes:

( x , y )
  x , y




where x and y are the respective coordinates, as floating-point
numbers.

Related:

  • Which data type for latitude and longitude?

Code Snippets

( x , y )
  x , y

Context

StackExchange Database Administrators Q#90072, answer score: 12

Revisions (0)

No revisions yet.