Spatial Indexing with SQL and Node - mysql

I'm about to start a Node.js with a lot of POI (point of Interest) that will be saved on SQL database.
Is there a way to make proximity searches (ie find all POI near a given point within a given range) easily with SQL and Node? I would like to use geohash algorithm + bookshelf for ORM but I can't find any document on the Internet explaining how to start.
Mongodb has a geo spatial index. I would like the same thing but with SQL.
Any help would be welcome

Geohash is simple translate the points to a binary and interleave it. Treat it as base-4 number. Try the Microsoft Bing tiling system. It has some free code example.

Related

Which database can be used to store processed data from NLP engine

I am looking at taking unstructured data in the form of files, processing it and storing it in a database for retrieval.
The data will be in natural language and the queries to get information will also be in natural language.
Ex: the data could be "Roses are red" and the query could be "What is the color of a rose?"
I have looked at several nlp systems, focusing more on open-source information extraction and relation extraction system and the following seems apt and easy for quick start:
https://www.npmjs.com/package/mitie
This can give data in the form of (word,type) pairs. It also gives a relation as result of running the the processing (check the site example).
I want to know if sql is good database to save this information. For retrieving the information, I will need to convert the natural language query also to some kind of (word, meaning) pairs
and for using sql I will have to write a layer that converts natural language to sql queries.
Please suggest if there are any open source database that work well in this situation. I'm open to suggestions for databases that work with other open-source information extraction and relation extraction systems if not MITIE.
SQL wont be an appropriate choice for your problem. You can use NLP or rules to extract relationships and then store that relationship in a Triple Store or a Graph database. There are many good open source Graph Databases like Neo4j and Apache Titan. You can query Google for Triple-stores, I suppose Apache Jena should be a good choice. After storing your data you can query your graphs using any of the Graph Query Languages like Gremlin or Cypher etc. (like SQL). Note that the heart of your system would be a Knowledge Graph.
You may also setup a Lucene/Solr based Search System on your unstructured data which may help you with answering your queries in conjunction with Graph Databases. All of these (NLP, IR, Graph DB/Triplestores etc.) would coexist to solve your problem.
It would be like an ensemble. No silver bullets :) However to start with look at Graph DB's or Triple-stores.

HTML5; finding what is near me with geolocation

Disclaimer: I am slow learner; I have a list of 300 businesses with address and grid coordinates. I know how to request a users location with HTML5 Geolocation. How do I use that information to determine which businesses are nearest to the user? I have found allot of tutorials but nothing exact and I'm lost. I am open to any technology or language to do this yet I would like to keep it simple. I have an IIS7 server and an OSX server and I could create a My SQL database or use SQL server 2008.
Get the distance between two points using Haversine or similar, see here - http://www.movable-type.co.uk/scripts/latlong.html
Then you just need to return all those points that fall within a certain radius of your originating point.

Restfull point in polygon in SQL Azure

I want to create a restfull WCF service in Azure to store polygons drawn in Bing maps. Each polygon has also a descriptive text. Response format must be JSON.
The most important feature must be to retrieve the list of polygons (with text) for a given point (lat long) (so I must have a point in polygon routine).
I am not a geo expert, but I was recommended to use the geo spatial part of SQL Azure. How can this be done ?
I have a suggestion.
- First try implementing your polygon detection in standard SQL Server.
- then port your SQL Server solution to an Azure equivalent.
- and finally expose a WCF interface to your functionality.
If you break it down like this you may find it easier to ask more specific questions that are more likely to get answered.

Spatial analysis in SAS?

Is there a way to do spatial analysis (NOT just graphics) in SAS? What I really want is the ability to geographic queries like one can do in PostGIS or SpatialLite in PROC SQL.
I asked this on the SAS-L list and got nothing.
Thanks!
I'm not sure whether your question is specific enough about what you're wanting to do, for someone to give you a good answer.
If you've got lat/long data, you could do detail and aggregate queries by choosing where clause criteria based on the lat/long values.
Incidentally, you might want to check out http://runsubmit.com for another stackoverflow style site with a more concentrated population of sas users.
I'm not familiar with PostGIS or SpatialLite, but SAS has some procedures dedicated to GIS specific tasks. This link says
SAS/GIS software enables you to do
more than simply view your data in its
spatial context. It also enables you
to interact with the data by selecting
features and performing actions that
are based on your selections.
I don't know if proc sql will be able to easily replicate those features, but once the data is in SAS data sets, I don't see why you couldn't at least do some basic querys.
SAS also has some examples data and code working with spatial data here.
The answer seems to be No, SAS doesn't support spatial datatypes and operators like spatialite or postgis.
(I am answering my own question to close the discussion, but thanks to all!)
Actually, when you consider that the SQL queries in Spatialite/PostGIS are just being translated into a specific method of calculation. It can actually be done.
So to answer your question, can it be done in SAS in an easy way like spatialite (i.e simple queries?), No
But you could write a function to do what you need using Base SAS, i find SAS to be one of the best languages to use for quick data analysis.

What's the best way to save KML in MySQL?

I have a few maps with certain areas (zones) which I'll want to capture in KML. Within those areas I need to pinpoint addresses.
How do I save those maps with its values as efficient as possible to query them later?
Maybe you could use MySQL spatial extensions.
Take a look at GIS and Spatial Extensions and to GIS on MySQL