Giter Site home page Giter Site logo

francesco1119 / osm_to_mssql Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 79 KB

Import OSM to MSSQL on SSMS through a SQL query with an HTTP request. BOOM!!!

License: GNU General Public License v3.0

sql-server sqlserver openstreetmap osm t-sql tsql

osm_to_mssql's Introduction

issues network stargazers LICENSE

OSM_to_MSSQL

Import OSM to MSSQL on SSMS and retrieve JSON through T-SQL with an HTTP request. BOOM!!!

The Story

The idea to build a simple way to import Open Street Map to Microsoft SQL Server was born after this post when I tragically realised that there was no current way to import easily and on the fly OSM to MSSQL.

The idea became even more challenging when people start blathering that it was impossible (why?) and that OSM felt better on MySQL or PostgreSQL database.

At that stage it became personal and I started coding.

How to use

  1. Open SSMS and enable Ole Automation Procedures running this query:
sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
sp_configure 'Ole Automation Procedures', 1;  
GO  
RECONFIGURE;  
GO
  1. Download the query in attach and paste it into SSMS.
  2. Edit DECLARE @place as NVARCHAR(30) = 'Paris' and instead of Paris put Barcelona or Spain or whatever
  3. Edit DECLARE @amenity as NVARCHAR(30) = 'cinema' and put whatever you want from the list of the amenities
  4. Press F5 and run the query

Troubleshooting:

How it works under the hood

Every time you run the query OSM_to_MSSQL creates a table called 'OSM_' + @amenity + '_' + @place.

Re-running the query will drop the old table and recreate a new one so yes, you can stick this query into a stored procedure and your data can be fresh new every day.

How cool is that?

Let's have an argument

OSM_to_MSSQL is using sp_OACreate and MSXML2.ServerXMLHTTP.6.0 to create the request. Using sp_OACreate is considered bad practice and MSXML2.ServerXMLHTTP.6.0 is deprecated. If you are not OK with that you can use SQLCRL but don't think not even for a second that this will be safer or it will query the API better or faster or it will provide you a place in Heaven.

Future developent

On spare time my TODO list is:

  • Brake the @URL into:
    • node(area.a)[amenity=cinema]
    • way(area.a)[amenity=cinema]
    • rel(area.a)[amenity=cinema]
  • Eventually create {{bbox}} URL for retrieve data from all over the World ([bbox=-180,-90,180,90])
  • Eventually provide development for MSXML6 call

osm_to_mssql's People

Contributors

francesco1119 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.