samedi 25 juin 2016

Pulling SQL Server GEOGRAPHY to POLYGONS

I have this query SELECT ' {"location":"'+ G.ZCTA5CE10 +', ' + INTPTLON10 + ', ' + INTPTLAT10 + '",'+ '"polygon":' + replace(replace(replace(replace(replace(replace(replace(G.geom.ToString(), 'POLYGON ((', '[{"lng":'), '))', '}]'), ', ', '},{"lng":'), ' ', ',"lat":'), ')', ''), '(', ''), 'MULTI', '') + '}' FROM REF_ZIP_GEOG G WITH(INDEX([geog_sidx])) WHERE G.geom.STDistance(geography::STPointFromText('POINT(-81.3225 32.113)', 4326))<= 40234; --40.234 KM ~ 25 Miles The intent of this query is to "Stringify" the GEOGRAPHY polygon into google maps. POLYGONS are working great. However, if the POLYGON is a MULTI-POLYGON, I am having issues working the JSON. The result is a Google error of a bad JSON. Has anyone worked with MULTI POLYGONS and could you recommend anything to alter my SQL statement to work this correctly? Thanks.

Aucun commentaire:

Enregistrer un commentaire