##########################################################################
# Script to project coordinates to the GoogleMaps projection and back again
# Date: 4/12/2016
# Author: Jim Graham
##########################################################################

# Setup the gateway to BlueSpray (remember that BlueSpray must be running)

from BlueSprayPy import *

# Create the projector object from the GoogleMaps projector object

TheInputSRS=STBlueSpray.NewGeographic(STGCS.WGS_84)

TheOutputSRS=STBlueSpray.NewGoogleMercator()

# Project a geographic coordinate (WGS 84) to GoogleMaps
Lat=40.0
Lon=-120.0
Easting,Northing=STBlueSpray.Project([Lon,Lat],TheInputSRS,TheOutputSRS)

# Get the result and project it back to geographic
Lon2,Lat2=STBlueSpray.Project([Easting,Northing],TheOutputSRS,TheInputSRS)

print("Original Lat,Lon= "+format(Lat)+", "+format(Lon))

print("Projected Easting, Northing= "+format(Easting)+", "+format(Northing))

print("Back-projected Lat,Lon= "+format(Lat2)+", "+format(Lon2))


