-
Notifications
You must be signed in to change notification settings - Fork 30
add wmts wms tms urltemplate rasterOverlay #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f17436
add wmts wms tms urltemplate rasterOverlay
chengdz 17ce0ea
improve rasterOverlays and add test files
chengdz 8535da2
Fixed wmts wms test file configuration error
chengdz dfe6e36
forgot to check in changes to src/vsgCs/CMakeLists.txt
chengdz 1d9691f
Fixed overlay-tms.json test file configuration error
chengdz f31cf9f
Handle code review
chengdz f664460
Merge branch 'timoore:master' into addRasterOverlay
chengdz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* <editor-fold desc="MIT License"> | ||
|
|
||
| Copyright(c) 2023 Timothy Moore | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| </editor-fold> */ | ||
|
|
||
| #include "CsTileMapServiceRasterOverlay.h" | ||
|
|
||
| #include "jsonUtils.h" | ||
| #include <CesiumRasterOverlays/TileMapServiceRasterOverlay.h> | ||
| #include <CesiumUtility/JsonHelpers.h> | ||
|
|
||
| using namespace vsgCs; | ||
|
|
||
| CesiumRasterOverlays::RasterOverlay* CsTileMapServiceRasterOverlay::createOverlay( | ||
| const CesiumRasterOverlays::RasterOverlayOptions& options) | ||
| { | ||
| if (this->Url.empty()) | ||
| { | ||
| // Don't create an overlay with an empty URL. | ||
| return nullptr; | ||
| } | ||
|
|
||
| CesiumRasterOverlays::TileMapServiceRasterOverlayOptions tmsOptions; | ||
| if (MaximumLevel > MinimumLevel && bSpecifyZoomLevels) | ||
| { | ||
| tmsOptions.minimumLevel = MinimumLevel; | ||
| tmsOptions.maximumLevel = MaximumLevel; | ||
| } | ||
|
|
||
| std::vector<CesiumAsync::IAssetAccessor::THeader> headers; | ||
|
|
||
| for (const auto& [Key, Value] : this->RequestHeaders) | ||
| { | ||
| headers.push_back(CesiumAsync::IAssetAccessor::THeader{ | ||
| (Key), | ||
| (Value) }); | ||
| } | ||
|
|
||
| return new CesiumRasterOverlays::TileMapServiceRasterOverlay( | ||
| (this->MaterialLayerKey), | ||
| (this->Url), | ||
| headers, | ||
| tmsOptions, | ||
| options); | ||
| } | ||
|
|
||
| namespace vsgCs | ||
| { | ||
| vsg::ref_ptr<vsg::Object> buildCsTileMapServiceRasterOverlay(const rapidjson::Value& json, | ||
| JSONObjectFactory* factory, | ||
| const vsg::ref_ptr<vsg::Object>& object) | ||
| { | ||
| auto overlay = create_or<CsTileMapServiceRasterOverlay>(object); | ||
| factory->build(json, "CsOverlay", overlay); | ||
| overlay->MaterialLayerKey = CesiumUtility::JsonHelpers::getStringOrDefault(json, "materialKey", | ||
| "Overlay0"); | ||
| overlay->Url = CesiumUtility::JsonHelpers::getStringOrDefault(json, "url", ""); | ||
|
|
||
| return overlay; | ||
| } | ||
|
|
||
| // XXX See jsonUtils for registration. | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* <editor-fold desc="MIT License"> | ||
|
|
||
| Copyright(c) 2023 Timothy Moore | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| </editor-fold> */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "CsOverlay.h" | ||
|
|
||
| namespace vsgCs | ||
| { | ||
| class VSGCS_EXPORT CsTileMapServiceRasterOverlay : public vsg::Inherit<CsOverlay, | ||
| CsTileMapServiceRasterOverlay> | ||
| { | ||
| public: | ||
| CsTileMapServiceRasterOverlay( | ||
| std::string in_Url = std::string()) | ||
| : Url(in_Url) | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * The base URL of the Tile Map Service (TMS). | ||
| */ | ||
| std::string Url; | ||
|
|
||
| /** | ||
| * True to directly specify minum and maximum zoom levels available from the | ||
| * server, or false to automatically determine the minimum and maximum zoom | ||
| * levels from the server's tilemapresource.xml file. | ||
| */ | ||
| bool bSpecifyZoomLevels = false; | ||
|
|
||
| /** | ||
| * Minimum zoom level. | ||
| */ | ||
| int32_t MinimumLevel = 0; | ||
|
|
||
| /** | ||
| * Maximum zoom level. | ||
| */ | ||
| int32_t MaximumLevel = 10; | ||
|
|
||
| /** | ||
| * HTTP headers to be attached to each request made for this raster overlay. | ||
| */ | ||
| std::map<std::string, std::string> RequestHeaders; | ||
|
|
||
| CesiumRasterOverlays::RasterOverlay* createOverlay( | ||
| const CesiumRasterOverlays::RasterOverlayOptions& options) override; | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /* <editor-fold desc="MIT License"> | ||
|
|
||
| Copyright(c) 2023 Timothy Moore | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| </editor-fold> */ | ||
|
|
||
| #include "CsUrlTemplateRasterOverlay.h" | ||
|
|
||
| #include "jsonUtils.h" | ||
| #include <CesiumRasterOverlays/UrlTemplateRasterOverlay.h> | ||
| #include <CesiumUtility/JsonHelpers.h> | ||
|
|
||
| using namespace vsgCs; | ||
|
|
||
| CesiumRasterOverlays::RasterOverlay* CsUrlTemplateRasterOverlay::createOverlay( | ||
| const CesiumRasterOverlays::RasterOverlayOptions& options) | ||
| { | ||
| if (this->TemplateUrl.empty()) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't use |
||
| { | ||
| // Don't create an overlay with an empty base URL. | ||
| return nullptr; | ||
| } | ||
|
|
||
| CesiumRasterOverlays::UrlTemplateRasterOverlayOptions urlTemplateOptions; | ||
|
|
||
| urlTemplateOptions.minimumLevel = MinimumLevel; | ||
| urlTemplateOptions.maximumLevel = MaximumLevel; | ||
|
|
||
| urlTemplateOptions.tileWidth = this->TileWidth; | ||
| urlTemplateOptions.tileHeight = this->TileHeight; | ||
|
|
||
| const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid; | ||
|
|
||
| if (this->Projection == | ||
| ECesiumUrlTemplateRasterOverlayProjection::Geographic) | ||
| { | ||
| urlTemplateOptions.projection = | ||
| CesiumGeospatial::GeographicProjection(ellipsoid); | ||
| } | ||
| else | ||
| { | ||
| urlTemplateOptions.projection = | ||
| CesiumGeospatial::WebMercatorProjection(ellipsoid); | ||
| } | ||
|
|
||
| if (bSpecifyTilingScheme) | ||
| { | ||
| CesiumGeospatial::GlobeRectangle globeRectangle = | ||
| CesiumGeospatial::GlobeRectangle::fromDegrees( | ||
| RectangleWest, | ||
| RectangleSouth, | ||
| RectangleEast, | ||
| RectangleNorth); | ||
| CesiumGeometry::Rectangle coverageRectangle = | ||
| CesiumGeospatial::projectRectangleSimple( | ||
| *urlTemplateOptions.projection, | ||
| globeRectangle); | ||
| urlTemplateOptions.coverageRectangle = coverageRectangle; | ||
| urlTemplateOptions.tilingScheme = CesiumGeometry::QuadtreeTilingScheme( | ||
| coverageRectangle, | ||
| RootTilesX, | ||
| RootTilesY); | ||
| } | ||
|
|
||
| std::vector<CesiumAsync::IAssetAccessor::THeader> headers; | ||
|
|
||
| for (const auto& [Key, Value] : this->RequestHeaders) | ||
| { | ||
| headers.push_back(CesiumAsync::IAssetAccessor::THeader{ | ||
| (Key), | ||
| (Value) }); | ||
| } | ||
|
|
||
| return new CesiumRasterOverlays::UrlTemplateRasterOverlay( | ||
| (this->MaterialLayerKey), | ||
|
timoore marked this conversation as resolved.
Outdated
|
||
| (this->TemplateUrl), | ||
| headers, | ||
| urlTemplateOptions, | ||
| options); | ||
| } | ||
|
|
||
| namespace vsgCs | ||
| { | ||
| vsg::ref_ptr<vsg::Object> buildCsUrlTemplateRasterOverlay(const rapidjson::Value& json, | ||
| JSONObjectFactory* factory, | ||
| const vsg::ref_ptr<vsg::Object>& object) | ||
| { | ||
| auto overlay = create_or<CsUrlTemplateRasterOverlay>(object); | ||
| factory->build(json, "CsOverlay", overlay); | ||
| overlay->MaterialLayerKey = CesiumUtility::JsonHelpers::getStringOrDefault(json, "materialKey", | ||
| "Overlay0"); | ||
| overlay->TemplateUrl = CesiumUtility::JsonHelpers::getStringOrDefault(json, "url", ""); | ||
| std::string projection = CesiumUtility::JsonHelpers::getStringOrDefault(json, "projection", ""); | ||
| overlay->Projection = projection == "geographic" ? ECesiumUrlTemplateRasterOverlayProjection::Geographic : ECesiumUrlTemplateRasterOverlayProjection::WebMercator; | ||
|
|
||
| return overlay; | ||
| } | ||
|
|
||
| // XXX See jsonUtils for registration. | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.