Storing world location data using spatial datatypes

  • hi

    the app we are building is a globe or world map that is generated in Unity.  The map, aside from real world continents, countries, and cities, will initially be blank, meaning there are no real world things, businesses, points of interest, or locations, etc being populated.  It will become populated with non-real world places, businesses in certain countries/cities.  So a business, Fantasy Business XYZ will be placed on the globe somewhere in a country/city.

    So I know I will have a BUSINESS table that stores the details of Fantasy Business XYZ, including the lat/long coordinates.  These coordinates will frequently be passed to the front end (unity) to take the user(who is exploring the globe) to a spot or pin on the globe.

    My question is should I be storing these coordinates as geometry, geography, or just a varchar data type?  I have never used spatial types in sql server but seems like that’s whatI would want to do.  Is it faster one way or the other or are there other considerations to have?

    Thanks,

    J

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • If all you're going to do is store Lat/Long pairs, and you're NEVER going to do any spatial calculations in SQL Server (going to let client or other service handle that), then it's probably OK to store as varchar... though you might want to consider storing those as decimal or floats & deriving strings on the fly (ideally in other service/client layer).

    But if you're going to do apply any geospatial functions for long distance calculations -- especially long-distance -- use geography. While geography types have more limitations than geometry, they have one big advantage -- they'll consider the earth's curvature when computing relationships of points. You could have potentially have errors in distance & direction calculations if you just use geometry. If you will only do relatively local/regional point comparisons, then you may be able to use geometry.

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply