@mapxus/mapxus-visual-jp 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bitbucket-pipelines.yml +50 -0
- package/config/rollup.js +33 -0
- package/config/rollup.serve.config.js +3 -0
- package/debug/circlemarker.html +444 -0
- package/debug/create_tags.html +474 -0
- package/debug/distance.html +220 -0
- package/debug/index.html +92 -0
- package/debug/integration.html +1084 -0
- package/debug/leaflet.html +54 -0
- package/debug/markers.html +115 -0
- package/debug/multi_monitor_sync.html +377 -0
- package/debug/outdoor.html +1026 -0
- package/debug/rect_tags.html +147 -0
- package/debug/rotate.html +236 -0
- package/debug/sample.html +324 -0
- package/debug/sequence.html +75 -0
- package/debug/tags.html +218 -0
- package/package.json +34 -10
- package/rollup.config.js +39 -0
- package/server.js +35 -0
- package/spec/api/APIv3.spec.ts +86 -0
- package/spec/component/Component.spec.ts +68 -0
- package/spec/component/StatsComponent.spec.ts +33 -0
- package/spec/component/direction/DirectionComponent.spec.ts +163 -0
- package/spec/component/direction/DirectionDOMRenderer.spec.ts +233 -0
- package/spec/component/keyboard/KeyZoomHandler.spec.ts +236 -0
- package/spec/component/marker/Marker.spec.ts +104 -0
- package/spec/component/marker/MarkerComponent.spec.ts +88 -0
- package/spec/component/marker/MarkerScene.spec.ts +223 -0
- package/spec/component/marker/MarkerSet.spec.ts +453 -0
- package/spec/component/mouse/DoubleClickZoomHandler.spec.ts +211 -0
- package/spec/component/popup/Popup.spec.ts +479 -0
- package/spec/component/popup/PopupComponent.spec.ts +414 -0
- package/spec/component/tag/CreateHandlerBase.spec.ts +83 -0
- package/spec/component/tag/CreatePointHandler.spec.ts +190 -0
- package/spec/component/tag/OutlineRenderTag.spec.ts +91 -0
- package/spec/component/tag/PointGeometry.spec.ts +131 -0
- package/spec/component/tag/PolygonGeometry.spec.ts +497 -0
- package/spec/component/tag/RectGeometry.spec.ts +1157 -0
- package/spec/component/tag/TagComponent.spec.ts +513 -0
- package/spec/component/tag/TagScene.spec.ts +346 -0
- package/spec/component/tag/TagSet.spec.ts +241 -0
- package/spec/component/utils/HandlerBase.spec.ts +203 -0
- package/spec/geo/Camera.spec.ts +250 -0
- package/spec/geo/GeoCoords.spec.ts +364 -0
- package/spec/geo/Spatial.spec.ts +711 -0
- package/spec/geo/Transform.spec.ts +850 -0
- package/spec/geo/ViewportCoords.spec.ts +534 -0
- package/spec/graph/FilterCreator.spec.ts +892 -0
- package/spec/graph/Graph.spec.ts +2078 -0
- package/spec/graph/GraphCalculator.spec.ts +263 -0
- package/spec/graph/GraphService.spec.ts +663 -0
- package/spec/graph/Node.spec.ts +373 -0
- package/spec/graph/NodeCache.spec.ts +206 -0
- package/spec/graph/Sequence.spec.ts +37 -0
- package/spec/graph/edge/EdgeCalculator.Pano.spec.ts +963 -0
- package/spec/graph/edge/EdgeCalculator.Sequence.spec.ts +108 -0
- package/spec/graph/edge/EdgeCalculator.Similar.spec.ts +272 -0
- package/spec/graph/edge/EdgeCalculator.Step.spec.ts +383 -0
- package/spec/graph/edge/EdgeCalculator.Turn.spec.ts +278 -0
- package/spec/graph/edge/EdgeCalculator.spec.ts +747 -0
- package/spec/helper/ContainerMockCreator.spec.ts +33 -0
- package/spec/helper/DOMRendererMockCreator.spec.ts +22 -0
- package/spec/helper/EdgeCalculatorHelper.spec.ts +96 -0
- package/spec/helper/EventHelper.spec.ts +92 -0
- package/spec/helper/GLRendererMockCreator.spec.ts +23 -0
- package/spec/helper/GeoHelper.spec.ts +16 -0
- package/spec/helper/ImageLoadingServiceMockCreator.spec.ts +24 -0
- package/spec/helper/KeyboardServiceMockCreator.spec.ts +21 -0
- package/spec/helper/LoadingServiceMockCreator.spec.ts +21 -0
- package/spec/helper/MockCreator.spec.ts +18 -0
- package/spec/helper/MockCreatorBase.spec.ts +17 -0
- package/spec/helper/MouseServiceMockCreator.spec.ts +38 -0
- package/spec/helper/NavigatorMockCreator.spec.ts +28 -0
- package/spec/helper/NodeHelper.spec.ts +77 -0
- package/spec/helper/NodeMockCreator.spec.ts +19 -0
- package/spec/helper/RenderServiceMockCreator.spec.ts +25 -0
- package/spec/helper/SpriteServiceMockCreator.spec.ts +22 -0
- package/spec/helper/StateServiceMockCreator.spec.ts +33 -0
- package/spec/helper/TouchServiceMockCreator.spec.ts +29 -0
- package/spec/helper/TransformHelper.spec.ts +17 -0
- package/spec/render/DOMRenderer.spec.ts +112 -0
- package/spec/render/GLRenderer.spec.ts +453 -0
- package/spec/render/RenderCamera.spec.ts +535 -0
- package/spec/render/RenderService.spec.ts +531 -0
- package/spec/state/StateBase.spec.ts +369 -0
- package/spec/state/StateService.spec.ts +9 -0
- package/spec/state/TraversingState.spec.ts +262 -0
- package/spec/state/WaitingState.spec.ts +319 -0
- package/spec/tiles/TextureProvider.spec.ts +653 -0
- package/spec/utils/EventEmitter.spec.ts +71 -0
- package/spec/utils/Support.spec.ts +54 -0
- package/spec/viewer/CacheService.spec.ts +160 -0
- package/spec/viewer/ComponentController.spec.ts +310 -0
- package/spec/viewer/LoadingService.spec.ts +19 -0
- package/spec/viewer/MouseService.spec.ts +1344 -0
- package/spec/viewer/Navigator.spec.ts +970 -0
- package/spec/viewer/Observer.spec.ts +96 -0
- package/spec/viewer/SpriteService.spec.ts +224 -0
- package/src/API.ts +3 -0
- package/src/Component.ts +77 -0
- package/src/Edge.ts +6 -0
- package/src/Error.ts +3 -0
- package/src/FilterRender.ts +27 -0
- package/src/Geo.ts +7 -0
- package/src/Graph.ts +19 -0
- package/src/MapxusVisual.ts +66 -0
- package/src/Render.ts +7 -0
- package/src/State.ts +8 -0
- package/src/Support.ts +35 -0
- package/src/Tiles.ts +5 -0
- package/src/Utils.ts +6 -0
- package/src/Viewer.ts +16 -0
- package/src/api/API.ts +396 -0
- package/src/api/Auth.ts +76 -0
- package/src/api/AuthStore.ts +11 -0
- package/src/api/GraphQLCreator.ts +100 -0
- package/src/api/interfaces/IAuth.ts +7 -0
- package/src/api/interfaces/IBuildingBase.ts +7 -0
- package/src/api/interfaces/IBuildingInfo.ts +19 -0
- package/src/api/interfaces/ICoreNode.ts +28 -0
- package/src/api/interfaces/IFillNode.ts +96 -0
- package/src/api/interfaces/IFloorInfo.ts +10 -0
- package/src/api/interfaces/IFullNode.ts +10 -0
- package/src/api/interfaces/IGPano.ts +38 -0
- package/src/api/interfaces/IImageTagInfo.ts +14 -0
- package/src/api/interfaces/IKey.ts +13 -0
- package/src/api/interfaces/ILatLon.ts +19 -0
- package/src/api/interfaces/IOutdoor.ts +14 -0
- package/src/api/interfaces/IPathNode.ts +37 -0
- package/src/api/interfaces/IProject.ts +8 -0
- package/src/api/interfaces/IQueryBuilding.ts +37 -0
- package/src/api/interfaces/IResponse.ts +7 -0
- package/src/api/interfaces/ISequence.ts +16 -0
- package/src/api/interfaces/IUser.ts +13 -0
- package/src/api/interfaces/interfaces.ts +17 -0
- package/src/component/AttributionComponent.ts +48 -0
- package/src/component/BackgroundComponent.ts +39 -0
- package/src/component/BearingComponent.ts +282 -0
- package/src/component/CacheComponent.ts +295 -0
- package/src/component/Component.ts +130 -0
- package/src/component/ComponentService.ts +150 -0
- package/src/component/CoverComponent.ts +132 -0
- package/src/component/DebugComponent.ts +157 -0
- package/src/component/ImageComponent.ts +96 -0
- package/src/component/LoadingComponent.ts +85 -0
- package/src/component/NavigationComponent.ts +233 -0
- package/src/component/RouteComponent.ts +354 -0
- package/src/component/StatsComponent.ts +100 -0
- package/src/component/direction/DirectionComponent.ts +254 -0
- package/src/component/direction/DirectionDOMCalculator.ts +243 -0
- package/src/component/direction/DirectionDOMRenderer.ts +631 -0
- package/src/component/imageplane/ImagePlaneComponent.ts +497 -0
- package/src/component/imageplane/ImagePlaneFactory.ts +314 -0
- package/src/component/imageplane/ImagePlaneGLRenderer.ts +247 -0
- package/src/component/imageplane/ImagePlaneScene.ts +87 -0
- package/src/component/imageplane/ImagePlaneShaders.ts +16 -0
- package/src/component/imageplane/SliderComponent.ts +697 -0
- package/src/component/imageplane/interfaces/IBBoxShaderMaterial.ts +10 -0
- package/src/component/imageplane/interfaces/IShaderMaterial.ts +9 -0
- package/src/component/imageplane/interfaces/interfaces.ts +2 -0
- package/src/component/imageplane/shaders/equirectangular.fragment.glsl.ts +26 -0
- package/src/component/imageplane/shaders/equirectangular.vertex.glsl.ts +15 -0
- package/src/component/imageplane/shaders/perspective.fragment.glsl.ts +27 -0
- package/src/component/imageplane/shaders/perspective.vertex.glsl.ts +15 -0
- package/src/component/interfaces/ICacheConfiguration.ts +72 -0
- package/src/component/interfaces/IComponentConfiguration.ts +5 -0
- package/src/component/interfaces/ICoverConfiguration.ts +15 -0
- package/src/component/interfaces/IDirectionConfiguration.ts +63 -0
- package/src/component/interfaces/IImagePlaneConfiguration.ts +17 -0
- package/src/component/interfaces/IKeyboardConfiguration.ts +44 -0
- package/src/component/interfaces/IMarkerConfiguration.ts +31 -0
- package/src/component/interfaces/IMouseConfiguration.ts +52 -0
- package/src/component/interfaces/INavigationConfiguration.ts +35 -0
- package/src/component/interfaces/IRouteConfiguration.ts +20 -0
- package/src/component/interfaces/ISequenceConfiguration.ts +72 -0
- package/src/component/interfaces/IShader.ts +6 -0
- package/src/component/interfaces/ISliderConfiguration.ts +61 -0
- package/src/component/interfaces/ITagConfiguration.ts +40 -0
- package/src/component/interfaces/interfaces.ts +17 -0
- package/src/component/keyboard/KeySequenceNavigationHandler.ts +86 -0
- package/src/component/keyboard/KeySpatialNavigationHandler.ts +216 -0
- package/src/component/keyboard/KeyZoomHandler.ts +106 -0
- package/src/component/keyboard/KeyboardComponent.ts +125 -0
- package/src/component/marker/Marker.ts +5 -0
- package/src/component/marker/MarkerComponent.ts +856 -0
- package/src/component/marker/MarkerScene.ts +145 -0
- package/src/component/marker/MarkerSet.ts +142 -0
- package/src/component/marker/interfaces/IArrowMarkerOptions.ts +41 -0
- package/src/component/marker/interfaces/ICircleMarkerOptions.ts +30 -0
- package/src/component/marker/interfaces/IDotMarkerOptions.ts +18 -0
- package/src/component/marker/interfaces/IMarkerEvent.ts +28 -0
- package/src/component/marker/interfaces/ISimpleMarkerOptions.ts +54 -0
- package/src/component/marker/interfaces/interfaces.ts +5 -0
- package/src/component/marker/marker/ArrowMarker.ts +84 -0
- package/src/component/marker/marker/CircleMarker.ts +82 -0
- package/src/component/marker/marker/DotMarker.ts +68 -0
- package/src/component/marker/marker/ImageMarker.ts +45 -0
- package/src/component/marker/marker/Marker.ts +99 -0
- package/src/component/marker/marker/SimpleMarker.ts +187 -0
- package/src/component/mouse/BounceHandler.ts +148 -0
- package/src/component/mouse/DoubleClickZoomHandler.ts +106 -0
- package/src/component/mouse/DragPanHandler.ts +489 -0
- package/src/component/mouse/HandlerTypes.ts +13 -0
- package/src/component/mouse/MouseComponent.ts +170 -0
- package/src/component/mouse/ScrollZoomHandler.ts +137 -0
- package/src/component/mouse/TouchZoomHandler.ts +136 -0
- package/src/component/path/PathComponent.ts +75 -0
- package/src/component/path/PathEvent.ts +245 -0
- package/src/component/path/PathMarker.ts +42 -0
- package/src/component/path/PathRender.ts +163 -0
- package/src/component/popup/Popup.ts +2 -0
- package/src/component/popup/PopupComponent.ts +244 -0
- package/src/component/popup/interfaces/IPopupOffset.ts +37 -0
- package/src/component/popup/interfaces/IPopupOptions.ts +81 -0
- package/src/component/popup/popup/Popup.ts +594 -0
- package/src/component/popup/popup/PopupAlignment.ts +3 -0
- package/src/component/sequence/SequenceComponent.ts +500 -0
- package/src/component/sequence/SequenceDOMInteraction.ts +23 -0
- package/src/component/sequence/SequenceDOMRenderer.ts +179 -0
- package/src/component/tag/Tag.ts +9 -0
- package/src/component/tag/TagComponent.ts +787 -0
- package/src/component/tag/TagCreator.ts +138 -0
- package/src/component/tag/TagDOMRenderer.ts +35 -0
- package/src/component/tag/TagMode.ts +37 -0
- package/src/component/tag/TagOperation.ts +7 -0
- package/src/component/tag/TagScene.ts +216 -0
- package/src/component/tag/TagSet.ts +186 -0
- package/src/component/tag/error/GeometryTagError.ts +11 -0
- package/src/component/tag/geometry/Geometry.ts +62 -0
- package/src/component/tag/geometry/PointGeometry.ts +89 -0
- package/src/component/tag/geometry/PolygonGeometry.ts +349 -0
- package/src/component/tag/geometry/RectGeometry.ts +759 -0
- package/src/component/tag/geometry/VertexGeometry.ts +185 -0
- package/src/component/tag/handlers/CreateHandlerBase.ts +81 -0
- package/src/component/tag/handlers/CreatePointHandler.ts +35 -0
- package/src/component/tag/handlers/CreatePolygonHandler.ts +33 -0
- package/src/component/tag/handlers/CreateRectDragHandler.ts +199 -0
- package/src/component/tag/handlers/CreateRectHandler.ts +57 -0
- package/src/component/tag/handlers/CreateVertexHandler.ts +165 -0
- package/src/component/tag/handlers/EditVertexHandler.ts +275 -0
- package/src/component/tag/handlers/TagHandlerBase.ts +57 -0
- package/src/component/tag/interfaces/IInteraction.ts +14 -0
- package/src/component/tag/interfaces/IOutlineCreateTagOptions.ts +15 -0
- package/src/component/tag/interfaces/IOutlineTagOptions.ts +89 -0
- package/src/component/tag/interfaces/ISpotTagOptions.ts +37 -0
- package/src/component/tag/interfaces/interfaces.ts +4 -0
- package/src/component/tag/tag/OutlineCreateTag.ts +330 -0
- package/src/component/tag/tag/OutlineRenderTag.ts +569 -0
- package/src/component/tag/tag/OutlineTag.ts +380 -0
- package/src/component/tag/tag/RenderTag.ts +50 -0
- package/src/component/tag/tag/SpotRenderTag.ts +160 -0
- package/src/component/tag/tag/SpotTag.ts +170 -0
- package/src/component/tag/tag/Tag.ts +103 -0
- package/src/component/utils/HandlerBase.ts +71 -0
- package/src/error/ArgumentBeeviewError.ts +11 -0
- package/src/error/BeeviewError.ts +9 -0
- package/src/error/GraphBeeviewError.ts +11 -0
- package/src/geo/Camera.ts +149 -0
- package/src/geo/GeoCoords.ts +280 -0
- package/src/geo/GeoRBush.ts +25 -0
- package/src/geo/Spatial.ts +259 -0
- package/src/geo/Transform.ts +543 -0
- package/src/geo/ViewportCoords.ts +518 -0
- package/src/geo/interfaces/ILatLonAlt.ts +7 -0
- package/src/geo/interfaces/interfaces.ts +1 -0
- package/src/graph/FilterCreator.ts +106 -0
- package/src/graph/FilterExpression.ts +16 -0
- package/src/graph/Graph.ts +1516 -0
- package/src/graph/GraphCalculator.ts +197 -0
- package/src/graph/GraphService.ts +516 -0
- package/src/graph/ImageLoadingService.ts +44 -0
- package/src/graph/MeshReader.ts +19 -0
- package/src/graph/Node.ts +622 -0
- package/src/graph/NodeCache.ts +548 -0
- package/src/graph/Sequence.ts +117 -0
- package/src/graph/edge/EdgeCalculator.ts +919 -0
- package/src/graph/edge/EdgeCalculatorCoefficients.ts +43 -0
- package/src/graph/edge/EdgeCalculatorDirections.ts +80 -0
- package/src/graph/edge/EdgeCalculatorSettings.ts +61 -0
- package/src/graph/edge/EdgeDirection.ts +63 -0
- package/src/graph/edge/interfaces/IEdge.ts +26 -0
- package/src/graph/edge/interfaces/IEdgeData.ts +22 -0
- package/src/graph/edge/interfaces/IPano.ts +8 -0
- package/src/graph/edge/interfaces/IPotentialEdge.ts +106 -0
- package/src/graph/edge/interfaces/IStep.ts +7 -0
- package/src/graph/edge/interfaces/ITurn.ts +7 -0
- package/src/graph/edge/interfaces/interfaces.ts +6 -0
- package/src/graph/interfaces/IEdgeStatus.ts +25 -0
- package/src/graph/interfaces/IGraphConfiguration.ts +26 -0
- package/src/graph/interfaces/ILoadStatus.ts +18 -0
- package/src/graph/interfaces/ILoadStatusObject.ts +8 -0
- package/src/graph/interfaces/IMesh.ts +20 -0
- package/src/graph/interfaces/interfaces.ts +5 -0
- package/src/render/DOMRenderer.ts +288 -0
- package/src/render/GLRenderStage.ts +6 -0
- package/src/render/GLRenderer.ts +436 -0
- package/src/render/RenderCamera.ts +212 -0
- package/src/render/RenderMode.ts +34 -0
- package/src/render/RenderService.ts +264 -0
- package/src/render/interfaces/IGLRender.ts +10 -0
- package/src/render/interfaces/IGLRenderFunction.ts +10 -0
- package/src/render/interfaces/IGLRenderHash.ts +8 -0
- package/src/render/interfaces/ISize.ts +6 -0
- package/src/render/interfaces/IVNodeHash.ts +8 -0
- package/src/render/interfaces/interfaces.ts +5 -0
- package/src/state/FrameGenerator.ts +36 -0
- package/src/state/State.ts +6 -0
- package/src/state/StateContext.ts +180 -0
- package/src/state/StateService.ts +600 -0
- package/src/state/StateTransitionMatrix.ts +58 -0
- package/src/state/interfaces/ICurrentState.ts +21 -0
- package/src/state/interfaces/IFrame.ts +9 -0
- package/src/state/interfaces/IRotation.ts +6 -0
- package/src/state/interfaces/IState.ts +11 -0
- package/src/state/interfaces/IStateContext.ts +31 -0
- package/src/state/interfaces/interfaces.ts +5 -0
- package/src/state/states/StateBase.ts +425 -0
- package/src/state/states/TraversingState.ts +861 -0
- package/src/state/states/WaitingState.ts +109 -0
- package/src/tiles/ImageTileLoader.ts +121 -0
- package/src/tiles/ImageTileStore.ts +70 -0
- package/src/tiles/RegionOfInterestCalculator.ts +158 -0
- package/src/tiles/TextureProvider.ts +609 -0
- package/src/tiles/interfaces/IBoundingBox.ts +28 -0
- package/src/tiles/interfaces/IRegionOfInterest.ts +25 -0
- package/src/tiles/interfaces/interfaces.ts +2 -0
- package/src/utils/DOM.ts +28 -0
- package/src/utils/EventEmitter.ts +61 -0
- package/src/utils/Func.ts +3 -0
- package/src/utils/Settings.ts +39 -0
- package/src/utils/Support.ts +70 -0
- package/src/utils/Urls.ts +43 -0
- package/src/viewer/Alignment.ts +53 -0
- package/src/viewer/CacheService.ts +75 -0
- package/src/viewer/ComponentController.ts +237 -0
- package/src/viewer/Container.ts +100 -0
- package/src/viewer/EventNames.ts +192 -0
- package/src/viewer/ImageSize.ts +28 -0
- package/src/viewer/KeyboardService.ts +15 -0
- package/src/viewer/LoadingService.ts +66 -0
- package/src/viewer/MouseService.ts +541 -0
- package/src/viewer/Navigator.ts +362 -0
- package/src/viewer/Observer.ts +441 -0
- package/src/viewer/Projection.ts +162 -0
- package/src/viewer/SpriteService.ts +281 -0
- package/src/viewer/TouchService.ts +336 -0
- package/src/viewer/Viewer.ts +1132 -0
- package/src/viewer/interfaces/IComponentOptions.ts +176 -0
- package/src/viewer/interfaces/IMouseClaim.ts +6 -0
- package/src/viewer/interfaces/IMouseDeferPixels.ts +6 -0
- package/src/viewer/interfaces/IPinch.ts +81 -0
- package/src/viewer/interfaces/ISpriteAtlas.ts +12 -0
- package/src/viewer/interfaces/IUnprojection.ts +9 -0
- package/src/viewer/interfaces/IViewerMouseEvent.ts +56 -0
- package/src/viewer/interfaces/IViewerOptions.ts +88 -0
- package/src/viewer/interfaces/PointOfView.ts +19 -0
- package/src/viewer/interfaces/interfaces.ts +9 -0
- package/styles/AttributionComponent.css +26 -0
- package/styles/BackgroundComponent.css +21 -0
- package/styles/BearingComponent.css +48 -0
- package/styles/CoverComponent.css +169 -0
- package/styles/DebugComponent.css +28 -0
- package/styles/DirectionComponent.css +154 -0
- package/styles/LoadingComponent.css +14 -0
- package/styles/NavigationComponent.css +64 -0
- package/styles/NorthBg.png +0 -0
- package/styles/PopupComponent.css +188 -0
- package/styles/RouteComponent.css +21 -0
- package/styles/SequenceComponent.css +120 -0
- package/styles/SliderComponent.css +82 -0
- package/styles/TagComponent.css +105 -0
- package/styles/cover-logo.png +0 -0
- package/styles/mapillary-js.css +29 -0
- package/styles/pano-indicator.svg +3 -0
- package/styles/pano.svg +20 -0
- package/styles/pointer-wheat.svg +3 -0
- package/styles/pointer-white.svg +3 -0
- package/styles/spinner.svg +1 -0
- package/styles/stepper-left.svg +1 -0
- package/styles/stepper-play.svg +1 -0
- package/styles/stepper-right.svg +1 -0
- package/styles/stepper-stop.svg +1 -0
- package/styles/turn-around.svg +3 -0
- package/styles/turn.svg +3 -0
- package/tsconfig.json +28 -0
- package/tslint.json +81 -0
- package/types/graphql/index.d.ts +28 -0
- package/types/graphql/language/ast/index.d.ts +7 -0
- package/types/images/index.d.ts +7 -0
- package/types/pbf/index.d.ts +16 -0
- package/types/rbush/index.d.ts +28 -0
- package/version/beeview-0.1.0.css +2 -0
- package/version/beeview-0.1.0.js +1 -0
- package/version/beeview-0.1.1.css +2 -0
- package/version/beeview-0.1.1.js +1 -0
- package/version/beeview-0.1.2.css +2 -0
- package/version/beeview-0.1.2.js +1 -0
- package/version/beeview-0.2.0.css +2 -0
- package/version/beeview-0.2.0.js +1 -0
- package/version/beeview-0.2.1.css +2 -0
- package/version/beeview-0.2.1.js +1 -0
- package/version/beeview-0.3.0.css +2 -0
- package/version/beeview-0.3.0.js +1 -0
- package/version/beeview-0.4.0.css +2 -0
- package/version/beeview-0.4.0.js +1 -0
- package/version/beeview-0.4.1.css +2 -0
- package/version/beeview-0.4.1.js +1 -0
- package/version/mapxus-visual-1.0.0.css +2 -0
- package/version/mapxus-visual-1.0.0.js +1 -0
- package/version/mapxus-visual-1.1.0.css +2 -0
- package/version/mapxus-visual-1.1.0.js +1 -0
- package/version/mapxus-visual-1.1.1.css +2 -0
- package/version/mapxus-visual-1.1.1.js +1 -0
- package/version/mapxus-visual-1.1.2.css +2 -0
- package/version/mapxus-visual-1.1.2.js +1 -0
- package/version/mapxus-visual-1.2.0.css +2 -0
- package/version/mapxus-visual-1.2.0.js +1 -0
- package/version/mapxus-visual-1.3.0.css +2 -0
- package/version/mapxus-visual-1.3.0.js +1 -0
- package/LICENSE +0 -11
- package/README.md +0 -28
- package/index.css +0 -2
- package/index.d.ts +0 -163
- package/index.js +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as geohash from "latlon-geohash";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
|
|
4
|
+
import {ILatLon} from "../API";
|
|
5
|
+
import {GeoCoords} from "../Geo";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class GraphCalculator
|
|
9
|
+
*
|
|
10
|
+
* @classdesc Represents a calculator for graph entities.
|
|
11
|
+
*/
|
|
12
|
+
export class GraphCalculator {
|
|
13
|
+
private _geoCoords: GeoCoords;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create a new graph calculator instance.
|
|
17
|
+
*
|
|
18
|
+
* @param {GeoCoords} geoCoords - Geo coords instance.
|
|
19
|
+
*/
|
|
20
|
+
constructor(geoCoords?: GeoCoords) {
|
|
21
|
+
this._geoCoords = geoCoords != null ? geoCoords : new GeoCoords();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Encode the geohash tile for geodetic coordinates.
|
|
26
|
+
*
|
|
27
|
+
* @param {ILatLon} latlon - Latitude and longitude to encode.
|
|
28
|
+
* @param {number} precision - Precision of the encoding.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string} The geohash tile for the lat, lon and precision.
|
|
31
|
+
*/
|
|
32
|
+
public encodeH(latLon: ILatLon, precision: number = 7): string {
|
|
33
|
+
return geohash.encode(latLon.lat, latLon.lon, precision);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Encode the geohash tiles within a threshold from a position
|
|
38
|
+
* using Manhattan distance.
|
|
39
|
+
*
|
|
40
|
+
* @param {ILatLon} latlon - Latitude and longitude to encode.
|
|
41
|
+
* @param {number} precision - Precision of the encoding.
|
|
42
|
+
* @param {number} threshold - Threshold of the encoding in meters.
|
|
43
|
+
*
|
|
44
|
+
* @returns {string} The geohash tiles reachable within the threshold.
|
|
45
|
+
*/
|
|
46
|
+
public encodeHs(latLon: ILatLon, precision: number = 7, threshold: number = 20): string[] {
|
|
47
|
+
let h: string = geohash.encode(latLon.lat, latLon.lon, precision);
|
|
48
|
+
let bounds: geohash.Bounds = geohash.bounds(h);
|
|
49
|
+
let ne: geohash.Point = bounds.ne;
|
|
50
|
+
let sw: geohash.Point = bounds.sw;
|
|
51
|
+
let neighbours: geohash.Neighbours = geohash.neighbours(h);
|
|
52
|
+
|
|
53
|
+
let bl: number[] = [0, 0, 0];
|
|
54
|
+
let tr: number[] =
|
|
55
|
+
this._geoCoords.geodeticToEnu(
|
|
56
|
+
ne.lat,
|
|
57
|
+
ne.lon,
|
|
58
|
+
0,
|
|
59
|
+
sw.lat,
|
|
60
|
+
sw.lon,
|
|
61
|
+
0);
|
|
62
|
+
|
|
63
|
+
let position: number[] =
|
|
64
|
+
this._geoCoords.geodeticToEnu(
|
|
65
|
+
latLon.lat,
|
|
66
|
+
latLon.lon,
|
|
67
|
+
0,
|
|
68
|
+
sw.lat,
|
|
69
|
+
sw.lon,
|
|
70
|
+
0);
|
|
71
|
+
|
|
72
|
+
let left: number = position[0] - bl[0];
|
|
73
|
+
let right: number = tr[0] - position[0];
|
|
74
|
+
let bottom: number = position[1] - bl[1];
|
|
75
|
+
let top: number = tr[1] - position[1];
|
|
76
|
+
|
|
77
|
+
let l: boolean = left < threshold;
|
|
78
|
+
let r: boolean = right < threshold;
|
|
79
|
+
let b: boolean = bottom < threshold;
|
|
80
|
+
let t: boolean = top < threshold;
|
|
81
|
+
|
|
82
|
+
let hs: string[] = [h];
|
|
83
|
+
|
|
84
|
+
if (t) {
|
|
85
|
+
hs.push(neighbours.n);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (t && l) {
|
|
89
|
+
hs.push(neighbours.nw);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (l) {
|
|
93
|
+
hs.push(neighbours.w);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (l && b) {
|
|
97
|
+
hs.push(neighbours.sw);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (b) {
|
|
101
|
+
hs.push(neighbours.s);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (b && r) {
|
|
105
|
+
hs.push(neighbours.se);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (r) {
|
|
109
|
+
hs.push(neighbours.e);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (r && t) {
|
|
113
|
+
hs.push(neighbours.ne);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return hs;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get the bounding box corners for a circle with radius of a threshold
|
|
121
|
+
* with center in a geodetic position.
|
|
122
|
+
*
|
|
123
|
+
* @param {ILatLon} latlon - Latitude and longitude to encode.
|
|
124
|
+
* @param {number} threshold - Threshold distance from the position in meters.
|
|
125
|
+
*
|
|
126
|
+
* @returns {Array<ILatLon>} The south west and north east corners of the
|
|
127
|
+
* bounding box.
|
|
128
|
+
*/
|
|
129
|
+
public boundingBoxCorners(latLon: ILatLon, threshold: number): [ILatLon, ILatLon] {
|
|
130
|
+
let bl: number[] =
|
|
131
|
+
this._geoCoords.enuToGeodetic(
|
|
132
|
+
-threshold,
|
|
133
|
+
-threshold,
|
|
134
|
+
0,
|
|
135
|
+
latLon.lat,
|
|
136
|
+
latLon.lon,
|
|
137
|
+
0);
|
|
138
|
+
|
|
139
|
+
let tr: number[] =
|
|
140
|
+
this._geoCoords.enuToGeodetic(
|
|
141
|
+
threshold,
|
|
142
|
+
threshold,
|
|
143
|
+
0,
|
|
144
|
+
latLon.lat,
|
|
145
|
+
latLon.lon,
|
|
146
|
+
0);
|
|
147
|
+
|
|
148
|
+
return [
|
|
149
|
+
{ lat: bl[0], lon: bl[1] },
|
|
150
|
+
{ lat: tr[0], lon: tr[1] },
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Convert a compass angle to an angle axis rotation vector.
|
|
156
|
+
*
|
|
157
|
+
* @param {number} compassAngle - The compass angle in degrees.
|
|
158
|
+
* @param {number} orientation - The orientation of the original image.
|
|
159
|
+
*
|
|
160
|
+
* @returns {Array<number>} Angle axis rotation vector.
|
|
161
|
+
*/
|
|
162
|
+
public rotationFromCompass(compassAngle: number, orientation: number): number[] {
|
|
163
|
+
let x: number = 0;
|
|
164
|
+
let y: number = 0;
|
|
165
|
+
let z: number = 0;
|
|
166
|
+
|
|
167
|
+
switch (orientation) {
|
|
168
|
+
case 1:
|
|
169
|
+
x = Math.PI / 2;
|
|
170
|
+
break;
|
|
171
|
+
case 3:
|
|
172
|
+
x = -Math.PI / 2;
|
|
173
|
+
z = Math.PI;
|
|
174
|
+
break;
|
|
175
|
+
case 6:
|
|
176
|
+
y = -Math.PI / 2;
|
|
177
|
+
z = -Math.PI / 2;
|
|
178
|
+
break;
|
|
179
|
+
case 8:
|
|
180
|
+
y = Math.PI / 2;
|
|
181
|
+
z = Math.PI / 2;
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let rz: THREE.Matrix4 = new THREE.Matrix4().makeRotationZ(z);
|
|
188
|
+
let euler: THREE.Euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
|
|
189
|
+
let re: THREE.Matrix4 = new THREE.Matrix4().makeRotationFromEuler(euler);
|
|
190
|
+
|
|
191
|
+
let rotation: THREE.Vector4 = new THREE.Vector4().setAxisAngleFromRotationMatrix(<any>re.multiply(rz));
|
|
192
|
+
|
|
193
|
+
return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default GraphCalculator;
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Observable,
|
|
3
|
+
Subject,
|
|
4
|
+
Subscription,
|
|
5
|
+
of,
|
|
6
|
+
ReplaySubject,
|
|
7
|
+
from,
|
|
8
|
+
EMPTY,
|
|
9
|
+
} from "rxjs";
|
|
10
|
+
import {
|
|
11
|
+
concat,
|
|
12
|
+
tap,
|
|
13
|
+
finalize,
|
|
14
|
+
first,
|
|
15
|
+
map,
|
|
16
|
+
mergeMap,
|
|
17
|
+
multicast,
|
|
18
|
+
refCount,
|
|
19
|
+
delay,
|
|
20
|
+
catchError,
|
|
21
|
+
last,
|
|
22
|
+
expand,
|
|
23
|
+
} from "rxjs/operators";
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
FilterExpression,
|
|
27
|
+
Graph,
|
|
28
|
+
ImageLoadingService,
|
|
29
|
+
Node,
|
|
30
|
+
Sequence,
|
|
31
|
+
} from "../Graph";
|
|
32
|
+
import { IPathNode } from "../api/interfaces/IPathNode";
|
|
33
|
+
import GraphCalculator from "./GraphCalculator";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @class GraphService
|
|
37
|
+
*
|
|
38
|
+
* @classdesc Represents a service for graph operations.
|
|
39
|
+
*/
|
|
40
|
+
export class GraphService {
|
|
41
|
+
private _graph$: Observable<Graph>;
|
|
42
|
+
|
|
43
|
+
private _imageLoadingService: ImageLoadingService;
|
|
44
|
+
|
|
45
|
+
private _firstGraphSubjects$: Subject<Graph>[];
|
|
46
|
+
|
|
47
|
+
private _initializeCacheSubscriptions: Subscription[];
|
|
48
|
+
private _sequenceSubscriptions: Subscription[];
|
|
49
|
+
private _spatialSubscriptions: Subscription[];
|
|
50
|
+
private _graphCalculator: GraphCalculator;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a new graph service instance.
|
|
54
|
+
*
|
|
55
|
+
* @param {Graph} graph - Graph instance to be operated on.
|
|
56
|
+
*/
|
|
57
|
+
constructor(graph: Graph, imageLoadingService: ImageLoadingService) {
|
|
58
|
+
this._graph$ = of(graph).pipe(
|
|
59
|
+
concat(graph.changed$),
|
|
60
|
+
multicast(new ReplaySubject(1)),
|
|
61
|
+
refCount(),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
this._graph$.subscribe(() => {
|
|
65
|
+
/*noop*/
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this._imageLoadingService = imageLoadingService;
|
|
69
|
+
|
|
70
|
+
this._firstGraphSubjects$ = [];
|
|
71
|
+
|
|
72
|
+
this._initializeCacheSubscriptions = [];
|
|
73
|
+
this._sequenceSubscriptions = [];
|
|
74
|
+
this._spatialSubscriptions = [];
|
|
75
|
+
this._graphCalculator = new GraphCalculator();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public cachePath$(key: string, date?: number): Observable<IPathNode[]> {
|
|
79
|
+
let path$: Observable<IPathNode[]> = this._graph$.pipe(
|
|
80
|
+
first(),
|
|
81
|
+
mergeMap((graph: Graph): Observable<IPathNode[]> => {
|
|
82
|
+
const node: Node = graph.getNode(key);
|
|
83
|
+
if (node.building) {
|
|
84
|
+
return graph.hasCachedPaths(node.building.id, date)
|
|
85
|
+
? of(graph.getCachedPaths(node.building.id, date))
|
|
86
|
+
: graph.cachePath$(key, date);
|
|
87
|
+
} else {
|
|
88
|
+
// Fix the outdoor path will not be displayed when the display outdoor data is initialized.
|
|
89
|
+
// so use delay 500ms
|
|
90
|
+
return of([]).pipe(delay(500));
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
multicast(new ReplaySubject(1)),
|
|
94
|
+
refCount(),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
path$.subscribe(
|
|
98
|
+
(path: IPathNode[]): void => {
|
|
99
|
+
this._imageLoadingService.loadpath$.next(path);
|
|
100
|
+
},
|
|
101
|
+
(error: Error): void => {
|
|
102
|
+
console.error(`Failed to cache path (${key})`, error);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return path$;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public cacheOutdoorPath$(
|
|
110
|
+
key: string,
|
|
111
|
+
date?: number,
|
|
112
|
+
): Observable<IPathNode[]> {
|
|
113
|
+
let path$: Observable<IPathNode[]> = this._graph$.pipe(
|
|
114
|
+
first(),
|
|
115
|
+
mergeMap((graph: Graph): Observable<IPathNode[]> => {
|
|
116
|
+
const node: Node = graph.getNode(key);
|
|
117
|
+
const outdoorImageHash: string = this._graphCalculator.encodeH(
|
|
118
|
+
node.latLon,
|
|
119
|
+
);
|
|
120
|
+
return graph.hasCachedPaths(outdoorImageHash, date)
|
|
121
|
+
? of(graph.getCachedPaths(outdoorImageHash, date))
|
|
122
|
+
: graph.cacheOutdoorPath$(
|
|
123
|
+
node.latLon.lon,
|
|
124
|
+
node.latLon.lat,
|
|
125
|
+
date,
|
|
126
|
+
);
|
|
127
|
+
}),
|
|
128
|
+
multicast(new ReplaySubject(1)),
|
|
129
|
+
refCount(),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
path$.subscribe(
|
|
133
|
+
(path: IPathNode[]): void => {
|
|
134
|
+
this._imageLoadingService.loadpathOutdoor$.next(path);
|
|
135
|
+
},
|
|
136
|
+
(error: Error): void => {
|
|
137
|
+
console.error(`Failed to cache path (${key})`, error);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return path$;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Cache a node in the graph and retrieve it.
|
|
146
|
+
*
|
|
147
|
+
* @description When called, the full properties of
|
|
148
|
+
* the node are retrieved and the node cache is initialized.
|
|
149
|
+
* After that the node assets are cached and the node
|
|
150
|
+
* is emitted to the observable when.
|
|
151
|
+
* In parallel to caching the node assets, the sequence and
|
|
152
|
+
* spatial edges of the node are cached. For this, the sequence
|
|
153
|
+
* of the node and the required tiles and spatial nodes are
|
|
154
|
+
* retrieved. The sequence and spatial edges may be set before
|
|
155
|
+
* or after the node is returned.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} key - Key of the node to cache.
|
|
158
|
+
* @return {Observable<Node>} Observable emitting a single item,
|
|
159
|
+
* the node, when it has been retrieved and its assets are cached.
|
|
160
|
+
* @throws {Error} Propagates any IO node caching errors to the caller.
|
|
161
|
+
*/
|
|
162
|
+
public cacheNode$(key: string): Observable<Node> {
|
|
163
|
+
let firstGraphSubject$: Subject<Graph> = new Subject<Graph>();
|
|
164
|
+
|
|
165
|
+
this._firstGraphSubjects$.push(firstGraphSubject$);
|
|
166
|
+
|
|
167
|
+
let firstGraph$: Observable<Graph> = firstGraphSubject$.pipe(
|
|
168
|
+
multicast(new ReplaySubject(1)),
|
|
169
|
+
refCount(),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
let node$: Observable<Node> = firstGraph$.pipe(
|
|
173
|
+
map((graph: Graph): Node => {
|
|
174
|
+
return graph.getNode(key);
|
|
175
|
+
}),
|
|
176
|
+
mergeMap((node: Node): Observable<Node> => {
|
|
177
|
+
return node.assetsCached ? of(node) : node.cacheAssets$();
|
|
178
|
+
}),
|
|
179
|
+
multicast(new ReplaySubject(1)),
|
|
180
|
+
refCount(),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
node$.subscribe(undefined, (error: Error): void => {
|
|
184
|
+
console.error(`Failed to cache node (${key})`, error);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
let initializeCacheSubscription: Subscription;
|
|
188
|
+
initializeCacheSubscription = this._graph$
|
|
189
|
+
.pipe(
|
|
190
|
+
first(),
|
|
191
|
+
mergeMap((graph: Graph): Observable<Graph> => {
|
|
192
|
+
if (graph.isCachingFull(key) || !graph.hasNode(key)) {
|
|
193
|
+
return graph.cacheFull$(key);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (graph.isCachingFill(key) || !graph.getNode(key).full) {
|
|
197
|
+
return graph.cacheFill$(key);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return of<Graph>(graph);
|
|
201
|
+
}),
|
|
202
|
+
tap((graph: Graph): void => {
|
|
203
|
+
if (!graph.hasInitializedCache(key)) {
|
|
204
|
+
graph.initializeCache(key);
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
207
|
+
finalize((): void => {
|
|
208
|
+
if (initializeCacheSubscription == null) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this._removeFromArray(
|
|
213
|
+
initializeCacheSubscription,
|
|
214
|
+
this._initializeCacheSubscriptions,
|
|
215
|
+
);
|
|
216
|
+
this._removeFromArray(
|
|
217
|
+
firstGraphSubject$,
|
|
218
|
+
this._firstGraphSubjects$,
|
|
219
|
+
);
|
|
220
|
+
}),
|
|
221
|
+
)
|
|
222
|
+
.subscribe(
|
|
223
|
+
(graph: Graph): void => {
|
|
224
|
+
firstGraphSubject$.next(graph);
|
|
225
|
+
firstGraphSubject$.complete();
|
|
226
|
+
},
|
|
227
|
+
(error: Error): void => {
|
|
228
|
+
firstGraphSubject$.error(error);
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
if (!initializeCacheSubscription.closed) {
|
|
233
|
+
this._initializeCacheSubscriptions.push(
|
|
234
|
+
initializeCacheSubscription,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let sequenceSubscription: Subscription;
|
|
239
|
+
sequenceSubscription = firstGraph$
|
|
240
|
+
.pipe(
|
|
241
|
+
mergeMap((graph: Graph): Observable<Graph> => {
|
|
242
|
+
if (
|
|
243
|
+
graph.isCachingNodeSequence(key) ||
|
|
244
|
+
!graph.hasNodeSequence(key)
|
|
245
|
+
) {
|
|
246
|
+
return graph.cacheNodeSequence$(key);
|
|
247
|
+
}
|
|
248
|
+
return of<Graph>(graph);
|
|
249
|
+
}),
|
|
250
|
+
tap((graph: Graph): void => {
|
|
251
|
+
if (!graph.getNode(key).sequenceEdges.cached) {
|
|
252
|
+
graph.cacheSequenceEdges(key);
|
|
253
|
+
}
|
|
254
|
+
}),
|
|
255
|
+
finalize((): void => {
|
|
256
|
+
if (sequenceSubscription == null) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
this._removeFromArray(
|
|
261
|
+
sequenceSubscription,
|
|
262
|
+
this._sequenceSubscriptions,
|
|
263
|
+
);
|
|
264
|
+
}),
|
|
265
|
+
)
|
|
266
|
+
.subscribe(
|
|
267
|
+
(graph: Graph): void => {
|
|
268
|
+
return;
|
|
269
|
+
},
|
|
270
|
+
(error: Error): void => {
|
|
271
|
+
console.error(
|
|
272
|
+
`Failed to cache sequence edges (${key}).`,
|
|
273
|
+
error,
|
|
274
|
+
);
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
if (!sequenceSubscription.closed) {
|
|
279
|
+
this._sequenceSubscriptions.push(sequenceSubscription);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let spatialSubscription: Subscription;
|
|
283
|
+
spatialSubscription = firstGraph$
|
|
284
|
+
.pipe(
|
|
285
|
+
catchError((): Observable<Graph> => {
|
|
286
|
+
return EMPTY;
|
|
287
|
+
}),
|
|
288
|
+
expand((graph: Graph): Observable<Graph> => {
|
|
289
|
+
if (graph.hasTiles(key)) {
|
|
290
|
+
return EMPTY;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return from<Observable<Graph>[]>(
|
|
294
|
+
graph.cacheTiles$(key),
|
|
295
|
+
).pipe(
|
|
296
|
+
mergeMap(
|
|
297
|
+
(graph$: Observable<Graph>): Observable<Graph> => {
|
|
298
|
+
return graph$.pipe(
|
|
299
|
+
mergeMap((g: Graph): Observable<Graph> => {
|
|
300
|
+
if (g.isCachingTiles(key)) {
|
|
301
|
+
return EMPTY;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return of<Graph>(g);
|
|
305
|
+
}),
|
|
306
|
+
catchError(
|
|
307
|
+
(
|
|
308
|
+
error: Error,
|
|
309
|
+
caught$: Observable<Graph>,
|
|
310
|
+
): Observable<Graph> => {
|
|
311
|
+
console.error(
|
|
312
|
+
`Failed to cache tile data (${key}).`,
|
|
313
|
+
error,
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
return EMPTY;
|
|
317
|
+
},
|
|
318
|
+
),
|
|
319
|
+
);
|
|
320
|
+
},
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
}),
|
|
324
|
+
last(),
|
|
325
|
+
mergeMap((graph: Graph): Observable<Graph> => {
|
|
326
|
+
if (graph.hasSpatialArea(key)) {
|
|
327
|
+
return of<Graph>(graph);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return from<Observable<Graph>[]>(
|
|
331
|
+
graph.cacheSpatialArea$(key),
|
|
332
|
+
).pipe(
|
|
333
|
+
mergeMap(
|
|
334
|
+
(graph$: Observable<Graph>): Observable<Graph> => {
|
|
335
|
+
return graph$.pipe(
|
|
336
|
+
catchError(
|
|
337
|
+
(
|
|
338
|
+
error: Error,
|
|
339
|
+
caught$: Observable<Graph>,
|
|
340
|
+
): Observable<Graph> => {
|
|
341
|
+
console.error(
|
|
342
|
+
`Failed to cache spatial nodes (${key}).`,
|
|
343
|
+
error,
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
return EMPTY;
|
|
347
|
+
},
|
|
348
|
+
),
|
|
349
|
+
);
|
|
350
|
+
},
|
|
351
|
+
),
|
|
352
|
+
);
|
|
353
|
+
}),
|
|
354
|
+
last(),
|
|
355
|
+
mergeMap((graph: Graph): Observable<Graph> => {
|
|
356
|
+
return graph.hasNodeSequence(key)
|
|
357
|
+
? of<Graph>(graph)
|
|
358
|
+
: graph.cacheNodeSequence$(key);
|
|
359
|
+
}),
|
|
360
|
+
tap((graph: Graph): void => {
|
|
361
|
+
if (!graph.getNode(key).spatialEdges.cached) {
|
|
362
|
+
graph.cacheSpatialEdges(key);
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
finalize((): void => {
|
|
366
|
+
if (spatialSubscription == null) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
this._removeFromArray(
|
|
371
|
+
spatialSubscription,
|
|
372
|
+
this._spatialSubscriptions,
|
|
373
|
+
);
|
|
374
|
+
}),
|
|
375
|
+
)
|
|
376
|
+
.subscribe(
|
|
377
|
+
(graph: Graph): void => {
|
|
378
|
+
return;
|
|
379
|
+
},
|
|
380
|
+
(error: Error): void => {
|
|
381
|
+
console.error(
|
|
382
|
+
`Failed to cache spatial edges (${key}).`,
|
|
383
|
+
error,
|
|
384
|
+
);
|
|
385
|
+
},
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
if (!spatialSubscription.closed) {
|
|
389
|
+
this._spatialSubscriptions.push(spatialSubscription);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return node$.pipe(
|
|
393
|
+
first((node: Node): boolean => {
|
|
394
|
+
return node.assetsCached;
|
|
395
|
+
}),
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Cache a sequence in the graph and retrieve it.
|
|
401
|
+
*
|
|
402
|
+
* @param {string} sequenceKey - Sequence key.
|
|
403
|
+
* @returns {Observable<Sequence>} Observable emitting a single item,
|
|
404
|
+
* the sequence, when it has been retrieved and its assets are cached.
|
|
405
|
+
* @throws {Error} Propagates any IO node caching errors to the caller.
|
|
406
|
+
*/
|
|
407
|
+
public cacheSequence$(sequenceKey: string): Observable<Sequence> {
|
|
408
|
+
return this._graph$.pipe(
|
|
409
|
+
first(),
|
|
410
|
+
mergeMap((graph: Graph): Observable<Graph> => {
|
|
411
|
+
if (
|
|
412
|
+
graph.isCachingSequence(sequenceKey) ||
|
|
413
|
+
!graph.hasSequence(sequenceKey)
|
|
414
|
+
) {
|
|
415
|
+
return graph.cacheSequence$(sequenceKey);
|
|
416
|
+
}
|
|
417
|
+
return of<Graph>(graph);
|
|
418
|
+
}),
|
|
419
|
+
map((graph: Graph): Sequence => {
|
|
420
|
+
return graph.getSequence(sequenceKey);
|
|
421
|
+
}),
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Set a spatial edge filter on the graph.
|
|
427
|
+
*
|
|
428
|
+
* @description Resets the spatial edges of all cached nodes.
|
|
429
|
+
*
|
|
430
|
+
* @param {FilterExpression} filter - Filter expression to be applied.
|
|
431
|
+
* @return {Observable<Graph>} Observable emitting a single item,
|
|
432
|
+
* the graph, when the spatial edges have been reset.
|
|
433
|
+
*/
|
|
434
|
+
public setFilter$(filter: FilterExpression): Observable<Graph> {
|
|
435
|
+
this._resetSubscriptions(this._spatialSubscriptions);
|
|
436
|
+
|
|
437
|
+
return this._graph$.pipe(
|
|
438
|
+
first(),
|
|
439
|
+
tap((graph: Graph): void => {
|
|
440
|
+
graph.resetSpatialEdges();
|
|
441
|
+
graph.setFilter(filter);
|
|
442
|
+
}),
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Reset the graph.
|
|
448
|
+
*
|
|
449
|
+
* @description Resets the graph but keeps the nodes of the
|
|
450
|
+
* supplied keys.
|
|
451
|
+
*
|
|
452
|
+
* @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
|
|
453
|
+
* @return {Observable<Node>} Observable emitting a single item,
|
|
454
|
+
* the graph, when it has been reset.
|
|
455
|
+
*/
|
|
456
|
+
public reset$(keepKeys: string[]): Observable<Graph> {
|
|
457
|
+
this._abortSubjects(this._firstGraphSubjects$);
|
|
458
|
+
this._resetSubscriptions(this._initializeCacheSubscriptions);
|
|
459
|
+
this._resetSubscriptions(this._sequenceSubscriptions);
|
|
460
|
+
this._resetSubscriptions(this._spatialSubscriptions);
|
|
461
|
+
|
|
462
|
+
return this._graph$.pipe(
|
|
463
|
+
first(),
|
|
464
|
+
tap((graph: Graph): void => {
|
|
465
|
+
graph.reset(keepKeys);
|
|
466
|
+
}),
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Uncache the graph.
|
|
472
|
+
*
|
|
473
|
+
* @description Uncaches the graph by removing tiles, nodes and
|
|
474
|
+
* sequences. Keeps the nodes of the supplied keys and the tiles
|
|
475
|
+
* related to those nodes.
|
|
476
|
+
*
|
|
477
|
+
* @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
|
|
478
|
+
* @return {Observable<Graph>} Observable emitting a single item,
|
|
479
|
+
* the graph, when the graph has been uncached.
|
|
480
|
+
*/
|
|
481
|
+
public uncache$(keepKeys: string[]): Observable<Graph> {
|
|
482
|
+
return this._graph$.pipe(
|
|
483
|
+
first(),
|
|
484
|
+
tap((graph: Graph): void => {
|
|
485
|
+
graph.uncache(keepKeys);
|
|
486
|
+
}),
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
private _abortSubjects<T>(subjects: Subject<T>[]): void {
|
|
491
|
+
for (let subject of subjects.slice()) {
|
|
492
|
+
this._removeFromArray(subject, subjects);
|
|
493
|
+
|
|
494
|
+
subject.error(new Error("Cache node request was aborted."));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
private _removeFromArray<T>(object: T, objects: T[]): void {
|
|
499
|
+
let index: number = objects.indexOf(object);
|
|
500
|
+
if (index !== -1) {
|
|
501
|
+
objects.splice(index, 1);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private _resetSubscriptions(subscriptions: Subscription[]): void {
|
|
506
|
+
for (let subscription of subscriptions.slice()) {
|
|
507
|
+
this._removeFromArray(subscription, subscriptions);
|
|
508
|
+
|
|
509
|
+
if (!subscription.closed) {
|
|
510
|
+
subscription.unsubscribe();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export default GraphService;
|