MySql find country via geometry / spatial data - mysql

i want request my db with LAT/LON an get back a countrycode.
i have the world borders in a mysql database (converted shapefile from djangoproject.com) as geometry datafield.
When using
SELECT countyname FROM `world` WHERE Contains(ogc_geom, POINT(-18, 64))
i get back not only "iceland" (which is true) but also greenland, russia and usa.
I tried other points (point in mongolia founds also in china and russia), tried using intersects(), checked with multipolygons...
good ideas?
thanks, stefan

I am not sure you can do this only using MySQL. If you can interface the MySQL data with a scripting language, the n you can try the following.
Generate an image of the world map. Each pixel in the image will store the country id. You can lookup the country details from the MySQL db using this id.

Related

Cant adopt geometry in Mysql 8.0 to connect with qGIS

I am developing a groundwater information system using mysql 8.0 workbench as my database developer and qGIS for visualising. I am new to both and had problems connecting with qGIS. My database is now connected to qGIS, However, I can't put my geometry on the shape file of qGIS although I have simple columns óf X and Y coords. I tried to add column to in my table.e.g alter table msc_project
add column geom Geometry SRID 31467; and then concat the x and y .e.g. select CONCAT(XCoord, ',', YCoord) as geom from msc_project;. This does not work, the concat only results in combined values which cannot be seen in the table while geom results in NULL. Answers and ideas would be appreciated Thanks.
P.S: I am importing data from excel sheet, the sheet has X and Y coordinates from Guasss-Kueger coordinate system. I used a shape file that select it.

Saving MySQL spatial data Google maps API Bounds

So I would like to save lat, lang and bounds spatial data to MySQL for now only to set a view port and zoom for places search. I saved lat, lang as POINT type and everything is fine but I'm stuck with bounds. I tried saving it as POLYGON but with no luck is it even a POLYGON? Inserting with PHPmyAdmin seems broken.. And I can't find straight forward explanation anywhere..
I tried inserting like that
(ST_GeomFromText('POLYGON((0 0, 0 0))'))
And it went through but when I proper data MySQL throws warning about null values
(ST_GeomFromText('POLYGON((29.3772 60.517,38.490877 74.889862))'))
Also what's even more confusing is that rows get inserted even though column is set as NOT NULL.

Can Neo4j Spatial Geoserver find the country, city given an ip address, if so, how to set up on nodes already created?

I have some data in Neo4j with nodes having ip addresses as properties and I would like to get lat, lon (and city, country) data based on the ip address, similar to using geoip.dat. Can Neo4j Spatial give me this data? What are the steps to achieve this?
Neo4j spatial does not support finding location based on ip. You must use an API designed for getting location off of IP , like http://freegeoip.net/.. you can try calling this API directly with cypher
MATCH (m:Entity)
CALL apoc.load.json("http://freegeoip.net/json/?q=" + m.ip) YIELD value
//return response
RETURN value

Polygon object support in Backand with an external MySQL

I saw a blog post that announced recent filtering support directly through Backand for MySQL points. However, my existing mysql database makes use of the Polygon types as I need to define areas that are more than circular.
At the moment, the Backand syncs the row with a type of String. Is there any way to retrieve my Point objects through the API? Is it possible to decode/encode the strings back into a MySQL Polygon object?
Thank you.
You can always use Backand's Query with SQL syntax (the default is NoSQL) to use all the MySQL geo functionality. You can query ST_Distance, ST_Within and get the individual coordinates of the polygon.
Here is a link how to get them
how to access multipolygon coordinates in mysql
Here is a link how to use MySQL for geo apps
https://www.percona.com/blog/2013/10/21/using-the-new-mysql-spatial-functions-5-6-for-geo-enabled-applications/
To add parameters to your query, add them to the parameters input (comma delimited) and use them with the anchor icon, see the image below.
In the left side of the screen, you get how to call it with angularjs $http syntax.
To add to #relly 's answer, I created a custom query and returned the polygon column as text, making sure to cast the column name to something that doesn't contain brackets using 'as'.

Using Point() in my query results in strange results, am i using it wrong or is this to be expected?

In MySQL Workbench I have a column for Latitude and Longitude and I would like to convert them to point() in order to use that data in a map on Data Tools (SSRS report). I have created a column with the geometry datatype like so:
CREATE Table alabama_table2 (StateName varchar(64),City varchar(64),SpatialData geometry)
And I have the following code for inserting the data
INSERT INTO alabama_table2
select (StateName,City,POINT(NewLatitude,NewLongitude)
From alabama_table
Group By City;
However my results come back in this weird format which I don't think is correct
What am I doing wrong?
You need to convert your internal geo format to text. Use
SELECT ... ST_AsText(geometry)
to retrieve human readable versions of your geometric data items.