Sunday, June 21, 2015

Tips on JSON and SQL Geography


Here is one way to get key and value attributes from a JSON string which contains the Key and Value attributes in JSON string format.


    var regex = new RegExp('"', 'g');
    $.each(jsonValues, function () {
        newhtml += "<tr>";
        newhtml += s + KeyandValue[0].toString().replace(regex ,'') +e;
        newhtml += s + KeyandValue[1].toString().replace(regex ,'') + e;
        newhtml + "</tr>";
    })
 
 

Here is one tip to convert between DBGeography and SQLGeography

//SqlGeography theGeography;
int srid = 4326; // or alternative
DbGeography newGeography = DbGeography.FromText(theGeography.ToString(), srid);

 
//To reverse it:
DbGeography theGeography;
SqlGeography newGeography = SqlGeography.Parse(theGeography.AsText()).MakeValid();


 
Happy coding.
 
 

All Blogs so far ...