/* DrawMap - a demo program for libosmscout Copyright (C) 2009 Tim Teulings This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include /* Example for the nordrhein-westfalen.osm (to be executed in meson build directory): Demos/DrawMapCairo ../maps/nordrhein-westfalen ../stylesheets/standard.oss 800 480 51.51241 7.46525 70000 test.png */ osmscout::DatabaseParameter databaseParameter; osmscout::DatabaseRef database; osmscout::MapServiceRef mapService; osmscout::StyleConfigRef styleConfig; osmscout::BasemapDatabaseRef basemapDatabase; osmscout::MercatorProjection projection; osmscout::MapParameter drawParameter; osmscout::AreaSearchParameter searchParameter; osmscout::MapData data; int DrawMapCairoInit(int argc, char* argv[]) { database=std::make_shared(databaseParameter); if (!database->Open("data/nordrhein-westfalen-latest/")) { std::cerr << "Cannot open database" << std::endl; return -1; } mapService=std::make_shared(database); styleConfig = std::make_shared(database->GetTypeConfig()); if (!styleConfig->Load("data/standard.oss")) { std::cerr << "Cannot open style" << std::endl; return -1; } drawParameter.SetFontName("/usr/share/fonts/TTF/LiberationSans-Regular.ttf"); drawParameter.SetFontSize(3.0); drawParameter.SetRenderSeaLand(true); drawParameter.SetRenderUnknowns(false); drawParameter.SetRenderBackground(false); drawParameter.SetRenderContourLines(false); drawParameter.SetRenderHillShading(false); //drawParameter.SetIconMode(args.iconMode); //drawParameter.SetIconPaths(args.iconPaths); drawParameter.SetDebugData(false); drawParameter.SetDebugPerformance(false); drawParameter.SetLabelLineMinCharCount(15); drawParameter.SetLabelLineMaxCharCount(30); drawParameter.SetLabelLineFitToArea(true); return 0; } int DrawMapCairo(cairo_surface_t *surface, double lat, double lon, unsigned int zoomlevel, double direction) { osmscout::GeoCoord center(lat, lon); osmscout::Magnification zoom{osmscout::Magnification::magClose}; std::list tiles; osmscout::MapPainterCairo painter(styleConfig); cairo_t *cairo=cairo_create(surface); assert(database); assert(database->IsOpen()); assert(mapService); assert(styleConfig); zoom.SetMagnification(zoomlevel); projection.Set(center, direction, zoom, 96, 800, 600); mapService->LookupTiles(projection, tiles); mapService->LoadMissingTileData(searchParameter,*styleConfig, tiles); mapService->AddTileDataToMapData(tiles, data); mapService->GetGroundTiles(projection, data.groundTiles); //LoadBaseMapTiles(data.baseMapTiles); osmscout::GeoBox boundingBox; projection.GetDimensions(boundingBox); if (!painter.DrawMap(projection, drawParameter, data, cairo)) std::cerr << "Cannot paint" << std::endl;; cairo_destroy(cairo); return 0; }