PTV xServer Coordinate Shifting Service

Coordinate Shifting Service

Chinese legislation requires that all digital map data is stored in China in a specific coordinate system. This coordinate system is also used in the PTV China Map. GPS based coordinates usually conform to the WGS-84 projection.
To map those two projections, PTV provides a service to convert WGS-84 based coordinates to the China specific coordinate system. No other formats are supported at this time. The service can be addressed as a simple REST web service via the following url:
http://china-cn.cloud.ptvgroup.com/CoordinateTransformation/shift
The payload of the request consists of an array of coordinates:
[{"longitude":121.47004, latitude":31.23136}, {"longitude":116.46, "latitude":39.92}]
Accordingly, the response is an array of coordinates, too:
[
{"longitude":121.47457,"latitude":31.22942},
{"longitude":116.46614,"latitude":39.92132}
]
Example on how to convert one coordinate via cURL:
Command:
curl -X POST "http://china-cn.cloud.ptvgroup.com/CoordinateTransformation/shift" --data "[{"latitude":31.23136, "longitude":121.47004}]"
Response:
[{"longitude":121.47457,"latitude":31.22942}]
Example on how to convert several coordinates via cURL:
Command:
curl -X POST "http://china-cn.cloud.ptvgroup.com/CoordinateTransformation/shift" --data "[{"latitude":31.23136, "longitude":121.47004}, {"latitude":39.92, "longitude":116.46}]"
Response:
[{"longitude":121.47457,"latitude":31.22942},{"longitude":116.46615,"latitude":39.92133}]
Example on how to address the service in JavaScript:
var objXMLHttpRequest = new XMLHttpRequest();
objXMLHttpRequest.open("POST", "http://china-cn.cloud.ptvgroup.com/CoordinateTransformation/shift", false);
objXMLHttpRequest.setRequestHeader("Content-Type", "application/json; charset=ISO-8859-1");
objXMLHttpRequest.send("[{'latitude':31.23136, 'longitude':121.47004}]");
var response = JSON.parse(objXMLHttpRequest.response);
var shiftedLat = response[0].latitude;
var shiftedLon = response[0].longitude;
Please note that this a very basic example, using neither a framework like jQuery nor calling the service asynchronously - which usually is a good idea. Example on how to address the service in Python:
import requests
import json
r = requests.post("http://china-cn.cloud.ptvgroup.com/CoordinateTransformation/shift", json=[{"latitude":31.23136, "longitude":121.47004}])
print r.text