The location updates provided by the NAO Suite are provided in the WGS84 referential (longitude, latitude). See section “How to convert coordinates” to see how to switch from WGS84 to pixels.
Download map package
When you upload floor plan as images to NAO Cloud and then align them with the building footprint, the images get geo-referenced. This georeference information can be retrieved from NAO Cloud together with the images.
In order to download the map package :
- Go to your site on NAO Cloud.
- From the left-side menu, click on Developer > Resources.
- Scroll down and find the Maps section then click on Download map package.
In the package you will find for each floor :
- The original image.
- A KML file that can be opened with Google Earth to display the image on top of Google Maps.
- A XML file that contains the geo-referencing information that can be used to convert cordinates between the WGS84 system (longitude / latitude) and image pixel system.
Note You can obtain the maps metadata, using the REST API.
Understanding KML
KML is an open standard officially named the OpenGIS® KML Encoding Standard (OGC KML). It is maintained by the Open Geospatial Consortium, Inc. (OGC). The complete specification for OGC KML can be found at http://www.opengeospatial.org/standards/kml/.
The complete XML schema for KML is located at http://schemas.opengis.net/kml/.
Here is an example of map package corresponding to Pole Star’s french office : maps_PoleStar.
You’ll find the following elements in the zip :
1_floor1_buildingMy Building.kml 1_floor1_buildingMy Building.png 1_floor1_buildingMy Building.xml 2_floor2_buildingMy Building.kml 2_floor2_buildingMy Building.png 2_floor2_buildingMy Building.xml
Looking at the content of 1_floor1_buildingMy Building.kml, we have :
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.1"> <GroundOverlay> <name>My Building - 1</name> <Icon> <href>1_floor1_buildingMy Building.png</href> <viewBoundScale>1.00</viewBoundScale> </Icon> <LatLonBox> <north>43.564402848056</north> <south>43.564174029578</south> <east>1.387571242989</east> <west>1.386984158534</west> <rotation>-17</rotation> </LatLonBox> </GroundOverlay> </kml>
Essentially, what this KML says is “to georeference picture 1_floor1_buildingMy Building.png on the Earth, here is its LatLonBox”.
What is a LatLonBox? More info at https://developers.google.com/kml/documentation/kmlreference#latlonbox
<LatLonBox> Specifies where the top, bottom, right, and left sides of a bounding box – the contours of your floor image – for the ground overlay are aligned.
- <north> Specifies the latitude of the north edge of the bounding box, in decimal degrees from 0 to ±90.
- <south> Specifies the latitude of the south edge of the bounding box, in decimal degrees from 0 to ±90.
- <east> Specifies the longitude of the east edge of the bounding box, in decimal degrees from 0 to ±180. (For overlays that overlap the meridian of 180° longitude, values can extend beyond that range.)
- <west> Specifies the longitude of the west edge of the bounding box, in decimal degrees from 0 to ±180. (For overlays that overlap the meridian of 180° longitude, values can extend beyond that range.)
- <rotation> Specifies a rotation of the overlay about its center, in degrees. Values can be ±180. The default is 0 (north). Rotations are specified in a counterclockwise direction.
How to convert coordinates
Standard process
a. Description
The Location object from the NAO Suite is in WGS84 system (longitude, latitude), thus in order to display this location on the image, we need to convert it to the pixel coordinates system. The conversion is easier with the georeference information in the XML files inside the map package.
The georeference information returned by NAO Cloud has the following format:
<?xml version='1.0' encoding='UTF-8'?> <Map_info name='1322' clockwiseRotationDegrees='15' altitude='5' pixelsPerMeter='11.85237609489639' file='1322_floor1_buildingMain.jpg'> <Matrix OffsetLat='37.41209344905285' OffsetLon='-122.00936907555737' YLat='-7.3262813931385e-07' XLat='-1.9675557357910394e-07' YLon='-2.4610123022592664e-07' XLon='9.205604832527496e-07'/> <Inv_matrix LonX='1013526.7794654198' LatX='-340459.46901106957' LonY='-272194.0806399637' LatY='-1273514.6956928407' OffsetX='136397064.3740145' OffsetY='14434622.759019297'/> </Map_info>
The pixel referential is assumed as follows:
Note You can obtain the maps metadata, using the REST API.
b. WGS84 to pixels
To convert (longitude, latitude) to (X,Y): use <Inv_matrix> item
X = longitude*LonX + latitude*LatX + OffsetX Y = longitude*LonY + latitude*LatY + OffsetY
c. Pixels to WGS84
To convert (X,Y) to (longitude, latitude): use <Matrix> item
longitude = XLon*X + YLon*Y + OffsetLon; latitude = XLat*X + YLat*Y + OffsetLat;
How to use maps with different ratio on NAO Cloud and in your app
On NAO Cloud
- Clone production site on NAO Cloud
- Import the decorated maps on the clone
- Change the maps floor levels/altitudes
- Decorated maps should be at the same altitudes as the production maps
- Technical maps: Any other floor level/altitude that is not used in production (keep it easy to come back to, e.g. do floor level + X*10 and altitude+(X*5), adjusting X to the original floor count)
- Align the decorated maps with the technical maps
- Delete technical maps from clone site (optional)
In your app
- Retrieve the georeferencing information of the decorated maps site.
- Follow the guide above to convert (lat, lon) coordinates to local (x, y) aligned with the decorated maps.
How to use maps with different orientation on NAO Cloud and in your app
rotated_X = Y rotated_Y = rotated_image_height - X
rotated_X = rotated_image_width - X rotated_Y = X