Beispiel #1
0
 /// Gets data represented by elements and meshes for given quad key.
 void getDataByQuadKey(int tag,                                 // request tag
                       const char *styleFile,                   // style file
                       int tileX, int tileY, int levelOfDetail, // quad key info
                       int eleDataType,                         // elevation data type
                       OnMeshBuilt *meshCallback,               // mesh callback
                       OnElementLoaded *elementCallback,        // element callback
                       OnError *errorCallback,                  // error callback
                       utymap::CancellationToken *cancellationToken) {
   utymap::QuadKey quadKey(levelOfDetail, tileX, tileY);
   auto eleProviderType = static_cast<ElevationDataType>(eleDataType);
   ::safeExecute([&]() {
     auto &styleProvider = context_.getStyleProvider(styleFile);
     auto &eleProvider = context_.getElevationProvider(quadKey, eleProviderType);
     ExportElementVisitor elementVisitor(tag, quadKey, context_.stringTable, styleProvider, eleProvider, elementCallback);
     context_.quadKeyBuilder.build(
       quadKey, styleProvider, eleProvider,
       [&meshCallback, tag](const utymap::math::Mesh &mesh) {
       // NOTE do not notify if mesh is empty.
       if (!mesh.vertices.empty()) {
         meshCallback(tag, mesh.name.data(),
           mesh.vertices.data(), static_cast<int>(mesh.vertices.size()),
           mesh.triangles.data(), static_cast<int>(mesh.triangles.size()),
           mesh.colors.data(), static_cast<int>(mesh.colors.size()),
           mesh.uvs.data(), static_cast<int>(mesh.uvs.size()),
           mesh.uvMap.data(), static_cast<int>(mesh.uvMap.size()));
       }
     }, [&elementVisitor](const utymap::entities::Element &element) {
       element.accept(elementVisitor);
     }, *cancellationToken);
   }, errorCallback);
 }
Beispiel #2
0
    // Loads quadKey.
    void loadQuadKey(const char* styleFile, const utymap::QuadKey& quadKey, OnMeshBuilt* meshCallback,
                  OnElementLoaded* elementCallback, OnError* errorCallback)
    {
        try {
            auto& eleProvider = quadKey.levelOfDetail <= SrtmElevationLodStart
                ? flatEleProvider_
                : (utymap::heightmap::ElevationProvider&) srtmEleProvider_;

            // TODO: preloading is not thread safe: extract separate API function
            eleProvider.preload(utymap::utils::GeoUtils::quadKeyToBoundingBox(quadKey));

            utymap::mapcss::StyleProvider& styleProvider = *getStyleProvider(styleFile);
            QuadKeyElementVisitor elementVisitor(stringTable_, styleProvider, quadKey.levelOfDetail, elementCallback);
            quadKeyBuilder_.build(quadKey, styleProvider, eleProvider,
                [&meshCallback](const utymap::meshing::Mesh& mesh) {
                meshCallback(mesh.name.data(),
                    mesh.vertices.data(), mesh.vertices.size(),
                    mesh.triangles.data(), mesh.triangles.size(),
                    mesh.colors.data(), mesh.colors.size());
            }, [&elementVisitor](const utymap::entities::Element& element) {
                element.accept(elementVisitor);
            });
        }
        catch (std::exception& ex) {
            errorCallback(ex.what());
        }
    }
Beispiel #3
0
 // Loads quadKey.
 void loadQuadKey(const char* styleFile, 
                  const utymap::QuadKey& quadKey, 
                  OnMeshBuilt* meshCallback,
                  OnElementLoaded* elementCallback, 
                  OnError* errorCallback)
 {
     safeExecute([&]() {
         auto styleProvider = getStyleProvider(styleFile);
         ExportElementVisitor elementVisitor(stringTable_, *styleProvider, quadKey.levelOfDetail, elementCallback);
         quadKeyBuilder_.build(quadKey, *styleProvider, getElevationProvider(quadKey),
             [&meshCallback](const utymap::meshing::Mesh& mesh) {
             // NOTE do not notify if mesh is empty.
             if (!mesh.vertices.empty()) {
                 meshCallback(mesh.name.data(),
                     mesh.vertices.data(), static_cast<int>(mesh.vertices.size()),
                     mesh.triangles.data(), static_cast<int>(mesh.triangles.size()),
                     mesh.colors.data(), static_cast<int>(mesh.colors.size()));
             }
         }, [&elementVisitor](const utymap::entities::Element& element) {
             element.accept(elementVisitor);
         });
     }, errorCallback);
 }