#ifndef TESTMAPEARTHREG_H #define TESTMAPEARTHREG_H /** * test map<-> earth registration * by converting the map to lon/lat and exporting to google-maps */ void testMapEarthReg(const std::string& fMap) { Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(fMap); std::ofstream outOSM("/apps/android/workspace/OTHER2017/osm/osm.txt"); outOSM << "lat lon title icon iconSize iconOffset\n"; outOSM.precision(20); // our markers std::ofstream outGooglePOI("/apps/android/workspace/OTHER2017/osm/googlePOI.js"); outGooglePOI << "function getPOI() {return [\n"; outGooglePOI.precision(20); int cnt = 0; for (Floorplan::EarthPosMapPos* em : map->earthReg.correspondences) { //mapCenter += em->posOnMap_m.xy(); //earthCenter.lat += em->posOnEarth.lat; //earthCenter.lon += em->posOnEarth.lon; outOSM << em->posOnEarth.lat << "\t" << em->posOnEarth.lon << "\t" << "title" << "\t" << "osm.png" << "\t" << "16,16" << "\t" << "-8,-8" << "\n"; outGooglePOI << "\t{lat:" << em->posOnEarth.lat << ", lng:" << em->posOnEarth.lon << "},\n"; ++cnt; } outGooglePOI << "];}"; outGooglePOI.flush(); outOSM.flush(); //const EarthMapping em1(Point3(mapCenter.x, mapCenter.y, 0), earthCenter, 0); // construct mapper const EarthMapping em(map); // export building's first floor std::ofstream outGooglePoly("/apps/android/workspace/OTHER2017/osm/googlePoly.js"); outGooglePoly << "function getPoly() {return [\n"; outGooglePoly.precision(20); // export to google maps lon/lat Floorplan::Floor* f1 = map->floors[1]; for (Floorplan::FloorOutlinePolygon* poly : f1->outline) { if (poly->method != Floorplan::OutlineMethod::ADD) {continue;} if (poly->outdoor) {continue;} outGooglePoly << "[\n"; for (int i = 0; i <= poly->poly.points.size(); ++i) { const Point2 p = poly->poly.points[i % poly->poly.points.size()]; const EarthPos ep = em.mapToWorld(Point3(p.x, p.y, 0)); outGooglePoly << "\t{lat:" << ep.lat << ", lng:" << ep.lon << "},\n"; } outGooglePoly << "],"; } outGooglePoly << "];}"; outGooglePoly.flush(); int i = 0; (void) i; } #endif // TESTMAPEARTHREG_H