# SET WHATEVER SCHEMA YOU LIKE and run this # DROP SCHEMA IF EXISTS `gambling`; # CREATE DATABASE `gambling` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ /*!80016 DEFAULT ENCRYPTION='N' */; USE gambling; DROP TABLE IF EXISTS `locations`; CREATE TABLE `locations` ( `idx` int NOT NULL AUTO_INCREMENT, `Short-Name` varchar(45) COLLATE utf8mb4_bin DEFAULT NULL, `GeoLoc` geometry DEFAULT NULL, PRIMARY KEY (`idx`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; insert into `locations` (`Short-Name`,`GeoLoc`) values ("BlueChip",ST_SRID(POINT (41.718692846098243,-86.892960902249271),4326)); insert into `locations` (`Short-Name`,`GeoLoc`) values ("4Winds-SB",ST_SRID(POINT (41.640771092229699,-86.292634483638253),4326)); insert into `locations` (`Short-Name`,`GeoLoc`) values ("4Winds-NB",ST_SRID(POINT (41.781732964225817,-86.708300417798142),4326)); insert into `locations` (`Short-Name`,`GeoLoc`) values ("4Winds-DP",ST_SRID(POINT (41.945720369297725,-86.16231096249841),4326)); Select `Short-Name`,ST_asText(GeoLoc) from locations; #***** Which if is like my system you will see..... # Short-Name ST_asText(GeoLoc) # --------------------------------------------------------- # BlueChip, POINT(-86.89296090224927 41.71869284609824) # 4Winds-SB, POINT(-86.29263448363825 41.6407710922297) # Winds-NB, POINT(-86.70830041779814 41.78173296422582) # 4Winds-DP, POINT(-86.16231096249841 41.945720369297725) # ---------------------------------------------------------- # And if you look at the actual blob you will see that the numbers are actually in there in the opposite order # and as an aside NOT in Antartica # ST_AsText should return the values as listed and not try to impose anything on them outside of the SRID rules ? # I did make it work in a procedure with the following commands ... # DECLARE orgin GEOMETRY ; # SELECT ST_Geomfromtext(St_AsText(geoloc)) FROM gameing_locations WHERE `Short-Name` LIKE "Orgin" LIMIT 1 into orgin; # SET d1 := ROUND(((ST_Distance_Sphere(orgin ,dest)) * 0.00062137119223733 ),2) ; *** Same exact select for dest *** # BTW it took hours and hours to finally get that to work fidding around with what should have been 2 minutes of code. hehe, and was # in the end. # I do not know why it did not flip-? in the select statement ...but the distances came out EXACTLY what google maps reports. # So good enough for what i am doing. # here is the procedure if that helps narrow things down ....because it works with ST_AsText with whatever voodoo is going on .. # CREATE DEFINER=`me`@`%` PROCEDURE `Distance`() # BEGIN # DECLARE tidx INT DEfault 1 ; # DECLARE rowcount INT DEFAULT 0 ; # DECLARE d1 FLOAT DEFAULT 0 ; # DECLARE orgin GEOMETRY ; # DECLARE dest GEOMETRY ; # SELECT COUNT(*) FROM gameing_locations INTO rowcount; # SELECT ST_Geomfromtext(St_AsText(geoloc)) FROM gameing_locations WHERE `Short-Name` LIKE "Orgin" LIMIT 1 into orgin; # UPDATE gameing_locations SET distance = 0 where idx=tidx ; # Sel: LOOP # SET tidx =tidx +1 ; # IF tidx > rowcount THEN leave Sel; END IF ; # # SELECT ST_GeomFromText(ST_AsText(geoloc)) FROM gameing_locations WHERE `Short-Name` NOT LIKE "Orgin" AND idx=tidx LIMIT 1 INTO dest; # SET d1 := ROUND(((ST_Distance_Sphere(orgin ,dest))* 0.00062137119223733 ),2) ; # # Select d1 ; # UPDATE gameing_locations SET distance = d1 where idx=tidx ; # END LOOP; # END