From 7f47883c481a1cd958cbd4f98c933c0637f9b10b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 11 Dec 2017 16:29:33 -0700 Subject: [PATCH] Transformed --- examples/Jugl.js | 7 + examples/accessible.js | 20 +- examples/animation.js | 38 +- examples/arcgis-image.js | 24 +- examples/arcgis-tiled.js | 22 +- examples/attributions.js | 24 +- examples/bing-maps.js | 16 +- examples/blend-modes.js | 66 +- examples/box-selection.js | 40 +- examples/button-title.js | 16 +- examples/canvas-gradient-pattern.js | 44 +- examples/canvas-tiles.js | 30 +- examples/cartodb.js | 22 +- examples/center.js | 52 +- examples/cluster.js | 56 +- examples/color-manipulation.js | 20 +- examples/custom-controls.js | 28 +- examples/custom-icon.js | 16 +- examples/custom-interactions.js | 70 +- examples/d3.js | 38 +- examples/device-orientation.js | 32 +- examples/drag-and-drop-image-vector.js | 96 +- examples/drag-and-drop.js | 96 +- examples/drag-rotate-and-zoom.js | 24 +- examples/draw-and-modify-features.js | 54 +- examples/draw-features.js | 28 +- examples/draw-freehand.js | 28 +- examples/draw-shapes.js | 36 +- examples/dynamic-data.js | 52 +- examples/earthquake-clusters.js | 84 +- examples/earthquake-custom-symbol.js | 54 +- examples/epsg-4326.js | 24 +- examples/export-map.js | 32 +- examples/export-pdf.js | 32 +- examples/extent-interaction.js | 36 +- examples/feature-animation.js | 60 +- examples/feature-move-animation.js | 76 +- examples/flight-animation.js | 46 +- examples/fractal.js | 24 +- examples/full-screen-drag-rotate-and-zoom.js | 32 +- examples/full-screen-source.js | 24 +- examples/full-screen.js | 24 +- examples/geojson-vt.js | 32 +- examples/geojson.js | 90 +- examples/geolocation-orientation.js | 38 +- examples/geolocation.js | 58 +- examples/getfeatureinfo-image.js | 16 +- examples/getfeatureinfo-layers.js | 8 +- examples/getfeatureinfo-tile.js | 16 +- examples/gpx.js | 52 +- examples/graticule.js | 30 +- examples/heatmap-earthquakes.js | 28 +- examples/here-maps.js | 16 +- examples/hit-tolerance.js | 38 +- examples/icon-color.js | 60 +- examples/icon-negative.js | 42 +- examples/icon-sprite-webgl.js | 38 +- examples/icon.js | 44 +- examples/igc.js | 74 +- examples/image-filter.js | 20 +- examples/image-load-events.js | 16 +- examples/image-vector-layer.js | 46 +- examples/jsts.js | 32 +- examples/kml-earthquakes.js | 44 +- examples/kml-timezones.js | 40 +- examples/kml.js | 32 +- examples/layer-clipping-webgl.js | 24 +- examples/layer-clipping.js | 20 +- examples/layer-extent.js | 24 +- examples/layer-group.js | 36 +- examples/layer-spy.js | 24 +- examples/layer-swipe.js | 26 +- examples/layer-z-index.js | 50 +- examples/lazy-source.js | 16 +- examples/line-arrows.js | 46 +- examples/localized-openstreetmap.js | 28 +- examples/magnify.js | 20 +- examples/mapbox-vector-tiles-advanced.js | 40 +- examples/mapbox-vector-tiles.js | 32 +- examples/mapguide-untiled.js | 16 +- examples/measure.js | 86 +- examples/min-max-resolution.js | 26 +- examples/min-zoom.js | 16 +- examples/mobile-full-screen.js | 20 +- examples/modify-features.js | 40 +- examples/modify-test.js | 96 +- examples/mouse-position.js | 30 +- examples/mousewheel-zoom.js | 24 +- examples/moveend.js | 28 +- examples/navigation-controls.js | 24 +- examples/osm-vector-tiles.js | 44 +- examples/overlay.js | 32 +- examples/overviewmap-custom.js | 36 +- examples/overviewmap.js | 24 +- examples/permalink.js | 20 +- examples/pinch-zoom.js | 24 +- examples/polygon-styles.js | 44 +- examples/popup.js | 26 +- examples/preload.js | 22 +- examples/raster.js | 24 +- examples/region-growing.js | 28 +- examples/regularshape.js | 54 +- examples/render-geometry.js | 32 +- examples/reprojection-by-code.js | 36 +- examples/reprojection-image.js | 32 +- examples/reprojection-wgs84.js | 16 +- examples/reprojection.js | 90 +- examples/resources/mapbox-streets-v6-style.js | 3 + examples/resources/prism/prism.min.js | 1 + .../zeroclipboard/ZeroClipboard.Core.js | 8 + .../zeroclipboard/ZeroClipboard.Core.min.js | 9 + .../resources/zeroclipboard/ZeroClipboard.js | 8 + .../zeroclipboard/ZeroClipboard.min.js | 9 + examples/reusable-source.js | 16 +- examples/rotation.js | 20 +- examples/scale-line.js | 24 +- examples/scaleline-indiana-east.js | 26 +- examples/sea-level.js | 32 +- examples/select-features.js | 48 +- examples/semi-transparent-layer.js | 26 +- examples/shaded-relief.js | 28 +- examples/side-by-side.js | 22 +- examples/simple.js | 16 +- examples/snap.js | 64 +- examples/sphere-mollweide.js | 28 +- examples/stamen.js | 24 +- examples/static-image.js | 24 +- examples/street-labels.js | 44 +- examples/symbol-atlas-webgl.js | 52 +- examples/synthetic-lines.js | 32 +- examples/synthetic-points.js | 60 +- examples/teleport.js | 20 +- examples/tile-load-events.js | 16 +- examples/tile-transitions.js | 20 +- examples/tilejson.js | 16 +- examples/tileutfgrid.js | 26 +- examples/tissot.js | 50 +- examples/topojson.js | 40 +- examples/topolis.js | 112 +- examples/translate-features.js | 40 +- examples/turf.js | 32 +- examples/vector-esri-edit.js | 54 +- examples/vector-esri.js | 68 +- examples/vector-label-decluttering.js | 46 +- examples/vector-labels.js | 74 +- examples/vector-layer.js | 56 +- examples/vector-osm.js | 82 +- examples/vector-tile-info.js | 20 +- examples/vector-wfs-getfeature.js | 48 +- examples/vector-wfs.js | 40 +- examples/wkt.js | 28 +- examples/wms-capabilities.js | 4 +- examples/wms-custom-proj.js | 40 +- examples/wms-custom-tilegrid-512x256.js | 34 +- examples/wms-image-custom-proj.js | 36 +- examples/wms-image.js | 24 +- examples/wms-no-proj.js | 28 +- examples/wms-tiled-wrap-180.js | 22 +- examples/wms-tiled.js | 22 +- examples/wms-time.js | 30 +- examples/wmts-capabilities.js | 4 +- examples/wmts-dimensions.js | 36 +- examples/wmts-hidpi.js | 26 +- examples/wmts-ign.js | 34 +- examples/wmts-layer-from-capabilities.js | 28 +- examples/wmts.js | 40 +- examples/xyz-esri-4326-512.js | 20 +- examples/xyz-esri.js | 20 +- examples/xyz-retina.js | 28 +- examples/xyz.js | 16 +- examples/zoom-constrained.js | 16 +- examples/zoomify.js | 20 +- examples/zoomslider.js | 20 +- src/ol/AssertionError.js | 15 +- src/ol/Attribution.js | 27 +- src/ol/CanvasMap.js | 55 +- src/ol/CenterConstraint.js | 20 +- src/ol/Collection.js | 76 +- src/ol/CollectionEventType.js | 9 +- src/ol/DeviceOrientation.js | 101 +- src/ol/Disposable.js | 16 +- src/ol/Feature.js | 80 +- src/ol/Geolocation.js | 170 +- src/ol/GeolocationProperty.js | 10 +- src/ol/Graticule.js | 137 +- src/ol/Image.js | 56 +- src/ol/ImageBase.js | 36 +- src/ol/ImageCanvas.js | 38 +- src/ol/ImageState.js | 9 +- src/ol/ImageTile.js | 74 +- src/ol/Kinetic.js | 19 +- src/ol/LayerType.js | 9 +- src/ol/Map.js | 77 +- src/ol/MapBrowserEvent.js | 26 +- src/ol/MapBrowserEventHandler.js | 116 +- src/ol/MapBrowserEventType.js | 16 +- src/ol/MapBrowserPointerEvent.js | 18 +- src/ol/MapEvent.js | 18 +- src/ol/MapEventType.js | 9 +- src/ol/MapProperty.js | 9 +- src/ol/Object.js | 66 +- src/ol/ObjectEventType.js | 9 +- src/ol/Observable.js | 54 +- src/ol/Overlay.js | 177 +- src/ol/OverlayPositioning.js | 9 +- src/ol/PluggableMap.js | 421 ++--- src/ol/PluginType.js | 9 +- src/ol/ResolutionConstraint.js | 22 +- src/ol/RotationConstraint.js | 19 +- src/ol/Sphere.js | 109 +- src/ol/Tile.js | 58 +- src/ol/TileCache.js | 28 +- src/ol/TileQueue.js | 46 +- src/ol/TileRange.js | 31 +- src/ol/TileState.js | 9 +- src/ol/TileUrlFunction.js | 39 +- src/ol/VectorImageTile.js | 106 +- src/ol/VectorTile.js | 70 +- src/ol/View.js | 290 ++-- src/ol/ViewHint.js | 9 +- src/ol/ViewProperty.js | 9 +- src/ol/array.js | 34 +- src/ol/asserts.js | 13 +- src/ol/color.js | 58 +- src/ol/colorlike.js | 17 +- src/ol/control.js | 25 +- src/ol/control/Attribution.js | 74 +- src/ol/control/Control.js | 48 +- src/ol/control/FullScreen.js | 80 +- src/ol/control/MousePosition.js | 78 +- src/ol/control/OverviewMap.js | 154 +- src/ol/control/Rotate.js | 52 +- src/ol/control/ScaleLine.js | 91 +- src/ol/control/ScaleLineUnits.js | 9 +- src/ol/control/Zoom.js | 44 +- src/ol/control/ZoomSlider.js | 106 +- src/ol/control/ZoomToExtent.js | 34 +- src/ol/coordinate.js | 64 +- src/ol/css.js | 18 +- src/ol/dom.js | 18 +- src/ol/easing.js | 22 +- src/ol/events.js | 59 +- src/ol/events/Event.js | 17 +- src/ol/events/EventTarget.js | 42 +- src/ol/events/EventType.js | 9 +- src/ol/events/KeyCode.js | 9 +- src/ol/events/condition.js | 62 +- src/ol/extent.js | 215 +-- src/ol/extent/Corner.js | 9 +- src/ol/extent/Relationship.js | 10 +- src/ol/featureloader.js | 36 +- src/ol/format/EsriJSON.js | 293 ++-- src/ol/format/Feature.js | 51 +- src/ol/format/FormatType.js | 10 +- src/ol/format/GML.js | 15 +- src/ol/format/GML2.js | 314 ++-- src/ol/format/GML3.js | 492 +++--- src/ol/format/GMLBase.js | 225 +-- src/ol/format/GPX.js | 514 +++--- src/ol/format/GeoJSON.js | 191 +-- src/ol/format/IGC.js | 82 +- src/ol/format/IGCZ.js | 9 +- src/ol/format/JSONFeature.js | 54 +- src/ol/format/KML.js | 1447 +++++++++-------- src/ol/format/MVT.js | 134 +- src/ol/format/OSMXML.js | 118 +- src/ol/format/OWS.js | 266 +-- src/ol/format/Polyline.js | 121 +- src/ol/format/TextFeature.js | 54 +- src/ol/format/TopoJSON.js | 136 +- src/ol/format/WFS.js | 492 +++--- src/ol/format/WKT.js | 333 ++-- src/ol/format/WMSCapabilities.js | 506 +++--- src/ol/format/WMSGetFeatureInfo.js | 66 +- src/ol/format/WMTSCapabilities.js | 326 ++-- src/ol/format/XLink.js | 12 +- src/ol/format/XML.js | 23 +- src/ol/format/XMLFeature.js | 90 +- src/ol/format/XSD.js | 79 +- src/ol/format/filter.js | 109 +- src/ol/format/filter/And.js | 17 +- src/ol/format/filter/Bbox.js | 18 +- src/ol/format/filter/Comparison.js | 18 +- src/ol/format/filter/ComparisonBinary.js | 18 +- src/ol/format/filter/Contains.js | 18 +- src/ol/format/filter/During.js | 18 +- src/ol/format/filter/EqualTo.js | 18 +- src/ol/format/filter/Filter.js | 11 +- src/ol/format/filter/GreaterThan.js | 18 +- src/ol/format/filter/GreaterThanOrEqualTo.js | 18 +- src/ol/format/filter/Intersects.js | 18 +- src/ol/format/filter/IsBetween.js | 18 +- src/ol/format/filter/IsLike.js | 18 +- src/ol/format/filter/IsNull.js | 18 +- src/ol/format/filter/LessThan.js | 18 +- src/ol/format/filter/LessThanOrEqualTo.js | 18 +- src/ol/format/filter/LogicalNary.js | 22 +- src/ol/format/filter/Not.js | 18 +- src/ol/format/filter/NotEqualTo.js | 18 +- src/ol/format/filter/Or.js | 18 +- src/ol/format/filter/Spatial.js | 18 +- src/ol/format/filter/Within.js | 18 +- src/ol/functions.js | 10 +- src/ol/geom/Circle.js | 72 +- src/ol/geom/Geometry.js | 82 +- src/ol/geom/GeometryCollection.js | 98 +- src/ol/geom/GeometryLayout.js | 10 +- src/ol/geom/GeometryType.js | 10 +- src/ol/geom/LineString.js | 108 +- src/ol/geom/LinearRing.js | 76 +- src/ol/geom/MultiLineString.js | 112 +- src/ol/geom/MultiPoint.js | 76 +- src/ol/geom/MultiPolygon.js | 136 +- src/ol/geom/Point.js | 58 +- src/ol/geom/Polygon.js | 156 +- src/ol/geom/SimpleGeometry.js | 104 +- src/ol/geom/flat/area.js | 16 +- src/ol/geom/flat/center.js | 15 +- src/ol/geom/flat/closest.js | 45 +- src/ol/geom/flat/contains.js | 27 +- src/ol/geom/flat/deflate.js | 18 +- src/ol/geom/flat/flip.js | 8 +- src/ol/geom/flat/geodesic.js | 55 +- src/ol/geom/flat/inflate.js | 16 +- src/ol/geom/flat/interiorpoint.js | 21 +- src/ol/geom/flat/interpolate.js | 29 +- src/ol/geom/flat/intersectsextent.js | 53 +- src/ol/geom/flat/length.js | 12 +- src/ol/geom/flat/orient.js | 29 +- src/ol/geom/flat/reverse.js | 8 +- src/ol/geom/flat/segments.js | 8 +- src/ol/geom/flat/simplify.js | 55 +- src/ol/geom/flat/straightchunk.js | 8 +- src/ol/geom/flat/textpath.js | 15 +- src/ol/geom/flat/topology.js | 13 +- src/ol/geom/flat/transform.js | 14 +- src/ol/has.js | 49 +- src/ol/index.js | 64 +- src/ol/interaction.js | 53 +- src/ol/interaction/DoubleClickZoom.js | 28 +- src/ol/interaction/DragAndDrop.js | 86 +- src/ol/interaction/DragBox.js | 70 +- src/ol/interaction/DragPan.js | 58 +- src/ol/interaction/DragRotate.js | 62 +- src/ol/interaction/DragRotateAndZoom.js | 60 +- src/ol/interaction/DragZoom.js | 40 +- src/ol/interaction/Draw.js | 296 ++-- src/ol/interaction/DrawEventType.js | 10 +- src/ol/interaction/Extent.js | 157 +- src/ol/interaction/ExtentEventType.js | 10 +- src/ol/interaction/Interaction.js | 65 +- src/ol/interaction/KeyboardPan.js | 54 +- src/ol/interaction/KeyboardZoom.js | 34 +- src/ol/interaction/Modify.js | 343 ++-- src/ol/interaction/ModifyEventType.js | 10 +- src/ol/interaction/MouseWheelZoom.js | 74 +- src/ol/interaction/PinchRotate.js | 52 +- src/ol/interaction/PinchZoom.js | 48 +- src/ol/interaction/Pointer.js | 77 +- src/ol/interaction/Property.js | 9 +- src/ol/interaction/Select.js | 124 +- src/ol/interaction/Snap.js | 174 +- src/ol/interaction/Translate.js | 102 +- src/ol/interaction/TranslateEventType.js | 10 +- src/ol/layer/Base.js | 111 +- src/ol/layer/Group.js | 108 +- src/ol/layer/Heatmap.js | 109 +- src/ol/layer/Image.js | 24 +- src/ol/layer/Layer.js | 82 +- src/ol/layer/Property.js | 9 +- src/ol/layer/Tile.js | 51 +- src/ol/layer/TileProperty.js | 9 +- src/ol/layer/Vector.js | 69 +- src/ol/layer/VectorRenderType.js | 9 +- src/ol/layer/VectorTile.js | 69 +- src/ol/layer/VectorTileRenderType.js | 9 +- src/ol/loadingstrategy.js | 12 +- src/ol/math.js | 33 +- src/ol/net.js | 13 +- src/ol/obj.js | 14 +- src/ol/plugins.js | 35 +- src/ol/pointer/EventSource.js | 13 +- src/ol/pointer/EventType.js | 10 +- src/ol/pointer/MouseSource.js | 70 +- src/ol/pointer/MsSource.js | 38 +- src/ol/pointer/NativeSource.js | 34 +- src/ol/pointer/PointerEvent.js | 29 +- src/ol/pointer/PointerEventHandler.js | 131 +- src/ol/pointer/TouchSource.js | 80 +- src/ol/proj.js | 193 +-- src/ol/proj/EPSG3857.js | 69 +- src/ol/proj/EPSG4326.js | 51 +- src/ol/proj/Projection.js | 51 +- src/ol/proj/Units.js | 19 +- src/ol/proj/common.js | 11 +- src/ol/proj/proj4.js | 16 +- src/ol/proj/projections.js | 20 +- src/ol/proj/transforms.js | 29 +- src/ol/render.js | 21 +- src/ol/render/Box.js | 32 +- src/ol/render/Event.js | 18 +- src/ol/render/EventType.js | 9 +- src/ol/render/Feature.js | 95 +- src/ol/render/ReplayGroup.js | 13 +- src/ol/render/ReplayType.js | 10 +- src/ol/render/VectorContext.js | 41 +- src/ol/render/canvas.js | 86 +- src/ol/render/canvas/ImageReplay.js | 38 +- src/ol/render/canvas/Immediate.js | 174 +- src/ol/render/canvas/Instruction.js | 9 +- src/ol/render/canvas/LineStringReplay.js | 52 +- src/ol/render/canvas/PolygonReplay.js | 76 +- src/ol/render/canvas/Replay.js | 248 +-- src/ol/render/canvas/ReplayGroup.js | 148 +- src/ol/render/canvas/TextReplay.js | 152 +- src/ol/render/replay.js | 47 +- src/ol/render/webgl.js | 34 +- src/ol/render/webgl/CircleReplay.js | 110 +- src/ol/render/webgl/ImageReplay.js | 42 +- src/ol/render/webgl/Immediate.js | 104 +- src/ol/render/webgl/LineStringReplay.js | 170 +- src/ol/render/webgl/PolygonReplay.js | 178 +- src/ol/render/webgl/Replay.js | 86 +- src/ol/render/webgl/ReplayGroup.js | 90 +- src/ol/render/webgl/TextReplay.js | 112 +- src/ol/render/webgl/TextureReplay.js | 87 +- .../webgl/circlereplay/defaultshader.js | 17 +- .../circlereplay/defaultshader/Locations.js | 36 +- .../webgl/linestringreplay/defaultshader.js | 17 +- .../defaultshader/Locations.js | 38 +- .../webgl/polygonreplay/defaultshader.js | 17 +- .../polygonreplay/defaultshader/Locations.js | 24 +- .../webgl/texturereplay/defaultshader.js | 17 +- .../texturereplay/defaultshader/Locations.js | 32 +- src/ol/renderer/Layer.js | 80 +- src/ol/renderer/Map.js | 100 +- src/ol/renderer/Type.js | 10 +- src/ol/renderer/canvas/ImageLayer.js | 94 +- src/ol/renderer/canvas/IntermediateCanvas.js | 52 +- src/ol/renderer/canvas/Layer.js | 90 +- src/ol/renderer/canvas/Map.js | 88 +- src/ol/renderer/canvas/TileLayer.js | 92 +- src/ol/renderer/canvas/VectorLayer.js | 116 +- src/ol/renderer/canvas/VectorTileLayer.js | 180 +- src/ol/renderer/vector.js | 119 +- src/ol/renderer/webgl/ImageLayer.js | 126 +- src/ol/renderer/webgl/Layer.js | 102 +- src/ol/renderer/webgl/Map.js | 188 +-- src/ol/renderer/webgl/TileLayer.js | 126 +- src/ol/renderer/webgl/VectorLayer.js | 86 +- src/ol/renderer/webgl/defaultmapshader.js | 17 +- .../webgl/defaultmapshader/Locations.js | 24 +- src/ol/renderer/webgl/tilelayershader.js | 17 +- .../webgl/tilelayershader/Locations.js | 20 +- src/ol/reproj.js | 55 +- src/ol/reproj/Image.js | 86 +- src/ol/reproj/Tile.js | 106 +- src/ol/reproj/Triangulation.js | 73 +- src/ol/size.js | 14 +- src/ol/source/BingMaps.js | 73 +- src/ol/source/CartoDB.js | 48 +- src/ol/source/Cluster.js | 68 +- src/ol/source/Image.js | 74 +- src/ol/source/ImageArcGISRest.js | 72 +- src/ol/source/ImageCanvas.js | 34 +- src/ol/source/ImageMapGuide.js | 72 +- src/ol/source/ImageStatic.js | 56 +- src/ol/source/ImageVector.js | 82 +- src/ol/source/ImageWMS.js | 128 +- src/ol/source/OSM.js | 22 +- src/ol/source/Raster.js | 174 +- src/ol/source/RasterOperationType.js | 9 +- src/ol/source/Source.js | 62 +- src/ol/source/Stamen.js | 34 +- src/ol/source/State.js | 9 +- src/ol/source/Tile.js | 90 +- src/ol/source/TileArcGISRest.js | 56 +- src/ol/source/TileDebug.js | 48 +- src/ol/source/TileEventType.js | 9 +- src/ol/source/TileImage.js | 128 +- src/ol/source/TileJSON.js | 68 +- src/ol/source/TileUTFGrid.js | 136 +- src/ol/source/TileWMS.js | 109 +- src/ol/source/UrlTile.js | 70 +- src/ol/source/Vector.js | 196 +-- src/ol/source/VectorEventType.js | 9 +- src/ol/source/VectorTile.js | 60 +- src/ol/source/WMSServerType.js | 10 +- src/ol/source/WMTS.js | 131 +- src/ol/source/WMTSRequestEncoding.js | 9 +- src/ol/source/XYZ.js | 24 +- src/ol/source/Zoomify.js | 72 +- src/ol/string.js | 10 +- src/ol/structs/LRUCache.js | 61 +- src/ol/structs/LinkedList.js | 32 +- src/ol/structs/PriorityQueue.js | 51 +- src/ol/structs/RBush.js | 59 +- src/ol/style.js | 11 +- src/ol/style/Atlas.js | 21 +- src/ol/style/AtlasManager.js | 39 +- src/ol/style/Circle.js | 24 +- src/ol/style/Fill.js | 27 +- src/ol/style/Icon.js | 118 +- src/ol/style/IconAnchorUnits.js | 9 +- src/ol/style/IconImage.js | 80 +- src/ol/style/IconImageCache.js | 29 +- src/ol/style/IconOrigin.js | 9 +- src/ol/style/Image.js | 51 +- src/ol/style/RegularShape.js | 102 +- src/ol/style/Stroke.js | 47 +- src/ol/style/Style.js | 135 +- src/ol/style/Text.js | 90 +- src/ol/style/TextPlacement.js | 10 +- src/ol/tilecoord.js | 22 +- src/ol/tilegrid.js | 81 +- src/ol/tilegrid/TileGrid.js | 117 +- src/ol/tilegrid/WMTS.js | 36 +- src/ol/transform.js | 53 +- src/ol/typedefs.js | 27 + src/ol/uri.js | 8 +- src/ol/vec/Mat4.js | 10 +- src/ol/webgl.js | 84 +- src/ol/webgl/Buffer.js | 25 +- src/ol/webgl/Context.js | 94 +- src/ol/webgl/ContextEventType.js | 10 +- src/ol/webgl/Fragment.js | 24 +- src/ol/webgl/Shader.js | 17 +- src/ol/webgl/Vertex.js | 24 +- src/ol/xml.js | 78 +- test/rendering/ol/layer/clip.test.js | 30 +- test/rendering/ol/layer/image.test.js | 36 +- test/rendering/ol/layer/tile.test.js | 68 +- test/rendering/ol/layer/vector.test.js | 392 +++-- test/rendering/ol/layer/vectortile.test.js | 64 +- test/rendering/ol/map.test.js | 26 +- test/rendering/ol/render.test.js | 88 +- test/rendering/ol/reproj/image.test.js | 30 +- test/rendering/ol/reproj/tile.test.js | 62 +- test/rendering/ol/source/raster.test.js | 20 +- test/rendering/ol/source/tilewms.test.js | 32 +- test/rendering/ol/style/circle.test.js | 132 +- test/rendering/ol/style/icon.test.js | 34 +- test/rendering/ol/style/linestring.test.js | 70 +- test/rendering/ol/style/polygon.test.js | 132 +- test/rendering/ol/style/regularshape.test.js | 74 +- test/rendering/ol/style/text.test.js | 168 +- test/spec/ol/array.test.js | 244 ++- test/spec/ol/assertionerror.test.js | 16 +- test/spec/ol/asserts.test.js | 6 +- test/spec/ol/collection.test.js | 92 +- test/spec/ol/color.test.js | 78 +- test/spec/ol/control/attribution.test.js | 42 +- test/spec/ol/control/control.test.js | 16 +- test/spec/ol/control/fullscreen.test.js | 8 +- test/spec/ol/control/mouseposition.test.js | 10 +- test/spec/ol/control/overviewmap.test.js | 32 +- test/spec/ol/control/rotate.test.js | 8 +- test/spec/ol/control/scaleline.test.js | 94 +- test/spec/ol/control/zoom.test.js | 8 +- test/spec/ol/control/zoomslider.test.js | 30 +- test/spec/ol/control/zoomtoextent.test.js | 8 +- test/spec/ol/coordinate.test.js | 66 +- test/spec/ol/css.test.js | 4 +- test/spec/ol/deviceorientation.test.js | 8 +- test/spec/ol/disposable.test.js | 14 +- test/spec/ol/dom/dom.test.js | 72 +- test/spec/ol/events.test.js | 108 +- test/spec/ol/events/event.test.js | 16 +- test/spec/ol/events/eventtarget.test.js | 20 +- test/spec/ol/extent.test.js | 288 ++-- test/spec/ol/feature.test.js | 146 +- test/spec/ol/featureloader.test.js | 18 +- test/spec/ol/format/esrijson.test.js | 242 ++- test/spec/ol/format/geojson.test.js | 234 +-- test/spec/ol/format/gml.test.js | 236 ++- test/spec/ol/format/gpx.test.js | 136 +- test/spec/ol/format/igc.test.js | 36 +- test/spec/ol/format/kml.test.js | 724 ++++----- test/spec/ol/format/mvt.test.js | 82 +- test/spec/ol/format/osmxml.test.js | 40 +- test/spec/ol/format/ows.test.js | 14 +- test/spec/ol/format/polyline.test.js | 86 +- test/spec/ol/format/topojson.test.js | 58 +- test/spec/ol/format/wfs.test.js | 318 ++-- test/spec/ol/format/wkt.test.js | 38 +- test/spec/ol/format/wmscapabilities.test.js | 6 +- test/spec/ol/format/wmsgetfeatureinfo.test.js | 16 +- test/spec/ol/format/wmtscapabilities.test.js | 8 +- test/spec/ol/format/xsd.test.js | 6 +- test/spec/ol/geolocation.test.js | 8 +- test/spec/ol/geom/circle.test.js | 14 +- test/spec/ol/geom/flat/area.test.js | 10 +- test/spec/ol/geom/flat/center.test.js | 18 +- test/spec/ol/geom/flat/closest.test.js | 30 +- test/spec/ol/geom/flat/contains.test.js | 14 +- test/spec/ol/geom/flat/deflate.test.js | 8 +- test/spec/ol/geom/flat/flip.test.js | 12 +- test/spec/ol/geom/flat/inflate.test.js | 8 +- test/spec/ol/geom/flat/interpolate.test.js | 22 +- .../ol/geom/flat/intersectsextent.test.js | 22 +- test/spec/ol/geom/flat/length.test.js | 20 +- test/spec/ol/geom/flat/orient.test.js | 16 +- test/spec/ol/geom/flat/reverse.test.js | 34 +- test/spec/ol/geom/flat/segments.test.js | 8 +- test/spec/ol/geom/flat/simplify.test.js | 82 +- test/spec/ol/geom/flat/straightchunk.test.js | 14 +- test/spec/ol/geom/flat/textpath.test.js | 38 +- .../ol/geom/flat/topologyflatgeom.test.js | 12 +- test/spec/ol/geom/flat/transform.test.js | 20 +- test/spec/ol/geom/geometrycollection.test.js | 102 +- test/spec/ol/geom/linestring.test.js | 36 +- test/spec/ol/geom/multilinestring.test.js | 42 +- test/spec/ol/geom/multipoint.test.js | 42 +- test/spec/ol/geom/multipolygon.test.js | 44 +- test/spec/ol/geom/point.test.js | 26 +- test/spec/ol/geom/polygon.test.js | 112 +- test/spec/ol/graticule.test.js | 42 +- test/spec/ol/imagetile.test.js | 70 +- test/spec/ol/index.test.js | 19 +- test/spec/ol/interaction/draganddrop.test.js | 54 +- .../ol/interaction/dragrotateandzoom.test.js | 46 +- test/spec/ol/interaction/dragzoom.test.js | 48 +- test/spec/ol/interaction/draw.test.js | 156 +- test/spec/ol/interaction/extent.test.js | 24 +- test/spec/ol/interaction/interaction.test.js | 58 +- test/spec/ol/interaction/keyboardpan.test.js | 24 +- test/spec/ol/interaction/keyboardzoom.test.js | 24 +- test/spec/ol/interaction/modify.test.js | 148 +- .../ol/interaction/mousewheelzoom.test.js | 94 +- test/spec/ol/interaction/select.test.js | 88 +- test/spec/ol/interaction/snap.test.js | 88 +- test/spec/ol/interaction/translate.test.js | 68 +- test/spec/ol/layer/group.test.js | 122 +- test/spec/ol/layer/heatmap.test.js | 8 +- test/spec/ol/layer/layer.test.js | 122 +- test/spec/ol/layer/tile.test.js | 12 +- test/spec/ol/layer/vector.test.js | 48 +- test/spec/ol/layer/vectortile.test.js | 24 +- test/spec/ol/map.test.js | 158 +- test/spec/ol/mapbrowserevent.test.js | 66 +- test/spec/ol/math.test.js | 106 +- test/spec/ol/net.test.js | 16 +- test/spec/ol/object.test.js | 28 +- test/spec/ol/objectutil.test.js | 28 +- test/spec/ol/observable.test.js | 22 +- test/spec/ol/overlay.test.js | 26 +- test/spec/ol/pointer/mousesource.test.js | 30 +- .../ol/pointer/pointereventhandler.test.js | 42 +- test/spec/ol/pointer/touchsource.test.js | 40 +- test/spec/ol/proj.test.js | 164 +- test/spec/ol/proj/epsg3857.test.js | 32 +- test/spec/ol/proj/transforms.test.js | 16 +- test/spec/ol/render.test.js | 24 +- test/spec/ol/render/box.test.js | 26 +- test/spec/ol/render/canvas/immediate.test.js | 92 +- test/spec/ol/render/canvas/index.test.js | 52 +- .../spec/ol/render/canvas/replaygroup.test.js | 6 +- test/spec/ol/render/canvas/textreplay.test.js | 30 +- test/spec/ol/render/feature.test.js | 32 +- .../spec/ol/render/webgl/circlereplay.test.js | 50 +- test/spec/ol/render/webgl/imagereplay.test.js | 22 +- test/spec/ol/render/webgl/immediate.test.js | 172 +- test/spec/ol/render/webgl/index.test.js | 6 +- .../ol/render/webgl/linestringreplay.test.js | 70 +- .../ol/render/webgl/polygonreplay.test.js | 62 +- test/spec/ol/render/webgl/textreplay.test.js | 46 +- .../ol/render/webgl/texturereplay.test.js | 16 +- .../ol/renderer/canvas/imagelayer.test.js | 20 +- .../canvas/intermediatecanvas.test.js | 22 +- test/spec/ol/renderer/canvas/map.test.js | 64 +- test/spec/ol/renderer/canvas/replay.test.js | 184 ++- .../spec/ol/renderer/canvas/tilelayer.test.js | 44 +- .../ol/renderer/canvas/vectorlayer.test.js | 134 +- .../renderer/canvas/vectortilelayer.test.js | 172 +- test/spec/ol/renderer/layer.test.js | 34 +- test/spec/ol/renderer/map.test.js | 16 +- test/spec/ol/renderer/vector.test.js | 88 +- .../spec/ol/renderer/webgl/imagelayer.test.js | 30 +- test/spec/ol/reproj/image.test.js | 22 +- test/spec/ol/reproj/reproj.test.js | 22 +- test/spec/ol/reproj/tile.test.js | 52 +- test/spec/ol/reproj/triangulation.test.js | 22 +- test/spec/ol/resolutionconstraint.test.js | 12 +- test/spec/ol/rotationconstraint.test.js | 6 +- test/spec/ol/size.test.js | 34 +- test/spec/ol/source/bingmaps.test.js | 32 +- test/spec/ol/source/cartodb.test.js | 12 +- test/spec/ol/source/cluster.test.js | 52 +- test/spec/ol/source/imagearcgisrest.test.js | 36 +- test/spec/ol/source/imagestatic.test.js | 14 +- test/spec/ol/source/imagewms.test.js | 52 +- test/spec/ol/source/raster.test.js | 62 +- test/spec/ol/source/source.test.js | 54 +- test/spec/ol/source/stamen.test.js | 8 +- test/spec/ol/source/tile.test.js | 76 +- test/spec/ol/source/tilearcgisrest.test.js | 68 +- test/spec/ol/source/tileimage.test.js | 94 +- test/spec/ol/source/tilejson.test.js | 28 +- test/spec/ol/source/tileutfgrid.test.js | 42 +- test/spec/ol/source/tilewms.test.js | 94 +- test/spec/ol/source/urltile.test.js | 32 +- test/spec/ol/source/vector.test.js | 170 +- test/spec/ol/source/vectortile.test.js | 50 +- test/spec/ol/source/wmts.test.js | 88 +- test/spec/ol/source/xyz.test.js | 38 +- test/spec/ol/source/zoomify.test.js | 58 +- test/spec/ol/sphere.test.js | 44 +- test/spec/ol/string.test.js | 44 +- test/spec/ol/structs/linkedlist.test.js | 14 +- test/spec/ol/structs/lrucache.test.js | 22 +- test/spec/ol/structs/priorityqueue.test.js | 14 +- test/spec/ol/structs/rbush.test.js | 10 +- test/spec/ol/style/atlasmanager.test.js | 48 +- test/spec/ol/style/circle.test.js | 114 +- test/spec/ol/style/fill.test.js | 12 +- test/spec/ol/style/icon.test.js | 54 +- test/spec/ol/style/iconimagecache.test.js | 36 +- test/spec/ol/style/regularshape.test.js | 116 +- test/spec/ol/style/stroke.test.js | 12 +- test/spec/ol/style/style.test.js | 98 +- test/spec/ol/style/text.test.js | 32 +- test/spec/ol/tile.test.js | 42 +- test/spec/ol/tilecache.test.js | 24 +- test/spec/ol/tilecoord.test.js | 70 +- test/spec/ol/tilegrid/tilegrid.test.js | 196 ++- test/spec/ol/tilegrid/wmts.test.js | 16 +- test/spec/ol/tilequeue.test.js | 38 +- test/spec/ol/tilerange.test.js | 50 +- test/spec/ol/tileurlfunction.test.js | 52 +- test/spec/ol/transform.test.js | 52 +- test/spec/ol/uri.test.js | 22 +- test/spec/ol/vec/mat4.test.js | 10 +- test/spec/ol/vectorimagetile.test.js | 116 +- test/spec/ol/vectortile.test.js | 30 +- test/spec/ol/view.test.js | 194 +-- test/spec/ol/webgl/buffer.test.js | 10 +- test/test-extensions.js | 8 +- 737 files changed, 22216 insertions(+), 21609 deletions(-) diff --git a/examples/Jugl.js b/examples/Jugl.js index 4f81a275cb..e3d61d2b42 100644 --- a/examples/Jugl.js +++ b/examples/Jugl.js @@ -1,3 +1,10 @@ +/* + * Jugl.js -- JavaScript Template Library + * + * Copyright 2007-2010 Tim Schaub + * Released under the MIT license. Please see + * http://github.com/tschaub/jugl/blob/master/license.txt for the full license. + */ /* * Jugl.js -- JavaScript Template Library * diff --git a/examples/accessible.js b/examples/accessible.js index 6ce87edac0..f6ec256354 100644 --- a/examples/accessible.js +++ b/examples/accessible.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/animation.js b/examples/animation.js index bfac92e190..b1191ae914 100644 --- a/examples/animation.js +++ b/examples/animation.js @@ -1,27 +1,27 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.easing'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_easing_ from '../src/ol/easing.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var london = ol.proj.fromLonLat([-0.12755, 51.507222]); -var moscow = ol.proj.fromLonLat([37.6178, 55.7517]); -var istanbul = ol.proj.fromLonLat([28.9744, 41.0128]); -var rome = ol.proj.fromLonLat([12.5, 41.9]); -var bern = ol.proj.fromLonLat([7.4458, 46.95]); +var london = _ol_proj_.fromLonLat([-0.12755, 51.507222]); +var moscow = _ol_proj_.fromLonLat([37.6178, 55.7517]); +var istanbul = _ol_proj_.fromLonLat([28.9744, 41.0128]); +var rome = _ol_proj_.fromLonLat([12.5, 41.9]); +var bern = _ol_proj_.fromLonLat([7.4458, 46.95]); -var view = new ol.View({ +var view = new _ol_View_({ center: istanbul, zoom: 6 }); -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ preload: 4, - source: new ol.source.OSM() + source: new _ol_source_OSM_() }) ], // Improve user experience by loading tiles while animating. Will make @@ -79,11 +79,11 @@ onClick('rotate-around-rome', function() { view.animate({ rotation: rotation + Math.PI, anchor: rome, - easing: ol.easing.easeIn + easing: _ol_easing_.easeIn }, { rotation: rotation + 2 * Math.PI, anchor: rome, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); }); @@ -119,11 +119,11 @@ onClick('spin-to-rome', function() { center[1] + (rome[1] - center[1]) / 2 ], rotation: Math.PI, - easing: ol.easing.easeIn + easing: _ol_easing_.easeIn }, { center: rome, rotation: 2 * Math.PI, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); }); diff --git a/examples/arcgis-image.js b/examples/arcgis-image.js index 4e1068f606..9d09864e80 100644 --- a/examples/arcgis-image.js +++ b/examples/arcgis-image.js @@ -1,29 +1,29 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Image'); -goog.require('ol.source.OSM'); -goog.require('ol.source.ImageArcGISRest'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_ImageArcGISRest_ from '../src/ol/source/ImageArcGISRest.js'; var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' + 'Specialty/ESRI_StateCityHighway_USA/MapServer'; var layers = [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Image({ - source: new ol.source.ImageArcGISRest({ + new _ol_layer_Image_({ + source: new _ol_source_ImageArcGISRest_({ ratio: 1, params: {}, url: url }) }) ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-10997148, 4569099], zoom: 4 }) diff --git a/examples/arcgis-tiled.js b/examples/arcgis-tiled.js index 568258f624..5032cd590e 100644 --- a/examples/arcgis-tiled.js +++ b/examples/arcgis-tiled.js @@ -1,27 +1,27 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileArcGISRest'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileArcGISRest_ from '../src/ol/source/TileArcGISRest.js'; var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/' + 'Specialty/ESRI_StateCityHighway_USA/MapServer'; var layers = [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ extent: [-13884991, 2870341, -7455066, 6338219], - source: new ol.source.TileArcGISRest({ + source: new _ol_source_TileArcGISRest_({ url: url }) }) ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-10997148, 4569099], zoom: 4 }) diff --git a/examples/attributions.js b/examples/attributions.js index 1ac6dca1f3..fa19bab4ef 100644 --- a/examples/attributions.js +++ b/examples/attributions.js @@ -1,22 +1,22 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.Attribution'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_Attribution_ from '../src/ol/control/Attribution.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var attribution = new ol.control.Attribution({ +var attribution = new _ol_control_Attribution_({ collapsible: false }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], - controls: ol.control.defaults({attribution: false}).extend([attribution]), + controls: _ol_control_.defaults({attribution: false}).extend([attribution]), target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/bing-maps.js b/examples/bing-maps.js index 274b63383f..a5c0f9d433 100644 --- a/examples/bing-maps.js +++ b/examples/bing-maps.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; var styles = [ @@ -15,10 +15,10 @@ var styles = [ var layers = []; var i, ii; for (i = 0, ii = styles.length; i < ii; ++i) { - layers.push(new ol.layer.Tile({ + layers.push(new _ol_layer_Tile_({ visible: false, preload: Infinity, - source: new ol.source.BingMaps({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: styles[i] // use maxZoom 19 to see stretched tiles instead of the BingMaps @@ -27,13 +27,13 @@ for (i = 0, ii = styles.length; i < ii; ++i) { }) })); } -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, // Improve user experience by loading tiles while dragging/zooming. Will make // zooming choppy on mobile or slow devices. loadTilesWhileInteracting: true, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-6655.5402445057125, 6709968.258934638], zoom: 13 }) diff --git a/examples/blend-modes.js b/examples/blend-modes.js index 45bd1b96a6..d8fad5222d 100644 --- a/examples/blend-modes.js +++ b/examples/blend-modes.js @@ -1,29 +1,29 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; // Create separate layers for red, green an blue circles. // // Every layer has one feature that is styled with a circle, together the // features form the corners of an equilateral triangle and their styles overlap -var redLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: [new ol.Feature(new ol.geom.Point([0, 0]))] +var redLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ + features: [new _ol_Feature_(new _ol_geom_Point_([0, 0]))] }), - style: new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.8)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgb(255,0,0)', width: 15 }), @@ -31,17 +31,17 @@ var redLayer = new ol.layer.Vector({ }) }) }); -var greenLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var greenLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ // 433.013 is roughly 250 * Math.sqrt(3) - features: [new ol.Feature(new ol.geom.Point([250, 433.013]))] + features: [new _ol_Feature_(new _ol_geom_Point_([250, 433.013]))] }), - style: new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,255,0,0.8)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgb(0,255,0)', width: 15 }), @@ -49,16 +49,16 @@ var greenLayer = new ol.layer.Vector({ }) }) }); -var blueLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: [new ol.Feature(new ol.geom.Point([500, 0]))] +var blueLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ + features: [new _ol_Feature_(new _ol_geom_Point_([500, 0]))] }), - style: new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,255,0.8)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgb(0,0,255)', width: 15 }), @@ -69,14 +69,14 @@ var blueLayer = new ol.layer.Vector({ // Create the map, the view is centered on the triangle. Zooming and panning is // restricted to a sane area -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ redLayer, greenLayer, blueLayer ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [250, 220], extent: [0, 0, 500, 500], resolution: 4, diff --git a/examples/box-selection.js b/examples/box-selection.js index f49a44eaac..455b6e625c 100644 --- a/examples/box-selection.js +++ b/examples/box-selection.js @@ -1,46 +1,46 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.events.condition'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction.DragBox'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_events_condition_ from '../src/ol/events/condition.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_DragBox_ from '../src/ol/interaction/DragBox.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Vector({ + new _ol_layer_Vector_({ source: vectorSource }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); // a normal select interaction to handle click -var select = new ol.interaction.Select(); +var select = new _ol_interaction_Select_(); map.addInteraction(select); var selectedFeatures = select.getFeatures(); // a DragBox interaction used to select features by drawing boxes -var dragBox = new ol.interaction.DragBox({ - condition: ol.events.condition.platformModifierKeyOnly +var dragBox = new _ol_interaction_DragBox_({ + condition: _ol_events_condition_.platformModifierKeyOnly }); map.addInteraction(dragBox); diff --git a/examples/button-title.js b/examples/button-title.js index ed0a165d31..01edba09d1 100644 --- a/examples/button-title.js +++ b/examples/button-title.js @@ -1,16 +1,16 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-8730000, 5930000], rotation: Math.PI / 5, zoom: 8 diff --git a/examples/canvas-gradient-pattern.js b/examples/canvas-gradient-pattern.js index 58ffb8ad75..7b350893b4 100644 --- a/examples/canvas-gradient-pattern.js +++ b/examples/canvas-gradient-pattern.js @@ -1,21 +1,21 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.has'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_has_ from '../src/ol/has.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); // Gradient and pattern are in canvas pixel space, so we adjust for the // renderer's pixel ratio -var pixelRatio = ol.has.DEVICE_PIXEL_RATIO; +var pixelRatio = _ol_has_.DEVICE_PIXEL_RATIO; // Generate a rainbow gradient function gradient(feature, resolution) { @@ -25,7 +25,7 @@ function gradient(feature, resolution) { // we just divide the geometry's extent width by resolution and multiply with // pixelRatio to match the renderer's pixel coordinate system. var grad = context.createLinearGradient(0, 0, - ol.extent.getWidth(extent) / resolution * pixelRatio, 0); + _ol_extent_.getWidth(extent) / resolution * pixelRatio, 0); grad.addColorStop(0, 'red'); grad.addColorStop(1 / 6, 'orange'); grad.addColorStop(2 / 6, 'yellow'); @@ -57,10 +57,10 @@ var pattern = (function() { }()); // Generate style for gradient or pattern fill -var fill = new ol.style.Fill(); -var style = new ol.style.Style({ +var fill = new _ol_style_Fill_(); +var style = new _ol_style_Style_({ fill: fill, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#333', width: 2 }) @@ -81,22 +81,22 @@ var getStackedStyle = function(feature, resolution) { }; // Create a vector layer that makes use of the style function above… -var vectorLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: getStackedStyle }); // … finally create a map with that layer. -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ vectorLayer ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([7, 52]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([7, 52]), zoom: 3 }) }); diff --git a/examples/canvas-tiles.js b/examples/canvas-tiles.js index 36050dca6d..188d8ccd09 100644 --- a/examples/canvas-tiles.js +++ b/examples/canvas-tiles.js @@ -1,33 +1,33 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileDebug'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileDebug_ from '../src/ol/source/TileDebug.js'; -var osmSource = new ol.source.OSM(); -var map = new ol.Map({ +var osmSource = new _ol_source_OSM_(); +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ source: osmSource }), - new ol.layer.Tile({ - source: new ol.source.TileDebug({ + new _ol_layer_Tile_({ + source: new _ol_source_TileDebug_({ projection: 'EPSG:3857', tileGrid: osmSource.getTileGrid() }) }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ - center: ol.proj.transform( + view: new _ol_View_({ + center: _ol_proj_.transform( [-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'), zoom: 10 }) diff --git a/examples/cartodb.js b/examples/cartodb.js index 8822a7ebf9..de959d0d67 100644 --- a/examples/cartodb.js +++ b/examples/cartodb.js @@ -1,8 +1,8 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.CartoDB'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_CartoDB_ from '../src/ol/source/CartoDB.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; var mapConfig = { 'layers': [{ @@ -15,22 +15,22 @@ var mapConfig = { }] }; -var cartoDBSource = new ol.source.CartoDB({ +var cartoDBSource = new _ol_source_CartoDB_({ account: 'documentation', config: mapConfig }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ source: cartoDBSource }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/center.js b/examples/center.js index c77f763f53..36a5b1c3df 100644 --- a/examples/center.js +++ b/examples/center.js @@ -1,56 +1,56 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var source = new ol.source.Vector({ +var source = new _ol_source_Vector_({ url: 'data/geojson/switzerland.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }); -var style = new ol.style.Style({ - fill: new ol.style.Fill({ +var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }) }) }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: source, style: style }); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 1 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), vectorLayer ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } diff --git a/examples/cluster.js b/examples/cluster.js index a2d858bca4..226b849cb8 100644 --- a/examples/cluster.js +++ b/examples/cluster.js @@ -1,17 +1,17 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Cluster'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Cluster_ from '../src/ol/source/Cluster.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; var distance = document.getElementById('distance'); @@ -21,38 +21,38 @@ var features = new Array(count); var e = 4500000; for (var i = 0; i < count; ++i) { var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e]; - features[i] = new ol.Feature(new ol.geom.Point(coordinates)); + features[i] = new _ol_Feature_(new _ol_geom_Point_(coordinates)); } -var source = new ol.source.Vector({ +var source = new _ol_source_Vector_({ features: features }); -var clusterSource = new ol.source.Cluster({ +var clusterSource = new _ol_source_Cluster_({ distance: parseInt(distance.value, 10), source: source }); var styleCache = {}; -var clusters = new ol.layer.Vector({ +var clusters = new _ol_layer_Vector_({ source: clusterSource, style: function(feature) { var size = feature.get('features').length; var style = styleCache[size]; if (!style) { - style = new ol.style.Style({ - image: new ol.style.Circle({ + style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 10, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#fff' }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#3399CC' }) }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: size.toString(), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#fff' }) }) @@ -63,14 +63,14 @@ var clusters = new ol.layer.Vector({ } }); -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, clusters], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/color-manipulation.js b/examples/color-manipulation.js index d54d7af4de..8202b84def 100644 --- a/examples/color-manipulation.js +++ b/examples/color-manipulation.js @@ -1,9 +1,9 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.source.Raster'); -goog.require('ol.source.Stamen'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_source_Raster_ from '../src/ol/source/Raster.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; /** @@ -100,8 +100,8 @@ function xyz2rgb(x) { 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); } -var raster = new ol.source.Raster({ - sources: [new ol.source.Stamen({ +var raster = new _ol_source_Raster_({ + sources: [new _ol_source_Stamen_({ layer: 'watercolor', transition: 0 })], @@ -148,14 +148,14 @@ raster.on('beforeoperations', function(event) { } }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Image({ + new _ol_layer_Image_({ source: raster }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 2500000], zoom: 2, maxZoom: 18 diff --git a/examples/custom-controls.js b/examples/custom-controls.js index d31c2d2a4a..84a826285e 100644 --- a/examples/custom-controls.js +++ b/examples/custom-controls.js @@ -1,10 +1,10 @@ -goog.require('ol'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.Control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_ from '../src/ol.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_Control_ from '../src/ol/control/Control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; /** @@ -43,13 +43,13 @@ app.RotateNorthControl = function(opt_options) { element.className = 'rotate-north ol-unselectable ol-control'; element.appendChild(button); - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, target: options.target }); }; -ol.inherits(app.RotateNorthControl, ol.control.Control); +_ol_.inherits(app.RotateNorthControl, _ol_control_Control_); // @@ -57,8 +57,8 @@ ol.inherits(app.RotateNorthControl, ol.control.Control); // -var map = new ol.Map({ - controls: ol.control.defaults({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } @@ -66,12 +66,12 @@ var map = new ol.Map({ new app.RotateNorthControl() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 3, rotation: 1 diff --git a/examples/custom-icon.js b/examples/custom-icon.js index 36e6788159..b2f3f4ad43 100644 --- a/examples/custom-icon.js +++ b/examples/custom-icon.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; var logoElement = document.createElement('a'); logoElement.href = 'https://www.osgeo.org/'; @@ -12,14 +12,14 @@ logoImage.src = 'https://www.osgeo.org/sites/all/themes/osgeo/logo.png'; logoElement.appendChild(logoImage); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }), diff --git a/examples/custom-interactions.js b/examples/custom-interactions.js index b0f6f952f7..9c557fd198 100644 --- a/examples/custom-interactions.js +++ b/examples/custom-interactions.js @@ -1,20 +1,20 @@ -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.TileJSON'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_ from '../src/ol.js'; +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Pointer_ from '../src/ol/interaction/Pointer.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; /** @@ -29,7 +29,7 @@ var app = {}; */ app.Drag = function() { - ol.interaction.Pointer.call(this, { + _ol_interaction_Pointer_.call(this, { handleDownEvent: app.Drag.prototype.handleDownEvent, handleDragEvent: app.Drag.prototype.handleDragEvent, handleMoveEvent: app.Drag.prototype.handleMoveEvent, @@ -61,7 +61,7 @@ app.Drag = function() { this.previousCursor_ = undefined; }; -ol.inherits(app.Drag, ol.interaction.Pointer); +_ol_.inherits(app.Drag, _ol_interaction_Pointer_); /** @@ -134,48 +134,48 @@ app.Drag.prototype.handleUpEvent = function() { }; -var pointFeature = new ol.Feature(new ol.geom.Point([0, 0])); +var pointFeature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); -var lineFeature = new ol.Feature( - new ol.geom.LineString([[-1e7, 1e6], [-1e6, 3e6]])); +var lineFeature = new _ol_Feature_( + new _ol_geom_LineString_([[-1e7, 1e6], [-1e6, 3e6]])); -var polygonFeature = new ol.Feature( - new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6], +var polygonFeature = new _ol_Feature_( + new _ol_geom_Polygon_([[[-3e6, -1e6], [-3e6, 1e6], [-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]])); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([new app.Drag()]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([new app.Drag()]), layers: [ - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure' }) }), - new ol.layer.Vector({ - source: new ol.source.Vector({ + new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [pointFeature, lineFeature, polygonFeature] }), - style: new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ + style: new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ anchor: [0.5, 46], anchorXUnits: 'fraction', anchorYUnits: 'pixels', opacity: 0.95, src: 'data/icon.png' })), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ width: 3, color: [255, 0, 0, 1] }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: [0, 0, 255, 0.6] }) }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/d3.js b/examples/d3.js index 3fbd0460b7..03eed0d3da 100644 --- a/examples/d3.js +++ b/examples/d3.js @@ -1,25 +1,25 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.ImageCanvas'); -goog.require('ol.source.Stamen'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_ImageCanvas_ from '../src/ol/source/ImageCanvas.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.Stamen({ + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'watercolor' }) }) ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-97, 38]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-97, 38]), zoom: 4 }) }); @@ -57,13 +57,13 @@ d3.json('data/topojson/us.json', function(error, us) { var pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1]; var geoBounds = d3.geoBounds(features); - var geoBoundsLeftBottom = ol.proj.transform( + var geoBoundsLeftBottom = _ol_proj_.transform( geoBounds[0], 'EPSG:4326', projection); - var geoBoundsRightTop = ol.proj.transform( + var geoBoundsRightTop = _ol_proj_.transform( geoBounds[1], 'EPSG:4326', projection); var geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0]; if (geoBoundsWidth < 0) { - geoBoundsWidth += ol.extent.getWidth(projection.getExtent()); + geoBoundsWidth += _ol_extent_.getWidth(projection.getExtent()); } var geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1]; @@ -72,7 +72,7 @@ d3.json('data/topojson/us.json', function(error, us) { var r = Math.max(widthResolution, heightResolution); var scale = r / (resolution / pixelRatio); - var center = ol.proj.transform(ol.extent.getCenter(extent), + var center = _ol_proj_.transform(_ol_extent_.getCenter(extent), projection, 'EPSG:4326'); d3Projection.scale(scale).center(center) .translate([canvasWidth / 2, canvasHeight / 2]); @@ -83,8 +83,8 @@ d3.json('data/topojson/us.json', function(error, us) { return canvas.node(); }; - var layer = new ol.layer.Image({ - source: new ol.source.ImageCanvas({ + var layer = new _ol_layer_Image_({ + source: new _ol_source_ImageCanvas_({ canvasFunction: canvasFunction, projection: 'EPSG:3857' }) diff --git a/examples/device-orientation.js b/examples/device-orientation.js index 1be0336b10..12b50a6406 100644 --- a/examples/device-orientation.js +++ b/examples/device-orientation.js @@ -1,27 +1,27 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.math'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_math_ from '../src/ol/math.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var projection = ol.proj.get('EPSG:3857'); -var view = new ol.View({ +var projection = _ol_proj_.get('EPSG:3857'); +var view = new _ol_View_({ center: [0, 0], projection: projection, extent: projection.getExtent(), zoom: 2 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } @@ -40,9 +40,9 @@ gn.init().then(function() { gn.start(function(event) { var center = view.getCenter(); var resolution = view.getResolution(); - var alpha = ol.math.toRadians(event.do.beta); - var beta = ol.math.toRadians(event.do.beta); - var gamma = ol.math.toRadians(event.do.gamma); + var alpha = _ol_math_.toRadians(event.do.beta); + var beta = _ol_math_.toRadians(event.do.beta); + var gamma = _ol_math_.toRadians(event.do.gamma); el('alpha').innerText = alpha + ' [rad]'; el('beta').innerText = beta + ' [rad]'; diff --git a/examples/drag-and-drop-image-vector.js b/examples/drag-and-drop-image-vector.js index a8fb251725..971f736329 100644 --- a/examples/drag-and-drop-image-vector.js +++ b/examples/drag-and-drop-image-vector.js @@ -1,73 +1,73 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GPX'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.format.IGC'); -goog.require('ol.format.KML'); -goog.require('ol.format.TopoJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DragAndDrop'); -goog.require('ol.layer.Vector'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GPX_ from '../src/ol/format/GPX.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_format_IGC_ from '../src/ol/format/IGC.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_DragAndDrop_ from '../src/ol/interaction/DragAndDrop.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var defaultStyle = { - 'Point': new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + 'Point': new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,255,0,0.5)' }), radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ff0', width: 1 }) }) }), - 'LineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'LineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 3 }) }), - 'Polygon': new ol.style.Style({ - fill: new ol.style.Fill({ + 'Polygon': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,255,255,0.5)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#0ff', width: 1 }) }), - 'MultiPoint': new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + 'MultiPoint': new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,255,0.5)' }), radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#f0f', width: 1 }) }) }), - 'MultiLineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'MultiLineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#0f0', width: 3 }) }), - 'MultiPolygon': new ol.style.Style({ - fill: new ol.style.Fill({ + 'MultiPolygon': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,255,0.5)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#00f', width: 1 }) @@ -83,38 +83,38 @@ var styleFunction = function(feature, resolution) { } }; -var dragAndDropInteraction = new ol.interaction.DragAndDrop({ +var dragAndDropInteraction = new _ol_interaction_DragAndDrop_({ formatConstructors: [ - ol.format.GPX, - ol.format.GeoJSON, - ol.format.IGC, - ol.format.KML, - ol.format.TopoJSON + _ol_format_GPX_, + _ol_format_GeoJSON_, + _ol_format_IGC_, + _ol_format_KML_, + _ol_format_TopoJSON_ ] }); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([dragAndDropInteraction]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([dragAndDropInteraction]), layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); dragAndDropInteraction.on('addfeatures', function(event) { - var vectorSource = new ol.source.Vector({ + var vectorSource = new _ol_source_Vector_({ features: event.features }); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ renderMode: 'image', source: vectorSource, style: styleFunction diff --git a/examples/drag-and-drop.js b/examples/drag-and-drop.js index 7d30d051b0..2fdb6fe3f9 100644 --- a/examples/drag-and-drop.js +++ b/examples/drag-and-drop.js @@ -1,73 +1,73 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GPX'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.format.IGC'); -goog.require('ol.format.KML'); -goog.require('ol.format.TopoJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DragAndDrop'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GPX_ from '../src/ol/format/GPX.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_format_IGC_ from '../src/ol/format/IGC.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_DragAndDrop_ from '../src/ol/interaction/DragAndDrop.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var defaultStyle = { - 'Point': new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + 'Point': new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,255,0,0.5)' }), radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ff0', width: 1 }) }) }), - 'LineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'LineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 3 }) }), - 'Polygon': new ol.style.Style({ - fill: new ol.style.Fill({ + 'Polygon': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,255,255,0.5)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#0ff', width: 1 }) }), - 'MultiPoint': new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + 'MultiPoint': new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,255,0.5)' }), radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#f0f', width: 1 }) }) }), - 'MultiLineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'MultiLineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#0f0', width: 3 }) }), - 'MultiPolygon': new ol.style.Style({ - fill: new ol.style.Fill({ + 'MultiPolygon': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,255,0.5)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#00f', width: 1 }) @@ -83,38 +83,38 @@ var styleFunction = function(feature, resolution) { } }; -var dragAndDropInteraction = new ol.interaction.DragAndDrop({ +var dragAndDropInteraction = new _ol_interaction_DragAndDrop_({ formatConstructors: [ - ol.format.GPX, - ol.format.GeoJSON, - ol.format.IGC, - ol.format.KML, - ol.format.TopoJSON + _ol_format_GPX_, + _ol_format_GeoJSON_, + _ol_format_IGC_, + _ol_format_KML_, + _ol_format_TopoJSON_ ] }); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([dragAndDropInteraction]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([dragAndDropInteraction]), layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); dragAndDropInteraction.on('addfeatures', function(event) { - var vectorSource = new ol.source.Vector({ + var vectorSource = new _ol_source_Vector_({ features: event.features }); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: vectorSource, style: styleFunction })); diff --git a/examples/drag-rotate-and-zoom.js b/examples/drag-rotate-and-zoom.js index 5c32a8ae98..bf82870f15 100644 --- a/examples/drag-rotate-and-zoom.js +++ b/examples/drag-rotate-and-zoom.js @@ -1,22 +1,22 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DragRotateAndZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_DragRotateAndZoom_ from '../src/ol/interaction/DragRotateAndZoom.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([ - new ol.interaction.DragRotateAndZoom() +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([ + new _ol_interaction_DragRotateAndZoom_() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/draw-and-modify-features.js b/examples/draw-and-modify-features.js index 6cc47d6213..396f1f86ba 100644 --- a/examples/draw-and-modify-features.js +++ b/examples/draw-and-modify-features.js @@ -1,63 +1,63 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction.Draw'); -goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.Snap'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js'; +import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector(); -var vector = new ol.layer.Vector({ +var source = new _ol_source_Vector_(); +var vector = new _ol_layer_Vector_({ source: source, - style: new ol.style.Style({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.2)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ffcc33', width: 2 }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 7, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#ffcc33' }) }) }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) }); -var modify = new ol.interaction.Modify({source: source}); +var modify = new _ol_interaction_Modify_({source: source}); map.addInteraction(modify); var draw, snap; // global so we can remove them later var typeSelect = document.getElementById('type'); function addInteractions() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: typeSelect.value }); map.addInteraction(draw); - snap = new ol.interaction.Snap({source: source}); + snap = new _ol_interaction_Snap_({source: source}); map.addInteraction(snap); } diff --git a/examples/draw-features.js b/examples/draw-features.js index 641c8e064c..986c48db2f 100644 --- a/examples/draw-features.js +++ b/examples/draw-features.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction.Draw'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector({wrapX: false}); +var source = new _ol_source_Vector_({wrapX: false}); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) @@ -31,7 +31,7 @@ var draw; // global so we can remove it later function addInteraction() { var value = typeSelect.value; if (value !== 'None') { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: typeSelect.value }); diff --git a/examples/draw-freehand.js b/examples/draw-freehand.js index f64e9366c4..70b08ce046 100644 --- a/examples/draw-freehand.js +++ b/examples/draw-freehand.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction.Draw'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector({wrapX: false}); +var source = new _ol_source_Vector_({wrapX: false}); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) @@ -31,7 +31,7 @@ var draw; // global so we can remove it later function addInteraction() { var value = typeSelect.value; if (value !== 'None') { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: typeSelect.value, freehand: true diff --git a/examples/draw-shapes.js b/examples/draw-shapes.js index 396092a664..57d1231915 100644 --- a/examples/draw-shapes.js +++ b/examples/draw-shapes.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Draw'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector({wrapX: false}); +var source = new _ol_source_Vector_({wrapX: false}); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) @@ -35,15 +35,15 @@ function addInteraction() { var geometryFunction; if (value === 'Square') { value = 'Circle'; - geometryFunction = ol.interaction.Draw.createRegularPolygon(4); + geometryFunction = _ol_interaction_Draw_.createRegularPolygon(4); } else if (value === 'Box') { value = 'Circle'; - geometryFunction = ol.interaction.Draw.createBox(); + geometryFunction = _ol_interaction_Draw_.createBox(); } else if (value === 'Star') { value = 'Circle'; geometryFunction = function(coordinates, geometry) { if (!geometry) { - geometry = new ol.geom.Polygon(null); + geometry = new _ol_geom_Polygon_(null); } var center = coordinates[0]; var last = coordinates[1]; @@ -65,7 +65,7 @@ function addInteraction() { return geometry; }; } - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: value, geometryFunction: geometryFunction diff --git a/examples/dynamic-data.js b/examples/dynamic-data.js index faa45e4fe2..b3e3ad56b9 100644 --- a/examples/dynamic-data.js +++ b/examples/dynamic-data.js @@ -1,50 +1,50 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_MultiPoint_ from '../src/ol/geom/MultiPoint.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); -var imageStyle = new ol.style.Style({ - image: new ol.style.Circle({ +var imageStyle = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, snapToPixel: false, - fill: new ol.style.Fill({color: 'yellow'}), - stroke: new ol.style.Stroke({color: 'red', width: 1}) + fill: new _ol_style_Fill_({color: 'yellow'}), + stroke: new _ol_style_Stroke_({color: 'red', width: 1}) }) }); -var headInnerImageStyle = new ol.style.Style({ - image: new ol.style.Circle({ +var headInnerImageStyle = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 2, snapToPixel: false, - fill: new ol.style.Fill({color: 'blue'}) + fill: new _ol_style_Fill_({color: 'blue'}) }) }); -var headOuterImageStyle = new ol.style.Style({ - image: new ol.style.Circle({ +var headOuterImageStyle = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, snapToPixel: false, - fill: new ol.style.Fill({color: 'black'}) + fill: new _ol_style_Fill_({color: 'black'}) }) }); @@ -66,9 +66,9 @@ map.on('postcompose', function(event) { coordinates.push([x, y]); } vectorContext.setStyle(imageStyle); - vectorContext.drawGeometry(new ol.geom.MultiPoint(coordinates)); + vectorContext.drawGeometry(new _ol_geom_MultiPoint_(coordinates)); - var headPoint = new ol.geom.Point(coordinates[coordinates.length - 1]); + var headPoint = new _ol_geom_Point_(coordinates[coordinates.length - 1]); vectorContext.setStyle(headOuterImageStyle); vectorContext.drawGeometry(headPoint); diff --git a/examples/earthquake-clusters.js b/examples/earthquake-clusters.js index 673943119b..4c8ecf10e5 100644 --- a/examples/earthquake-clusters.js +++ b/examples/earthquake-clusters.js @@ -1,37 +1,37 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.KML'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Cluster'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Cluster_ from '../src/ol/source/Cluster.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; -var earthquakeFill = new ol.style.Fill({ +var earthquakeFill = new _ol_style_Fill_({ color: 'rgba(255, 153, 0, 0.8)' }); -var earthquakeStroke = new ol.style.Stroke({ +var earthquakeStroke = new _ol_style_Stroke_({ color: 'rgba(255, 204, 0, 0.2)', width: 1 }); -var textFill = new ol.style.Fill({ +var textFill = new _ol_style_Fill_({ color: '#fff' }); -var textStroke = new ol.style.Stroke({ +var textStroke = new _ol_style_Stroke_({ color: 'rgba(0, 0, 0, 0.6)', width: 3 }); -var invisibleFill = new ol.style.Fill({ +var invisibleFill = new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.01)' }); @@ -43,9 +43,9 @@ function createEarthquakeStyle(feature) { var magnitude = parseFloat(name.substr(2)); var radius = 5 + 20 * (magnitude - 5); - return new ol.style.Style({ + return new _ol_style_Style_({ geometry: feature.getGeometry(), - image: new ol.style.RegularShape({ + image: new _ol_style_RegularShape_({ radius1: radius, radius2: 3, points: 5, @@ -64,13 +64,13 @@ function calculateClusterInfo(resolution) { for (var i = features.length - 1; i >= 0; --i) { feature = features[i]; var originalFeatures = feature.get('features'); - var extent = ol.extent.createEmpty(); + var extent = _ol_extent_.createEmpty(); var j, jj; for (j = 0, jj = originalFeatures.length; j < jj; ++j) { - ol.extent.extend(extent, originalFeatures[j].getGeometry().getExtent()); + _ol_extent_.extend(extent, originalFeatures[j].getGeometry().getExtent()); } maxFeatureCount = Math.max(maxFeatureCount, jj); - radius = 0.25 * (ol.extent.getWidth(extent) + ol.extent.getHeight(extent)) / + radius = 0.25 * (_ol_extent_.getWidth(extent) + _ol_extent_.getHeight(extent)) / resolution; feature.set('radius', radius); } @@ -85,14 +85,14 @@ function styleFunction(feature, resolution) { var style; var size = feature.get('features').length; if (size > 1) { - style = new ol.style.Style({ - image: new ol.style.Circle({ + style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: feature.get('radius'), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: [255, 153, 0, Math.min(0.8, 0.4 + (size / maxFeatureCount))] }) }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: size.toString(), fill: textFill, stroke: textStroke @@ -106,8 +106,8 @@ function styleFunction(feature, resolution) { } function selectStyleFunction(feature) { - var styles = [new ol.style.Style({ - image: new ol.style.Circle({ + var styles = [new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: feature.get('radius'), fill: invisibleFill }) @@ -121,12 +121,12 @@ function selectStyleFunction(feature) { return styles; } -vector = new ol.layer.Vector({ - source: new ol.source.Cluster({ +vector = new _ol_layer_Vector_({ + source: new _ol_source_Cluster_({ distance: 40, - source: new ol.source.Vector({ + source: new _ol_source_Vector_({ url: 'data/kml/2012_Earthquakes_Mag5.kml', - format: new ol.format.KML({ + format: new _ol_format_KML_({ extractStyles: false }) }) @@ -134,15 +134,15 @@ vector = new ol.layer.Vector({ style: styleFunction }); -var raster = new ol.layer.Tile({ - source: new ol.source.Stamen({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], - interactions: ol.interaction.defaults().extend([new ol.interaction.Select({ + interactions: _ol_interaction_.defaults().extend([new _ol_interaction_Select_({ condition: function(evt) { return evt.type == 'pointermove' || evt.type == 'singleclick'; @@ -150,7 +150,7 @@ var map = new ol.Map({ style: selectStyleFunction })]), target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/earthquake-custom-symbol.js b/examples/earthquake-custom-symbol.js index 0327d884ce..e2c3f01e06 100644 --- a/examples/earthquake-custom-symbol.js +++ b/examples/earthquake-custom-symbol.js @@ -1,16 +1,16 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.KML'); -goog.require('ol.geom.Polygon'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.render'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_render_ from '../src/ol/render.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var symbol = [[0, 0], [4, 2], [6, 0], [10, 5], [6, 3], [4, 5], [0, 0]]; @@ -32,16 +32,16 @@ var styleFunction = function(feature) { if (!style) { var canvas = /** @type {HTMLCanvasElement} */ (document.createElement('canvas')); - var vectorContext = ol.render.toContext( + var vectorContext = _ol_render_.toContext( /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')), {size: [size, size], pixelRatio: 1}); - vectorContext.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: 'rgba(255, 153, 0, 0.4)'}), - stroke: new ol.style.Stroke({color: 'rgba(255, 204, 0, 0.2)', width: 2}) + vectorContext.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'rgba(255, 153, 0, 0.4)'}), + stroke: new _ol_style_Stroke_({color: 'rgba(255, 204, 0, 0.2)', width: 2}) })); - vectorContext.drawGeometry(new ol.geom.Polygon([symbol.map(scaleFunction)])); - style = new ol.style.Style({ - image: new ol.style.Icon({ + vectorContext.drawGeometry(new _ol_geom_Polygon_([symbol.map(scaleFunction)])); + style = new _ol_style_Style_({ + image: new _ol_style_Icon_({ img: canvas, imgSize: [size, size], rotation: 1.2 @@ -52,26 +52,26 @@ var styleFunction = function(feature) { return style; }; -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/kml/2012_Earthquakes_Mag5.kml', - format: new ol.format.KML({ + format: new _ol_format_KML_({ extractStyles: false }) }), style: styleFunction }); -var raster = new ol.layer.Tile({ - source: new ol.source.Stamen({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/epsg-4326.js b/examples/epsg-4326.js index 807f1a2fee..761efa7a45 100644 --- a/examples/epsg-4326.js +++ b/examples/epsg-4326.js @@ -1,14 +1,14 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.ScaleLine'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; var layers = [ - new ol.layer.Tile({ - source: new ol.source.TileWMS({ + new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: { 'LAYERS': 'ne:NE1_HR_LC_SR_W_DR', @@ -18,15 +18,15 @@ var layers = [ }) ]; -var map = new ol.Map({ - controls: ol.control.defaults().extend([ - new ol.control.ScaleLine({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ + new _ol_control_ScaleLine_({ units: 'degrees' }) ]), layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], zoom: 2 diff --git a/examples/export-map.js b/examples/export-map.js index d96475a82d..d0d9323f1e 100644 --- a/examples/export-map.js +++ b/examples/export-map.js @@ -1,33 +1,33 @@ // NOCOMPILE // this example uses FileSaver.js for which we don't have an externs file. -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Vector({ - source: new ol.source.Vector({ + new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }) }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/export-pdf.js b/examples/export-pdf.js index ff253f1f94..18397ef3c8 100644 --- a/examples/export-pdf.js +++ b/examples/export-pdf.js @@ -1,40 +1,40 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.WKT'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_WKT_ from '../src/ol/format/WKT.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var format = new ol.format.WKT(); +var format = new _ol_format_WKT_(); var feature = format.readFeature( 'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' + '-20.1708984375, 38.814697265625 -35.6396484375, 13.502197265625 ' + '-39.1552734375, 10.689697265625 -25.0927734375))'); feature.getGeometry().transform('EPSG:4326', 'EPSG:3857'); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/extent-interaction.js b/examples/extent-interaction.js index 79a457e869..b2bb3f2457 100644 --- a/examples/extent-interaction.js +++ b/examples/extent-interaction.js @@ -1,36 +1,36 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.events.condition'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction.Extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_events_condition_ from '../src/ol/events/condition.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_Extent_ from '../src/ol/interaction/Extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Vector({ + new _ol_layer_Vector_({ source: vectorSource }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); -var extent = new ol.interaction.Extent({ - condition: ol.events.condition.platformModifierKeyOnly +var extent = new _ol_interaction_Extent_({ + condition: _ol_events_condition_.platformModifierKeyOnly }); map.addInteraction(extent); extent.setActive(false); diff --git a/examples/feature-animation.js b/examples/feature-animation.js index d04e741717..1ba80c1194 100644 --- a/examples/feature-animation.js +++ b/examples/feature-animation.js @@ -1,44 +1,44 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.Observable'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.easing'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Observable_ from '../src/ol/Observable.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_easing_ from '../src/ol/easing.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM({ + new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ wrapX: false }) }) ], - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) }); -var source = new ol.source.Vector({ +var source = new _ol_source_Vector_({ wrapX: false }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source }); map.addLayer(vector); @@ -46,9 +46,9 @@ map.addLayer(vector); function addRandomFeature() { var x = Math.random() * 360 - 180; var y = Math.random() * 180 - 90; - var geom = new ol.geom.Point(ol.proj.transform([x, y], + var geom = new _ol_geom_Point_(_ol_proj_.transform([x, y], 'EPSG:4326', 'EPSG:3857')); - var feature = new ol.Feature(geom); + var feature = new _ol_Feature_(geom); source.addFeature(feature); } @@ -64,14 +64,14 @@ function flash(feature) { var elapsed = frameState.time - start; var elapsedRatio = elapsed / duration; // radius will be 5 at start and 30 at end. - var radius = ol.easing.easeOut(elapsedRatio) * 25 + 5; - var opacity = ol.easing.easeOut(1 - elapsedRatio); + var radius = _ol_easing_.easeOut(elapsedRatio) * 25 + 5; + var opacity = _ol_easing_.easeOut(1 - elapsedRatio); - var style = new ol.style.Style({ - image: new ol.style.Circle({ + var style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: radius, snapToPixel: false, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255, 0, 0, ' + opacity + ')', width: 0.25 + opacity }) @@ -81,7 +81,7 @@ function flash(feature) { vectorContext.setStyle(style); vectorContext.drawGeometry(flashGeom); if (elapsed > duration) { - ol.Observable.unByKey(listenerKey); + _ol_Observable_.unByKey(listenerKey); return; } // tell OpenLayers to continue postcompose animation diff --git a/examples/feature-move-animation.js b/examples/feature-move-animation.js index fa6dfea05b..d8a58a1ff3 100644 --- a/examples/feature-move-animation.js +++ b/examples/feature-move-animation.js @@ -1,17 +1,17 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.Polyline'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_Polyline_ from '../src/ol/format/Polyline.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; // This long string is placed here due to jsFiddle limitations. // It is usually loaded with AJAX. @@ -57,7 +57,7 @@ var polyline = [ '~@ym@yjA??a@cFd@kBrCgDbAUnAcBhAyAdk@et@??kF}D??OL' ].join(''); -var route = /** @type {ol.geom.LineString} */ (new ol.format.Polyline({ +var route = /** @type {ol.geom.LineString} */ (new _ol_format_Polyline_({ factor: 1e6 }).readGeometry(polyline, { dataProjection: 'EPSG:4326', @@ -67,41 +67,41 @@ var route = /** @type {ol.geom.LineString} */ (new ol.format.Polyline({ var routeCoords = route.getCoordinates(); var routeLength = routeCoords.length; -var routeFeature = new ol.Feature({ +var routeFeature = new _ol_Feature_({ type: 'route', geometry: route }); -var geoMarker = new ol.Feature({ +var geoMarker = new _ol_Feature_({ type: 'geoMarker', - geometry: new ol.geom.Point(routeCoords[0]) + geometry: new _ol_geom_Point_(routeCoords[0]) }); -var startMarker = new ol.Feature({ +var startMarker = new _ol_Feature_({ type: 'icon', - geometry: new ol.geom.Point(routeCoords[0]) + geometry: new _ol_geom_Point_(routeCoords[0]) }); -var endMarker = new ol.Feature({ +var endMarker = new _ol_Feature_({ type: 'icon', - geometry: new ol.geom.Point(routeCoords[routeLength - 1]) + geometry: new _ol_geom_Point_(routeCoords[routeLength - 1]) }); var styles = { - 'route': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'route': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ width: 6, color: [237, 212, 0, 0.8] }) }), - 'icon': new ol.style.Style({ - image: new ol.style.Icon({ + 'icon': new _ol_style_Style_({ + image: new _ol_style_Icon_({ anchor: [0.5, 1], src: 'data/icon.png' }) }), - 'geoMarker': new ol.style.Style({ - image: new ol.style.Circle({ + 'geoMarker': new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 7, snapToPixel: false, - fill: new ol.style.Fill({color: 'black'}), - stroke: new ol.style.Stroke({ + fill: new _ol_style_Fill_({color: 'black'}), + stroke: new _ol_style_Stroke_({ color: 'white', width: 2 }) }) @@ -113,8 +113,8 @@ var speed, now; var speedInput = document.getElementById('speed'); var startButton = document.getElementById('start-animation'); -var vectorLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [routeFeature, geoMarker, startMarker, endMarker] }), style: function(feature) { @@ -127,18 +127,18 @@ var vectorLayer = new ol.layer.Vector({ }); var center = [-5639523.95, -3501274.52]; -var map = new ol.Map({ +var map = new _ol_Map_({ target: document.getElementById('map'), loadTilesWhileAnimating: true, - view: new ol.View({ + view: new _ol_View_({ center: center, zoom: 10, minZoom: 2, maxZoom: 19 }), layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'AerialWithLabels', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) @@ -162,8 +162,8 @@ var moveFeature = function(event) { return; } - var currentPoint = new ol.geom.Point(routeCoords[index]); - var feature = new ol.Feature(currentPoint); + var currentPoint = new _ol_geom_Point_(routeCoords[index]); + var feature = new _ol_Feature_(currentPoint); vectorContext.drawFeature(feature, styles.geoMarker); } // tell OpenLayers to continue the postcompose animation diff --git a/examples/flight-animation.js b/examples/flight-animation.js index 5b018d3eff..b98b305a89 100644 --- a/examples/flight-animation.js +++ b/examples/flight-animation.js @@ -1,33 +1,33 @@ // NOCOMPILE -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.Stamen({ + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); -var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ +var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#EAE911', width: 2 }) @@ -61,7 +61,7 @@ var animateFlights = function(event) { } var maxIndex = Math.min(elapsedPoints, coords.length); - var currentLine = new ol.geom.LineString(coords.slice(0, maxIndex)); + var currentLine = new _ol_geom_LineString_(coords.slice(0, maxIndex)); // directly draw the line with the vector context vectorContext.drawGeometry(currentLine); @@ -71,7 +71,7 @@ var animateFlights = function(event) { map.render(); }; -flightsSource = new ol.source.Vector({ +flightsSource = new _ol_source_Vector_({ wrapX: false, attributions: 'Flight data by ' + 'OpenFlights,', @@ -93,10 +93,10 @@ flightsSource = new ol.source.Vector({ var arcLine = arcGenerator.Arc(100, {offset: 10}); if (arcLine.geometries.length === 1) { - var line = new ol.geom.LineString(arcLine.geometries[0].coords); - line.transform(ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857')); + var line = new _ol_geom_LineString_(arcLine.geometries[0].coords); + line.transform(_ol_proj_.get('EPSG:4326'), _ol_proj_.get('EPSG:3857')); - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ geometry: line, finished: false }); @@ -110,7 +110,7 @@ flightsSource = new ol.source.Vector({ } }); -var flightsLayer = new ol.layer.Vector({ +var flightsLayer = new _ol_layer_Vector_({ source: flightsSource, style: function(feature) { // if the animation is still active for a feature, do not diff --git a/examples/fractal.js b/examples/fractal.js index c3e583dd82..d0ff0b515c 100644 --- a/examples/fractal.js +++ b/examples/fractal.js @@ -1,9 +1,9 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; var radius = 10e6; var cos30 = Math.cos(Math.PI / 6); @@ -11,22 +11,22 @@ var sin30 = Math.sin(Math.PI / 6); var rise = radius * sin30; var run = radius * cos30; -var triangle = new ol.geom.LineString([ +var triangle = new _ol_geom_LineString_([ [0, radius], [run, -rise], [-run, -rise], [0, radius] ]); -var feature = new ol.Feature(triangle); +var feature = new _ol_Feature_(triangle); -var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) diff --git a/examples/full-screen-drag-rotate-and-zoom.js b/examples/full-screen-drag-rotate-and-zoom.js index 48e59a9c15..50d2c7a7ce 100644 --- a/examples/full-screen-drag-rotate-and-zoom.js +++ b/examples/full-screen-drag-rotate-and-zoom.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.FullScreen'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DragRotateAndZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_FullScreen_ from '../src/ol/control/FullScreen.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_DragRotateAndZoom_ from '../src/ol/interaction/DragRotateAndZoom.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; -var map = new ol.Map({ - controls: ol.control.defaults().extend([ - new ol.control.FullScreen() +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ + new _ol_control_FullScreen_() ]), - interactions: ol.interaction.defaults().extend([ - new ol.interaction.DragRotateAndZoom() + interactions: _ol_interaction_.defaults().extend([ + new _ol_interaction_DragRotateAndZoom_() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) @@ -25,7 +25,7 @@ var map = new ol.Map({ ], // Use the canvas renderer because it's currently the fastest target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-33519607, 5616436], rotation: -Math.PI / 8, zoom: 8 diff --git a/examples/full-screen-source.js b/examples/full-screen-source.js index 785cf2677e..1b781d0c95 100644 --- a/examples/full-screen-source.js +++ b/examples/full-screen-source.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.FullScreen'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_FullScreen_ from '../src/ol/control/FullScreen.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var view = new ol.View({ +var view = new _ol_View_({ center: [-9101767, 2822912], zoom: 14 }); -var map = new ol.Map({ - controls: ol.control.defaults().extend([ - new ol.control.FullScreen({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ + new _ol_control_FullScreen_({ source: 'fullscreen' }) ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', diff --git a/examples/full-screen.js b/examples/full-screen.js index ee93e4a657..b5da25da7a 100644 --- a/examples/full-screen.js +++ b/examples/full-screen.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.FullScreen'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_FullScreen_ from '../src/ol/control/FullScreen.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; -var view = new ol.View({ +var view = new _ol_View_({ center: [-9101767, 2822912], zoom: 14 }); -var map = new ol.Map({ - controls: ol.control.defaults().extend([ - new ol.control.FullScreen() +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ + new _ol_control_FullScreen_() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) diff --git a/examples/geojson-vt.js b/examples/geojson-vt.js index 2252f649df..57a5f7d959 100644 --- a/examples/geojson-vt.js +++ b/examples/geojson-vt.js @@ -1,12 +1,12 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.source.OSM'); -goog.require('ol.source.VectorTile'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.proj.Projection'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; +import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; var replacer = function(key, value) { @@ -48,19 +48,19 @@ var replacer = function(key, value) { } }; -var tilePixels = new ol.proj.Projection({ +var tilePixels = new _ol_proj_Projection_({ code: 'TILE_PIXELS', units: 'tile-pixels' }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -74,8 +74,8 @@ fetch(url).then(function(response) { extent: 4096, debug: 1 }); - var vectorSource = new ol.source.VectorTile({ - format: new ol.format.GeoJSON(), + var vectorSource = new _ol_source_VectorTile_({ + format: new _ol_format_GeoJSON_(), tileLoadFunction: function(tile) { var format = tile.getFormat(); var tileCoord = tile.getTileCoord(); @@ -93,7 +93,7 @@ fetch(url).then(function(response) { }, url: 'data:' // arbitrary url, we don't use it in the tileLoadFunction }); - var vectorLayer = new ol.layer.VectorTile({ + var vectorLayer = new _ol_layer_VectorTile_({ source: vectorSource }); map.addLayer(vectorLayer); diff --git a/examples/geojson.js b/examples/geojson.js index fe76499fd7..3b207afd98 100644 --- a/examples/geojson.js +++ b/examples/geojson.js @@ -1,85 +1,85 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.geom.Circle'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_geom_Circle_ from '../src/ol/geom/Circle.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var image = new ol.style.Circle({ +var image = new _ol_style_Circle_({ radius: 5, fill: null, - stroke: new ol.style.Stroke({color: 'red', width: 1}) + stroke: new _ol_style_Stroke_({color: 'red', width: 1}) }); var styles = { - 'Point': new ol.style.Style({ + 'Point': new _ol_style_Style_({ image: image }), - 'LineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'LineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'green', width: 1 }) }), - 'MultiLineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'MultiLineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'green', width: 1 }) }), - 'MultiPoint': new ol.style.Style({ + 'MultiPoint': new _ol_style_Style_({ image: image }), - 'MultiPolygon': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'MultiPolygon': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'yellow', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 0, 0.1)' }) }), - 'Polygon': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'Polygon': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', lineDash: [4], width: 3 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 0, 255, 0.1)' }) }), - 'GeometryCollection': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'GeometryCollection': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'magenta', width: 2 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'magenta' }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 10, fill: null, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'magenta' }) }) }), - 'Circle': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'Circle': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'red', width: 2 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.2)' }) }) @@ -160,31 +160,31 @@ var geojsonObject = { }] }; -var vectorSource = new ol.source.Vector({ - features: (new ol.format.GeoJSON()).readFeatures(geojsonObject) +var vectorSource = new _ol_source_Vector_({ + features: (new _ol_format_GeoJSON_()).readFeatures(geojsonObject) }); -vectorSource.addFeature(new ol.Feature(new ol.geom.Circle([5e6, 7e6], 1e6))); +vectorSource.addFeature(new _ol_Feature_(new _ol_geom_Circle_([5e6, 7e6], 1e6))); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: vectorSource, style: styleFunction }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), vectorLayer ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/geolocation-orientation.js b/examples/geolocation-orientation.js index 3edfe41bf5..65534111af 100644 --- a/examples/geolocation-orientation.js +++ b/examples/geolocation-orientation.js @@ -1,28 +1,28 @@ -goog.require('ol.Geolocation'); -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.geom.LineString'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; // creating the view -var view = new ol.View({ - center: ol.proj.fromLonLat([5.8713, 45.6452]), +var view = new _ol_View_({ + center: _ol_proj_.fromLonLat([5.8713, 45.6452]), zoom: 19 }); // creating the map -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } @@ -32,7 +32,7 @@ var map = new ol.Map({ // Geolocation marker var markerEl = document.getElementById('geolocation_marker'); -var marker = new ol.Overlay({ +var marker = new _ol_Overlay_({ positioning: 'center-center', element: markerEl, stopEvent: false @@ -42,11 +42,11 @@ map.addOverlay(marker); // LineString to store the different geolocation positions. This LineString // is time aware. // The Z dimension is actually used to store the rotation (heading). -var positions = new ol.geom.LineString([], +var positions = new _ol_geom_LineString_([], /** @type {ol.geom.GeometryLayout} */ ('XYZM')); // Geolocation Control -var geolocation = new ol.Geolocation({ +var geolocation = new _ol_Geolocation_({ projection: view.getProjection(), trackingOptions: { maximumAge: 10000, @@ -215,7 +215,7 @@ function simulatePositionChange(position) { geolocation.set('accuracy', coords.accuracy); geolocation.set('heading', degToRad(coords.heading)); var position_ = [coords.longitude, coords.latitude]; - var projectedPosition = ol.proj.transform(position_, 'EPSG:4326', + var projectedPosition = _ol_proj_.transform(position_, 'EPSG:4326', 'EPSG:3857'); geolocation.set('position', projectedPosition); geolocation.set('speed', coords.speed); diff --git a/examples/geolocation.js b/examples/geolocation.js index b17bcbe10f..159e0348d3 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -1,31 +1,31 @@ -goog.require('ol.Feature'); -goog.require('ol.Geolocation'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 2 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } @@ -33,7 +33,7 @@ var map = new ol.Map({ view: view }); -var geolocation = new ol.Geolocation({ +var geolocation = new _ol_Geolocation_({ projection: view.getProjection() }); @@ -61,19 +61,19 @@ geolocation.on('error', function(error) { info.style.display = ''; }); -var accuracyFeature = new ol.Feature(); +var accuracyFeature = new _ol_Feature_(); geolocation.on('change:accuracyGeometry', function() { accuracyFeature.setGeometry(geolocation.getAccuracyGeometry()); }); -var positionFeature = new ol.Feature(); -positionFeature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ +var positionFeature = new _ol_Feature_(); +positionFeature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 6, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#3399CC' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#fff', width: 2 }) @@ -83,12 +83,12 @@ positionFeature.setStyle(new ol.style.Style({ geolocation.on('change:position', function() { var coordinates = geolocation.getPosition(); positionFeature.setGeometry(coordinates ? - new ol.geom.Point(coordinates) : null); + new _ol_geom_Point_(coordinates) : null); }); -new ol.layer.Vector({ +new _ol_layer_Vector_({ map: map, - source: new ol.source.Vector({ + source: new _ol_source_Vector_({ features: [accuracyFeature, positionFeature] }) }); diff --git a/examples/getfeatureinfo-image.js b/examples/getfeatureinfo-image.js index 432d2e6c87..5f1d287d72 100644 --- a/examples/getfeatureinfo-image.js +++ b/examples/getfeatureinfo-image.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.source.ImageWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; -var wmsSource = new ol.source.ImageWMS({ +var wmsSource = new _ol_source_ImageWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'ne:ne'}, serverType: 'geoserver', crossOrigin: 'anonymous' }); -var wmsLayer = new ol.layer.Image({ +var wmsLayer = new _ol_layer_Image_({ source: wmsSource }); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 1 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [wmsLayer], target: 'map', view: view diff --git a/examples/getfeatureinfo-layers.js b/examples/getfeatureinfo-layers.js index ffe9240adc..67458d5c72 100644 --- a/examples/getfeatureinfo-layers.js +++ b/examples/getfeatureinfo-layers.js @@ -1,21 +1,21 @@ -goog.require('ol.format.WMSGetFeatureInfo'); +import _ol_format_WMSGetFeatureInfo_ from '../src/ol/format/WMSGetFeatureInfo.js'; fetch('data/wmsgetfeatureinfo/osm-restaurant-hotel.xml').then(function(response) { return response.text(); }).then(function(response) { // this is the standard way to read the features - var allFeatures = new ol.format.WMSGetFeatureInfo().readFeatures(response); + var allFeatures = new _ol_format_WMSGetFeatureInfo_().readFeatures(response); document.getElementById('all').innerText = allFeatures.length.toString(); // when specifying the 'layers' options, only the features of those // layers are returned by the format - var hotelFeatures = new ol.format.WMSGetFeatureInfo({ + var hotelFeatures = new _ol_format_WMSGetFeatureInfo_({ layers: ['hotel'] }).readFeatures(response); document.getElementById('hotel').innerText = hotelFeatures.length.toString(); - var restaurantFeatures = new ol.format.WMSGetFeatureInfo({ + var restaurantFeatures = new _ol_format_WMSGetFeatureInfo_({ layers: ['restaurant'] }).readFeatures(response); document.getElementById('restaurant').innerText = restaurantFeatures.length.toString(); diff --git a/examples/getfeatureinfo-tile.js b/examples/getfeatureinfo-tile.js index f912b6b2ff..11cbb4039e 100644 --- a/examples/getfeatureinfo-tile.js +++ b/examples/getfeatureinfo-tile.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; -var wmsSource = new ol.source.TileWMS({ +var wmsSource = new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'ne:ne', 'TILED': true}, serverType: 'geoserver', crossOrigin: 'anonymous' }); -var wmsLayer = new ol.layer.Tile({ +var wmsLayer = new _ol_layer_Tile_({ source: wmsSource }); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 1 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [wmsLayer], target: 'map', view: view diff --git a/examples/gpx.js b/examples/gpx.js index 226b406367..3d263bfd1a 100644 --- a/examples/gpx.js +++ b/examples/gpx.js @@ -1,63 +1,63 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GPX'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GPX_ from '../src/ol/format/GPX.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }); var style = { - 'Point': new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + 'Point': new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,255,0,0.4)' }), radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ff0', width: 1 }) }) }), - 'LineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'LineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 3 }) }), - 'MultiLineString': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'MultiLineString': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#0f0', width: 3 }) }) }; -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/gpx/fells_loop.gpx', - format: new ol.format.GPX() + format: new _ol_format_GPX_() }), style: function(feature) { return style[feature.getGeometry().getType()]; } }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [-7916041.528716288, 5228379.045749711], zoom: 12 }) diff --git a/examples/graticule.js b/examples/graticule.js index 760212c2c7..46d33f1c4f 100644 --- a/examples/graticule.js +++ b/examples/graticule.js @@ -1,32 +1,32 @@ -goog.require('ol.Graticule'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.style.Stroke'); +import _ol_Graticule_ from '../src/ol/Graticule.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM({ + new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ wrapX: false }) }) ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([4.8, 47.75]), - extent: ol.proj.get('EPSG:3857').getExtent(), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([4.8, 47.75]), + extent: _ol_proj_.get('EPSG:3857').getExtent(), zoom: 5 }) }); // Create the graticule component -var graticule = new ol.Graticule({ +var graticule = new _ol_Graticule_({ // the style to use for the lines, optional. - strokeStyle: new ol.style.Stroke({ + strokeStyle: new _ol_style_Stroke_({ color: 'rgba(255,120,0,0.9)', width: 2, lineDash: [0.5, 4] diff --git a/examples/heatmap-earthquakes.js b/examples/heatmap-earthquakes.js index 939338143e..09ccb7cc90 100644 --- a/examples/heatmap-earthquakes.js +++ b/examples/heatmap-earthquakes.js @@ -1,18 +1,18 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.KML'); -goog.require('ol.layer.Heatmap'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_layer_Heatmap_ from '../src/ol/layer/Heatmap.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; var blur = document.getElementById('blur'); var radius = document.getElementById('radius'); -var vector = new ol.layer.Heatmap({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Heatmap_({ + source: new _ol_source_Vector_({ url: 'data/kml/2012_Earthquakes_Mag5.kml', - format: new ol.format.KML({ + format: new _ol_format_KML_({ extractStyles: false }) }), @@ -29,16 +29,16 @@ vector.getSource().on('addfeature', function(event) { event.feature.set('weight', magnitude - 5); }); -var raster = new ol.layer.Tile({ - source: new ol.source.Stamen({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/here-maps.js b/examples/here-maps.js index 066bff149c..4906916dfb 100644 --- a/examples/here-maps.js +++ b/examples/here-maps.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; var appId = 'kDm0Jq1K4Ak7Bwtn8uvk'; var appCode = 'xnmvc4dKZrDfGlvQHXSvwQ'; @@ -56,10 +56,10 @@ var layers = []; var i, ii; for (i = 0, ii = hereLayers.length; i < ii; ++i) { var layerDesc = hereLayers[i]; - layers.push(new ol.layer.Tile({ + layers.push(new _ol_layer_Tile_({ visible: false, preload: Infinity, - source: new ol.source.XYZ({ + source: new _ol_source_XYZ_({ url: createUrl(urlTpl, layerDesc), attributions: 'Map Tiles © ' + new Date().getFullYear() + ' ' + 'HERE' @@ -67,13 +67,13 @@ for (i = 0, ii = hereLayers.length; i < ii; ++i) { })); } -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, // Improve user experience by loading tiles while dragging/zooming. Will make // zooming choppy on mobile or slow devices. loadTilesWhileInteracting: true, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [921371.9389, 6358337.7609], zoom: 10 }) diff --git a/examples/hit-tolerance.js b/examples/hit-tolerance.js index bc3f9612be..89a00f7ade 100644 --- a/examples/hit-tolerance.js +++ b/examples/hit-tolerance.js @@ -1,38 +1,38 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.Feature'); -goog.require('ol.geom.LineString'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ +var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'black', width: 1 }) }); -var feature = new ol.Feature(new ol.geom.LineString([[-4000000, 0], [4000000, 0]])); +var feature = new _ol_Feature_(new _ol_geom_LineString_([[-4000000, 0], [4000000, 0]])); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }), style: style }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/icon-color.js b/examples/icon-color.js index 62c6437f99..0d80b69913 100644 --- a/examples/icon-color.js +++ b/examples/icon-color.js @@ -1,46 +1,46 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.TileJSON'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var rome = new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([12.5, 41.9])) +var rome = new _ol_Feature_({ + geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([12.5, 41.9])) }); -var london = new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([-0.12755, 51.507222])) +var london = new _ol_Feature_({ + geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([-0.12755, 51.507222])) }); -var madrid = new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat([-3.683333, 40.4])) +var madrid = new _ol_Feature_({ + geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([-3.683333, 40.4])) }); -rome.setStyle(new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ +rome.setStyle(new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ color: '#8959A8', crossOrigin: 'anonymous', src: 'data/dot.png' })) })); -london.setStyle(new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ +london.setStyle(new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ color: '#4271AE', crossOrigin: 'anonymous', src: 'data/dot.png' })) })); -madrid.setStyle(new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ +madrid.setStyle(new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ color: [113, 140, 0], crossOrigin: 'anonymous', src: 'data/dot.png' @@ -48,26 +48,26 @@ madrid.setStyle(new ol.style.Style({ })); -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ features: [rome, london, madrid] }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); -var rasterLayer = new ol.layer.Tile({ - source: new ol.source.TileJSON({ +var rasterLayer = new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure', crossOrigin: '' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [rasterLayer, vectorLayer], target: document.getElementById('map'), - view: new ol.View({ - center: ol.proj.fromLonLat([2.896372, 44.60240]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([2.896372, 44.60240]), zoom: 3 }) }); diff --git a/examples/icon-negative.js b/examples/icon-negative.js index 22e6f8b46d..58dd69028f 100644 --- a/examples/icon-negative.js +++ b/examples/icon-negative.js @@ -1,19 +1,19 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; function createStyle(src, img) { - return new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ + return new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ anchor: [0.5, 0.96], crossOrigin: 'anonymous', src: src, @@ -23,30 +23,30 @@ function createStyle(src, img) { }); } -var iconFeature = new ol.Feature(new ol.geom.Point([0, 0])); +var iconFeature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); iconFeature.set('style', createStyle('data/icon.png', undefined)); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.Stamen({layer: 'watercolor'}) + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({layer: 'watercolor'}) }), - new ol.layer.Vector({ + new _ol_layer_Vector_({ style: function(feature) { return feature.get('style'); }, - source: new ol.source.Vector({features: [iconFeature]}) + source: new _ol_source_Vector_({features: [iconFeature]}) }) ], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 3 }) }); var selectStyle = {}; -var select = new ol.interaction.Select({ +var select = new _ol_interaction_Select_({ style: function(feature) { var image = feature.get('style').getImage().getImage(); if (!selectStyle[image.src]) { diff --git a/examples/icon-sprite-webgl.js b/examples/icon-sprite-webgl.js index dfaeb8e220..c496b57b03 100644 --- a/examples/icon-sprite-webgl.js +++ b/examples/icon-sprite-webgl.js @@ -1,11 +1,11 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var iconInfo = [{ @@ -44,7 +44,7 @@ var iconCount = iconInfo.length; var icons = new Array(iconCount); for (i = 0; i < iconCount; ++i) { var info = iconInfo[i]; - icons[i] = new ol.style.Icon({ + icons[i] = new _ol_style_Icon_({ offset: info.offset, opacity: info.opacity, rotateWithView: info.rotateWithView, @@ -61,29 +61,29 @@ var features = new Array(featureCount); var feature, geometry; var e = 25000000; for (i = 0; i < featureCount; ++i) { - geometry = new ol.geom.Point( + geometry = new _ol_geom_Point_( [2 * e * Math.random() - e, 2 * e * Math.random() - e]); - feature = new ol.Feature(geometry); + feature = new _ol_Feature_(geometry); feature.setStyle( - new ol.style.Style({ + new _ol_style_Style_({ image: icons[i % (iconCount - 1)] }) ); features[i] = feature; } -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ features: features }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource }); -var map = new ol.Map({ +var map = new _ol_Map_({ renderer: /** @type {Array} */ (['webgl', 'canvas']), layers: [vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 5 }) @@ -96,12 +96,12 @@ for (i = 0; i < featureCount; i += 30) { overlayFeatures.push(clone); } -new ol.layer.Vector({ +new _ol_layer_Vector_({ map: map, - source: new ol.source.Vector({ + source: new _ol_source_Vector_({ features: overlayFeatures }), - style: new ol.style.Style({ + style: new _ol_style_Style_({ image: icons[iconCount - 1] }) }); diff --git a/examples/icon.js b/examples/icon.js index a8c1969772..782236f282 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -1,25 +1,25 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.TileJSON'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var iconFeature = new ol.Feature({ - geometry: new ol.geom.Point([0, 0]), +var iconFeature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([0, 0]), name: 'Null Island', population: 4000, rainfall: 500 }); -var iconStyle = new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({ +var iconStyle = new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ ({ anchor: [0.5, 46], anchorXUnits: 'fraction', anchorYUnits: 'pixels', @@ -29,25 +29,25 @@ var iconStyle = new ol.style.Style({ iconFeature.setStyle(iconStyle); -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ features: [iconFeature] }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); -var rasterLayer = new ol.layer.Tile({ - source: new ol.source.TileJSON({ +var rasterLayer = new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure', crossOrigin: '' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [rasterLayer, vectorLayer], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 3 }) @@ -55,7 +55,7 @@ var map = new ol.Map({ var element = document.getElementById('popup'); -var popup = new ol.Overlay({ +var popup = new _ol_Overlay_({ element: element, positioning: 'bottom-center', stopEvent: false, diff --git a/examples/igc.js b/examples/igc.js index f8f1cb2df7..0ee92a6aee 100644 --- a/examples/igc.js +++ b/examples/igc.js @@ -1,18 +1,18 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.IGC'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_IGC_ from '../src/ol/format/IGC.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var colors = { @@ -28,8 +28,8 @@ var styleFunction = function(feature) { var color = colors[feature.get('PLT')]; var style = styleCache[color]; if (!style) { - style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: color, width: 3 }) @@ -39,7 +39,7 @@ var styleFunction = function(feature) { return style; }; -var vectorSource = new ol.source.Vector(); +var vectorSource = new _ol_source_Vector_(); var igcUrls = [ 'data/igc/Clement-Latour.igc', @@ -58,7 +58,7 @@ function get(url, callback) { client.send(); } -var igcFormat = new ol.format.IGC(); +var igcFormat = new _ol_format_IGC_(); for (var i = 0; i < igcUrls.length; ++i) { get(igcUrls[i], function(data) { var features = igcFormat.readFeatures(data, @@ -80,30 +80,30 @@ vectorSource.on('addfeature', function(event) { }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM({ + new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ attributions: [ 'All maps © OpenCycleMap', - ol.source.OSM.ATTRIBUTION + _ol_source_OSM_.ATTRIBUTION ], url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' }) }), - new ol.layer.Vector({ + new _ol_layer_Vector_({ source: vectorSource, style: styleFunction }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [703365.7089403362, 5714629.865071137], zoom: 9 }) @@ -123,7 +123,7 @@ var displaySnap = function(coordinate) { var geometry = closestFeature.getGeometry(); var closestPoint = geometry.getClosestPoint(coordinate); if (point === null) { - point = new ol.geom.Point(closestPoint); + point = new _ol_geom_Point_(closestPoint); } else { point.setCoordinates(closestPoint); } @@ -132,7 +132,7 @@ var displaySnap = function(coordinate) { closestFeature.get('PLT') + ' (' + date.toUTCString() + ')'; var coordinates = [coordinate, [closestPoint[0], closestPoint[1]]]; if (line === null) { - line = new ol.geom.LineString(coordinates); + line = new _ol_geom_LineString_(coordinates); } else { line.setCoordinates(coordinates); } @@ -152,13 +152,13 @@ map.on('click', function(evt) { displaySnap(evt.coordinate); }); -var stroke = new ol.style.Stroke({ +var stroke = new _ol_style_Stroke_({ color: 'rgba(255,0,0,0.9)', width: 1 }); -var style = new ol.style.Style({ +var style = new _ol_style_Style_({ stroke: stroke, - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 5, fill: null, stroke: stroke @@ -175,13 +175,13 @@ map.on('postcompose', function(evt) { } }); -var featureOverlay = new ol.layer.Vector({ - source: new ol.source.Vector(), +var featureOverlay = new _ol_layer_Vector_({ + source: new _ol_source_Vector_(), map: map, - style: new ol.style.Style({ - image: new ol.style.Circle({ + style: new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.9)' }) }) @@ -196,7 +196,7 @@ document.getElementById('time').addEventListener('input', function() { var coordinate = geometry.getCoordinateAtM(m, true); var highlight = feature.get('highlight'); if (highlight === undefined) { - highlight = new ol.Feature(new ol.geom.Point(coordinate)); + highlight = new _ol_Feature_(new _ol_geom_Point_(coordinate)); feature.set('highlight', highlight); featureOverlay.getSource().addFeature(highlight); } else { diff --git a/examples/image-filter.js b/examples/image-filter.js index 81188dd058..e8929e5852 100644 --- a/examples/image-filter.js +++ b/examples/image-filter.js @@ -1,20 +1,20 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; -var imagery = new ol.layer.Tile({ - source: new ol.source.BingMaps({key: key, imagerySet: 'Aerial'}) +var imagery = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'}) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [imagery], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-120, 50]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-120, 50]), zoom: 6 }) }); diff --git a/examples/image-load-events.js b/examples/image-load-events.js index 1d611be5e3..082b2f158a 100644 --- a/examples/image-load-events.js +++ b/examples/image-load-events.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.source.ImageWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; /** @@ -77,7 +77,7 @@ Progress.prototype.hide = function() { var progress = new Progress(document.getElementById('progress')); -var source = new ol.source.ImageWMS({ +var source = new _ol_source_ImageWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'topp:states'}, serverType: 'geoserver' @@ -94,13 +94,13 @@ source.on('imageloaderror', function() { progress.addLoaded(); }); -var map = new ol.Map({ +var map = new _ol_Map_({ logo: false, layers: [ - new ol.layer.Image({source: source}) + new _ol_layer_Image_({source: source}) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-10997148, 4569099], zoom: 4 }) diff --git a/examples/image-vector-layer.js b/examples/image-vector-layer.js index 3a5561a72f..199c0fe46d 100644 --- a/examples/image-vector-layer.js +++ b/examples/image-vector-layer.js @@ -1,32 +1,32 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; -var style = new ol.style.Style({ - fill: new ol.style.Fill({ +var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }), - text: new ol.style.Text() + text: new _ol_style_Text_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Vector({ + new _ol_layer_Vector_({ renderMode: 'image', - source: new ol.source.Vector({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: function(feature) { style.getText().setText(feature.get('name')); @@ -35,21 +35,21 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) }); -var featureOverlay = new ol.layer.Vector({ - source: new ol.source.Vector(), +var featureOverlay = new _ol_layer_Vector_({ + source: new _ol_source_Vector_(), map: map, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.1)' }) }) diff --git a/examples/jsts.js b/examples/jsts.js index 2cd7a8d81d..56211c1933 100644 --- a/examples/jsts.js +++ b/examples/jsts.js @@ -1,20 +1,20 @@ // NOCOMPILE // this example uses JSTS for which we don't have an externs file. -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var source = new ol.source.Vector(); +var source = new _ol_source_Vector_(); fetch('data/geojson/roads-seoul.geojson').then(function(response) { return response.json(); }).then(function(json) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var features = format.readFeatures(json, {featureProjection: 'EPSG:3857'}); var parser = new jsts.io.OL3Parser(); @@ -33,19 +33,19 @@ fetch('data/geojson/roads-seoul.geojson').then(function(response) { source.addFeatures(features); }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: source }); -var rasterLayer = new ol.layer.Tile({ - source: new ol.source.OSM() +var rasterLayer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [rasterLayer, vectorLayer], target: document.getElementById('map'), - view: new ol.View({ - center: ol.proj.fromLonLat([126.979293, 37.528787]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([126.979293, 37.528787]), zoom: 15 }) }); diff --git a/examples/kml-earthquakes.js b/examples/kml-earthquakes.js index 656bd41236..5aefdb7491 100644 --- a/examples/kml-earthquakes.js +++ b/examples/kml-earthquakes.js @@ -1,14 +1,14 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.KML'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var styleCache = {}; @@ -21,13 +21,13 @@ var styleFunction = function(feature) { var radius = 5 + 20 * (magnitude - 5); var style = styleCache[radius]; if (!style) { - style = new ol.style.Style({ - image: new ol.style.Circle({ + style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: radius, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 153, 0, 0.4)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255, 204, 0, 0.2)', width: 1 }) @@ -38,26 +38,26 @@ var styleFunction = function(feature) { return style; }; -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/kml/2012_Earthquakes_Mag5.kml', - format: new ol.format.KML({ + format: new _ol_format_KML_({ extractStyles: false }) }), style: styleFunction }); -var raster = new ol.layer.Tile({ - source: new ol.source.Stamen({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/kml-timezones.js b/examples/kml-timezones.js index 9db2419682..355076b149 100644 --- a/examples/kml-timezones.js +++ b/examples/kml-timezones.js @@ -1,13 +1,13 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.KML'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; /* @@ -35,36 +35,36 @@ var styleFunction = function(feature) { delta = 24 - delta; } var opacity = 0.75 * (1 - delta / 12); - return new ol.style.Style({ - fill: new ol.style.Fill({ + return new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: [0xff, 0xff, 0x33, opacity] }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ffffff' }) }); }; -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/kml/timezones.kml', - format: new ol.format.KML({ + format: new _ol_format_KML_({ extractStyles: false }) }), style: styleFunction }); -var raster = new ol.layer.Tile({ - source: new ol.source.Stamen({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'toner' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/kml.js b/examples/kml.js index ae364217ba..91a5f6e22e 100644 --- a/examples/kml.js +++ b/examples/kml.js @@ -1,32 +1,32 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.KML'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_KML_ from '../src/ol/format/KML.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var projection = ol.proj.get('EPSG:3857'); +var projection = _ol_proj_.get('EPSG:3857'); -var raster = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/kml/2012-02-10.kml', - format: new ol.format.KML() + format: new _ol_format_KML_() }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [876970.8463461736, 5859807.853963373], projection: projection, zoom: 10 diff --git a/examples/layer-clipping-webgl.js b/examples/layer-clipping-webgl.js index 53581f97c9..31079f67b8 100644 --- a/examples/layer-clipping-webgl.js +++ b/examples/layer-clipping-webgl.js @@ -1,11 +1,11 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.has'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_has_ from '../src/ol/has.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -if (!ol.has.WEBGL) { +if (!_ol_has_.WEBGL) { var info = document.getElementById('no-webgl'); /** * display error message @@ -13,20 +13,20 @@ if (!ol.has.WEBGL) { info.style.display = ''; } else { - var osm = new ol.layer.Tile({ - source: new ol.source.OSM() + var osm = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); - var map = new ol.Map({ + var map = new _ol_Map_({ layers: [osm], renderer: /** @type {Array} */ (['webgl', 'canvas']), target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/layer-clipping.js b/examples/layer-clipping.js index 3047eed841..d3da23da0c 100644 --- a/examples/layer-clipping.js +++ b/examples/layer-clipping.js @@ -1,22 +1,22 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var osm = new ol.layer.Tile({ - source: new ol.source.OSM() +var osm = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [osm], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/layer-extent.js b/examples/layer-extent.js index edd1d1ceba..c1aed418b7 100644 --- a/examples/layer-extent.js +++ b/examples/layer-extent.js @@ -1,11 +1,11 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; function transform(extent) { - return ol.proj.transformExtent(extent, 'EPSG:4326', 'EPSG:3857'); + return _ol_proj_.transformExtent(extent, 'EPSG:4326', 'EPSG:3857'); } var extents = { @@ -15,25 +15,25 @@ var extents = { Sweden: transform([11.02737, 55.36174, 23.90338, 69.10625]) }; -var base = new ol.layer.Tile({ - source: new ol.source.TileJSON({ +var base = new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.world-light.json?secure', crossOrigin: 'anonymous' }) }); -var overlay = new ol.layer.Tile({ +var overlay = new _ol_layer_Tile_({ extent: extents.India, - source: new ol.source.TileJSON({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.world-black.json?secure', crossOrigin: 'anonymous' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [base, overlay], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) diff --git a/examples/layer-group.js b/examples/layer-group.js index 25f6f33450..4c895d1f8b 100644 --- a/examples/layer-group.js +++ b/examples/layer-group.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Group'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Group_ from '../src/ol/layer/Group.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() - }), new ol.layer.Group({ + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() + }), new _ol_layer_Group_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.20110804-hoa-foodinsecurity-3month.json?secure', crossOrigin: 'anonymous' }) }), - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.world-borders-light.json?secure', crossOrigin: 'anonymous' }) @@ -28,8 +28,8 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([37.40570, 8.81566]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([37.40570, 8.81566]), zoom: 4 }) }); @@ -49,7 +49,7 @@ function bindInputs(layerid, layer) { } map.getLayers().forEach(function(layer, i) { bindInputs('#layer' + i, layer); - if (layer instanceof ol.layer.Group) { + if (layer instanceof _ol_layer_Group_) { layer.getLayers().forEach(function(sublayer, j) { bindInputs('#layer' + i + j, sublayer); }); diff --git a/examples/layer-spy.js b/examples/layer-spy.js index 0aa98e6809..a1eab6ae26 100644 --- a/examples/layer-spy.js +++ b/examples/layer-spy.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; -var roads = new ol.layer.Tile({ - source: new ol.source.BingMaps({key: key, imagerySet: 'Road'}) +var roads = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({key: key, imagerySet: 'Road'}) }); -var imagery = new ol.layer.Tile({ - source: new ol.source.BingMaps({key: key, imagerySet: 'Aerial'}) +var imagery = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'}) }); var container = document.getElementById('map'); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [roads, imagery], target: container, - view: new ol.View({ - center: ol.proj.fromLonLat([-109, 46.5]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-109, 46.5]), zoom: 6 }) }); diff --git a/examples/layer-swipe.js b/examples/layer-swipe.js index c4c014b58c..5f5b91cb15 100644 --- a/examples/layer-swipe.js +++ b/examples/layer-swipe.js @@ -1,29 +1,29 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var osm = new ol.layer.Tile({ - source: new ol.source.OSM() +var osm = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var bing = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var bing = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [osm, bing], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/layer-z-index.js b/examples/layer-z-index.js index 01c28e7d33..d1e94887c9 100644 --- a/examples/layer-z-index.js +++ b/examples/layer-z-index.js @@ -1,30 +1,30 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var stroke = new ol.style.Stroke({color: 'black', width: 1}); +var stroke = new _ol_style_Stroke_({color: 'black', width: 1}); var styles = { - 'square': new ol.style.Style({ - image: new ol.style.RegularShape({ - fill: new ol.style.Fill({color: 'blue'}), + 'square': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ + fill: new _ol_style_Fill_({color: 'blue'}), stroke: stroke, points: 4, radius: 80, angle: Math.PI / 4 }) }), - 'triangle': new ol.style.Style({ - image: new ol.style.RegularShape({ - fill: new ol.style.Fill({color: 'red'}), + 'triangle': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ + fill: new _ol_style_Fill_({color: 'red'}), stroke: stroke, points: 3, radius: 80, @@ -32,9 +32,9 @@ var styles = { angle: 0 }) }), - 'star': new ol.style.Style({ - image: new ol.style.RegularShape({ - fill: new ol.style.Fill({color: 'green'}), + 'star': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ + fill: new _ol_style_Fill_({color: 'green'}), stroke: stroke, points: 5, radius: 80, @@ -46,14 +46,14 @@ var styles = { function createLayer(coordinates, style, zIndex) { - var feature = new ol.Feature(new ol.geom.Point(coordinates)); + var feature = new _ol_Feature_(new _ol_geom_Point_(coordinates)); feature.setStyle(style); - var source = new ol.source.Vector({ + var source = new _ol_source_Vector_({ features: [feature] }); - var vectorLayer = new ol.layer.Vector({ + var vectorLayer = new _ol_layer_Vector_({ source: source }); vectorLayer.setZIndex(zIndex); @@ -69,10 +69,10 @@ var layers = []; layers.push(layer1); layers.push(layer2); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 18 }) diff --git a/examples/lazy-source.js b/examples/lazy-source.js index 27682c1011..90a3455d57 100644 --- a/examples/lazy-source.js +++ b/examples/lazy-source.js @@ -1,16 +1,16 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var source = new ol.source.OSM(); +var source = new _ol_source_OSM_(); -var layer = new ol.layer.Tile(); +var layer = new _ol_layer_Tile_(); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/line-arrows.js b/examples/line-arrows.js index ee13201a7e..8af18a8169 100644 --- a/examples/line-arrows.js +++ b/examples/line-arrows.js @@ -1,27 +1,27 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.interaction.Draw'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector(); +var source = new _ol_source_Vector_(); var styleFunction = function(feature) { var geometry = feature.getGeometry(); var styles = [ // linestring - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#ffcc33', width: 2 }) @@ -33,9 +33,9 @@ var styleFunction = function(feature) { var dy = end[1] - start[1]; var rotation = Math.atan2(dy, dx); // arrows - styles.push(new ol.style.Style({ - geometry: new ol.geom.Point(end), - image: new ol.style.Icon({ + styles.push(new _ol_style_Style_({ + geometry: new _ol_geom_Point_(end), + image: new _ol_style_Icon_({ src: 'data/arrow.png', anchor: [0.75, 0.5], rotateWithView: true, @@ -46,21 +46,21 @@ var styleFunction = function(feature) { return styles; }; -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source, style: styleFunction }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) }); -map.addInteraction(new ol.interaction.Draw({ +map.addInteraction(new _ol_interaction_Draw_({ source: source, type: 'LineString' })); diff --git a/examples/localized-openstreetmap.js b/examples/localized-openstreetmap.js index 71d72d517d..7b1cfe593f 100644 --- a/examples/localized-openstreetmap.js +++ b/examples/localized-openstreetmap.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var openCycleMapLayer = new ol.layer.Tile({ - source: new ol.source.OSM({ +var openCycleMapLayer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ attributions: [ 'All maps © OpenCycleMap', - ol.source.OSM.ATTRIBUTION + _ol_source_OSM_.ATTRIBUTION ], url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' }) }); -var openSeaMapLayer = new ol.layer.Tile({ - source: new ol.source.OSM({ +var openSeaMapLayer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ attributions: [ 'All maps © OpenSeaMap', - ol.source.OSM.ATTRIBUTION + _ol_source_OSM_.ATTRIBUTION ], opaque: false, url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png' @@ -28,18 +28,18 @@ var openSeaMapLayer = new ol.layer.Tile({ }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ openCycleMapLayer, openSeaMapLayer ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ maxZoom: 18, center: [-244780.24508882355, 5986452.183179816], zoom: 15 diff --git a/examples/magnify.js b/examples/magnify.js index 81e5f86a3d..b3eec88561 100644 --- a/examples/magnify.js +++ b/examples/magnify.js @@ -1,22 +1,22 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; -var imagery = new ol.layer.Tile({ - source: new ol.source.BingMaps({key: key, imagerySet: 'Aerial'}) +var imagery = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'}) }); var container = document.getElementById('map'); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [imagery], target: container, - view: new ol.View({ - center: ol.proj.fromLonLat([-109, 46.5]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-109, 46.5]), zoom: 6 }) }); diff --git a/examples/mapbox-vector-tiles-advanced.js b/examples/mapbox-vector-tiles-advanced.js index ecfe823f08..8819765488 100644 --- a/examples/mapbox-vector-tiles-advanced.js +++ b/examples/mapbox-vector-tiles-advanced.js @@ -1,15 +1,15 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.MVT'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.proj'); -goog.require('ol.source.VectorTile'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_MVT_ from '../src/ol/format/MVT.js'; +import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; +import _ol_tilegrid_TileGrid_ from '../src/ol/tilegrid/TileGrid.js'; var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg'; @@ -30,26 +30,26 @@ function tileUrlFunction(tileCoord) { ((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1)); } -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.VectorTile({ - source: new ol.source.VectorTile({ + new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({ attributions: '© Mapbox ' + '© ' + 'OpenStreetMap contributors', - format: new ol.format.MVT(), - tileGrid: new ol.tilegrid.TileGrid({ - extent: ol.proj.get('EPSG:3857').getExtent(), + format: new _ol_format_MVT_(), + tileGrid: new _ol_tilegrid_TileGrid_({ + extent: _ol_proj_.get('EPSG:3857').getExtent(), resolutions: resolutions, tileSize: 512 }), tileUrlFunction: tileUrlFunction }), - style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text) + style: createMapboxStreetsV6Style(_ol_style_Style_, _ol_style_Fill_, _ol_style_Stroke_, _ol_style_Icon_, _ol_style_Text_) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], minZoom: 1, zoom: 2 diff --git a/examples/mapbox-vector-tiles.js b/examples/mapbox-vector-tiles.js index c2262324e0..8b2e67ae64 100644 --- a/examples/mapbox-vector-tiles.js +++ b/examples/mapbox-vector-tiles.js @@ -1,34 +1,34 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.MVT'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.source.VectorTile'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_MVT_ from '../src/ol/format/MVT.js'; +import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; +import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.VectorTile({ + new _ol_layer_VectorTile_({ declutter: true, - source: new ol.source.VectorTile({ + source: new _ol_source_VectorTile_({ attributions: '© Mapbox ' + '© ' + 'OpenStreetMap contributors', - format: new ol.format.MVT(), + format: new _ol_format_MVT_(), url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' + '{z}/{x}/{y}.vector.pbf?access_token=' + key }), - style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text) + style: createMapboxStreetsV6Style(_ol_style_Style_, _ol_style_Fill_, _ol_style_Stroke_, _ol_style_Icon_, _ol_style_Text_) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/mapguide-untiled.js b/examples/mapguide-untiled.js index e5fcc04349..b3f5a3b6c2 100644 --- a/examples/mapguide-untiled.js +++ b/examples/mapguide-untiled.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.source.ImageMapGuide'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_source_ImageMapGuide_ from '../src/ol/source/ImageMapGuide.js'; var mdf = 'Library://Public/Samples/Sheboygan/Maps/Sheboygan.MapDefinition'; var agentUrl = @@ -12,11 +12,11 @@ var bounds = [ -87.595394059497067, 43.823852564430069 ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Image({ + new _ol_layer_Image_({ extent: bounds, - source: new ol.source.ImageMapGuide({ + source: new _ol_source_ImageMapGuide_({ projection: 'EPSG:4326', url: agentUrl, useOverlay: false, @@ -32,7 +32,7 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-87.7302542509315, 43.744459064634], projection: 'EPSG:4326', zoom: 12 diff --git a/examples/measure.js b/examples/measure.js index 6f09548a0b..746e13f24e 100644 --- a/examples/measure.js +++ b/examples/measure.js @@ -1,40 +1,40 @@ -goog.require('ol.Map'); -goog.require('ol.Observable'); -goog.require('ol.Overlay'); -goog.require('ol.Sphere'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Draw'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Observable_ from '../src/ol/Observable.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_Sphere_ from '../src/ol/Sphere.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var source = new ol.source.Vector(); +var source = new _ol_source_Vector_(); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: source, - style: new ol.style.Style({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.2)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ffcc33', width: 2 }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 7, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#ffcc33' }) }) @@ -104,9 +104,9 @@ var pointerMoveHandler = function(evt) { if (sketch) { var geom = (sketch.getGeometry()); - if (geom instanceof ol.geom.Polygon) { + if (geom instanceof _ol_geom_Polygon_) { helpMsg = continuePolygonMsg; - } else if (geom instanceof ol.geom.LineString) { + } else if (geom instanceof _ol_geom_LineString_) { helpMsg = continueLineMsg; } } @@ -118,10 +118,10 @@ var pointerMoveHandler = function(evt) { }; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 15 }) @@ -144,7 +144,7 @@ var draw; // global so we can remove it later * @return {string} The formatted length. */ var formatLength = function(line) { - var length = ol.Sphere.getLength(line); + var length = _ol_Sphere_.getLength(line); var output; if (length > 100) { output = (Math.round(length / 1000 * 100) / 100) + @@ -163,7 +163,7 @@ var formatLength = function(line) { * @return {string} Formatted area. */ var formatArea = function(polygon) { - var area = ol.Sphere.getArea(polygon); + var area = _ol_Sphere_.getArea(polygon); var output; if (area > 10000) { output = (Math.round(area / 1000000 * 100) / 100) + @@ -177,24 +177,24 @@ var formatArea = function(polygon) { function addInteraction() { var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString'); - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: type, - style: new ol.style.Style({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.2)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(0, 0, 0, 0.5)', lineDash: [10, 10], width: 2 }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(0, 0, 0, 0.7)' }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.2)' }) }) @@ -217,10 +217,10 @@ function addInteraction() { listener = sketch.getGeometry().on('change', function(evt) { var geom = evt.target; var output; - if (geom instanceof ol.geom.Polygon) { + if (geom instanceof _ol_geom_Polygon_) { output = formatArea(geom); tooltipCoord = geom.getInteriorPoint().getCoordinates(); - } else if (geom instanceof ol.geom.LineString) { + } else if (geom instanceof _ol_geom_LineString_) { output = formatLength(geom); tooltipCoord = geom.getLastCoordinate(); } @@ -238,7 +238,7 @@ function addInteraction() { // unset tooltip so that a new one can be created measureTooltipElement = null; createMeasureTooltip(); - ol.Observable.unByKey(listener); + _ol_Observable_.unByKey(listener); }, this); } @@ -252,7 +252,7 @@ function createHelpTooltip() { } helpTooltipElement = document.createElement('div'); helpTooltipElement.className = 'tooltip hidden'; - helpTooltip = new ol.Overlay({ + helpTooltip = new _ol_Overlay_({ element: helpTooltipElement, offset: [15, 0], positioning: 'center-left' @@ -270,7 +270,7 @@ function createMeasureTooltip() { } measureTooltipElement = document.createElement('div'); measureTooltipElement.className = 'tooltip tooltip-measure'; - measureTooltip = new ol.Overlay({ + measureTooltip = new _ol_Overlay_({ element: measureTooltipElement, offset: [0, -15], positioning: 'bottom-center' diff --git a/examples/min-max-resolution.js b/examples/min-max-resolution.js index d24e5ceabe..3a90a6fc43 100644 --- a/examples/min-max-resolution.js +++ b/examples/min-max-resolution.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; /** * Create the map. */ -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM(), + new _ol_layer_Tile_({ + source: new _ol_source_OSM_(), minResolution: 200, maxResolution: 2000 }), - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy.json?secure', crossOrigin: 'anonymous' }), @@ -26,12 +26,12 @@ var map = new ol.Map({ }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [653600, 5723680], zoom: 5 }) diff --git a/examples/min-zoom.js b/examples/min-zoom.js index af35ff4405..1db9857cd4 100644 --- a/examples/min-zoom.js +++ b/examples/min-zoom.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; var viewport = document.getElementById('map'); @@ -12,16 +12,16 @@ function getMinZoom() { var initialZoom = getMinZoom(); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], minZoom: initialZoom, zoom: initialZoom }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', diff --git a/examples/mobile-full-screen.js b/examples/mobile-full-screen.js index 2ec7e0455e..1726704860 100644 --- a/examples/mobile-full-screen.js +++ b/examples/mobile-full-screen.js @@ -1,19 +1,19 @@ -goog.require('ol.Geolocation'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 2 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Road' }) @@ -23,7 +23,7 @@ var map = new ol.Map({ view: view }); -var geolocation = new ol.Geolocation({ +var geolocation = new _ol_Geolocation_({ projection: view.getProjection(), tracking: true }); diff --git a/examples/modify-features.js b/examples/modify-features.js index 0fdeb33838..e8db4f57cd 100644 --- a/examples/modify-features.js +++ b/examples/modify-features.js @@ -1,40 +1,40 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON(), + format: new _ol_format_GeoJSON_(), wrapX: false }) }); -var select = new ol.interaction.Select({ +var select = new _ol_interaction_Select_({ wrapX: false }); -var modify = new ol.interaction.Modify({ +var modify = new _ol_interaction_Modify_({ features: select.getFeatures() }); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([select, modify]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([select, modify]), layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/modify-test.js b/examples/modify-test.js index daf61dd1e0..8553ac8fa9 100644 --- a/examples/modify-test.js +++ b/examples/modify-test.js @@ -1,55 +1,55 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var styleFunction = (function() { var styles = {}; - var image = new ol.style.Circle({ + var image = new _ol_style_Circle_({ radius: 5, fill: null, - stroke: new ol.style.Stroke({color: 'orange', width: 2}) + stroke: new _ol_style_Stroke_({color: 'orange', width: 2}) }); - styles['Point'] = new ol.style.Style({image: image}); - styles['Polygon'] = new ol.style.Style({ - stroke: new ol.style.Stroke({ + styles['Point'] = new _ol_style_Style_({image: image}); + styles['Polygon'] = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', width: 3 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 0, 255, 0.1)' }) }); - styles['MultiLineString'] = new ol.style.Style({ - stroke: new ol.style.Stroke({ + styles['MultiLineString'] = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'green', width: 3 }) }); - styles['MultiPolygon'] = new ol.style.Style({ - stroke: new ol.style.Stroke({ + styles['MultiPolygon'] = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'yellow', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 0, 0.1)' }) }); - styles['default'] = new ol.style.Style({ - stroke: new ol.style.Stroke({ + styles['default'] = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'red', width: 3 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 0, 0, 0.1)' }), image: image @@ -144,11 +144,11 @@ var geojsonObject = { }] }; -var source = new ol.source.Vector({ - features: (new ol.format.GeoJSON()).readFeatures(geojsonObject) +var source = new _ol_source_Vector_({ + features: (new _ol_format_GeoJSON_()).readFeatures(geojsonObject) }); -var layer = new ol.layer.Vector({ +var layer = new _ol_layer_Vector_({ source: source, style: styleFunction }); @@ -156,19 +156,19 @@ var layer = new ol.layer.Vector({ var overlayStyle = (function() { var styles = {}; styles['Polygon'] = [ - new ol.style.Style({ - fill: new ol.style.Fill({ + new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: [255, 255, 255, 0.5] }) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [255, 255, 255, 1], width: 5 }) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [0, 153, 255, 1], width: 3 }) @@ -177,14 +177,14 @@ var overlayStyle = (function() { styles['MultiPolygon'] = styles['Polygon']; styles['LineString'] = [ - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [255, 255, 255, 1], width: 5 }) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [0, 153, 255, 1], width: 3 }) @@ -193,13 +193,13 @@ var overlayStyle = (function() { styles['MultiLineString'] = styles['LineString']; styles['Point'] = [ - new ol.style.Style({ - image: new ol.style.Circle({ + new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 7, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: [0, 153, 255, 1] }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: [255, 255, 255, 0.75], width: 1.5 }) @@ -216,11 +216,11 @@ var overlayStyle = (function() { }; })(); -var select = new ol.interaction.Select({ +var select = new _ol_interaction_Select_({ style: overlayStyle }); -var modify = new ol.interaction.Modify({ +var modify = new _ol_interaction_Modify_({ features: select.getFeatures(), style: overlayStyle, insertVertexCondition: function() { @@ -231,11 +231,11 @@ var modify = new ol.interaction.Modify({ } }); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([select, modify]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([select, modify]), layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 1000000], zoom: 2 }) diff --git a/examples/mouse-position.js b/examples/mouse-position.js index c80afc5c76..03eee02f7a 100644 --- a/examples/mouse-position.js +++ b/examples/mouse-position.js @@ -1,13 +1,13 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.MousePosition'); -goog.require('ol.coordinate'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_MousePosition_ from '../src/ol/control/MousePosition.js'; +import _ol_coordinate_ from '../src/ol/coordinate.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var mousePositionControl = new ol.control.MousePosition({ - coordinateFormat: ol.coordinate.createStringXY(4), +var mousePositionControl = new _ol_control_MousePosition_({ + coordinateFormat: _ol_coordinate_.createStringXY(4), projection: 'EPSG:4326', // comment the following two lines to have the mouse position // be placed within the map. @@ -16,19 +16,19 @@ var mousePositionControl = new ol.control.MousePosition({ undefinedHTML: ' ' }); -var map = new ol.Map({ - controls: ol.control.defaults({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }).extend([mousePositionControl]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -41,6 +41,6 @@ projectionSelect.addEventListener('change', function(event) { var precisionInput = document.getElementById('precision'); precisionInput.addEventListener('change', function(event) { - var format = ol.coordinate.createStringXY(event.target.valueAsNumber); + var format = _ol_coordinate_.createStringXY(event.target.valueAsNumber); mousePositionControl.setCoordinateFormat(format); }); diff --git a/examples/mousewheel-zoom.js b/examples/mousewheel-zoom.js index 17f7c91af6..7788700e5a 100644 --- a/examples/mousewheel-zoom.js +++ b/examples/mousewheel-zoom.js @@ -1,24 +1,24 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction'); -goog.require('ol.interaction.MouseWheelZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_MouseWheelZoom_ from '../src/ol/interaction/MouseWheelZoom.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ - interactions: ol.interaction.defaults({mouseWheelZoom: false}).extend([ - new ol.interaction.MouseWheelZoom({ +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults({mouseWheelZoom: false}).extend([ + new _ol_interaction_MouseWheelZoom_({ constrainResolution: true // force zooming to a integer zoom }) ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/moveend.js b/examples/moveend.js index be2c34a319..df15fa1beb 100644 --- a/examples/moveend.js +++ b/examples/moveend.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -37,9 +37,9 @@ function wrapLon(value) { function onMoveEnd(evt) { var map = evt.map; var extent = map.getView().calculateExtent(map.getSize()); - var bottomLeft = ol.proj.transform(ol.extent.getBottomLeft(extent), + var bottomLeft = _ol_proj_.transform(_ol_extent_.getBottomLeft(extent), 'EPSG:3857', 'EPSG:4326'); - var topRight = ol.proj.transform(ol.extent.getTopRight(extent), + var topRight = _ol_proj_.transform(_ol_extent_.getTopRight(extent), 'EPSG:3857', 'EPSG:4326'); display('left', wrapLon(bottomLeft[0])); display('bottom', bottomLeft[1]); diff --git a/examples/navigation-controls.js b/examples/navigation-controls.js index ea1fd3af74..72c7f1b83b 100644 --- a/examples/navigation-controls.js +++ b/examples/navigation-controls.js @@ -1,18 +1,18 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.ZoomToExtent'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_ZoomToExtent_ from '../src/ol/control/ZoomToExtent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ - controls: ol.control.defaults({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }).extend([ - new ol.control.ZoomToExtent({ + new _ol_control_ZoomToExtent_({ extent: [ 813079.7791264898, 5929220.284081122, 848966.9639063801, 5936863.986909639 @@ -20,12 +20,12 @@ var map = new ol.Map({ }) ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/osm-vector-tiles.js b/examples/osm-vector-tiles.js index 846a06d219..10e9ee8b8a 100644 --- a/examples/osm-vector-tiles.js +++ b/examples/osm-vector-tiles.js @@ -1,12 +1,12 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.TopoJSON'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.proj'); -goog.require('ol.source.VectorTile'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var key = 'vector-tiles-5eJz6JX'; @@ -16,18 +16,18 @@ var roadColor = { 'minor_road': '#ccb', 'highway': '#f39' }; -var buildingStyle = new ol.style.Style({ - fill: new ol.style.Fill({ +var buildingStyle = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: '#666', opacity: 0.4 }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#444', width: 1 }) }); -var waterStyle = new ol.style.Style({ - fill: new ol.style.Fill({ +var waterStyle = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: '#9db9e8' }) }); @@ -46,8 +46,8 @@ var roadStyle = function(feature) { color = roadColor[kind]; width = kind == 'highway' ? 1.5 : 1; } - style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: color, width: width }), @@ -58,13 +58,13 @@ var roadStyle = function(feature) { return style; }; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.VectorTile({ - source: new ol.source.VectorTile({ + new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({ attributions: '© OpenStreetMap contributors, Who’s On First, ' + 'Natural Earth, and openstreetmapdata.com', - format: new ol.format.TopoJSON({ + format: new _ol_format_TopoJSON_({ layerName: 'layer', layers: ['water', 'roads', 'buildings'] }), @@ -82,8 +82,8 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-74.0064, 40.7142]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-74.0064, 40.7142]), maxZoom: 19, zoom: 15 }) diff --git a/examples/overlay.js b/examples/overlay.js index a6398f22cb..834b5717b7 100644 --- a/examples/overlay.js +++ b/examples/overlay.js @@ -1,29 +1,29 @@ -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.coordinate'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_coordinate_ from '../src/ol/coordinate.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var layer = new ol.layer.Tile({ - source: new ol.source.OSM() +var layer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); -var pos = ol.proj.fromLonLat([16.3725, 48.208889]); +var pos = _ol_proj_.fromLonLat([16.3725, 48.208889]); // Vienna marker -var marker = new ol.Overlay({ +var marker = new _ol_Overlay_({ position: pos, positioning: 'center-center', element: document.getElementById('marker'), @@ -32,14 +32,14 @@ var marker = new ol.Overlay({ map.addOverlay(marker); // Vienna label -var vienna = new ol.Overlay({ +var vienna = new _ol_Overlay_({ position: pos, element: document.getElementById('vienna') }); map.addOverlay(vienna); // Popup showing the position the user clicked -var popup = new ol.Overlay({ +var popup = new _ol_Overlay_({ element: document.getElementById('popup') }); map.addOverlay(popup); @@ -47,7 +47,7 @@ map.addOverlay(popup); map.on('click', function(evt) { var element = popup.getElement(); var coordinate = evt.coordinate; - var hdms = ol.coordinate.toStringHDMS(ol.proj.transform( + var hdms = _ol_coordinate_.toStringHDMS(_ol_proj_.transform( coordinate, 'EPSG:3857', 'EPSG:4326')); $(element).popover('destroy'); diff --git a/examples/overviewmap-custom.js b/examples/overviewmap-custom.js index 13b280cfc9..643e14ef9e 100644 --- a/examples/overviewmap-custom.js +++ b/examples/overviewmap-custom.js @@ -1,19 +1,19 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.OverviewMap'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DragRotateAndZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_OverviewMap_ from '../src/ol/control/OverviewMap.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_DragRotateAndZoom_ from '../src/ol/interaction/DragRotateAndZoom.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var overviewMapControl = new ol.control.OverviewMap({ +var overviewMapControl = new _ol_control_OverviewMap_({ // see in overviewmap-custom.html to see the custom CSS used className: 'ol-overviewmap ol-custom-overviewmap', layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM({ + new _ol_layer_Tile_({ + source: new _ol_source_OSM_({ 'url': 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' }) @@ -24,20 +24,20 @@ var overviewMapControl = new ol.control.OverviewMap({ collapsed: false }); -var map = new ol.Map({ - controls: ol.control.defaults().extend([ +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ overviewMapControl ]), - interactions: ol.interaction.defaults().extend([ - new ol.interaction.DragRotateAndZoom() + interactions: _ol_interaction_.defaults().extend([ + new _ol_interaction_DragRotateAndZoom_() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [500000, 6000000], zoom: 7 }) diff --git a/examples/overviewmap.js b/examples/overviewmap.js index 96f55ad75b..8a887ae5fc 100644 --- a/examples/overviewmap.js +++ b/examples/overviewmap.js @@ -1,21 +1,21 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.OverviewMap'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_OverviewMap_ from '../src/ol/control/OverviewMap.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ - controls: ol.control.defaults().extend([ - new ol.control.OverviewMap() +var map = new _ol_Map_({ + controls: _ol_control_.defaults().extend([ + new _ol_control_OverviewMap_() ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [500000, 6000000], zoom: 7 }) diff --git a/examples/permalink.js b/examples/permalink.js index 181ee061e5..7e0d5a82b1 100644 --- a/examples/permalink.js +++ b/examples/permalink.js @@ -1,8 +1,8 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; // default zoom, center and rotation var zoom = 2; @@ -23,19 +23,19 @@ if (window.location.hash !== '') { } } -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: center, zoom: zoom, rotation: rotation diff --git a/examples/pinch-zoom.js b/examples/pinch-zoom.js index 5e3227f167..83f512b732 100644 --- a/examples/pinch-zoom.js +++ b/examples/pinch-zoom.js @@ -1,24 +1,24 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction'); -goog.require('ol.interaction.PinchZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_PinchZoom_ from '../src/ol/interaction/PinchZoom.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ - interactions: ol.interaction.defaults({pinchZoom: false}).extend([ - new ol.interaction.PinchZoom({ +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults({pinchZoom: false}).extend([ + new _ol_interaction_PinchZoom_({ constrainResolution: true // force zooming to a integer zoom }) ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/polygon-styles.js b/examples/polygon-styles.js index c585e7710c..52ac3347fd 100644 --- a/examples/polygon-styles.js +++ b/examples/polygon-styles.js @@ -1,13 +1,13 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_geom_MultiPoint_ from '../src/ol/geom/MultiPoint.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var styles = [ /* We are using two different styles for the polygons: @@ -17,26 +17,26 @@ var styles = [ * returned as `MultiPoint` geometry, which will be used to render * the style. */ - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', width: 3 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 0, 255, 0.1)' }) }), - new ol.style.Style({ - image: new ol.style.Circle({ + new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'orange' }) }), geometry: function(feature) { // return the coordinates of the first ring of the polygon var coordinates = feature.getGeometry().getCoordinates()[0]; - return new ol.geom.MultiPoint(coordinates); + return new _ol_geom_MultiPoint_(coordinates); } }) ]; @@ -80,19 +80,19 @@ var geojsonObject = { }] }; -var source = new ol.source.Vector({ - features: (new ol.format.GeoJSON()).readFeatures(geojsonObject) +var source = new _ol_source_Vector_({ + features: (new _ol_format_GeoJSON_()).readFeatures(geojsonObject) }); -var layer = new ol.layer.Vector({ +var layer = new _ol_layer_Vector_({ source: source, style: styles }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 3000000], zoom: 2 }) diff --git a/examples/popup.js b/examples/popup.js index 26d5196bae..893f5fda10 100644 --- a/examples/popup.js +++ b/examples/popup.js @@ -1,10 +1,10 @@ -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.coordinate'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_coordinate_ from '../src/ol/coordinate.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; /** @@ -18,7 +18,7 @@ var closer = document.getElementById('popup-closer'); /** * Create an overlay to anchor the popup to the map. */ -var overlay = new ol.Overlay({ +var overlay = new _ol_Overlay_({ element: container, autoPan: true, autoPanAnimation: { @@ -41,10 +41,10 @@ closer.onclick = function() { /** * Create the map. */ -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy.json?secure', crossOrigin: 'anonymous' }) @@ -52,7 +52,7 @@ var map = new ol.Map({ ], overlays: [overlay], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -64,7 +64,7 @@ var map = new ol.Map({ */ map.on('singleclick', function(evt) { var coordinate = evt.coordinate; - var hdms = ol.coordinate.toStringHDMS(ol.proj.transform( + var hdms = _ol_coordinate_.toStringHDMS(_ol_proj_.transform( coordinate, 'EPSG:3857', 'EPSG:4326')); content.innerHTML = '

You clicked here:

' + hdms + diff --git a/examples/preload.js b/examples/preload.js index f646491c45..8ae65a9643 100644 --- a/examples/preload.js +++ b/examples/preload.js @@ -1,19 +1,19 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; -var view = new ol.View({ +var view = new _ol_View_({ center: [-4808600, -2620936], zoom: 8 }); -var map1 = new ol.Map({ +var map1 = new _ol_Map_({ layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ preload: Infinity, - source: new ol.source.BingMaps({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) @@ -23,11 +23,11 @@ var map1 = new ol.Map({ view: view }); -var map2 = new ol.Map({ +var map2 = new _ol_Map_({ layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ preload: 0, // default value - source: new ol.source.BingMaps({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'AerialWithLabels' }) diff --git a/examples/raster.js b/examples/raster.js index 821ea049c1..11f1bb6875 100644 --- a/examples/raster.js +++ b/examples/raster.js @@ -1,11 +1,11 @@ // NOCOMPILE // this example uses d3 for which we don't have an externs file. -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Raster'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Raster_ from '../src/ol/source/Raster.js'; var minVgi = 0; var maxVgi = 0.25; @@ -49,7 +49,7 @@ function summarize(value, counts) { /** * Use aerial imagery as the input data for the raster source. */ -var bing = new ol.source.BingMaps({ +var bing = new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }); @@ -59,7 +59,7 @@ var bing = new ol.source.BingMaps({ * Create a raster source where pixels with VGI values above a threshold will * be colored green. */ -var raster = new ol.source.Raster({ +var raster = new _ol_source_Raster_({ sources: [bing], /** * Run calculations on pixel data. @@ -110,17 +110,17 @@ raster.on('afteroperations', function(event) { schedulePlot(event.resolution, event.data.counts, event.data.threshold); }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ source: bing }), - new ol.layer.Image({ + new _ol_layer_Image_({ source: raster }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-9651695, 4937351], zoom: 13, minZoom: 12, diff --git a/examples/region-growing.js b/examples/region-growing.js index b4ffc3a7e4..522a81bd17 100644 --- a/examples/region-growing.js +++ b/examples/region-growing.js @@ -1,11 +1,11 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Raster'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Raster_ from '../src/ol/source/Raster.js'; function growRegion(inputs, data) { var image = inputs[0]; @@ -74,11 +74,11 @@ function next4Edges(edge) { var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; -var imagery = new ol.layer.Tile({ - source: new ol.source.BingMaps({key: key, imagerySet: 'Aerial'}) +var imagery = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({key: key, imagerySet: 'Aerial'}) }); -var raster = new ol.source.Raster({ +var raster = new _ol_source_Raster_({ sources: [imagery.getSource()], operationType: 'image', operation: growRegion, @@ -89,16 +89,16 @@ var raster = new ol.source.Raster({ } }); -var rasterImage = new ol.layer.Image({ +var rasterImage = new _ol_layer_Image_({ opacity: 0.7, source: raster }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [imagery, rasterImage], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-119.07, 47.65]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-119.07, 47.65]), zoom: 11 }) }); diff --git a/examples/regularshape.js b/examples/regularshape.js index 7d269bd1a0..7d40f8d7c7 100644 --- a/examples/regularshape.js +++ b/examples/regularshape.js @@ -1,21 +1,21 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var stroke = new ol.style.Stroke({color: 'black', width: 2}); -var fill = new ol.style.Fill({color: 'red'}); +var stroke = new _ol_style_Stroke_({color: 'black', width: 2}); +var fill = new _ol_style_Fill_({color: 'red'}); var styles = { - 'square': new ol.style.Style({ - image: new ol.style.RegularShape({ + 'square': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 4, @@ -23,8 +23,8 @@ var styles = { angle: Math.PI / 4 }) }), - 'triangle': new ol.style.Style({ - image: new ol.style.RegularShape({ + 'triangle': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 3, @@ -33,8 +33,8 @@ var styles = { angle: 0 }) }), - 'star': new ol.style.Style({ - image: new ol.style.RegularShape({ + 'star': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 5, @@ -43,8 +43,8 @@ var styles = { angle: 0 }) }), - 'cross': new ol.style.Style({ - image: new ol.style.RegularShape({ + 'cross': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 4, @@ -53,8 +53,8 @@ var styles = { angle: 0 }) }), - 'x': new ol.style.Style({ - image: new ol.style.RegularShape({ + 'x': new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 4, @@ -72,24 +72,24 @@ var features = new Array(count); var e = 4500000; for (var i = 0; i < count; ++i) { var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e]; - features[i] = new ol.Feature(new ol.geom.Point(coordinates)); + features[i] = new _ol_Feature_(new _ol_geom_Point_(coordinates)); features[i].setStyle(styles[styleKeys[Math.floor(Math.random() * 5)]]); } -var source = new ol.source.Vector({ +var source = new _ol_source_Vector_({ features: features }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: source }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ vectorLayer ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/render-geometry.js b/examples/render-geometry.js index c3c5087659..b290e87290 100644 --- a/examples/render-geometry.js +++ b/examples/render-geometry.js @@ -1,22 +1,22 @@ -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_render_ from '../src/ol/render.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var canvas = document.getElementById('canvas'); -var vectorContext = ol.render.toContext(canvas.getContext('2d'), {size: [100, 100]}); +var vectorContext = _ol_render_.toContext(canvas.getContext('2d'), {size: [100, 100]}); -var fill = new ol.style.Fill({color: 'blue'}); -var stroke = new ol.style.Stroke({color: 'black'}); -var style = new ol.style.Style({ +var fill = new _ol_style_Fill_({color: 'blue'}); +var stroke = new _ol_style_Stroke_({color: 'black'}); +var style = new _ol_style_Style_({ fill: fill, stroke: stroke, - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 10, fill: fill, stroke: stroke @@ -24,6 +24,6 @@ var style = new ol.style.Style({ }); vectorContext.setStyle(style); -vectorContext.drawGeometry(new ol.geom.LineString([[10, 10], [90, 90]])); -vectorContext.drawGeometry(new ol.geom.Polygon([[[2, 2], [98, 2], [2, 98], [2, 2]]])); -vectorContext.drawGeometry(new ol.geom.Point([88, 88])); +vectorContext.drawGeometry(new _ol_geom_LineString_([[10, 10], [90, 90]])); +vectorContext.drawGeometry(new _ol_geom_Polygon_([[[2, 2], [98, 2], [2, 98], [2, 2]]])); +vectorContext.drawGeometry(new _ol_geom_Point_([88, 88])); diff --git a/examples/reprojection-by-code.js b/examples/reprojection-by-code.js index 77ee3c208a..f8fe3af6c2 100644 --- a/examples/reprojection-by-code.js +++ b/examples/reprojection-by-code.js @@ -1,20 +1,20 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileImage'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:3857', center: [0, 0], zoom: 1 @@ -30,7 +30,7 @@ var renderEdgesCheckbox = document.getElementById('render-edges'); function setProjection(code, name, proj4def, bbox) { if (code === null || name === null || proj4def === null || bbox === null) { resultSpan.innerHTML = 'Nothing usable found, using EPSG:3857...'; - map.setView(new ol.View({ + map.setView(new _ol_View_({ projection: 'EPSG:3857', center: [0, 0], zoom: 1 @@ -42,14 +42,14 @@ function setProjection(code, name, proj4def, bbox) { var newProjCode = 'EPSG:' + code; proj4.defs(newProjCode, proj4def); - var newProj = ol.proj.get(newProjCode); - var fromLonLat = ol.proj.getTransform('EPSG:4326', newProj); + var newProj = _ol_proj_.get(newProjCode); + var fromLonLat = _ol_proj_.getTransform('EPSG:4326', newProj); // very approximate calculation of projection extent - var extent = ol.extent.applyTransform( + var extent = _ol_extent_.applyTransform( [bbox[1], bbox[2], bbox[3], bbox[0]], fromLonLat); newProj.setExtent(extent); - var newView = new ol.View({ + var newView = new _ol_View_({ projection: newProj }); map.setView(newView); @@ -97,9 +97,9 @@ searchButton.onclick = function(event) { */ renderEdgesCheckbox.onchange = function() { map.getLayers().forEach(function(layer) { - if (layer instanceof ol.layer.Tile) { + if (layer instanceof _ol_layer_Tile_) { var source = layer.getSource(); - if (source instanceof ol.source.TileImage) { + if (source instanceof _ol_source_TileImage_) { source.setRenderReprojectionEdges(renderEdgesCheckbox.checked); } } diff --git a/examples/reprojection-image.js b/examples/reprojection-image.js index ee223d4c2a..869bc81eb6 100644 --- a/examples/reprojection-image.js +++ b/examples/reprojection-image.js @@ -1,11 +1,11 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.ImageStatic'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' + @@ -14,13 +14,13 @@ proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' + '+units=m +no_defs'); var imageExtent = [0, 0, 700000, 1300000]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Image({ - source: new ol.source.ImageStatic({ + new _ol_layer_Image_({ + source: new _ol_source_ImageStatic_({ url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/' + 'British_National_Grid.svg/2000px-British_National_Grid.svg.png', crossOrigin: '', @@ -30,9 +30,9 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ - center: ol.proj.transform( - ol.extent.getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'), + view: new _ol_View_({ + center: _ol_proj_.transform( + _ol_extent_.getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'), zoom: 4 }) }); diff --git a/examples/reprojection-wgs84.js b/examples/reprojection-wgs84.js index 4d350119fd..f99eafdc96 100644 --- a/examples/reprojection-wgs84.js +++ b/examples/reprojection-wgs84.js @@ -1,16 +1,16 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], zoom: 2 diff --git a/examples/reprojection.js b/examples/reprojection.js index 92a5029ae2..8c626865e0 100644 --- a/examples/reprojection.js +++ b/examples/reprojection.js @@ -1,61 +1,61 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.WMTSCapabilities'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileImage'); -goog.require('ol.source.TileWMS'); -goog.require('ol.source.WMTS'); -goog.require('ol.source.XYZ'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; +import _ol_tilegrid_TileGrid_ from '../src/ol/tilegrid/TileGrid.js'; proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' + '+x_0=400000 +y_0=-100000 +ellps=airy ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+units=m +no_defs'); -var proj27700 = ol.proj.get('EPSG:27700'); +var proj27700 = _ol_proj_.get('EPSG:27700'); proj27700.setExtent([0, 0, 700000, 1300000]); proj4.defs('EPSG:23032', '+proj=utm +zone=32 +ellps=intl ' + '+towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs'); -var proj23032 = ol.proj.get('EPSG:23032'); +var proj23032 = _ol_proj_.get('EPSG:23032'); proj23032.setExtent([-1206118.71, 4021309.92, 1295389.00, 8051813.28]); proj4.defs('EPSG:5479', '+proj=lcc +lat_1=-76.66666666666667 +lat_2=' + '-79.33333333333333 +lat_0=-78 +lon_0=163 +x_0=7000000 +y_0=5000000 ' + '+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); -var proj5479 = ol.proj.get('EPSG:5479'); +var proj5479 = _ol_proj_.get('EPSG:5479'); proj5479.setExtent([6825737.53, 4189159.80, 9633741.96, 5782472.71]); proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' + '+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs'); -var proj21781 = ol.proj.get('EPSG:21781'); +var proj21781 = _ol_proj_.get('EPSG:21781'); proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]); proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 ' + '+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); -var proj3413 = ol.proj.get('EPSG:3413'); +var proj3413 = _ol_proj_.get('EPSG:3413'); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); proj4.defs('EPSG:2163', '+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 ' + '+a=6370997 +b=6370997 +units=m +no_defs'); -var proj2163 = ol.proj.get('EPSG:2163'); +var proj2163 = _ol_proj_.get('EPSG:2163'); proj2163.setExtent([-8040784.5135, -2577524.9210, 3668901.4484, 4785105.1096]); proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' + '+units=m +no_defs'); -var proj54009 = ol.proj.get('ESRI:54009'); +var proj54009 = _ol_proj_.get('ESRI:54009'); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); var layers = {}; -layers['bng'] = new ol.layer.Tile({ - source: new ol.source.XYZ({ +layers['bng'] = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ projection: 'EPSG:27700', url: 'https://tileserver.maptiler.com/miniscale/{z}/{x}/{y}.png', crossOrigin: '', @@ -63,12 +63,12 @@ layers['bng'] = new ol.layer.Tile({ }) }); -layers['osm'] = new ol.layer.Tile({ - source: new ol.source.OSM() +layers['osm'] = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -layers['wms4326'] = new ol.layer.Tile({ - source: new ol.source.TileWMS({ +layers['wms4326'] = new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', crossOrigin: '', params: { @@ -79,8 +79,8 @@ layers['wms4326'] = new ol.layer.Tile({ }) }); -layers['wms21781'] = new ol.layer.Tile({ - source: new ol.source.TileWMS({ +layers['wms21781'] = new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ attributions: '© Pixelmap 1:1000000 / geo.admin.ch', crossOrigin: 'anonymous', @@ -93,27 +93,27 @@ layers['wms21781'] = new ol.layer.Tile({ }) }); -var parser = new ol.format.WMTSCapabilities(); +var parser = new _ol_format_WMTSCapabilities_(); var url = 'https://map1.vis.earthdata.nasa.gov/wmts-arctic/' + 'wmts.cgi?SERVICE=WMTS&request=GetCapabilities'; fetch(url).then(function(response) { return response.text(); }).then(function(text) { var result = parser.read(text); - var options = ol.source.WMTS.optionsFromCapabilities(result, { + var options = _ol_source_WMTS_.optionsFromCapabilities(result, { layer: 'OSM_Land_Mask', matrixSet: 'EPSG3413_250m' }); options.crossOrigin = ''; options.projection = 'EPSG:3413'; options.wrapX = false; - layers['wmts3413'] = new ol.layer.Tile({ - source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + layers['wmts3413'] = new _ol_layer_Tile_({ + source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) }); }); -layers['grandcanyon'] = new ol.layer.Tile({ - source: new ol.source.XYZ({ +layers['grandcanyon'] = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ url: 'https://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png', crossOrigin: '', tilePixelRatio: 2, @@ -124,19 +124,19 @@ layers['grandcanyon'] = new ol.layer.Tile({ }); var startResolution = - ol.extent.getWidth(ol.proj.get('EPSG:3857').getExtent()) / 256; + _ol_extent_.getWidth(_ol_proj_.get('EPSG:3857').getExtent()) / 256; var resolutions = new Array(22); for (var i = 0, ii = resolutions.length; i < ii; ++i) { resolutions[i] = startResolution / Math.pow(2, i); } -layers['states'] = new ol.layer.Tile({ - source: new ol.source.TileWMS({ +layers['states'] = new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', crossOrigin: '', params: {'LAYERS': 'topp:states'}, serverType: 'geoserver', - tileGrid: new ol.tilegrid.TileGrid({ + tileGrid: new _ol_tilegrid_TileGrid_({ extent: [-13884991, 2870341, -7455066, 6338219], resolutions: resolutions, tileSize: [512, 256] @@ -146,13 +146,13 @@ layers['states'] = new ol.layer.Tile({ }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ layers['osm'], layers['bng'] ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:3857', center: [0, 0], zoom: 2 @@ -167,18 +167,18 @@ var renderEdgesCheckbox = document.getElementById('render-edges'); var renderEdges = false; function updateViewProjection() { - var newProj = ol.proj.get(viewProjSelect.value); + var newProj = _ol_proj_.get(viewProjSelect.value); var newProjExtent = newProj.getExtent(); - var newView = new ol.View({ + var newView = new _ol_View_({ projection: newProj, - center: ol.extent.getCenter(newProjExtent || [0, 0, 0, 0]), + center: _ol_extent_.getCenter(newProjExtent || [0, 0, 0, 0]), zoom: 0, extent: newProjExtent || undefined }); map.setView(newView); // Example how to prevent double occurrence of map by limiting layer extent - if (newProj == ol.proj.get('EPSG:3857')) { + if (newProj == _ol_proj_.get('EPSG:3857')) { layers['bng'].setExtent([-1057216, 6405988, 404315, 8759696]); } else { layers['bng'].setExtent(undefined); @@ -196,9 +196,9 @@ viewProjSelect.onchange = function() { updateViewProjection(); var updateRenderEdgesOnLayer = function(layer) { - if (layer instanceof ol.layer.Tile) { + if (layer instanceof _ol_layer_Tile_) { var source = layer.getSource(); - if (source instanceof ol.source.TileImage) { + if (source instanceof _ol_source_TileImage_) { source.setRenderReprojectionEdges(renderEdges); } } diff --git a/examples/resources/mapbox-streets-v6-style.js b/examples/resources/mapbox-streets-v6-style.js index c19a63be25..83e63e8694 100644 --- a/examples/resources/mapbox-streets-v6-style.js +++ b/examples/resources/mapbox-streets-v6-style.js @@ -1,6 +1,9 @@ // Styles for the mapbox-streets-v6 vector tile data set. Loosely based on // http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6.json +// Styles for the mapbox-streets-v6 vector tile data set. Loosely based on +// http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6.json + function createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text) { var fill = new Fill({color: ''}); var stroke = new Stroke({color: '', width: 1}); diff --git a/examples/resources/prism/prism.min.js b/examples/resources/prism/prism.min.js index 21ea6df0f1..57504d4a86 100644 --- a/examples/resources/prism/prism.min.js +++ b/examples/resources/prism/prism.min.js @@ -1,4 +1,5 @@ /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */ +/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */ self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);; Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/=|>|"/}},punctuation:/\/?>/,"attr-name":{pattern:/[\w:-]+/,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});; Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{punctuation:/[;:]/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,punctuation:/[\{\};:]/,"function":/[-a-z0-9]+(?=\()/i},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));; diff --git a/examples/resources/zeroclipboard/ZeroClipboard.Core.js b/examples/resources/zeroclipboard/ZeroClipboard.Core.js index b58b14675b..90f998656d 100644 --- a/examples/resources/zeroclipboard/ZeroClipboard.Core.js +++ b/examples/resources/zeroclipboard/ZeroClipboard.Core.js @@ -1,3 +1,11 @@ +/*! + * ZeroClipboard + * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. + * Copyright (c) 2009-2014 Jon Rohan, James M. Greene + * Licensed MIT + * http://zeroclipboard.org/ + * v2.2.0 + */ /*! * ZeroClipboard * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. diff --git a/examples/resources/zeroclipboard/ZeroClipboard.Core.min.js b/examples/resources/zeroclipboard/ZeroClipboard.Core.min.js index 01efd47115..8174dcdec3 100644 --- a/examples/resources/zeroclipboard/ZeroClipboard.Core.min.js +++ b/examples/resources/zeroclipboard/ZeroClipboard.Core.min.js @@ -1,3 +1,12 @@ +/*! + * ZeroClipboard + * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. + * Copyright (c) 2009-2014 Jon Rohan, James M. Greene + * Licensed MIT + * http://zeroclipboard.org/ + * v2.2.0 + */ +//# sourceMappingURL=ZeroClipboard.Core.min.map /*! * ZeroClipboard * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. diff --git a/examples/resources/zeroclipboard/ZeroClipboard.js b/examples/resources/zeroclipboard/ZeroClipboard.js index 6e20b5910f..c310abf944 100644 --- a/examples/resources/zeroclipboard/ZeroClipboard.js +++ b/examples/resources/zeroclipboard/ZeroClipboard.js @@ -1,3 +1,11 @@ +/*! + * ZeroClipboard + * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. + * Copyright (c) 2009-2014 Jon Rohan, James M. Greene + * Licensed MIT + * http://zeroclipboard.org/ + * v2.2.0 + */ /*! * ZeroClipboard * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. diff --git a/examples/resources/zeroclipboard/ZeroClipboard.min.js b/examples/resources/zeroclipboard/ZeroClipboard.min.js index 6ecd08854a..961d57a248 100644 --- a/examples/resources/zeroclipboard/ZeroClipboard.min.js +++ b/examples/resources/zeroclipboard/ZeroClipboard.min.js @@ -1,3 +1,12 @@ +/*! + * ZeroClipboard + * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. + * Copyright (c) 2009-2014 Jon Rohan, James M. Greene + * Licensed MIT + * http://zeroclipboard.org/ + * v2.2.0 + */ +//# sourceMappingURL=ZeroClipboard.min.map /*! * ZeroClipboard * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. diff --git a/examples/reusable-source.js b/examples/reusable-source.js index b9c4ac3ca3..de03599762 100644 --- a/examples/reusable-source.js +++ b/examples/reusable-source.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; var urls = [ 'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-jan/{z}/{x}/{y}.png', @@ -10,16 +10,16 @@ var urls = [ 'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png' ]; -var source = new ol.source.XYZ(); +var source = new _ol_source_XYZ_(); -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ source: source }) ], - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/rotation.js b/examples/rotation.js index afaacb521b..eee8790545 100644 --- a/examples/rotation.js +++ b/examples/rotation.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [14200000, 4130000], rotation: Math.PI / 6, zoom: 10 diff --git a/examples/scale-line.js b/examples/scale-line.js index c8dbf41e7f..e68c2ffa18 100644 --- a/examples/scale-line.js +++ b/examples/scale-line.js @@ -1,15 +1,15 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.ScaleLine'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var scaleLineControl = new ol.control.ScaleLine(); +var scaleLineControl = new _ol_control_ScaleLine_(); -var map = new ol.Map({ - controls: ol.control.defaults({ +var map = new _ol_Map_({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } @@ -17,12 +17,12 @@ var map = new ol.Map({ scaleLineControl ]), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/scaleline-indiana-east.js b/examples/scaleline-indiana-east.js index eb5449e390..249347e144 100644 --- a/examples/scaleline-indiana-east.js +++ b/examples/scaleline-indiana-east.js @@ -1,9 +1,9 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control.ScaleLine'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' + 'SPHEROID["GRS1980",6378137.000,298.25722210]],PRIMEM["Greenwich",0],' + @@ -15,21 +15,21 @@ proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' + 'PARAMETER["latitude_of_origin",37.50000000000000],' + 'UNIT["Foot_US",0.30480060960122]]'); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: 'Indiana-East', - center: ol.proj.fromLonLat([-85.685, 39.891], 'Indiana-East'), + center: _ol_proj_.fromLonLat([-85.685, 39.891], 'Indiana-East'), zoom: 7, - extent: ol.proj.transformExtent([-172.54, 23.81, -47.74, 86.46], + extent: _ol_proj_.transformExtent([-172.54, 23.81, -47.74, 86.46], 'EPSG:4326', 'Indiana-East'), minZoom: 6 }) }); -map.addControl(new ol.control.ScaleLine({units: 'us'})); +map.addControl(new _ol_control_ScaleLine_({units: 'us'})); diff --git a/examples/sea-level.js b/examples/sea-level.js index 269627e82d..ea6a4b8dcb 100644 --- a/examples/sea-level.js +++ b/examples/sea-level.js @@ -1,11 +1,11 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.Raster'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Raster_ from '../src/ol/source/Raster.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; function flood(pixels, data) { var pixel = pixels[0]; @@ -24,32 +24,32 @@ function flood(pixels, data) { } var key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg'; -var elevation = new ol.source.XYZ({ +var elevation = new _ol_source_XYZ_({ url: 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=' + key, crossOrigin: 'anonymous', transition: 0 }); -var raster = new ol.source.Raster({ +var raster = new _ol_source_Raster_({ sources: [elevation], operation: flood }); -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ url: 'https://api.mapbox.com/styles/v1/tschaub/ciutc102t00c62js5fqd47kqw/tiles/256/{z}/{x}/{y}?access_token=' + key }) }), - new ol.layer.Image({ + new _ol_layer_Image_({ opacity: 0.6, source: raster }) ], - view: new ol.View({ - center: ol.proj.fromLonLat([-122.3267, 37.8377]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-122.3267, 37.8377]), zoom: 11 }) }); @@ -74,6 +74,6 @@ for (var i = 0, ii = locations.length; i < ii; ++i) { function relocate(event) { var data = event.target.dataset; var view = map.getView(); - view.setCenter(ol.proj.fromLonLat(data.center.split(',').map(Number))); + view.setCenter(_ol_proj_.fromLonLat(data.center.split(',').map(Number))); view.setZoom(Number(data.zoom)); } diff --git a/examples/select-features.js b/examples/select-features.js index 8d68284e2c..c2a8a4a934 100644 --- a/examples/select-features.js +++ b/examples/select-features.js @@ -1,28 +1,28 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.events.condition'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_events_condition_ from '../src/ol/events/condition.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -31,22 +31,22 @@ var map = new ol.Map({ var select = null; // ref to currently selected interaction // select interaction working on "singleclick" -var selectSingleClick = new ol.interaction.Select(); +var selectSingleClick = new _ol_interaction_Select_(); // select interaction working on "click" -var selectClick = new ol.interaction.Select({ - condition: ol.events.condition.click +var selectClick = new _ol_interaction_Select_({ + condition: _ol_events_condition_.click }); // select interaction working on "pointermove" -var selectPointerMove = new ol.interaction.Select({ - condition: ol.events.condition.pointerMove +var selectPointerMove = new _ol_interaction_Select_({ + condition: _ol_events_condition_.pointerMove }); -var selectAltClick = new ol.interaction.Select({ +var selectAltClick = new _ol_interaction_Select_({ condition: function(mapBrowserEvent) { - return ol.events.condition.click(mapBrowserEvent) && - ol.events.condition.altKeyOnly(mapBrowserEvent); + return _ol_events_condition_.click(mapBrowserEvent) && + _ol_events_condition_.altKeyOnly(mapBrowserEvent); } }); diff --git a/examples/semi-transparent-layer.js b/examples/semi-transparent-layer.js index e8834bfc38..3ff8a0bfeb 100644 --- a/examples/semi-transparent-layer.js +++ b/examples/semi-transparent-layer.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.json?secure', crossOrigin: 'anonymous' }) }) ], target: 'map', - view: new ol.View({ - center: ol.proj.fromLonLat([-77.93255, 37.9555]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-77.93255, 37.9555]), zoom: 7 }) }); diff --git a/examples/shaded-relief.js b/examples/shaded-relief.js index 9d190c449a..b98d9ca3f7 100644 --- a/examples/shaded-relief.js +++ b/examples/shaded-relief.js @@ -1,11 +1,11 @@ // NOCOMPILE -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Raster'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Raster_ from '../src/ol/source/Raster.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; /** @@ -102,30 +102,30 @@ function shade(inputs, data) { return {data: shadeData, width: width, height: height}; } -var elevation = new ol.source.XYZ({ +var elevation = new _ol_source_XYZ_({ url: 'https://{a-d}.tiles.mapbox.com/v3/aj.sf-dem/{z}/{x}/{y}.png', crossOrigin: 'anonymous', transition: 0 }); -var raster = new ol.source.Raster({ +var raster = new _ol_source_Raster_({ sources: [elevation], operationType: 'image', operation: shade }); -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Image({ + new _ol_layer_Image_({ opacity: 0.3, source: raster }) ], - view: new ol.View({ + view: new _ol_View_({ extent: [-13675026, 4439648, -13580856, 4580292], center: [-13615645, 4497969], minZoom: 10, diff --git a/examples/side-by-side.js b/examples/side-by-side.js index 4567fdfb25..8ee526103a 100644 --- a/examples/side-by-side.js +++ b/examples/side-by-side.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.has'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_has_ from '../src/ol/has.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var layer = new ol.layer.Tile({ - source: new ol.source.OSM() +var layer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 1 }); -var map1 = new ol.Map({ +var map1 = new _ol_Map_({ target: 'canvasMap', layers: [layer], view: view }); -if (ol.has.WEBGL) { - var map2 = new ol.Map({ +if (_ol_has_.WEBGL) { + var map2 = new _ol_Map_({ target: 'webglMap', renderer: /** @type {Array} */ (['webgl', 'canvas']), layers: [layer], diff --git a/examples/simple.js b/examples/simple.js index 6d452df233..45fe7ecfa1 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -1,17 +1,17 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/snap.js b/examples/snap.js index 0ac9206b5c..f942462291 100644 --- a/examples/snap.js +++ b/examples/snap.js @@ -1,45 +1,45 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.interaction.Draw'); -goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.Select'); -goog.require('ol.interaction.Snap'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector(), - style: new ol.style.Style({ - fill: new ol.style.Fill({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_(), + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.2)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#ffcc33', width: 2 }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 7, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#ffcc33' }) }) }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 4 }) @@ -47,10 +47,10 @@ var map = new ol.Map({ var Modify = { init: function() { - this.select = new ol.interaction.Select(); + this.select = new _ol_interaction_Select_(); map.addInteraction(this.select); - this.modify = new ol.interaction.Modify({ + this.modify = new _ol_interaction_Modify_({ features: this.select.getFeatures() }); map.addInteraction(this.modify); @@ -84,19 +84,19 @@ var Draw = { map.addInteraction(this.Circle); this.Circle.setActive(false); }, - Point: new ol.interaction.Draw({ + Point: new _ol_interaction_Draw_({ source: vector.getSource(), type: 'Point' }), - LineString: new ol.interaction.Draw({ + LineString: new _ol_interaction_Draw_({ source: vector.getSource(), type: 'LineString' }), - Polygon: new ol.interaction.Draw({ + Polygon: new _ol_interaction_Draw_({ source: vector.getSource(), type: 'Polygon' }), - Circle: new ol.interaction.Draw({ + Circle: new _ol_interaction_Draw_({ source: vector.getSource(), type: 'Circle' }), @@ -144,7 +144,7 @@ Modify.setActive(false); // The snap interaction must be added after the Modify and Draw interactions // in order for its map browser event handlers to be fired first. Its handlers // are responsible of doing the snapping. -var snap = new ol.interaction.Snap({ +var snap = new _ol_interaction_Snap_({ source: vector.getSource() }); map.addInteraction(snap); diff --git a/examples/sphere-mollweide.js b/examples/sphere-mollweide.js index 42192f6172..80dfc77e50 100644 --- a/examples/sphere-mollweide.js +++ b/examples/sphere-mollweide.js @@ -1,10 +1,10 @@ -goog.require('ol.Graticule'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.Vector'); +import _ol_Graticule_ from '../src/ol/Graticule.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' + @@ -12,25 +12,25 @@ proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' + // Configure the Sphere Mollweide projection object with an extent, // and a world extent. These are required for the Graticule. -var sphereMollweideProjection = new ol.proj.Projection({ +var sphereMollweideProjection = new _ol_proj_Projection_({ code: 'ESRI:53009', extent: [-9009954.605703328, -9009954.605703328, 9009954.605703328, 9009954.605703328], worldExtent: [-179, -89.99, 179, 89.99] }); -var map = new ol.Map({ +var map = new _ol_Map_({ keyboardEventTarget: document, layers: [ - new ol.layer.Vector({ - source: new ol.source.Vector({ + new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries-110m.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], projection: sphereMollweideProjection, resolutions: [65536, 32768, 16384, 8192, 4096, 2048], @@ -38,6 +38,6 @@ var map = new ol.Map({ }) }); -new ol.Graticule({ +new _ol_Graticule_({ map: map }); diff --git a/examples/stamen.js b/examples/stamen.js index 0485540933..22974626bc 100644 --- a/examples/stamen.js +++ b/examples/stamen.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.Stamen'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.Stamen({ + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'watercolor' }) }), - new ol.layer.Tile({ - source: new ol.source.Stamen({ + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'terrain-labels' }) }) ], target: 'map', - view: new ol.View({ - center: ol.proj.transform( + view: new _ol_View_({ + center: _ol_proj_.transform( [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) diff --git a/examples/static-image.js b/examples/static-image.js index 9a34294e77..cb75f733e1 100644 --- a/examples/static-image.js +++ b/examples/static-image.js @@ -1,25 +1,25 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Image'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.ImageStatic'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Image_ from '../src/ol/layer/Image.js'; +import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; +import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js'; // Map views always need a projection. Here we just want to map image // coordinates directly to map coordinates, so we create a projection that uses // the image extent in pixels. var extent = [0, 0, 1024, 968]; -var projection = new ol.proj.Projection({ +var projection = new _ol_proj_Projection_({ code: 'xkcd-image', units: 'pixels', extent: extent }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Image({ - source: new ol.source.ImageStatic({ + new _ol_layer_Image_({ + source: new _ol_source_ImageStatic_({ attributions: '© xkcd', url: 'https://imgs.xkcd.com/comics/online_communities.png', projection: projection, @@ -28,9 +28,9 @@ var map = new ol.Map({ }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: projection, - center: ol.extent.getCenter(extent), + center: _ol_extent_.getCenter(extent), zoom: 2, maxZoom: 8 }) diff --git a/examples/street-labels.js b/examples/street-labels.js index 83cdfd25c1..4f5e844bd9 100644 --- a/examples/street-labels.js +++ b/examples/street-labels.js @@ -1,36 +1,36 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; -var style = new ol.style.Style({ - text: new ol.style.Text({ +var style = new _ol_style_Style_({ + text: new _ol_style_Text_({ font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"', placement: 'line', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'white' }) }) }); var viewExtent = [1817379, 6139595, 1827851, 6143616]; -var map = new ol.Map({ - layers: [new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var map = new _ol_Map_({ + layers: [new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) - }), new ol.layer.Vector({ + }), new _ol_layer_Vector_({ declutter: true, - source: new ol.source.Vector({ - format: new ol.format.GeoJSON(), + source: new _ol_source_Vector_({ + format: new _ol_format_GeoJSON_(), url: 'data/geojson/vienna-streets.geojson' }), style: function(feature) { @@ -39,9 +39,9 @@ var map = new ol.Map({ } })], target: 'map', - view: new ol.View({ + view: new _ol_View_({ extent: viewExtent, - center: ol.extent.getCenter(viewExtent), + center: _ol_extent_.getCenter(viewExtent), zoom: 17, minZoom: 14 }) diff --git a/examples/symbol-atlas-webgl.js b/examples/symbol-atlas-webgl.js index dccb014246..cf3c00fe73 100644 --- a/examples/symbol-atlas-webgl.js +++ b/examples/symbol-atlas-webgl.js @@ -1,17 +1,17 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.AtlasManager'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_AtlasManager_ from '../src/ol/style/AtlasManager.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var atlasManager = new ol.style.AtlasManager({ +var atlasManager = new _ol_style_AtlasManager_({ // we increase the initial size so that all symbols fit into // a single atlas image initialSize: 512 @@ -47,14 +47,14 @@ for (i = 0; i < symbolInfo.length; ++i) { var info = symbolInfo[i]; for (j = 0; j < radiuses.length; ++j) { // circle symbol - symbols.push(new ol.style.Circle({ + symbols.push(new _ol_style_Circle_({ opacity: info.opacity, scale: info.scale, radius: radiuses[j], - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: info.fillColor }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: info.strokeColor, width: 1 }), @@ -64,17 +64,17 @@ for (i = 0; i < symbolInfo.length; ++i) { })); // star symbol - symbols.push(new ol.style.RegularShape({ + symbols.push(new _ol_style_RegularShape_({ points: 8, opacity: info.opacity, scale: info.scale, radius: radiuses[j], radius2: radiuses[j] * 0.7, angle: 1.4, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: info.fillColor }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: info.strokeColor, width: 1 }), @@ -88,29 +88,29 @@ var features = new Array(featureCount); var feature, geometry; var e = 25000000; for (i = 0; i < featureCount; ++i) { - geometry = new ol.geom.Point( + geometry = new _ol_geom_Point_( [2 * e * Math.random() - e, 2 * e * Math.random() - e]); - feature = new ol.Feature(geometry); + feature = new _ol_Feature_(geometry); feature.setStyle( - new ol.style.Style({ + new _ol_style_Style_({ image: symbols[i % symbolCount] }) ); features[i] = feature; } -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ features: features }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource }); -var map = new ol.Map({ +var map = new _ol_Map_({ renderer: /** @type {Array} */ (['webgl', 'canvas']), layers: [vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 4 }) diff --git a/examples/synthetic-lines.js b/examples/synthetic-lines.js index 928c155b80..8216af2069 100644 --- a/examples/synthetic-lines.js +++ b/examples/synthetic-lines.js @@ -1,11 +1,11 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var count = 10000; @@ -30,31 +30,31 @@ for (i = 0; i < count; ++i) { deltaX = delta * signX; deltaY = delta * signY; endPoint = [startPoint[0] + deltaX, startPoint[1] + deltaY]; - features[i] = new ol.Feature({ - 'geometry': new ol.geom.LineString([startPoint, endPoint]) + features[i] = new _ol_Feature_({ + 'geometry': new _ol_geom_LineString_([startPoint, endPoint]) }); startPoint = endPoint; } -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: features, wrapX: false }), - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#666666', width: 1 }) }) }); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 0 }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [vector], target: 'map', view: view diff --git a/examples/synthetic-points.js b/examples/synthetic-points.js index 4c1e672bf0..7b9d62b20f 100644 --- a/examples/synthetic-points.js +++ b/examples/synthetic-points.js @@ -1,22 +1,22 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var count = 20000; var features = new Array(count); var e = 18000000; for (var i = 0; i < count; ++i) { - features[i] = new ol.Feature({ - 'geometry': new ol.geom.Point( + features[i] = new _ol_Feature_({ + 'geometry': new _ol_geom_Point_( [2 * e * Math.random() - e, 2 * e * Math.random() - e]), 'i': i, 'size': i % 2 ? 10 : 20 @@ -24,37 +24,37 @@ for (var i = 0; i < count; ++i) { } var styles = { - '10': new ol.style.Style({ - image: new ol.style.Circle({ + '10': new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({color: '#666666'}), - stroke: new ol.style.Stroke({color: '#bada55', width: 1}) + fill: new _ol_style_Fill_({color: '#666666'}), + stroke: new _ol_style_Stroke_({color: '#bada55', width: 1}) }) }), - '20': new ol.style.Style({ - image: new ol.style.Circle({ + '20': new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 10, - fill: new ol.style.Fill({color: '#666666'}), - stroke: new ol.style.Stroke({color: '#bada55', width: 1}) + fill: new _ol_style_Fill_({color: '#666666'}), + stroke: new _ol_style_Stroke_({color: '#bada55', width: 1}) }) }) }; -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ features: features, wrapX: false }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource, style: function(feature) { return styles[feature.get('size')]; } }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -71,12 +71,12 @@ var displaySnap = function(coordinate) { var geometry = closestFeature.getGeometry(); var closestPoint = geometry.getClosestPoint(coordinate); if (point === null) { - point = new ol.geom.Point(closestPoint); + point = new _ol_geom_Point_(closestPoint); } else { point.setCoordinates(closestPoint); } if (line === null) { - line = new ol.geom.LineString([coordinate, closestPoint]); + line = new _ol_geom_LineString_([coordinate, closestPoint]); } else { line.setCoordinates([coordinate, closestPoint]); } @@ -96,13 +96,13 @@ map.on('click', function(evt) { displaySnap(evt.coordinate); }); -var stroke = new ol.style.Stroke({ +var stroke = new _ol_style_Stroke_({ color: 'rgba(255,255,0,0.9)', width: 3 }); -var style = new ol.style.Style({ +var style = new _ol_style_Style_({ stroke: stroke, - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 10, stroke: stroke }) diff --git a/examples/teleport.js b/examples/teleport.js index 9a55da9356..f0a2e8762e 100644 --- a/examples/teleport.js +++ b/examples/teleport.js @@ -1,22 +1,22 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }) ], - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/tile-load-events.js b/examples/tile-load-events.js index 5925c4cc65..c7be28be85 100644 --- a/examples/tile-load-events.js +++ b/examples/tile-load-events.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; /** @@ -77,7 +77,7 @@ Progress.prototype.hide = function() { var progress = new Progress(document.getElementById('progress')); -var source = new ol.source.TileJSON({ +var source = new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.world-bright.json?secure', crossOrigin: 'anonymous' }); @@ -93,13 +93,13 @@ source.on('tileloaderror', function() { progress.addLoaded(); }); -var map = new ol.Map({ +var map = new _ol_Map_({ logo: false, layers: [ - new ol.layer.Tile({source: source}) + new _ol_layer_Tile_({source: source}) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/tile-transitions.js b/examples/tile-transitions.js index 83a9b01dda..7a1d310c4e 100644 --- a/examples/tile-transitions.js +++ b/examples/tile-transitions.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; var url = 'https://{a-c}.tiles.mapbox.com/v3/mapbox.world-bright/{z}/{x}/{y}.png'; -var withTransition = new ol.layer.Tile({ - source: new ol.source.XYZ({url: url}) +var withTransition = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({url: url}) }); -var withoutTransition = new ol.layer.Tile({ - source: new ol.source.XYZ({url: url, transition: 0}), +var withoutTransition = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({url: url, transition: 0}), visible: false }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [withTransition, withoutTransition], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2, maxZoom: 11 diff --git a/examples/tilejson.js b/examples/tilejson.js index ec69fb2082..ee1b53fe98 100644 --- a/examples/tilejson.js +++ b/examples/tilejson.js @@ -1,20 +1,20 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileJSON'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.TileJSON({ + new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.geography-class.json?secure', crossOrigin: 'anonymous' }) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/tileutfgrid.js b/examples/tileutfgrid.js index 92c69a2aa2..d30b92cf19 100644 --- a/examples/tileutfgrid.js +++ b/examples/tileutfgrid.js @@ -1,32 +1,32 @@ -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileJSON'); -goog.require('ol.source.TileUTFGrid'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Overlay_ from '../src/ol/Overlay.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; +import _ol_source_TileUTFGrid_ from '../src/ol/source/TileUTFGrid.js'; var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg'; -var mapLayer = new ol.layer.Tile({ - source: new ol.source.TileJSON({ +var mapLayer = new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key }) }); -var gridSource = new ol.source.TileUTFGrid({ +var gridSource = new _ol_source_TileUTFGrid_({ url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key }); -var gridLayer = new ol.layer.Tile({source: gridSource}); +var gridLayer = new _ol_layer_Tile_({source: gridSource}); -var view = new ol.View({ +var view = new _ol_View_({ center: [0, 0], zoom: 1 }); var mapElement = document.getElementById('map'); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [mapLayer, gridLayer], target: mapElement, view: view @@ -36,7 +36,7 @@ var infoElement = document.getElementById('country-info'); var flagElement = document.getElementById('country-flag'); var nameElement = document.getElementById('country-name'); -var infoOverlay = new ol.Overlay({ +var infoOverlay = new _ol_Overlay_({ element: infoElement, offset: [15, 15], stopEvent: false diff --git a/examples/tissot.js b/examples/tissot.js index 821788169a..9d8e95b5d4 100644 --- a/examples/tissot.js +++ b/examples/tissot.js @@ -1,25 +1,25 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.Sphere'); -goog.require('ol.View'); -goog.require('ol.geom.Polygon'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.TileWMS'); -goog.require('ol.source.Vector'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_Sphere_ from '../src/ol/Sphere.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var vectorLayer4326 = new ol.layer.Vector({ - source: new ol.source.Vector() +var vectorLayer4326 = new _ol_layer_Vector_({ + source: new _ol_source_Vector_() }); -var vectorLayer3857 = new ol.layer.Vector({ - source: new ol.source.Vector() +var vectorLayer3857 = new _ol_layer_Vector_({ + source: new _ol_source_Vector_() }); -var map4326 = new ol.Map({ +var map4326 = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.TileWMS({ + new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: { 'LAYERS': 'ne:NE1_HR_LC_SR_W_DR', @@ -30,17 +30,17 @@ var map4326 = new ol.Map({ vectorLayer4326 ], target: 'map4326', - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], zoom: 2 }) }); -var map3857 = new ol.Map({ +var map3857 = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.TileWMS({ + new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: { 'LAYERS': 'ne:NE1_HR_LC_SR_W_DR', @@ -51,21 +51,21 @@ var map3857 = new ol.Map({ vectorLayer3857 ], target: 'map3857', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); -var wgs84Sphere = new ol.Sphere(6378137); +var wgs84Sphere = new _ol_Sphere_(6378137); var radius = 800000; var x, y; for (x = -180; x < 180; x += 30) { for (y = -90; y < 90; y += 30) { - var circle4326 = ol.geom.Polygon.circular(wgs84Sphere, [x, y], radius, 64); + var circle4326 = _ol_geom_Polygon_.circular(wgs84Sphere, [x, y], radius, 64); var circle3857 = circle4326.clone().transform('EPSG:4326', 'EPSG:3857'); - vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326)); - vectorLayer3857.getSource().addFeature(new ol.Feature(circle3857)); + vectorLayer4326.getSource().addFeature(new _ol_Feature_(circle4326)); + vectorLayer3857.getSource().addFeature(new _ol_Feature_(circle3857)); } } diff --git a/examples/topojson.js b/examples/topojson.js index 9a61751023..2d302eaa4c 100644 --- a/examples/topojson.js +++ b/examples/topojson.js @@ -1,35 +1,35 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.TopoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.TileJSON'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.TileJSON({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_TileJSON_({ url: 'https://api.tiles.mapbox.com/v3/mapbox.world-dark.json?secure' }) }); -var style = new ol.style.Style({ - fill: new ol.style.Fill({ +var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }) }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/topojson/world-110m.json', - format: new ol.format.TopoJSON({ + format: new _ol_format_TopoJSON_({ // don't want to render the full world polygon (stored as 'land' layer), // which repeats all countries layers: ['countries'] @@ -39,10 +39,10 @@ var vector = new ol.layer.Vector({ style: style }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) diff --git a/examples/topolis.js b/examples/topolis.js index 203546664d..75e58af213 100644 --- a/examples/topolis.js +++ b/examples/topolis.js @@ -1,43 +1,43 @@ // NOCOMPILE // this example uses topolis and toastr for which we don't have an externs file. -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Draw'); -goog.require('ol.interaction.Snap'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Text'); -goog.require('ol.control.MousePosition'); +import _ol_Feature_ from '../src/ol/Feature.js'; +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_geom_Point_ from '../src/ol/geom/Point.js'; +import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; +import _ol_geom_Polygon_ from '../src/ol/geom/Polygon.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_interaction_Snap_ from '../src/ol/interaction/Snap.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; +import _ol_control_MousePosition_ from '../src/ol/control/MousePosition.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var nodes = new ol.source.Vector({wrapX: false}); -var nodesLayer = new ol.layer.Vector({ +var nodes = new _ol_source_Vector_({wrapX: false}); +var nodesLayer = new _ol_layer_Vector_({ source: nodes, style: function(f) { - var style = new ol.style.Style({ - image: new ol.style.Circle({ + var style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 8, - fill: new ol.style.Fill({color: 'rgba(255, 0, 0, 0.2)'}), - stroke: new ol.style.Stroke({color: 'red', width: 1}) + fill: new _ol_style_Fill_({color: 'rgba(255, 0, 0, 0.2)'}), + stroke: new _ol_style_Stroke_({color: 'red', width: 1}) }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: f.get('node').id.toString(), - fill: new ol.style.Fill({color: 'red'}), - stroke: new ol.style.Stroke({ + fill: new _ol_style_Fill_({color: 'red'}), + stroke: new _ol_style_Stroke_({ color: 'white', width: 3 }) @@ -47,19 +47,19 @@ var nodesLayer = new ol.layer.Vector({ } }); -var edges = new ol.source.Vector({wrapX: false}); -var edgesLayer = new ol.layer.Vector({ +var edges = new _ol_source_Vector_({wrapX: false}); +var edgesLayer = new _ol_layer_Vector_({ source: edges, style: function(f) { - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', width: 1 }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: f.get('edge').id.toString(), - fill: new ol.style.Fill({color: 'blue'}), - stroke: new ol.style.Stroke({ + fill: new _ol_style_Fill_({color: 'blue'}), + stroke: new _ol_style_Stroke_({ color: 'white', width: 2 }) @@ -69,23 +69,23 @@ var edgesLayer = new ol.layer.Vector({ } }); -var faces = new ol.source.Vector({wrapX: false}); -var facesLayer = new ol.layer.Vector({ +var faces = new _ol_source_Vector_({wrapX: false}); +var facesLayer = new _ol_layer_Vector_({ source: faces, style: function(f) { - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'black', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 255, 0, 0.2)' }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ font: 'bold 12px sans-serif', text: f.get('face').id.toString(), - fill: new ol.style.Fill({color: 'green'}), - stroke: new ol.style.Stroke({ + fill: new _ol_style_Fill_({color: 'green'}), + stroke: new _ol_style_Stroke_({ color: 'white', width: 2 }) @@ -95,10 +95,10 @@ var facesLayer = new ol.layer.Vector({ } }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, facesLayer, edgesLayer, nodesLayer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-11000000, 4600000], zoom: 16 }) @@ -113,7 +113,7 @@ topo.on('removenode', function(e) { topo.on('addedge', edgeToFeature); topo.on('modedge', function(e) { var feature = edges.getFeatureById(e.id); - feature.setGeometry(new ol.geom.LineString(e.coordinates)); + feature.setGeometry(new _ol_geom_LineString_(e.coordinates)); }); topo.on('removeedge', function(e) { removeElementFeature(edges, e); @@ -129,8 +129,8 @@ function removeElementFeature(source, element) { } function nodeToFeature(node) { - var feature = new ol.Feature({ - geometry: new ol.geom.Point(node.coordinate), + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_(node.coordinate), node: node }); feature.setId(node.id); @@ -138,8 +138,8 @@ function nodeToFeature(node) { } function edgeToFeature(edge) { - var feature = new ol.Feature({ - geometry: new ol.geom.LineString(edge.coordinates), + var feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_(edge.coordinates), edge: edge }); feature.setId(edge.id); @@ -148,8 +148,8 @@ function edgeToFeature(edge) { function faceToFeature(face) { var coordinates = topo.getFaceGeometry(face); - var feature = new ol.Feature({ - geometry: new ol.geom.Polygon(coordinates), + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_(coordinates), face: face }); feature.setId(face.id); @@ -204,13 +204,13 @@ function onDrawend(e) { } } -var draw = new ol.interaction.Draw({ +var draw = new _ol_interaction_Draw_({ type: 'LineString' }); draw.on('drawend', onDrawend); map.addInteraction(draw); -var snap = new ol.interaction.Snap({ +var snap = new _ol_interaction_Snap_({ source: edges }); map.addInteraction(snap); -map.addControl(new ol.control.MousePosition()); +map.addControl(new _ol_control_MousePosition_()); diff --git a/examples/translate-features.js b/examples/translate-features.js index a2c5939cb8..54cecc4e4c 100644 --- a/examples/translate-features.js +++ b/examples/translate-features.js @@ -1,37 +1,37 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Select'); -goog.require('ol.interaction.Translate'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_interaction_Translate_ from '../src/ol/interaction/Translate.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }) }); -var select = new ol.interaction.Select(); +var select = new _ol_interaction_Select_(); -var translate = new ol.interaction.Translate({ +var translate = new _ol_interaction_Translate_({ features: select.getFeatures() }); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([select, translate]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([select, translate]), layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) diff --git a/examples/turf.js b/examples/turf.js index 61ce74cfc9..7c3664aff2 100644 --- a/examples/turf.js +++ b/examples/turf.js @@ -1,20 +1,20 @@ // NOCOMPILE // this example uses turf.js for which we don't have an externs file. -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var source = new ol.source.Vector(); +var source = new _ol_source_Vector_(); fetch('data/geojson/roads-seoul.geojson').then(function(response) { return response.json(); }).then(function(json) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var features = format.readFeatures(json); var street = features[0]; @@ -38,19 +38,19 @@ fetch('data/geojson/roads-seoul.geojson').then(function(response) { street.getGeometry().transform('EPSG:4326', 'EPSG:3857'); source.addFeature(street); }); -var vectorLayer = new ol.layer.Vector({ +var vectorLayer = new _ol_layer_Vector_({ source: source }); -var rasterLayer = new ol.layer.Tile({ - source: new ol.source.OSM() +var rasterLayer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [rasterLayer, vectorLayer], target: document.getElementById('map'), - view: new ol.View({ - center: ol.proj.fromLonLat([126.980366, 37.526540]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([126.980366, 37.526540]), zoom: 15 }) }); diff --git a/examples/vector-esri-edit.js b/examples/vector-esri-edit.js index b4ca7d9526..f99c193345 100644 --- a/examples/vector-esri-edit.js +++ b/examples/vector-esri-edit.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.EsriJSON'); -goog.require('ol.interaction'); -goog.require('ol.interaction.Draw'); -goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.loadingstrategy'); -goog.require('ol.proj'); -goog.require('ol.source.Vector'); -goog.require('ol.source.XYZ'); -goog.require('ol.tilegrid'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_EsriJSON_ from '../src/ol/format/EsriJSON.js'; +import _ol_interaction_ from '../src/ol/interaction.js'; +import _ol_interaction_Draw_ from '../src/ol/interaction/Draw.js'; +import _ol_interaction_Modify_ from '../src/ol/interaction/Modify.js'; +import _ol_interaction_Select_ from '../src/ol/interaction/Select.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; +import _ol_tilegrid_ from '../src/ol/tilegrid.js'; var serviceUrl = 'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/' + 'services/PDX_Pedestrian_Districts/FeatureServer/'; var layer = '0'; -var esrijsonFormat = new ol.format.EsriJSON(); +var esrijsonFormat = new _ol_format_EsriJSON_(); -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ loader: function(extent, resolution, projection) { var url = serviceUrl + layer + '/query/?f=json&' + 'returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=' + @@ -44,17 +44,17 @@ var vectorSource = new ol.source.Vector({ } }}); }, - strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({ + strategy: _ol_loadingstrategy_.tile(_ol_tilegrid_.createXYZ({ tileSize: 512 })) }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource }); -var raster = new ol.layer.Tile({ - source: new ol.source.XYZ({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ attributions: 'Tiles © ArcGIS', url: 'https://server.arcgisonline.com/ArcGIS/rest/services/' + @@ -62,26 +62,26 @@ var raster = new ol.layer.Tile({ }) }); -var draw = new ol.interaction.Draw({ +var draw = new _ol_interaction_Draw_({ source: vectorSource, type: 'Polygon' }); -var select = new ol.interaction.Select(); +var select = new _ol_interaction_Select_(); select.setActive(false); var selected = select.getFeatures(); -var modify = new ol.interaction.Modify({ +var modify = new _ol_interaction_Modify_({ features: selected }); modify.setActive(false); -var map = new ol.Map({ - interactions: ol.interaction.defaults().extend([draw, select, modify]), +var map = new _ol_Map_({ + interactions: _ol_interaction_.defaults().extend([draw, select, modify]), layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ - center: ol.proj.transform([-122.619, 45.512], 'EPSG:4326', 'EPSG:3857'), + view: new _ol_View_({ + center: _ol_proj_.transform([-122.619, 45.512], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) }); diff --git a/examples/vector-esri.js b/examples/vector-esri.js index 823dea7877..b3a0f41232 100644 --- a/examples/vector-esri.js +++ b/examples/vector-esri.js @@ -1,64 +1,64 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.EsriJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.loadingstrategy'); -goog.require('ol.proj'); -goog.require('ol.source.Vector'); -goog.require('ol.source.XYZ'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.tilegrid'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_EsriJSON_ from '../src/ol/format/EsriJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_tilegrid_ from '../src/ol/tilegrid.js'; var serviceUrl = 'https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/' + 'Petroleum/KSFields/FeatureServer/'; var layer = '0'; -var esrijsonFormat = new ol.format.EsriJSON(); +var esrijsonFormat = new _ol_format_EsriJSON_(); var styleCache = { - 'ABANDONED': new ol.style.Style({ - fill: new ol.style.Fill({ + 'ABANDONED': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(225, 225, 225, 255)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(0, 0, 0, 255)', width: 0.4 }) }), - 'GAS': new ol.style.Style({ - fill: new ol.style.Fill({ + 'GAS': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 0, 0, 255)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(110, 110, 110, 255)', width: 0.4 }) }), - 'OIL': new ol.style.Style({ - fill: new ol.style.Fill({ + 'OIL': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(56, 168, 0, 255)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(110, 110, 110, 255)', width: 0 }) }), - 'OILGAS': new ol.style.Style({ - fill: new ol.style.Fill({ + 'OILGAS': new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(168, 112, 0, 255)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(110, 110, 110, 255)', width: 0.4 }) }) }; -var vectorSource = new ol.source.Vector({ +var vectorSource = new _ol_source_Vector_({ loader: function(extent, resolution, projection) { var url = serviceUrl + layer + '/query/?f=json&' + 'returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=' + @@ -82,12 +82,12 @@ var vectorSource = new ol.source.Vector({ } }}); }, - strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({ + strategy: _ol_loadingstrategy_.tile(_ol_tilegrid_.createXYZ({ tileSize: 512 })) }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource, style: function(feature) { var classify = feature.get('activeprod'); @@ -95,8 +95,8 @@ var vector = new ol.layer.Vector({ } }); -var raster = new ol.layer.Tile({ - source: new ol.source.XYZ({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ attributions: 'Tiles © ArcGIS', url: 'https://server.arcgisonline.com/ArcGIS/rest/services/' + @@ -104,11 +104,11 @@ var raster = new ol.layer.Tile({ }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ - center: ol.proj.transform([-97.6114, 38.8403], 'EPSG:4326', 'EPSG:3857'), + view: new _ol_View_({ + center: _ol_proj_.transform([-97.6114, 38.8403], 'EPSG:4326', 'EPSG:3857'), zoom: 7 }) }); diff --git a/examples/vector-label-decluttering.js b/examples/vector-label-decluttering.js index 27ecb61dbb..8173e8f08d 100644 --- a/examples/vector-label-decluttering.js +++ b/examples/vector-label-decluttering.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) }); -var labelStyle = new ol.style.Style({ +var labelStyle = new _ol_style_Style_({ geometry: function(feature) { var geometry = feature.getGeometry(); if (geometry.getType() == 'MultiPolygon') { @@ -26,7 +26,7 @@ var labelStyle = new ol.style.Style({ var widest = 0; for (var i = 0, ii = polygons.length; i < ii; ++i) { var polygon = polygons[i]; - var width = ol.extent.getWidth(polygon.getExtent()); + var width = _ol_extent_.getWidth(polygon.getExtent()); if (width > widest) { widest = width; geometry = polygon; @@ -35,33 +35,33 @@ var labelStyle = new ol.style.Style({ } return geometry; }, - text: new ol.style.Text({ + text: new _ol_style_Text_({ font: '12px Calibri,sans-serif', overflow: true, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#000' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#fff', width: 3 }) }) }); -var countryStyle = new ol.style.Style({ - fill: new ol.style.Fill({ +var countryStyle = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }) }); var style = [countryStyle, labelStyle]; -var vectorLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: function(feature) { labelStyle.getText().setText(feature.get('name')); diff --git a/examples/vector-labels.js b/examples/vector-labels.js index 29237f9082..e39e1d8630 100644 --- a/examples/vector-labels.js +++ b/examples/vector-labels.js @@ -1,15 +1,15 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; var openSansAdded = false; @@ -109,13 +109,13 @@ var createTextStyle = function(feature, resolution, dom) { var outlineColor = dom.outline.value; var outlineWidth = parseInt(dom.outlineWidth.value, 10); - return new ol.style.Text({ + return new _ol_style_Text_({ textAlign: align == '' ? undefined : align, textBaseline: baseline, font: font, text: getText(feature, resolution, dom), - fill: new ol.style.Fill({color: fillColor}), - stroke: new ol.style.Stroke({color: outlineColor, width: outlineWidth}), + fill: new _ol_style_Fill_({color: fillColor}), + stroke: new _ol_style_Stroke_({color: outlineColor, width: outlineWidth}), offsetX: offsetX, offsetY: offsetY, placement: placement, @@ -128,22 +128,22 @@ var createTextStyle = function(feature, resolution, dom) { // Polygons function polygonStyleFunction(feature, resolution) { - return new ol.style.Style({ - stroke: new ol.style.Stroke({ + return new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 0, 255, 0.1)' }), text: createTextStyle(feature, resolution, myDom.polygons) }); } -var vectorPolygons = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorPolygons = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/polygon-samples.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: polygonStyleFunction }); @@ -151,8 +151,8 @@ var vectorPolygons = new ol.layer.Vector({ // Lines function lineStyleFunction(feature, resolution) { - return new ol.style.Style({ - stroke: new ol.style.Stroke({ + return new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'green', width: 2 }), @@ -160,10 +160,10 @@ function lineStyleFunction(feature, resolution) { }); } -var vectorLines = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorLines = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/line-samples.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: lineStyleFunction }); @@ -171,35 +171,35 @@ var vectorLines = new ol.layer.Vector({ // Points function pointStyleFunction(feature, resolution) { - return new ol.style.Style({ - image: new ol.style.Circle({ + return new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 10, - fill: new ol.style.Fill({color: 'rgba(255, 0, 0, 0.1)'}), - stroke: new ol.style.Stroke({color: 'red', width: 1}) + fill: new _ol_style_Fill_({color: 'rgba(255, 0, 0, 0.1)'}), + stroke: new _ol_style_Stroke_({color: 'red', width: 1}) }), text: createTextStyle(feature, resolution, myDom.points) }); } -var vectorPoints = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorPoints = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/point-samples.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: pointStyleFunction }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), vectorPolygons, vectorLines, vectorPoints ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-8161939, 6095025], zoom: 8 }) diff --git a/examples/vector-layer.js b/examples/vector-layer.js index 4495d7d889..14d340e96a 100644 --- a/examples/vector-layer.js +++ b/examples/vector-layer.js @@ -1,38 +1,38 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; +import _ol_style_Text_ from '../src/ol/style/Text.js'; -var style = new ol.style.Style({ - fill: new ol.style.Fill({ +var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', width: 1 }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ font: '12px Calibri,sans-serif', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#000' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#fff', width: 3 }) }) }); -var vectorLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vectorLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ url: 'data/geojson/countries.geojson', - format: new ol.format.GeoJSON() + format: new _ol_format_GeoJSON_() }), style: function(feature) { style.getText().setText(feature.get('name')); @@ -40,37 +40,37 @@ var vectorLayer = new ol.layer.Vector({ } }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [vectorLayer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) }); -var highlightStyle = new ol.style.Style({ - stroke: new ol.style.Stroke({ +var highlightStyle = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.1)' }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ font: '12px Calibri,sans-serif', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#000' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#f00', width: 3 }) }) }); -var featureOverlay = new ol.layer.Vector({ - source: new ol.source.Vector(), +var featureOverlay = new _ol_layer_Vector_({ + source: new _ol_source_Vector_(), map: map, style: function(feature) { highlightStyle.getText().setText(feature.get('name')); diff --git a/examples/vector-osm.js b/examples/vector-osm.js index 8eaa252ab5..fa1d7b02ef 100644 --- a/examples/vector-osm.js +++ b/examples/vector-osm.js @@ -1,74 +1,74 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.format.OSMXML'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.loadingstrategy'); -goog.require('ol.proj'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_format_OSMXML_ from '../src/ol/format/OSMXML.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; var map; var styles = { 'amenity': { - 'parking': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'parking': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(170, 170, 170, 1.0)', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(170, 170, 170, 0.3)' }) }) }, 'building': { - '.*': new ol.style.Style({ + '.*': new _ol_style_Style_({ zIndex: 100, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(246, 99, 79, 1.0)', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(246, 99, 79, 0.3)' }) }) }, 'highway': { - 'service': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'service': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255, 255, 255, 1.0)', width: 2 }) }), - '.*': new ol.style.Style({ - stroke: new ol.style.Stroke({ + '.*': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255, 255, 255, 1.0)', width: 3 }) }) }, 'landuse': { - 'forest|grass|allotments': new ol.style.Style({ - stroke: new ol.style.Stroke({ + 'forest|grass|allotments': new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(140, 208, 95, 1.0)', width: 1 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(140, 208, 95, 0.3)' }) }) }, 'natural': { - 'tree': new ol.style.Style({ - image: new ol.style.Circle({ + 'tree': new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 2, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(140, 208, 95, 1.0)' }), stroke: null @@ -77,15 +77,15 @@ var styles = { } }; -var vectorSource = new ol.source.Vector({ - format: new ol.format.OSMXML(), +var vectorSource = new _ol_source_Vector_({ + format: new _ol_format_OSMXML_(), loader: function(extent, resolution, projection) { var epsg4326Extent = - ol.proj.transformExtent(extent, projection, 'EPSG:4326'); + _ol_proj_.transformExtent(extent, projection, 'EPSG:4326'); var client = new XMLHttpRequest(); client.open('POST', 'https://overpass-api.de/api/interpreter'); client.addEventListener('load', function() { - var features = new ol.format.OSMXML().readFeatures(client.responseText, { + var features = new _ol_format_OSMXML_().readFeatures(client.responseText, { featureProjection: map.getView().getProjection() }); vectorSource.addFeatures(features); @@ -96,10 +96,10 @@ var vectorSource = new ol.source.Vector({ ');rel(bn)->.foo;way(bn);node(w)->.foo;rel(bw););out meta;'; client.send(query); }, - strategy: ol.loadingstrategy.bbox + strategy: _ol_loadingstrategy_.bbox }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource, style: function(feature) { for (var key in styles) { @@ -116,22 +116,22 @@ var vector = new ol.layer.Vector({ } }); -var raster = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }); -map = new ol.Map({ +map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [739218, 5906096], maxZoom: 19, zoom: 17 diff --git a/examples/vector-tile-info.js b/examples/vector-tile-info.js index 2ee277516a..b43407df8f 100644 --- a/examples/vector-tile-info.js +++ b/examples/vector-tile-info.js @@ -1,18 +1,18 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.MVT'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.source.VectorTile'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_MVT_ from '../src/ol/format/MVT.js'; +import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; +import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }), - layers: [new ol.layer.VectorTile({ - source: new ol.source.VectorTile({ - format: new ol.format.MVT(), + layers: [new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({ + format: new _ol_format_MVT_(), url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf' }) })] diff --git a/examples/vector-wfs-getfeature.js b/examples/vector-wfs-getfeature.js index ca4fae3dee..3473a2fb08 100644 --- a/examples/vector-wfs-getfeature.js +++ b/examples/vector-wfs-getfeature.js @@ -1,38 +1,38 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.filter'); -goog.require('ol.format.WFS'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_filter_ from '../src/ol/format/filter.js'; +import _ol_format_WFS_ from '../src/ol/format/WFS.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var vectorSource = new ol.source.Vector(); -var vector = new ol.layer.Vector({ +var vectorSource = new _ol_source_Vector_(); +var vector = new _ol_layer_Vector_({ source: vectorSource, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(0, 0, 255, 1.0)', width: 2 }) }) }); -var raster = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [-8908887.277395891, 5381918.072437216], maxZoom: 19, zoom: 12 @@ -40,15 +40,15 @@ var map = new ol.Map({ }); // generate a GetFeature request -var featureRequest = new ol.format.WFS().writeGetFeature({ +var featureRequest = new _ol_format_WFS_().writeGetFeature({ srsName: 'EPSG:3857', featureNS: 'http://openstreemap.org', featurePrefix: 'osm', featureTypes: ['water_areas'], outputFormat: 'application/json', - filter: ol.format.filter.and( - ol.format.filter.like('name', 'Mississippi*'), - ol.format.filter.equalTo('waterway', 'riverbank') + filter: _ol_format_filter_.and( + _ol_format_filter_.like('name', 'Mississippi*'), + _ol_format_filter_.equalTo('waterway', 'riverbank') ) }); @@ -59,7 +59,7 @@ fetch('https://ahocevar.com/geoserver/wfs', { }).then(function(response) { return response.json(); }).then(function(json) { - var features = new ol.format.GeoJSON().readFeatures(json); + var features = new _ol_format_GeoJSON_().readFeatures(json); vectorSource.addFeatures(features); map.getView().fit(vectorSource.getExtent()); }); diff --git a/examples/vector-wfs.js b/examples/vector-wfs.js index 7ca04e5a3d..64114664b8 100644 --- a/examples/vector-wfs.js +++ b/examples/vector-wfs.js @@ -1,48 +1,48 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.loadingstrategy'); -goog.require('ol.source.BingMaps'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; +import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../src/ol/style/Style.js'; -var vectorSource = new ol.source.Vector({ - format: new ol.format.GeoJSON(), +var vectorSource = new _ol_source_Vector_({ + format: new _ol_format_GeoJSON_(), url: function(extent) { return 'https://ahocevar.com/geoserver/wfs?service=WFS&' + 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' + 'outputFormat=application/json&srsname=EPSG:3857&' + 'bbox=' + extent.join(',') + ',EPSG:3857'; }, - strategy: ol.loadingstrategy.bbox + strategy: _ol_loadingstrategy_.bbox }); -var vector = new ol.layer.Vector({ +var vector = new _ol_layer_Vector_({ source: vectorSource, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'rgba(0, 0, 255, 1.0)', width: 2 }) }) }); -var raster = new ol.layer.Tile({ - source: new ol.source.BingMaps({ +var raster = new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ imagerySet: 'Aerial', key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5' }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: document.getElementById('map'), - view: new ol.View({ + view: new _ol_View_({ center: [-8908887.277395891, 5381918.072437216], maxZoom: 19, zoom: 12 diff --git a/examples/wkt.js b/examples/wkt.js index 5d18d901f3..428460b16a 100644 --- a/examples/wkt.js +++ b/examples/wkt.js @@ -1,36 +1,36 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.WKT'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.OSM'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_WKT_ from '../src/ol/format/WKT.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_Vector_ from '../src/ol/source/Vector.js'; -var raster = new ol.layer.Tile({ - source: new ol.source.OSM() +var raster = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); var wkt = 'POLYGON((10.689 -25.092, 34.595 ' + '-20.170, 38.814 -35.639, 13.502 ' + '-39.155, 10.689 -25.092))'; -var format = new ol.format.WKT(); +var format = new _ol_format_WKT_(); var feature = format.readFeature(wkt, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }); -var vector = new ol.layer.Vector({ - source: new ol.source.Vector({ +var vector = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }) }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [raster, vector], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [2952104.0199, -3277504.823], zoom: 4 }) diff --git a/examples/wms-capabilities.js b/examples/wms-capabilities.js index 349634ddf3..5b673fe42e 100644 --- a/examples/wms-capabilities.js +++ b/examples/wms-capabilities.js @@ -1,6 +1,6 @@ -goog.require('ol.format.WMSCapabilities'); +import _ol_format_WMSCapabilities_ from '../src/ol/format/WMSCapabilities.js'; -var parser = new ol.format.WMSCapabilities(); +var parser = new _ol_format_WMSCapabilities_(); fetch('data/ogcsample.xml').then(function(response) { return response.text(); diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js index 21daf44a2e..89379aaa3b 100644 --- a/examples/wms-custom-proj.js +++ b/examples/wms-custom-proj.js @@ -1,11 +1,11 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.control.ScaleLine'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; // By default OpenLayers does not know about the EPSG:21781 (Swiss) projection. @@ -13,20 +13,20 @@ goog.require('ol.source.TileWMS'); // ol.proj.addProjection to make it available to the library for lookup by its // code. -var projection = new ol.proj.Projection({ +var projection = new _ol_proj_Projection_({ code: 'EPSG:21781', // The extent is used to determine zoom level 0. Recommended values for a // projection's validity extent can be found at https://epsg.io/. extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864], units: 'm' }); -ol.proj.addProjection(projection); +_ol_proj_.addProjection(projection); // We also declare EPSG:21781/EPSG:4326 transform functions. These functions // are necessary for the ScaleLine control and when calling ol.proj.transform // for setting the view's initial center (see below). -ol.proj.addCoordinateTransforms('EPSG:4326', projection, +_ol_proj_.addCoordinateTransforms('EPSG:4326', projection, function(coordinate) { return [ WGStoCHy(coordinate[1], coordinate[0]), @@ -42,9 +42,9 @@ ol.proj.addCoordinateTransforms('EPSG:4326', projection, var extent = [420000, 30000, 900000, 350000]; var layers = [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ extent: extent, - source: new ol.source.TileWMS({ + source: new _ol_source_TileWMS_({ url: 'https://wms.geo.admin.ch/', crossOrigin: 'anonymous', attributions: '© Pixelmap 1:1000000 / geo.admin.ch', crossOrigin: 'anonymous', @@ -20,8 +20,8 @@ var layers = [ url: 'https://wms.geo.admin.ch/' }) }), - new ol.layer.Image({ - source: new ol.source.ImageWMS({ + new _ol_layer_Image_({ + source: new _ol_source_ImageWMS_({ attributions: '© National parks / geo.admin.ch', crossOrigin: 'anonymous', @@ -37,15 +37,15 @@ var layers = [ // projection object. Requesting tiles only needs the code together with a // tile grid of Cartesian coordinates; it does not matter how those // coordinates relate to latitude or longitude. -var projection = new ol.proj.Projection({ +var projection = new _ol_proj_Projection_({ code: 'EPSG:21781', units: 'm' }); -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [660000, 190000], projection: projection, zoom: 9 diff --git a/examples/wms-tiled-wrap-180.js b/examples/wms-tiled-wrap-180.js index e44259d786..c5f46b27d0 100644 --- a/examples/wms-tiled-wrap-180.js +++ b/examples/wms-tiled-wrap-180.js @@ -1,26 +1,26 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; var layers = [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ - source: new ol.source.TileWMS({ + new _ol_layer_Tile_({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/ne/wms', params: {'LAYERS': 'ne:ne_10m_admin_0_countries', 'TILED': true}, serverType: 'geoserver' }) }) ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }) diff --git a/examples/wms-tiled.js b/examples/wms-tiled.js index 1804c5857f..467e12091a 100644 --- a/examples/wms-tiled.js +++ b/examples/wms-tiled.js @@ -1,17 +1,17 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; var layers = [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ extent: [-13884991, 2870341, -7455066, 6338219], - source: new ol.source.TileWMS({ + source: new _ol_source_TileWMS_({ url: 'https://ahocevar.com/geoserver/wms', params: {'LAYERS': 'topp:states', 'TILED': true}, serverType: 'geoserver', @@ -20,10 +20,10 @@ var layers = [ }) }) ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [-10997148, 4569099], zoom: 4 }) diff --git a/examples/wms-time.js b/examples/wms-time.js index bed8b05b33..25f501b268 100644 --- a/examples/wms-time.js +++ b/examples/wms-time.js @@ -1,40 +1,40 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.Stamen'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; +import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; function threeHoursAgo() { return new Date(Math.round(Date.now() / 3600000) * 3600000 - 3600000 * 3); } -var extent = ol.proj.transformExtent([-126, 24, -66, 50], 'EPSG:4326', 'EPSG:3857'); +var extent = _ol_proj_.transformExtent([-126, 24, -66, 50], 'EPSG:4326', 'EPSG:3857'); var startDate = threeHoursAgo(); var frameRate = 0.5; // frames per second var animationId = null; var layers = [ - new ol.layer.Tile({ - source: new ol.source.Stamen({ + new _ol_layer_Tile_({ + source: new _ol_source_Stamen_({ layer: 'terrain' }) }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ extent: extent, - source: new ol.source.TileWMS({ + source: new _ol_source_TileWMS_({ attributions: ['Iowa State University'], url: 'https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi', params: {'LAYERS': 'nexrad-n0r-wmst'} }) }) ]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: layers, target: 'map', - view: new ol.View({ - center: ol.extent.getCenter(extent), + view: new _ol_View_({ + center: _ol_extent_.getCenter(extent), zoom: 4 }) }); diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index aebfeabb90..33f4b024c0 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,6 +1,6 @@ -goog.require('ol.format.WMTSCapabilities'); +import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; -var parser = new ol.format.WMTSCapabilities(); +var parser = new _ol_format_WMTSCapabilities_(); fetch('data/WMTSCapabilities.xml').then(function(response) { return response.text(); diff --git a/examples/wmts-dimensions.js b/examples/wmts-dimensions.js index 8361aea1a9..7bb988563e 100644 --- a/examples/wmts-dimensions.js +++ b/examples/wmts-dimensions.js @@ -1,32 +1,32 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.WMTS'); -goog.require('ol.tilegrid.WMTS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; // create the WMTS tile grid in the google projection -var projection = ol.proj.get('EPSG:3857'); +var projection = _ol_proj_.get('EPSG:3857'); var tileSizePixels = 256; -var tileSizeMtrs = ol.extent.getWidth(projection.getExtent()) / tileSizePixels; +var tileSizeMtrs = _ol_extent_.getWidth(projection.getExtent()) / tileSizePixels; var matrixIds = []; var resolutions = []; for (var i = 0; i <= 14; i++) { matrixIds[i] = i; resolutions[i] = tileSizeMtrs / Math.pow(2, i); } -var tileGrid = new ol.tilegrid.WMTS({ - origin: ol.extent.getTopLeft(projection.getExtent()), +var tileGrid = new _ol_tilegrid_WMTS_({ + origin: _ol_extent_.getTopLeft(projection.getExtent()), resolutions: resolutions, matrixIds: matrixIds }); var scalgoToken = 'CC5BF28A7D96B320C7DFBFD1236B5BEB'; -var wmtsSource = new ol.source.WMTS({ +var wmtsSource = new _ol_source_WMTS_({ url: 'http://ts2.scalgo.com/olpatch/wmts?token=' + scalgoToken, layer: 'SRTM_4_1:SRTM_4_1_flooded_sealevels', format: 'image/png', @@ -43,18 +43,18 @@ var wmtsSource = new ol.source.WMTS({ } }); -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', - view: new ol.View({ + view: new _ol_View_({ projection: projection, center: [-9871995, 3566245], zoom: 6 }), layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ opacity: 0.5, source: wmtsSource }) diff --git a/examples/wmts-hidpi.js b/examples/wmts-hidpi.js index e5dbf7a625..65a49263a0 100644 --- a/examples/wmts-hidpi.js +++ b/examples/wmts-hidpi.js @@ -1,9 +1,9 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.WMTSCapabilities'); -goog.require('ol.has'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.WMTS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; +import _ol_has_ from '../src/ol/has.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; var capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml'; @@ -11,13 +11,13 @@ var capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml'; // HiDPI support: // * Use 'bmaphidpi' layer (pixel ratio 2) for device pixel ratio > 1 // * Use 'geolandbasemap' layer (pixel ratio 1) for device pixel ratio == 1 -var hiDPI = ol.has.DEVICE_PIXEL_RATIO > 1; +var hiDPI = _ol_has_.DEVICE_PIXEL_RATIO > 1; var layer = hiDPI ? 'bmaphidpi' : 'geolandbasemap'; var tilePixelRatio = hiDPI ? 2 : 1; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [1823849, 6143760], zoom: 11 }) @@ -26,14 +26,14 @@ var map = new ol.Map({ fetch(capabilitiesUrl).then(function(response) { return response.text(); }).then(function(text) { - var result = new ol.format.WMTSCapabilities().read(text); - var options = ol.source.WMTS.optionsFromCapabilities(result, { + var result = new _ol_format_WMTSCapabilities_().read(text); + var options = _ol_source_WMTS_.optionsFromCapabilities(result, { layer: layer, matrixSet: 'google3857', style: 'normal' }); options.tilePixelRatio = tilePixelRatio; - map.addLayer(new ol.layer.Tile({ - source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + map.addLayer(new _ol_layer_Tile_({ + source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) })); }); diff --git a/examples/wmts-ign.js b/examples/wmts-ign.js index 2e3dc155ed..e7c2108dde 100644 --- a/examples/wmts-ign.js +++ b/examples/wmts-ign.js @@ -1,37 +1,37 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.WMTS'); -goog.require('ol.tilegrid.WMTS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ zoom: 5, - center: ol.proj.transform([5, 45], 'EPSG:4326', 'EPSG:3857') + center: _ol_proj_.transform([5, 45], 'EPSG:4326', 'EPSG:3857') }) }); var resolutions = []; var matrixIds = []; -var proj3857 = ol.proj.get('EPSG:3857'); -var maxResolution = ol.extent.getWidth(proj3857.getExtent()) / 256; +var proj3857 = _ol_proj_.get('EPSG:3857'); +var maxResolution = _ol_extent_.getWidth(proj3857.getExtent()) / 256; for (var i = 0; i < 18; i++) { matrixIds[i] = i.toString(); resolutions[i] = maxResolution / Math.pow(2, i); } -var tileGrid = new ol.tilegrid.WMTS({ +var tileGrid = new _ol_tilegrid_WMTS_({ origin: [-20037508, 20037508], resolutions: resolutions, matrixIds: matrixIds @@ -41,7 +41,7 @@ var tileGrid = new ol.tilegrid.WMTS({ // Expiration date is 06/29/2018. var key = '2mqbg0z6cx7ube8gsou10nrt'; -var ign_source = new ol.source.WMTS({ +var ign_source = new _ol_source_WMTS_({ url: 'https://wxs.ign.fr/' + key + '/wmts', layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS', matrixSet: 'PM', @@ -54,7 +54,7 @@ var ign_source = new ol.source.WMTS({ 'theme/geoportal/img/logo_gp.gif">' }); -var ign = new ol.layer.Tile({ +var ign = new _ol_layer_Tile_({ source: ign_source }); diff --git a/examples/wmts-layer-from-capabilities.js b/examples/wmts-layer-from-capabilities.js index 45badb4c89..1db2bda3f4 100644 --- a/examples/wmts-layer-from-capabilities.js +++ b/examples/wmts-layer-from-capabilities.js @@ -1,35 +1,35 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.WMTSCapabilities'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); -goog.require('ol.source.WMTS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; -var parser = new ol.format.WMTSCapabilities(); +var parser = new _ol_format_WMTSCapabilities_(); var map; fetch('data/WMTSCapabilities.xml').then(function(response) { return response.text(); }).then(function(text) { var result = parser.read(text); - var options = ol.source.WMTS.optionsFromCapabilities(result, { + var options = _ol_source_WMTS_.optionsFromCapabilities(result, { layer: 'layer-7328', matrixSet: 'EPSG:3857' }); - map = new ol.Map({ + map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM(), + new _ol_layer_Tile_({ + source: new _ol_source_OSM_(), opacity: 0.7 }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ opacity: 1, - source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) + source: new _ol_source_WMTS_(/** @type {!olx.source.WMTSOptions} */ (options)) }) ], target: 'map', - view: new ol.View({ + view: new _ol_View_({ center: [19412406.33, -5050500.21], zoom: 5 }) diff --git a/examples/wmts.js b/examples/wmts.js index 243cdc38ee..d5c0b566d8 100644 --- a/examples/wmts.js +++ b/examples/wmts.js @@ -1,17 +1,17 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control'); -goog.require('ol.extent'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.WMTS'); -goog.require('ol.tilegrid.WMTS'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ from '../src/ol/control.js'; +import _ol_extent_ from '../src/ol/extent.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; +import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; -var projection = ol.proj.get('EPSG:3857'); +var projection = _ol_proj_.get('EPSG:3857'); var projectionExtent = projection.getExtent(); -var size = ol.extent.getWidth(projectionExtent) / 256; +var size = _ol_extent_.getWidth(projectionExtent) / 256; var resolutions = new Array(14); var matrixIds = new Array(14); for (var z = 0; z < 14; ++z) { @@ -20,15 +20,15 @@ for (var z = 0; z < 14; ++z) { matrixIds[z] = z; } -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM(), + new _ol_layer_Tile_({ + source: new _ol_source_OSM_(), opacity: 0.7 }), - new ol.layer.Tile({ + new _ol_layer_Tile_({ opacity: 0.7, - source: new ol.source.WMTS({ + source: new _ol_source_WMTS_({ attributions: 'Tiles © ArcGIS', url: 'https://services.arcgisonline.com/arcgis/rest/' + @@ -37,8 +37,8 @@ var map = new ol.Map({ matrixSet: 'EPSG:3857', format: 'image/png', projection: projection, - tileGrid: new ol.tilegrid.WMTS({ - origin: ol.extent.getTopLeft(projectionExtent), + tileGrid: new _ol_tilegrid_WMTS_({ + origin: _ol_extent_.getTopLeft(projectionExtent), resolutions: resolutions, matrixIds: matrixIds }), @@ -48,12 +48,12 @@ var map = new ol.Map({ }) ], target: 'map', - controls: ol.control.defaults({ + controls: _ol_control_.defaults({ attributionOptions: { collapsible: false } }), - view: new ol.View({ + view: new _ol_View_({ center: [-11158582, 4813697], zoom: 4 }) diff --git a/examples/xyz-esri-4326-512.js b/examples/xyz-esri-4326-512.js index 33b791200a..f39dcfedc3 100644 --- a/examples/xyz-esri-4326-512.js +++ b/examples/xyz-esri-4326-512.js @@ -1,10 +1,10 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; -var projection = ol.proj.get('EPSG:4326'); +var projection = _ol_proj_.get('EPSG:4326'); // The tile size supported by the ArcGIS tile service. var tileSize = 512; @@ -12,11 +12,11 @@ var tileSize = 512; var urlTemplate = 'https://services.arcgisonline.com/arcgis/rest/services/' + 'ESRI_Imagery_World_2D/MapServer/tile/{z}/{y}/{x}'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ attributions: 'Copyright:© 2013 ESRI, i-cubed, GeoEye', maxZoom: 16, projection: projection, @@ -30,7 +30,7 @@ var map = new ol.Map({ }) }) ], - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], projection: projection, zoom: 2, diff --git a/examples/xyz-esri.js b/examples/xyz-esri.js index a1ad487259..19cd89750f 100644 --- a/examples/xyz-esri.js +++ b/examples/xyz-esri.js @@ -1,15 +1,15 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ attributions: 'Tiles © ArcGIS', url: 'https://server.arcgisonline.com/ArcGIS/rest/services/' + @@ -17,8 +17,8 @@ var map = new ol.Map({ }) }) ], - view: new ol.View({ - center: ol.proj.fromLonLat([-121.1, 47.5]), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat([-121.1, 47.5]), zoom: 7 }) }); diff --git a/examples/xyz-retina.js b/examples/xyz-retina.js index 930052342f..7362b09bd7 100644 --- a/examples/xyz-retina.js +++ b/examples/xyz-retina.js @@ -1,23 +1,23 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.source.OSM'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_proj_ from '../src/ol/proj.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; var mapMinZoom = 1; var mapMaxZoom = 15; var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062]; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() + new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }), - new ol.layer.Tile({ - extent: ol.proj.transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'), - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + extent: _ol_proj_.transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'), + source: new _ol_source_XYZ_({ attributions: 'Tiles © USGS, rendered with ' + 'MapTiler', url: 'https://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png', @@ -27,9 +27,9 @@ var map = new ol.Map({ }) }) ], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:3857', - center: ol.proj.transform([-112.18688965, 36.057944835], + center: _ol_proj_.transform([-112.18688965, 36.057944835], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) diff --git a/examples/xyz.js b/examples/xyz.js index 9dae032e92..ceb1b8bb85 100644 --- a/examples/xyz.js +++ b/examples/xyz.js @@ -1,20 +1,20 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' }) }) ], - view: new ol.View({ + view: new _ol_View_({ center: [-472202, 7530279], zoom: 12 }) diff --git a/examples/zoom-constrained.js b/examples/zoom-constrained.js index bac2401548..a9bd845e24 100644 --- a/examples/zoom-constrained.js +++ b/examples/zoom-constrained.js @@ -1,20 +1,20 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.BingMaps'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; -var map = new ol.Map({ +var map = new _ol_Map_({ target: 'map', layers: [ - new ol.layer.Tile({ - source: new ol.source.BingMaps({ + new _ol_layer_Tile_({ + source: new _ol_source_BingMaps_({ key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5', imagerySet: 'Aerial' }) }) ], - view: new ol.View({ + view: new _ol_View_({ center: [-13553864, 5918250], zoom: 11, minZoom: 9, diff --git a/examples/zoomify.js b/examples/zoomify.js index ebc0814483..d205b0ece2 100644 --- a/examples/zoomify.js +++ b/examples/zoomify.js @@ -1,7 +1,7 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.Zoomify'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_Zoomify_ from '../src/ol/source/Zoomify.js'; var imgWidth = 9911; var imgHeight = 6100; @@ -10,8 +10,8 @@ var zoomifyUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' + '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/'; var iipUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?FIF=' + '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF' + '&JTL={z},{tileIndex}'; -var layer = new ol.layer.Tile({ - source: new ol.source.Zoomify({ +var layer = new _ol_layer_Tile_({ + source: new _ol_source_Zoomify_({ url: zoomifyUrl, size: [imgWidth, imgHeight], crossOrigin: 'anonymous' @@ -20,10 +20,10 @@ var layer = new ol.layer.Tile({ var extent = [0, -imgHeight, imgWidth, 0]; -var map = new ol.Map({ +var map = new _ol_Map_({ layers: [layer], target: 'map', - view: new ol.View({ + view: new _ol_View_({ // adjust zoom levels to those provided by the source resolutions: layer.getSource().getTileGrid().getResolutions(), // constrain the center: center cannot be set outside this extent @@ -36,13 +36,13 @@ var control = document.getElementById('zoomifyProtocol'); control.addEventListener('change', function(event) { var value = event.currentTarget.value; if (value === 'iip') { - layer.setSource(new ol.source.Zoomify({ + layer.setSource(new _ol_source_Zoomify_({ url: iipUrl, size: [imgWidth, imgHeight], crossOrigin: 'anonymous' })); } else if (value === 'zoomify') { - layer.setSource(new ol.source.Zoomify({ + layer.setSource(new _ol_source_Zoomify_({ url: zoomifyUrl, size: [imgWidth, imgHeight], crossOrigin: 'anonymous' diff --git a/examples/zoomslider.js b/examples/zoomslider.js index 6d81a37e40..9640574e9b 100644 --- a/examples/zoomslider.js +++ b/examples/zoomslider.js @@ -1,8 +1,8 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control.ZoomSlider'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_Map_ from '../src/ol/Map.js'; +import _ol_View_ from '../src/ol/View.js'; +import _ol_control_ZoomSlider_ from '../src/ol/control/ZoomSlider.js'; +import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../src/ol/source/OSM.js'; /** @@ -14,19 +14,19 @@ goog.require('ol.source.OSM'); var createMap = function(divId) { var source, layer, map, zoomslider; - source = new ol.source.OSM(); - layer = new ol.layer.Tile({ + source = new _ol_source_OSM_(); + layer = new _ol_layer_Tile_({ source: source }); - map = new ol.Map({ + map = new _ol_Map_({ layers: [layer], target: divId, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) }); - zoomslider = new ol.control.ZoomSlider(); + zoomslider = new _ol_control_ZoomSlider_(); map.addControl(zoomslider); return map; }; diff --git a/src/ol/AssertionError.js b/src/ol/AssertionError.js index 2f0af35e02..8b864b6e81 100644 --- a/src/ol/AssertionError.js +++ b/src/ol/AssertionError.js @@ -1,6 +1,7 @@ -goog.provide('ol.AssertionError'); - -goog.require('ol'); +/** + * @module ol/AssertionError + */ +import _ol_ from './index.js'; /** * Error object thrown when an assertion failed. This is an ECMA-262 Error, @@ -11,9 +12,9 @@ goog.require('ol'); * @implements {oli.AssertionError} * @param {number} code Error code. */ -ol.AssertionError = function(code) { +var _ol_AssertionError_ = function(code) { - var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest'; + var path = _ol_.VERSION ? _ol_.VERSION.split('-')[0] : 'latest'; /** * @type {string} @@ -34,4 +35,6 @@ ol.AssertionError = function(code) { this.name = 'AssertionError'; }; -ol.inherits(ol.AssertionError, Error); + +_ol_.inherits(_ol_AssertionError_, Error); +export default _ol_AssertionError_; diff --git a/src/ol/Attribution.js b/src/ol/Attribution.js index 161d7e46d9..9a4484589d 100644 --- a/src/ol/Attribution.js +++ b/src/ol/Attribution.js @@ -1,9 +1,9 @@ -goog.provide('ol.Attribution'); - -goog.require('ol.TileRange'); -goog.require('ol.math'); -goog.require('ol.tilegrid'); - +/** + * @module ol/Attribution + */ +import _ol_TileRange_ from './TileRange.js'; +import _ol_math_ from './math.js'; +import _ol_tilegrid_ from './tilegrid.js'; /** * @classdesc @@ -27,7 +27,7 @@ goog.require('ol.tilegrid'); * @struct * @api */ -ol.Attribution = function(options) { +var _ol_Attribution_ = function(options) { /** * @private @@ -49,7 +49,7 @@ ol.Attribution = function(options) { * @return {string} The attribution HTML. * @api */ -ol.Attribution.prototype.getHTML = function() { +_ol_Attribution_.prototype.getHTML = function() { return this.html_; }; @@ -60,7 +60,7 @@ ol.Attribution.prototype.getHTML = function() { * @param {!ol.proj.Projection} projection Projection. * @return {boolean} Intersects any tile range. */ -ol.Attribution.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, projection) { +_ol_Attribution_.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, projection) { if (!this.tileRanges_) { return true; } @@ -77,13 +77,13 @@ ol.Attribution.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, return true; } var extentTileRange = tileGrid.getTileRangeForExtentAndZ( - ol.tilegrid.extentFromProjection(projection), parseInt(zKey, 10)); + _ol_tilegrid_.extentFromProjection(projection), parseInt(zKey, 10)); var width = extentTileRange.getWidth(); if (tileRange.minX < extentTileRange.minX || tileRange.maxX > extentTileRange.maxX) { - if (testTileRange.intersects(new ol.TileRange( - ol.math.modulo(tileRange.minX, width), - ol.math.modulo(tileRange.maxX, width), + if (testTileRange.intersects(new _ol_TileRange_( + _ol_math_.modulo(tileRange.minX, width), + _ol_math_.modulo(tileRange.maxX, width), tileRange.minY, tileRange.maxY))) { return true; } @@ -96,3 +96,4 @@ ol.Attribution.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, } return false; }; +export default _ol_Attribution_; diff --git a/src/ol/CanvasMap.js b/src/ol/CanvasMap.js index 93bca407e2..d9cfd425f1 100644 --- a/src/ol/CanvasMap.js +++ b/src/ol/CanvasMap.js @@ -1,25 +1,26 @@ -goog.provide('ol.CanvasMap'); - -goog.require('ol'); -goog.require('ol.PluggableMap'); -goog.require('ol.PluginType'); -goog.require('ol.control'); -goog.require('ol.interaction'); -goog.require('ol.obj'); -goog.require('ol.plugins'); -goog.require('ol.renderer.canvas.ImageLayer'); -goog.require('ol.renderer.canvas.Map'); -goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.renderer.canvas.VectorLayer'); -goog.require('ol.renderer.canvas.VectorTileLayer'); +/** + * @module ol/CanvasMap + */ +import _ol_ from './index.js'; +import _ol_PluggableMap_ from './PluggableMap.js'; +import _ol_PluginType_ from './PluginType.js'; +import _ol_control_ from './control.js'; +import _ol_interaction_ from './interaction.js'; +import _ol_obj_ from './obj.js'; +import _ol_plugins_ from './plugins.js'; +import _ol_renderer_canvas_ImageLayer_ from './renderer/canvas/ImageLayer.js'; +import _ol_renderer_canvas_Map_ from './renderer/canvas/Map.js'; +import _ol_renderer_canvas_TileLayer_ from './renderer/canvas/TileLayer.js'; +import _ol_renderer_canvas_VectorLayer_ from './renderer/canvas/VectorLayer.js'; +import _ol_renderer_canvas_VectorTileLayer_ from './renderer/canvas/VectorTileLayer.js'; -ol.plugins.register(ol.PluginType.MAP_RENDERER, ol.renderer.canvas.Map); -ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [ - ol.renderer.canvas.ImageLayer, - ol.renderer.canvas.TileLayer, - ol.renderer.canvas.VectorLayer, - ol.renderer.canvas.VectorTileLayer +_ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_canvas_Map_); +_ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ + _ol_renderer_canvas_ImageLayer_, + _ol_renderer_canvas_TileLayer_, + _ol_renderer_canvas_VectorLayer_, + _ol_renderer_canvas_VectorTileLayer_ ]); @@ -71,16 +72,18 @@ ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [ * @fires ol.render.Event#precompose * @api */ -ol.CanvasMap = function(options) { - options = ol.obj.assign({}, options); +var _ol_CanvasMap_ = function(options) { + options = _ol_obj_.assign({}, options); delete options.renderer; if (!options.controls) { - options.controls = ol.control.defaults(); + options.controls = _ol_control_.defaults(); } if (!options.interactions) { - options.interactions = ol.interaction.defaults(); + options.interactions = _ol_interaction_.defaults(); } - ol.PluggableMap.call(this, options); + _ol_PluggableMap_.call(this, options); }; -ol.inherits(ol.CanvasMap, ol.PluggableMap); + +_ol_.inherits(_ol_CanvasMap_, _ol_PluggableMap_); +export default _ol_CanvasMap_; diff --git a/src/ol/CenterConstraint.js b/src/ol/CenterConstraint.js index abb55e654d..698fa62c85 100644 --- a/src/ol/CenterConstraint.js +++ b/src/ol/CenterConstraint.js @@ -1,13 +1,15 @@ -goog.provide('ol.CenterConstraint'); - -goog.require('ol.math'); +/** + * @module ol/CenterConstraint + */ +import _ol_math_ from './math.js'; +var _ol_CenterConstraint_ = {}; /** * @param {ol.Extent} extent Extent. * @return {ol.CenterConstraintType} The constraint. */ -ol.CenterConstraint.createExtent = function(extent) { +_ol_CenterConstraint_.createExtent = function(extent) { return ( /** * @param {ol.Coordinate|undefined} center Center. @@ -16,13 +18,14 @@ ol.CenterConstraint.createExtent = function(extent) { function(center) { if (center) { return [ - ol.math.clamp(center[0], extent[0], extent[2]), - ol.math.clamp(center[1], extent[1], extent[3]) + _ol_math_.clamp(center[0], extent[0], extent[2]), + _ol_math_.clamp(center[1], extent[1], extent[3]) ]; } else { return undefined; } - }); + } + ); }; @@ -30,6 +33,7 @@ ol.CenterConstraint.createExtent = function(extent) { * @param {ol.Coordinate|undefined} center Center. * @return {ol.Coordinate|undefined} Center. */ -ol.CenterConstraint.none = function(center) { +_ol_CenterConstraint_.none = function(center) { return center; }; +export default _ol_CenterConstraint_; diff --git a/src/ol/Collection.js b/src/ol/Collection.js index cea644b072..52a2f7bea8 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -1,16 +1,16 @@ +/** + * @module ol/Collection + */ /** * An implementation of Google Maps' MVCArray. * @see https://developers.google.com/maps/documentation/javascript/reference */ -goog.provide('ol.Collection'); - -goog.require('ol'); -goog.require('ol.AssertionError'); -goog.require('ol.CollectionEventType'); -goog.require('ol.Object'); -goog.require('ol.events.Event'); - +import _ol_ from './index.js'; +import _ol_AssertionError_ from './AssertionError.js'; +import _ol_CollectionEventType_ from './CollectionEventType.js'; +import _ol_Object_ from './Object.js'; +import _ol_events_Event_ from './events/Event.js'; /** * @classdesc @@ -28,9 +28,9 @@ goog.require('ol.events.Event'); * @template T * @api */ -ol.Collection = function(opt_array, opt_options) { +var _ol_Collection_ = function(opt_array, opt_options) { - ol.Object.call(this); + _ol_Object_.call(this); var options = opt_options || {}; @@ -55,14 +55,15 @@ ol.Collection = function(opt_array, opt_options) { this.updateLength_(); }; -ol.inherits(ol.Collection, ol.Object); + +_ol_.inherits(_ol_Collection_, _ol_Object_); /** * Remove all elements from the collection. * @api */ -ol.Collection.prototype.clear = function() { +_ol_Collection_.prototype.clear = function() { while (this.getLength() > 0) { this.pop(); } @@ -76,7 +77,7 @@ ol.Collection.prototype.clear = function() { * @return {ol.Collection.} This collection. * @api */ -ol.Collection.prototype.extend = function(arr) { +_ol_Collection_.prototype.extend = function(arr) { var i, ii; for (i = 0, ii = arr.length; i < ii; ++i) { this.push(arr[i]); @@ -94,7 +95,7 @@ ol.Collection.prototype.extend = function(arr) { * @template S * @api */ -ol.Collection.prototype.forEach = function(f, opt_this) { +_ol_Collection_.prototype.forEach = function(f, opt_this) { var fn = (opt_this) ? f.bind(opt_this) : f; var array = this.array_; for (var i = 0, ii = array.length; i < ii; ++i) { @@ -111,7 +112,7 @@ ol.Collection.prototype.forEach = function(f, opt_this) { * @return {!Array.} Array. * @api */ -ol.Collection.prototype.getArray = function() { +_ol_Collection_.prototype.getArray = function() { return this.array_; }; @@ -122,7 +123,7 @@ ol.Collection.prototype.getArray = function() { * @return {T} Element. * @api */ -ol.Collection.prototype.item = function(index) { +_ol_Collection_.prototype.item = function(index) { return this.array_[index]; }; @@ -133,8 +134,10 @@ ol.Collection.prototype.item = function(index) { * @observable * @api */ -ol.Collection.prototype.getLength = function() { - return /** @type {number} */ (this.get(ol.Collection.Property_.LENGTH)); +_ol_Collection_.prototype.getLength = function() { + return ( + /** @type {number} */ this.get(_ol_Collection_.Property_.LENGTH) + ); }; @@ -144,14 +147,14 @@ ol.Collection.prototype.getLength = function() { * @param {T} elem Element. * @api */ -ol.Collection.prototype.insertAt = function(index, elem) { +_ol_Collection_.prototype.insertAt = function(index, elem) { if (this.unique_) { this.assertUnique_(elem); } this.array_.splice(index, 0, elem); this.updateLength_(); this.dispatchEvent( - new ol.Collection.Event(ol.CollectionEventType.ADD, elem)); + new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); }; @@ -161,7 +164,7 @@ ol.Collection.prototype.insertAt = function(index, elem) { * @return {T|undefined} Element. * @api */ -ol.Collection.prototype.pop = function() { +_ol_Collection_.prototype.pop = function() { return this.removeAt(this.getLength() - 1); }; @@ -172,7 +175,7 @@ ol.Collection.prototype.pop = function() { * @return {number} New length of the collection. * @api */ -ol.Collection.prototype.push = function(elem) { +_ol_Collection_.prototype.push = function(elem) { if (this.unique_) { this.assertUnique_(elem); } @@ -188,7 +191,7 @@ ol.Collection.prototype.push = function(elem) { * @return {T|undefined} The removed element or undefined if none found. * @api */ -ol.Collection.prototype.remove = function(elem) { +_ol_Collection_.prototype.remove = function(elem) { var arr = this.array_; var i, ii; for (i = 0, ii = arr.length; i < ii; ++i) { @@ -207,12 +210,12 @@ ol.Collection.prototype.remove = function(elem) { * @return {T|undefined} Value. * @api */ -ol.Collection.prototype.removeAt = function(index) { +_ol_Collection_.prototype.removeAt = function(index) { var prev = this.array_[index]; this.array_.splice(index, 1); this.updateLength_(); this.dispatchEvent( - new ol.Collection.Event(ol.CollectionEventType.REMOVE, prev)); + new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); return prev; }; @@ -223,7 +226,7 @@ ol.Collection.prototype.removeAt = function(index) { * @param {T} elem Element. * @api */ -ol.Collection.prototype.setAt = function(index, elem) { +_ol_Collection_.prototype.setAt = function(index, elem) { var n = this.getLength(); if (index < n) { if (this.unique_) { @@ -232,9 +235,9 @@ ol.Collection.prototype.setAt = function(index, elem) { var prev = this.array_[index]; this.array_[index] = elem; this.dispatchEvent( - new ol.Collection.Event(ol.CollectionEventType.REMOVE, prev)); + new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); this.dispatchEvent( - new ol.Collection.Event(ol.CollectionEventType.ADD, elem)); + new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); } else { var j; for (j = n; j < index; ++j) { @@ -248,8 +251,8 @@ ol.Collection.prototype.setAt = function(index, elem) { /** * @private */ -ol.Collection.prototype.updateLength_ = function() { - this.set(ol.Collection.Property_.LENGTH, this.array_.length); +_ol_Collection_.prototype.updateLength_ = function() { + this.set(_ol_Collection_.Property_.LENGTH, this.array_.length); }; @@ -258,10 +261,10 @@ ol.Collection.prototype.updateLength_ = function() { * @param {T} elem Element. * @param {number=} opt_except Optional index to ignore. */ -ol.Collection.prototype.assertUnique_ = function(elem, opt_except) { +_ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) { for (var i = 0, ii = this.array_.length; i < ii; ++i) { if (this.array_[i] === elem && i !== opt_except) { - throw new ol.AssertionError(58); + throw new _ol_AssertionError_(58); } } }; @@ -271,7 +274,7 @@ ol.Collection.prototype.assertUnique_ = function(elem, opt_except) { * @enum {string} * @private */ -ol.Collection.Property_ = { +_ol_Collection_.Property_ = { LENGTH: 'length' }; @@ -287,9 +290,9 @@ ol.Collection.Property_ = { * @param {ol.CollectionEventType} type Type. * @param {*=} opt_element Element. */ -ol.Collection.Event = function(type, opt_element) { +_ol_Collection_.Event = function(type, opt_element) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The element that is added to or removed from the collection. @@ -299,4 +302,5 @@ ol.Collection.Event = function(type, opt_element) { this.element = opt_element; }; -ol.inherits(ol.Collection.Event, ol.events.Event); +_ol_.inherits(_ol_Collection_.Event, _ol_events_Event_); +export default _ol_Collection_; diff --git a/src/ol/CollectionEventType.js b/src/ol/CollectionEventType.js index e1e81877ad..78a71224d2 100644 --- a/src/ol/CollectionEventType.js +++ b/src/ol/CollectionEventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.CollectionEventType'); - +/** + * @module ol/CollectionEventType + */ /** * @enum {string} */ -ol.CollectionEventType = { +var _ol_CollectionEventType_ = { /** * Triggered when an item is added to the collection. * @event ol.Collection.Event#add @@ -17,3 +18,5 @@ ol.CollectionEventType = { */ REMOVE: 'remove' }; + +export default _ol_CollectionEventType_; diff --git a/src/ol/DeviceOrientation.js b/src/ol/DeviceOrientation.js index b78680658e..71bc027cb8 100644 --- a/src/ol/DeviceOrientation.js +++ b/src/ol/DeviceOrientation.js @@ -1,11 +1,11 @@ -goog.provide('ol.DeviceOrientation'); - -goog.require('ol.events'); -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.has'); -goog.require('ol.math'); - +/** + * @module ol/DeviceOrientation + */ +import _ol_events_ from './events.js'; +import _ol_ from './index.js'; +import _ol_Object_ from './Object.js'; +import _ol_has_ from './has.js'; +import _ol_math_ from './math.js'; /** * @classdesc @@ -64,9 +64,9 @@ goog.require('ol.math'); * @param {olx.DeviceOrientationOptions=} opt_options Options. * @api */ -ol.DeviceOrientation = function(opt_options) { +var _ol_DeviceOrientation_ = function(opt_options) { - ol.Object.call(this); + _ol_Object_.call(this); var options = opt_options ? opt_options : {}; @@ -76,22 +76,23 @@ ol.DeviceOrientation = function(opt_options) { */ this.listenerKey_ = null; - ol.events.listen(this, - ol.Object.getChangeEventType(ol.DeviceOrientation.Property_.TRACKING), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_DeviceOrientation_.Property_.TRACKING), this.handleTrackingChanged_, this); this.setTracking(options.tracking !== undefined ? options.tracking : false); }; -ol.inherits(ol.DeviceOrientation, ol.Object); + +_ol_.inherits(_ol_DeviceOrientation_, _ol_Object_); /** * @inheritDoc */ -ol.DeviceOrientation.prototype.disposeInternal = function() { +_ol_DeviceOrientation_.prototype.disposeInternal = function() { this.setTracking(false); - ol.Object.prototype.disposeInternal.call(this); + _ol_Object_.prototype.disposeInternal.call(this); }; @@ -99,27 +100,27 @@ ol.DeviceOrientation.prototype.disposeInternal = function() { * @private * @param {Event} originalEvent Event. */ -ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) { +_ol_DeviceOrientation_.prototype.orientationChange_ = function(originalEvent) { var event = /** @type {DeviceOrientationEvent} */ (originalEvent); if (event.alpha !== null) { - var alpha = ol.math.toRadians(event.alpha); - this.set(ol.DeviceOrientation.Property_.ALPHA, alpha); + var alpha = _ol_math_.toRadians(event.alpha); + this.set(_ol_DeviceOrientation_.Property_.ALPHA, alpha); // event.absolute is undefined in iOS. if (typeof event.absolute === 'boolean' && event.absolute) { - this.set(ol.DeviceOrientation.Property_.HEADING, alpha); + this.set(_ol_DeviceOrientation_.Property_.HEADING, alpha); } else if (typeof event.webkitCompassHeading === 'number' && event.webkitCompassAccuracy != -1) { - var heading = ol.math.toRadians(event.webkitCompassHeading); - this.set(ol.DeviceOrientation.Property_.HEADING, heading); + var heading = _ol_math_.toRadians(event.webkitCompassHeading); + this.set(_ol_DeviceOrientation_.Property_.HEADING, heading); } } if (event.beta !== null) { - this.set(ol.DeviceOrientation.Property_.BETA, - ol.math.toRadians(event.beta)); + this.set(_ol_DeviceOrientation_.Property_.BETA, + _ol_math_.toRadians(event.beta)); } if (event.gamma !== null) { - this.set(ol.DeviceOrientation.Property_.GAMMA, - ol.math.toRadians(event.gamma)); + this.set(_ol_DeviceOrientation_.Property_.GAMMA, + _ol_math_.toRadians(event.gamma)); } this.changed(); }; @@ -132,9 +133,10 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) { * @observable * @api */ -ol.DeviceOrientation.prototype.getAlpha = function() { - return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientation.Property_.ALPHA)); +_ol_DeviceOrientation_.prototype.getAlpha = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.ALPHA) + ); }; @@ -145,9 +147,10 @@ ol.DeviceOrientation.prototype.getAlpha = function() { * @observable * @api */ -ol.DeviceOrientation.prototype.getBeta = function() { - return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientation.Property_.BETA)); +_ol_DeviceOrientation_.prototype.getBeta = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.BETA) + ); }; @@ -158,9 +161,10 @@ ol.DeviceOrientation.prototype.getBeta = function() { * @observable * @api */ -ol.DeviceOrientation.prototype.getGamma = function() { - return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientation.Property_.GAMMA)); +_ol_DeviceOrientation_.prototype.getGamma = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.GAMMA) + ); }; @@ -171,9 +175,10 @@ ol.DeviceOrientation.prototype.getGamma = function() { * @observable * @api */ -ol.DeviceOrientation.prototype.getHeading = function() { - return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientation.Property_.HEADING)); +_ol_DeviceOrientation_.prototype.getHeading = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_DeviceOrientation_.Property_.HEADING) + ); }; @@ -183,23 +188,24 @@ ol.DeviceOrientation.prototype.getHeading = function() { * @observable * @api */ -ol.DeviceOrientation.prototype.getTracking = function() { - return /** @type {boolean} */ ( - this.get(ol.DeviceOrientation.Property_.TRACKING)); +_ol_DeviceOrientation_.prototype.getTracking = function() { + return ( + /** @type {boolean} */ this.get(_ol_DeviceOrientation_.Property_.TRACKING) + ); }; /** * @private */ -ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { - if (ol.has.DEVICE_ORIENTATION) { +_ol_DeviceOrientation_.prototype.handleTrackingChanged_ = function() { + if (_ol_has_.DEVICE_ORIENTATION) { var tracking = this.getTracking(); if (tracking && !this.listenerKey_) { - this.listenerKey_ = ol.events.listen(window, 'deviceorientation', + this.listenerKey_ = _ol_events_.listen(window, 'deviceorientation', this.orientationChange_, this); } else if (!tracking && this.listenerKey_ !== null) { - ol.events.unlistenByKey(this.listenerKey_); + _ol_events_.unlistenByKey(this.listenerKey_); this.listenerKey_ = null; } } @@ -213,8 +219,8 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { * @observable * @api */ -ol.DeviceOrientation.prototype.setTracking = function(tracking) { - this.set(ol.DeviceOrientation.Property_.TRACKING, tracking); +_ol_DeviceOrientation_.prototype.setTracking = function(tracking) { + this.set(_ol_DeviceOrientation_.Property_.TRACKING, tracking); }; @@ -222,10 +228,11 @@ ol.DeviceOrientation.prototype.setTracking = function(tracking) { * @enum {string} * @private */ -ol.DeviceOrientation.Property_ = { +_ol_DeviceOrientation_.Property_ = { ALPHA: 'alpha', BETA: 'beta', GAMMA: 'gamma', HEADING: 'heading', TRACKING: 'tracking' }; +export default _ol_DeviceOrientation_; diff --git a/src/ol/Disposable.js b/src/ol/Disposable.js index 42978aac89..db8315b133 100644 --- a/src/ol/Disposable.js +++ b/src/ol/Disposable.js @@ -1,24 +1,25 @@ -goog.provide('ol.Disposable'); - -goog.require('ol'); +/** + * @module ol/Disposable + */ +import _ol_ from './index.js'; /** * Objects that need to clean up after themselves. * @constructor */ -ol.Disposable = function() {}; +var _ol_Disposable_ = function() {}; /** * The object has already been disposed. * @type {boolean} * @private */ -ol.Disposable.prototype.disposed_ = false; +_ol_Disposable_.prototype.disposed_ = false; /** * Clean up. */ -ol.Disposable.prototype.dispose = function() { +_ol_Disposable_.prototype.dispose = function() { if (!this.disposed_) { this.disposed_ = true; this.disposeInternal(); @@ -29,4 +30,5 @@ ol.Disposable.prototype.dispose = function() { * Extension point for disposable objects. * @protected */ -ol.Disposable.prototype.disposeInternal = ol.nullFunction; +_ol_Disposable_.prototype.disposeInternal = _ol_.nullFunction; +export default _ol_Disposable_; diff --git a/src/ol/Feature.js b/src/ol/Feature.js index 66b371556f..9947eac82a 100644 --- a/src/ol/Feature.js +++ b/src/ol/Feature.js @@ -1,13 +1,13 @@ -goog.provide('ol.Feature'); - -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.geom.Geometry'); -goog.require('ol.style.Style'); - +/** + * @module ol/Feature + */ +import _ol_asserts_ from './asserts.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_ from './index.js'; +import _ol_Object_ from './Object.js'; +import _ol_geom_Geometry_ from './geom/Geometry.js'; +import _ol_style_Style_ from './style/Style.js'; /** * @classdesc @@ -54,9 +54,9 @@ goog.require('ol.style.Style'); * include a Geometry associated with a `geometry` key. * @api */ -ol.Feature = function(opt_geometryOrProperties) { +var _ol_Feature_ = function(opt_geometryOrProperties) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @private @@ -90,12 +90,12 @@ ol.Feature = function(opt_geometryOrProperties) { */ this.geometryChangeKey_ = null; - ol.events.listen( - this, ol.Object.getChangeEventType(this.geometryName_), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(this.geometryName_), this.handleGeometryChanged_, this); if (opt_geometryOrProperties !== undefined) { - if (opt_geometryOrProperties instanceof ol.geom.Geometry || + if (opt_geometryOrProperties instanceof _ol_geom_Geometry_ || !opt_geometryOrProperties) { var geometry = opt_geometryOrProperties; this.setGeometry(geometry); @@ -106,7 +106,8 @@ ol.Feature = function(opt_geometryOrProperties) { } } }; -ol.inherits(ol.Feature, ol.Object); + +_ol_.inherits(_ol_Feature_, _ol_Object_); /** @@ -115,8 +116,8 @@ ol.inherits(ol.Feature, ol.Object); * @return {ol.Feature} The clone. * @api */ -ol.Feature.prototype.clone = function() { - var clone = new ol.Feature(this.getProperties()); +_ol_Feature_.prototype.clone = function() { + var clone = new _ol_Feature_(this.getProperties()); clone.setGeometryName(this.getGeometryName()); var geometry = this.getGeometry(); if (geometry) { @@ -138,7 +139,7 @@ ol.Feature.prototype.clone = function() { * @api * @observable */ -ol.Feature.prototype.getGeometry = function() { +_ol_Feature_.prototype.getGeometry = function() { return /** @type {ol.geom.Geometry|undefined} */ ( this.get(this.geometryName_)); }; @@ -151,7 +152,7 @@ ol.Feature.prototype.getGeometry = function() { * @return {number|string|undefined} Id. * @api */ -ol.Feature.prototype.getId = function() { +_ol_Feature_.prototype.getId = function() { return this.id_; }; @@ -163,7 +164,7 @@ ol.Feature.prototype.getId = function() { * for this feature. * @api */ -ol.Feature.prototype.getGeometryName = function() { +_ol_Feature_.prototype.getGeometryName = function() { return this.geometryName_; }; @@ -175,7 +176,7 @@ ol.Feature.prototype.getGeometryName = function() { * ol.FeatureStyleFunction|ol.StyleFunction} The feature style. * @api */ -ol.Feature.prototype.getStyle = function() { +_ol_Feature_.prototype.getStyle = function() { return this.style_; }; @@ -186,7 +187,7 @@ ol.Feature.prototype.getStyle = function() { * representing the current style of this feature. * @api */ -ol.Feature.prototype.getStyleFunction = function() { +_ol_Feature_.prototype.getStyleFunction = function() { return this.styleFunction_; }; @@ -194,7 +195,7 @@ ol.Feature.prototype.getStyleFunction = function() { /** * @private */ -ol.Feature.prototype.handleGeometryChange_ = function() { +_ol_Feature_.prototype.handleGeometryChange_ = function() { this.changed(); }; @@ -202,15 +203,15 @@ ol.Feature.prototype.handleGeometryChange_ = function() { /** * @private */ -ol.Feature.prototype.handleGeometryChanged_ = function() { +_ol_Feature_.prototype.handleGeometryChanged_ = function() { if (this.geometryChangeKey_) { - ol.events.unlistenByKey(this.geometryChangeKey_); + _ol_events_.unlistenByKey(this.geometryChangeKey_); this.geometryChangeKey_ = null; } var geometry = this.getGeometry(); if (geometry) { - this.geometryChangeKey_ = ol.events.listen(geometry, - ol.events.EventType.CHANGE, this.handleGeometryChange_, this); + this.geometryChangeKey_ = _ol_events_.listen(geometry, + _ol_events_EventType_.CHANGE, this.handleGeometryChange_, this); } this.changed(); }; @@ -223,7 +224,7 @@ ol.Feature.prototype.handleGeometryChanged_ = function() { * @api * @observable */ -ol.Feature.prototype.setGeometry = function(geometry) { +_ol_Feature_.prototype.setGeometry = function(geometry) { this.set(this.geometryName_, geometry); }; @@ -237,10 +238,10 @@ ol.Feature.prototype.setGeometry = function(geometry) { * @api * @fires ol.events.Event#event:change */ -ol.Feature.prototype.setStyle = function(style) { +_ol_Feature_.prototype.setStyle = function(style) { this.style_ = style; this.styleFunction_ = !style ? - undefined : ol.Feature.createStyleFunction(style); + undefined : _ol_Feature_.createStyleFunction(style); this.changed(); }; @@ -254,7 +255,7 @@ ol.Feature.prototype.setStyle = function(style) { * @api * @fires ol.events.Event#event:change */ -ol.Feature.prototype.setId = function(id) { +_ol_Feature_.prototype.setId = function(id) { this.id_ = id; this.changed(); }; @@ -267,13 +268,13 @@ ol.Feature.prototype.setId = function(id) { * @param {string} name The property name of the default geometry. * @api */ -ol.Feature.prototype.setGeometryName = function(name) { - ol.events.unlisten( - this, ol.Object.getChangeEventType(this.geometryName_), +_ol_Feature_.prototype.setGeometryName = function(name) { + _ol_events_.unlisten( + this, _ol_Object_.getChangeEventType(this.geometryName_), this.handleGeometryChanged_, this); this.geometryName_ = name; - ol.events.listen( - this, ol.Object.getChangeEventType(this.geometryName_), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(this.geometryName_), this.handleGeometryChanged_, this); this.handleGeometryChanged_(); }; @@ -287,7 +288,7 @@ ol.Feature.prototype.setGeometryName = function(name) { * A feature style function, a single style, or an array of styles. * @return {ol.FeatureStyleFunction} A style function. */ -ol.Feature.createStyleFunction = function(obj) { +_ol_Feature_.createStyleFunction = function(obj) { var styleFunction; if (typeof obj === 'function') { @@ -306,7 +307,7 @@ ol.Feature.createStyleFunction = function(obj) { if (Array.isArray(obj)) { styles = obj; } else { - ol.asserts.assert(obj instanceof ol.style.Style, + _ol_asserts_.assert(obj instanceof _ol_style_Style_, 41); // Expected an `ol.style.Style` or an array of `ol.style.Style` styles = [obj]; } @@ -316,3 +317,4 @@ ol.Feature.createStyleFunction = function(obj) { } return styleFunction; }; +export default _ol_Feature_; diff --git a/src/ol/Geolocation.js b/src/ol/Geolocation.js index 1a6ecf2efc..eec6638af4 100644 --- a/src/ol/Geolocation.js +++ b/src/ol/Geolocation.js @@ -1,19 +1,19 @@ +/** + * @module ol/Geolocation + */ // FIXME handle geolocation not supported -goog.provide('ol.Geolocation'); - -goog.require('ol'); -goog.require('ol.GeolocationProperty'); -goog.require('ol.Object'); -goog.require('ol.Sphere'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.geom.Polygon'); -goog.require('ol.has'); -goog.require('ol.math'); -goog.require('ol.proj'); -goog.require('ol.proj.EPSG4326'); - +import _ol_ from './index.js'; +import _ol_GeolocationProperty_ from './GeolocationProperty.js'; +import _ol_Object_ from './Object.js'; +import _ol_Sphere_ from './Sphere.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_geom_Polygon_ from './geom/Polygon.js'; +import _ol_has_ from './has.js'; +import _ol_math_ from './math.js'; +import _ol_proj_ from './proj.js'; +import _ol_proj_EPSG4326_ from './proj/EPSG4326.js'; /** * @classdesc @@ -41,9 +41,9 @@ goog.require('ol.proj.EPSG4326'); * @param {olx.GeolocationOptions=} opt_options Options. * @api */ -ol.Geolocation = function(opt_options) { +var _ol_Geolocation_ = function(opt_options) { - ol.Object.call(this); + _ol_Object_.call(this); var options = opt_options || {}; @@ -58,13 +58,13 @@ ol.Geolocation = function(opt_options) { * @private * @type {ol.TransformFunction} */ - this.transform_ = ol.proj.identityTransform; + this.transform_ = _ol_proj_.identityTransform; /** * @private * @type {ol.Sphere} */ - this.sphere_ = new ol.Sphere(ol.proj.EPSG4326.RADIUS); + this.sphere_ = new _ol_Sphere_(_ol_proj_EPSG4326_.RADIUS); /** * @private @@ -72,11 +72,11 @@ ol.Geolocation = function(opt_options) { */ this.watchId_ = undefined; - ol.events.listen( - this, ol.Object.getChangeEventType(ol.GeolocationProperty.PROJECTION), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_GeolocationProperty_.PROJECTION), this.handleProjectionChanged_, this); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_GeolocationProperty_.TRACKING), this.handleTrackingChanged_, this); if (options.projection !== undefined) { @@ -89,29 +89,30 @@ ol.Geolocation = function(opt_options) { this.setTracking(options.tracking !== undefined ? options.tracking : false); }; -ol.inherits(ol.Geolocation, ol.Object); + +_ol_.inherits(_ol_Geolocation_, _ol_Object_); /** * @inheritDoc */ -ol.Geolocation.prototype.disposeInternal = function() { +_ol_Geolocation_.prototype.disposeInternal = function() { this.setTracking(false); - ol.Object.prototype.disposeInternal.call(this); + _ol_Object_.prototype.disposeInternal.call(this); }; /** * @private */ -ol.Geolocation.prototype.handleProjectionChanged_ = function() { +_ol_Geolocation_.prototype.handleProjectionChanged_ = function() { var projection = this.getProjection(); if (projection) { - this.transform_ = ol.proj.getTransformFromProjections( - ol.proj.get('EPSG:4326'), projection); + this.transform_ = _ol_proj_.getTransformFromProjections( + _ol_proj_.get('EPSG:4326'), projection); if (this.position_) { this.set( - ol.GeolocationProperty.POSITION, this.transform_(this.position_)); + _ol_GeolocationProperty_.POSITION, this.transform_(this.position_)); } } }; @@ -120,8 +121,8 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() { /** * @private */ -ol.Geolocation.prototype.handleTrackingChanged_ = function() { - if (ol.has.GEOLOCATION) { +_ol_Geolocation_.prototype.handleTrackingChanged_ = function() { + if (_ol_has_.GEOLOCATION) { var tracking = this.getTracking(); if (tracking && this.watchId_ === undefined) { this.watchId_ = navigator.geolocation.watchPosition( @@ -140,16 +141,16 @@ ol.Geolocation.prototype.handleTrackingChanged_ = function() { * @private * @param {GeolocationPosition} position position event. */ -ol.Geolocation.prototype.positionChange_ = function(position) { +_ol_Geolocation_.prototype.positionChange_ = function(position) { var coords = position.coords; - this.set(ol.GeolocationProperty.ACCURACY, coords.accuracy); - this.set(ol.GeolocationProperty.ALTITUDE, + this.set(_ol_GeolocationProperty_.ACCURACY, coords.accuracy); + this.set(_ol_GeolocationProperty_.ALTITUDE, coords.altitude === null ? undefined : coords.altitude); - this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY, + this.set(_ol_GeolocationProperty_.ALTITUDE_ACCURACY, coords.altitudeAccuracy === null ? undefined : coords.altitudeAccuracy); - this.set(ol.GeolocationProperty.HEADING, coords.heading === null ? - undefined : ol.math.toRadians(coords.heading)); + this.set(_ol_GeolocationProperty_.HEADING, coords.heading === null ? + undefined : _ol_math_.toRadians(coords.heading)); if (!this.position_) { this.position_ = [coords.longitude, coords.latitude]; } else { @@ -157,13 +158,13 @@ ol.Geolocation.prototype.positionChange_ = function(position) { this.position_[1] = coords.latitude; } var projectedPosition = this.transform_(this.position_); - this.set(ol.GeolocationProperty.POSITION, projectedPosition); - this.set(ol.GeolocationProperty.SPEED, + this.set(_ol_GeolocationProperty_.POSITION, projectedPosition); + this.set(_ol_GeolocationProperty_.SPEED, coords.speed === null ? undefined : coords.speed); - var geometry = ol.geom.Polygon.circular( + var geometry = _ol_geom_Polygon_.circular( this.sphere_, this.position_, coords.accuracy); geometry.applyTransform(this.transform_); - this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry); + this.set(_ol_GeolocationProperty_.ACCURACY_GEOMETRY, geometry); this.changed(); }; @@ -177,8 +178,8 @@ ol.Geolocation.prototype.positionChange_ = function(position) { * @private * @param {GeolocationPositionError} error error object. */ -ol.Geolocation.prototype.positionError_ = function(error) { - error.type = ol.events.EventType.ERROR; +_ol_Geolocation_.prototype.positionError_ = function(error) { + error.type = _ol_events_EventType_.ERROR; this.setTracking(false); this.dispatchEvent(/** @type {{type: string, target: undefined}} */ (error)); }; @@ -191,9 +192,10 @@ ol.Geolocation.prototype.positionError_ = function(error) { * @observable * @api */ -ol.Geolocation.prototype.getAccuracy = function() { - return /** @type {number|undefined} */ ( - this.get(ol.GeolocationProperty.ACCURACY)); +_ol_Geolocation_.prototype.getAccuracy = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ACCURACY) + ); }; @@ -203,9 +205,10 @@ ol.Geolocation.prototype.getAccuracy = function() { * @observable * @api */ -ol.Geolocation.prototype.getAccuracyGeometry = function() { - return /** @type {?ol.geom.Polygon} */ ( - this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null); +_ol_Geolocation_.prototype.getAccuracyGeometry = function() { + return ( + /** @type {?ol.geom.Polygon} */ this.get(_ol_GeolocationProperty_.ACCURACY_GEOMETRY) || null + ); }; @@ -216,9 +219,10 @@ ol.Geolocation.prototype.getAccuracyGeometry = function() { * @observable * @api */ -ol.Geolocation.prototype.getAltitude = function() { - return /** @type {number|undefined} */ ( - this.get(ol.GeolocationProperty.ALTITUDE)); +_ol_Geolocation_.prototype.getAltitude = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ALTITUDE) + ); }; @@ -229,9 +233,10 @@ ol.Geolocation.prototype.getAltitude = function() { * @observable * @api */ -ol.Geolocation.prototype.getAltitudeAccuracy = function() { - return /** @type {number|undefined} */ ( - this.get(ol.GeolocationProperty.ALTITUDE_ACCURACY)); +_ol_Geolocation_.prototype.getAltitudeAccuracy = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ALTITUDE_ACCURACY) + ); }; @@ -241,9 +246,10 @@ ol.Geolocation.prototype.getAltitudeAccuracy = function() { * @observable * @api */ -ol.Geolocation.prototype.getHeading = function() { - return /** @type {number|undefined} */ ( - this.get(ol.GeolocationProperty.HEADING)); +_ol_Geolocation_.prototype.getHeading = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.HEADING) + ); }; @@ -254,9 +260,10 @@ ol.Geolocation.prototype.getHeading = function() { * @observable * @api */ -ol.Geolocation.prototype.getPosition = function() { - return /** @type {ol.Coordinate|undefined} */ ( - this.get(ol.GeolocationProperty.POSITION)); +_ol_Geolocation_.prototype.getPosition = function() { + return ( + /** @type {ol.Coordinate|undefined} */ this.get(_ol_GeolocationProperty_.POSITION) + ); }; @@ -267,9 +274,10 @@ ol.Geolocation.prototype.getPosition = function() { * @observable * @api */ -ol.Geolocation.prototype.getProjection = function() { - return /** @type {ol.proj.Projection|undefined} */ ( - this.get(ol.GeolocationProperty.PROJECTION)); +_ol_Geolocation_.prototype.getProjection = function() { + return ( + /** @type {ol.proj.Projection|undefined} */ this.get(_ol_GeolocationProperty_.PROJECTION) + ); }; @@ -280,9 +288,10 @@ ol.Geolocation.prototype.getProjection = function() { * @observable * @api */ -ol.Geolocation.prototype.getSpeed = function() { - return /** @type {number|undefined} */ ( - this.get(ol.GeolocationProperty.SPEED)); +_ol_Geolocation_.prototype.getSpeed = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.SPEED) + ); }; @@ -292,9 +301,10 @@ ol.Geolocation.prototype.getSpeed = function() { * @observable * @api */ -ol.Geolocation.prototype.getTracking = function() { - return /** @type {boolean} */ ( - this.get(ol.GeolocationProperty.TRACKING)); +_ol_Geolocation_.prototype.getTracking = function() { + return ( + /** @type {boolean} */ this.get(_ol_GeolocationProperty_.TRACKING) + ); }; @@ -307,9 +317,10 @@ ol.Geolocation.prototype.getTracking = function() { * @observable * @api */ -ol.Geolocation.prototype.getTrackingOptions = function() { - return /** @type {GeolocationPositionOptions|undefined} */ ( - this.get(ol.GeolocationProperty.TRACKING_OPTIONS)); +_ol_Geolocation_.prototype.getTrackingOptions = function() { + return ( + /** @type {GeolocationPositionOptions|undefined} */ this.get(_ol_GeolocationProperty_.TRACKING_OPTIONS) + ); }; @@ -320,8 +331,8 @@ ol.Geolocation.prototype.getTrackingOptions = function() { * @observable * @api */ -ol.Geolocation.prototype.setProjection = function(projection) { - this.set(ol.GeolocationProperty.PROJECTION, ol.proj.get(projection)); +_ol_Geolocation_.prototype.setProjection = function(projection) { + this.set(_ol_GeolocationProperty_.PROJECTION, _ol_proj_.get(projection)); }; @@ -331,8 +342,8 @@ ol.Geolocation.prototype.setProjection = function(projection) { * @observable * @api */ -ol.Geolocation.prototype.setTracking = function(tracking) { - this.set(ol.GeolocationProperty.TRACKING, tracking); +_ol_Geolocation_.prototype.setTracking = function(tracking) { + this.set(_ol_GeolocationProperty_.TRACKING, tracking); }; @@ -345,6 +356,7 @@ ol.Geolocation.prototype.setTracking = function(tracking) { * @observable * @api */ -ol.Geolocation.prototype.setTrackingOptions = function(options) { - this.set(ol.GeolocationProperty.TRACKING_OPTIONS, options); +_ol_Geolocation_.prototype.setTrackingOptions = function(options) { + this.set(_ol_GeolocationProperty_.TRACKING_OPTIONS, options); }; +export default _ol_Geolocation_; diff --git a/src/ol/GeolocationProperty.js b/src/ol/GeolocationProperty.js index 08017cf714..087e7aa842 100644 --- a/src/ol/GeolocationProperty.js +++ b/src/ol/GeolocationProperty.js @@ -1,10 +1,10 @@ -goog.provide('ol.GeolocationProperty'); - - +/** + * @module ol/GeolocationProperty + */ /** * @enum {string} */ -ol.GeolocationProperty = { +var _ol_GeolocationProperty_ = { ACCURACY: 'accuracy', ACCURACY_GEOMETRY: 'accuracyGeometry', ALTITUDE: 'altitude', @@ -16,3 +16,5 @@ ol.GeolocationProperty = { TRACKING: 'tracking', TRACKING_OPTIONS: 'trackingOptions' }; + +export default _ol_GeolocationProperty_; diff --git a/src/ol/Graticule.js b/src/ol/Graticule.js index a35eb51b41..07bf3b887a 100644 --- a/src/ol/Graticule.js +++ b/src/ol/Graticule.js @@ -1,18 +1,18 @@ -goog.provide('ol.Graticule'); - -goog.require('ol.coordinate'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.flat.geodesic'); -goog.require('ol.math'); -goog.require('ol.proj'); -goog.require('ol.render.EventType'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Text'); - +/** + * @module ol/Graticule + */ +import _ol_coordinate_ from './coordinate.js'; +import _ol_extent_ from './extent.js'; +import _ol_geom_GeometryLayout_ from './geom/GeometryLayout.js'; +import _ol_geom_LineString_ from './geom/LineString.js'; +import _ol_geom_Point_ from './geom/Point.js'; +import _ol_geom_flat_geodesic_ from './geom/flat/geodesic.js'; +import _ol_math_ from './math.js'; +import _ol_proj_ from './proj.js'; +import _ol_render_EventType_ from './render/EventType.js'; +import _ol_style_Fill_ from './style/Fill.js'; +import _ol_style_Stroke_ from './style/Stroke.js'; +import _ol_style_Text_ from './style/Text.js'; /** * Render a grid for a coordinate system on a map. @@ -20,7 +20,7 @@ goog.require('ol.style.Text'); * @param {olx.GraticuleOptions=} opt_options Options. * @api */ -ol.Graticule = function(opt_options) { +var _ol_Graticule_ = function(opt_options) { var options = opt_options || {}; /** @@ -113,7 +113,7 @@ ol.Graticule = function(opt_options) { * @private */ this.strokeStyle_ = options.strokeStyle !== undefined ? - options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_; + options.strokeStyle : _ol_Graticule_.DEFAULT_STROKE_STYLE_; /** * @type {ol.TransformFunction|undefined} @@ -146,7 +146,7 @@ ol.Graticule = function(opt_options) { this.parallelsLabels_ = null; if (options.showLabels == true) { - var degreesToString = ol.coordinate.degreesToStringHDMS; + var degreesToString = _ol_coordinate_.degreesToStringHDMS; /** * @type {null|function(number):string} @@ -185,13 +185,13 @@ ol.Graticule = function(opt_options) { * @private */ this.lonLabelStyle_ = options.lonLabelStyle !== undefined ? options.lonLabelStyle : - new ol.style.Text({ + new _ol_style_Text_({ font: '12px Calibri,sans-serif', textBaseline: 'bottom', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,0,1)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255,255,255,1)', width: 3 }) @@ -202,13 +202,13 @@ ol.Graticule = function(opt_options) { * @private */ this.latLabelStyle_ = options.latLabelStyle !== undefined ? options.latLabelStyle : - new ol.style.Text({ + new _ol_style_Text_({ font: '12px Calibri,sans-serif', textAlign: 'end', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,0,1)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'rgba(255,255,255,1)', width: 3 }) @@ -227,7 +227,7 @@ ol.Graticule = function(opt_options) { * @private * @const */ -ol.Graticule.DEFAULT_STROKE_STYLE_ = new ol.style.Stroke({ +_ol_Graticule_.DEFAULT_STROKE_STYLE_ = new _ol_style_Stroke_({ color: 'rgba(0,0,0,0.2)' }); @@ -237,7 +237,7 @@ ol.Graticule.DEFAULT_STROKE_STYLE_ = new ol.style.Stroke({ * @type {Array.} * @private */ -ol.Graticule.intervals_ = [90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, +_ol_Graticule_.intervals_ = [90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001]; @@ -251,10 +251,10 @@ ol.Graticule.intervals_ = [90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, * @return {number} Index. * @private */ -ol.Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) { +_ol_Graticule_.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) { var lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index); - if (ol.extent.intersects(lineString.getExtent(), extent)) { + if (_ol_extent_.intersects(lineString.getExtent(), extent)) { if (this.meridiansLabels_) { var textPoint = this.getMeridianPoint_(lineString, extent, index); this.meridiansLabels_[index] = { @@ -274,16 +274,16 @@ ol.Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredToler * @return {ol.geom.Point} Meridian point. * @private */ -ol.Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) { +_ol_Graticule_.prototype.getMeridianPoint_ = function(lineString, extent, index) { var flatCoordinates = lineString.getFlatCoordinates(); var clampedBottom = Math.max(extent[1], flatCoordinates[1]); var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]); - var lat = ol.math.clamp( + var lat = _ol_math_.clamp( extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_, clampedBottom, clampedTop); var coordinate = [flatCoordinates[0], lat]; var point = this.meridiansLabels_[index] !== undefined ? - this.meridiansLabels_[index].geom : new ol.geom.Point(null); + this.meridiansLabels_[index].geom : new _ol_geom_Point_(null); point.setCoordinates(coordinate); return point; }; @@ -299,10 +299,10 @@ ol.Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) { * @return {number} Index. * @private */ -ol.Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) { +_ol_Graticule_.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) { var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index); - if (ol.extent.intersects(lineString.getExtent(), extent)) { + if (_ol_extent_.intersects(lineString.getExtent(), extent)) { if (this.parallelsLabels_) { var textPoint = this.getParallelPoint_(lineString, extent, index); this.parallelsLabels_[index] = { @@ -323,16 +323,16 @@ ol.Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredToler * @return {ol.geom.Point} Parallel point. * @private */ -ol.Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) { +_ol_Graticule_.prototype.getParallelPoint_ = function(lineString, extent, index) { var flatCoordinates = lineString.getFlatCoordinates(); var clampedLeft = Math.max(extent[0], flatCoordinates[0]); var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]); - var lon = ol.math.clamp( + var lon = _ol_math_.clamp( extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_, clampedLeft, clampedRight); var coordinate = [lon, flatCoordinates[1]]; var point = this.parallelsLabels_[index] !== undefined ? - this.parallelsLabels_[index].geom : new ol.geom.Point(null); + this.parallelsLabels_[index].geom : new _ol_geom_Point_(null); point.setCoordinates(coordinate); return point; }; @@ -345,7 +345,7 @@ ol.Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) { * @param {number} squaredTolerance Squared tolerance. * @private */ -ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, squaredTolerance) { +_ol_Graticule_.prototype.createGraticule_ = function(extent, center, resolution, squaredTolerance) { var interval = this.getInterval_(resolution); if (interval == -1) { @@ -372,7 +372,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s Math.min(extent[3], this.maxLatP_) ]; - validExtent = ol.proj.transformExtent(validExtent, this.projection_, + validExtent = _ol_proj_.transformExtent(validExtent, this.projection_, 'EPSG:4326'); var maxLat = validExtent[3]; var maxLon = validExtent[2]; @@ -382,7 +382,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s // Create meridians centerLon = Math.floor(centerLon / interval) * interval; - lon = ol.math.clamp(centerLon, this.minLon_, this.maxLon_); + lon = _ol_math_.clamp(centerLon, this.minLon_, this.maxLon_); idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0); @@ -392,7 +392,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx); } - lon = ol.math.clamp(centerLon, this.minLon_, this.maxLon_); + lon = _ol_math_.clamp(centerLon, this.minLon_, this.maxLon_); cnt = 0; while (lon != this.maxLon_ && cnt++ < maxLines) { @@ -408,7 +408,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s // Create parallels centerLat = Math.floor(centerLat / interval) * interval; - lat = ol.math.clamp(centerLat, this.minLat_, this.maxLat_); + lat = _ol_math_.clamp(centerLat, this.minLat_, this.maxLat_); idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0); @@ -418,7 +418,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx); } - lat = ol.math.clamp(centerLat, this.minLat_, this.maxLat_); + lat = _ol_math_.clamp(centerLat, this.minLat_, this.maxLat_); cnt = 0; while (lat != this.maxLat_ && cnt++ < maxLines) { @@ -439,7 +439,7 @@ ol.Graticule.prototype.createGraticule_ = function(extent, center, resolution, s * @return {number} The interval in degrees. * @private */ -ol.Graticule.prototype.getInterval_ = function(resolution) { +_ol_Graticule_.prototype.getInterval_ = function(resolution) { var centerLon = this.projectionCenterLonLat_[0]; var centerLat = this.projectionCenterLonLat_[1]; var interval = -1; @@ -449,8 +449,8 @@ ol.Graticule.prototype.getInterval_ = function(resolution) { var p1 = []; /** @type {Array.} **/ var p2 = []; - for (i = 0, ii = ol.Graticule.intervals_.length; i < ii; ++i) { - delta = ol.Graticule.intervals_[i] / 2; + for (i = 0, ii = _ol_Graticule_.intervals_.length; i < ii; ++i) { + delta = _ol_Graticule_.intervals_[i] / 2; p1[0] = centerLon - delta; p1[1] = centerLat - delta; p2[0] = centerLon + delta; @@ -461,7 +461,7 @@ ol.Graticule.prototype.getInterval_ = function(resolution) { if (dist <= target) { break; } - interval = ol.Graticule.intervals_[i]; + interval = _ol_Graticule_.intervals_[i]; } return interval; }; @@ -472,7 +472,7 @@ ol.Graticule.prototype.getInterval_ = function(resolution) { * @return {ol.PluggableMap} The map. * @api */ -ol.Graticule.prototype.getMap = function() { +_ol_Graticule_.prototype.getMap = function() { return this.map_; }; @@ -486,13 +486,13 @@ ol.Graticule.prototype.getMap = function() { * @param {number} index Index. * @private */ -ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, +_ol_Graticule_.prototype.getMeridian_ = function(lon, minLat, maxLat, squaredTolerance, index) { - var flatCoordinates = ol.geom.flat.geodesic.meridian(lon, + var flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon, minLat, maxLat, this.projection_, squaredTolerance); var lineString = this.meridians_[index] !== undefined ? - this.meridians_[index] : new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); + this.meridians_[index] : new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, flatCoordinates); return lineString; }; @@ -502,7 +502,7 @@ ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, * @return {Array.} The meridians. * @api */ -ol.Graticule.prototype.getMeridians = function() { +_ol_Graticule_.prototype.getMeridians = function() { return this.meridians_; }; @@ -516,13 +516,13 @@ ol.Graticule.prototype.getMeridians = function() { * @param {number} index Index. * @private */ -ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, +_ol_Graticule_.prototype.getParallel_ = function(lat, minLon, maxLon, squaredTolerance, index) { - var flatCoordinates = ol.geom.flat.geodesic.parallel(lat, + var flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat, minLon, maxLon, this.projection_, squaredTolerance); var lineString = this.parallels_[index] !== undefined ? - this.parallels_[index] : new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); + this.parallels_[index] : new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, flatCoordinates); return lineString; }; @@ -532,7 +532,7 @@ ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, * @return {Array.} The parallels. * @api */ -ol.Graticule.prototype.getParallels = function() { +_ol_Graticule_.prototype.getParallels = function() { return this.parallels_; }; @@ -541,7 +541,7 @@ ol.Graticule.prototype.getParallels = function() { * @param {ol.render.Event} e Event. * @private */ -ol.Graticule.prototype.handlePostCompose_ = function(e) { +_ol_Graticule_.prototype.handlePostCompose_ = function(e) { var vectorContext = e.vectorContext; var frameState = e.frameState; var extent = frameState.extent; @@ -554,7 +554,7 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) { resolution * resolution / (4 * pixelRatio * pixelRatio); var updateProjectionInfo = !this.projection_ || - !ol.proj.equivalent(this.projection_, projection); + !_ol_proj_.equivalent(this.projection_, projection); if (updateProjectionInfo) { this.updateProjectionInfo_(projection); @@ -597,12 +597,12 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) { * @param {ol.proj.Projection} projection Projection. * @private */ -ol.Graticule.prototype.updateProjectionInfo_ = function(projection) { - var epsg4326Projection = ol.proj.get('EPSG:4326'); +_ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) { + var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var extent = projection.getExtent(); var worldExtent = projection.getWorldExtent(); - var worldExtentP = ol.proj.transformExtent(worldExtent, + var worldExtentP = _ol_proj_.transformExtent(worldExtent, epsg4326Projection, projection); var maxLat = worldExtent[3]; @@ -626,14 +626,14 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) { this.minLonP_ = minLonP; - this.fromLonLatTransform_ = ol.proj.getTransform( + this.fromLonLatTransform_ = _ol_proj_.getTransform( epsg4326Projection, projection); - this.toLonLatTransform_ = ol.proj.getTransform( + this.toLonLatTransform_ = _ol_proj_.getTransform( projection, epsg4326Projection); this.projectionCenterLonLat_ = this.toLonLatTransform_( - ol.extent.getCenter(extent)); + _ol_extent_.getCenter(extent)); this.projection_ = projection; }; @@ -645,16 +645,17 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) { * @param {ol.PluggableMap} map Map. * @api */ -ol.Graticule.prototype.setMap = function(map) { +_ol_Graticule_.prototype.setMap = function(map) { if (this.map_) { - this.map_.un(ol.render.EventType.POSTCOMPOSE, + this.map_.un(_ol_render_EventType_.POSTCOMPOSE, this.handlePostCompose_, this); this.map_.render(); } if (map) { - map.on(ol.render.EventType.POSTCOMPOSE, + map.on(_ol_render_EventType_.POSTCOMPOSE, this.handlePostCompose_, this); map.render(); } this.map_ = map; }; +export default _ol_Graticule_; diff --git a/src/ol/Image.js b/src/ol/Image.js index 4c49259f1e..be19a01ba1 100644 --- a/src/ol/Image.js +++ b/src/ol/Image.js @@ -1,12 +1,12 @@ -goog.provide('ol.Image'); - -goog.require('ol'); -goog.require('ol.ImageBase'); -goog.require('ol.ImageState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); - +/** + * @module ol/Image + */ +import _ol_ from './index.js'; +import _ol_ImageBase_ from './ImageBase.js'; +import _ol_ImageState_ from './ImageState.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_extent_ from './extent.js'; /** * @constructor @@ -18,9 +18,9 @@ goog.require('ol.extent'); * @param {?string} crossOrigin Cross origin. * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. */ -ol.Image = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) { +var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) { - ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.ImageState.IDLE); + _ol_ImageBase_.call(this, extent, resolution, pixelRatio, _ol_ImageState_.IDLE); /** * @private @@ -47,7 +47,7 @@ ol.Image = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadF * @protected * @type {ol.ImageState} */ - this.state = ol.ImageState.IDLE; + this.state = _ol_ImageState_.IDLE; /** * @private @@ -56,14 +56,15 @@ ol.Image = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadF this.imageLoadFunction_ = imageLoadFunction; }; -ol.inherits(ol.Image, ol.ImageBase); + +_ol_.inherits(_ol_Image_, _ol_ImageBase_); /** * @inheritDoc * @api */ -ol.Image.prototype.getImage = function() { +_ol_Image_.prototype.getImage = function() { return this.image_; }; @@ -73,8 +74,8 @@ ol.Image.prototype.getImage = function() { * * @private */ -ol.Image.prototype.handleImageError_ = function() { - this.state = ol.ImageState.ERROR; +_ol_Image_.prototype.handleImageError_ = function() { + this.state = _ol_ImageState_.ERROR; this.unlistenImage_(); this.changed(); }; @@ -85,11 +86,11 @@ ol.Image.prototype.handleImageError_ = function() { * * @private */ -ol.Image.prototype.handleImageLoad_ = function() { +_ol_Image_.prototype.handleImageLoad_ = function() { if (this.resolution === undefined) { - this.resolution = ol.extent.getHeight(this.extent) / this.image_.height; + this.resolution = _ol_extent_.getHeight(this.extent) / this.image_.height; } - this.state = ol.ImageState.LOADED; + this.state = _ol_ImageState_.LOADED; this.unlistenImage_(); this.changed(); }; @@ -102,14 +103,14 @@ ol.Image.prototype.handleImageLoad_ = function() { * @override * @api */ -ol.Image.prototype.load = function() { - if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) { - this.state = ol.ImageState.LOADING; +_ol_Image_.prototype.load = function() { + if (this.state == _ol_ImageState_.IDLE || this.state == _ol_ImageState_.ERROR) { + this.state = _ol_ImageState_.LOADING; this.changed(); this.imageListenerKeys_ = [ - ol.events.listenOnce(this.image_, ol.events.EventType.ERROR, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.ERROR, this.handleImageError_, this), - ol.events.listenOnce(this.image_, ol.events.EventType.LOAD, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.LOAD, this.handleImageLoad_, this) ]; this.imageLoadFunction_(this, this.src_); @@ -120,7 +121,7 @@ ol.Image.prototype.load = function() { /** * @param {HTMLCanvasElement|Image|HTMLVideoElement} image Image. */ -ol.Image.prototype.setImage = function(image) { +_ol_Image_.prototype.setImage = function(image) { this.image_ = image; }; @@ -130,7 +131,8 @@ ol.Image.prototype.setImage = function(image) { * * @private */ -ol.Image.prototype.unlistenImage_ = function() { - this.imageListenerKeys_.forEach(ol.events.unlistenByKey); +_ol_Image_.prototype.unlistenImage_ = function() { + this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey); this.imageListenerKeys_ = null; }; +export default _ol_Image_; diff --git a/src/ol/ImageBase.js b/src/ol/ImageBase.js index 7ce6e3bcb1..08469e278d 100644 --- a/src/ol/ImageBase.js +++ b/src/ol/ImageBase.js @@ -1,9 +1,9 @@ -goog.provide('ol.ImageBase'); - -goog.require('ol'); -goog.require('ol.events.EventTarget'); -goog.require('ol.events.EventType'); - +/** + * @module ol/ImageBase + */ +import _ol_ from './index.js'; +import _ol_events_EventTarget_ from './events/EventTarget.js'; +import _ol_events_EventType_ from './events/EventType.js'; /** * @constructor @@ -14,9 +14,9 @@ goog.require('ol.events.EventType'); * @param {number} pixelRatio Pixel ratio. * @param {ol.ImageState} state State. */ -ol.ImageBase = function(extent, resolution, pixelRatio, state) { +var _ol_ImageBase_ = function(extent, resolution, pixelRatio, state) { - ol.events.EventTarget.call(this); + _ol_events_EventTarget_.call(this); /** * @protected @@ -43,21 +43,22 @@ ol.ImageBase = function(extent, resolution, pixelRatio, state) { this.state = state; }; -ol.inherits(ol.ImageBase, ol.events.EventTarget); + +_ol_.inherits(_ol_ImageBase_, _ol_events_EventTarget_); /** * @protected */ -ol.ImageBase.prototype.changed = function() { - this.dispatchEvent(ol.events.EventType.CHANGE); +_ol_ImageBase_.prototype.changed = function() { + this.dispatchEvent(_ol_events_EventType_.CHANGE); }; /** * @return {ol.Extent} Extent. */ -ol.ImageBase.prototype.getExtent = function() { +_ol_ImageBase_.prototype.getExtent = function() { return this.extent; }; @@ -66,13 +67,13 @@ ol.ImageBase.prototype.getExtent = function() { * @abstract * @return {HTMLCanvasElement|Image|HTMLVideoElement} Image. */ -ol.ImageBase.prototype.getImage = function() {}; +_ol_ImageBase_.prototype.getImage = function() {}; /** * @return {number} PixelRatio. */ -ol.ImageBase.prototype.getPixelRatio = function() { +_ol_ImageBase_.prototype.getPixelRatio = function() { return this.pixelRatio_; }; @@ -80,7 +81,7 @@ ol.ImageBase.prototype.getPixelRatio = function() { /** * @return {number} Resolution. */ -ol.ImageBase.prototype.getResolution = function() { +_ol_ImageBase_.prototype.getResolution = function() { return /** @type {number} */ (this.resolution); }; @@ -88,7 +89,7 @@ ol.ImageBase.prototype.getResolution = function() { /** * @return {ol.ImageState} State. */ -ol.ImageBase.prototype.getState = function() { +_ol_ImageBase_.prototype.getState = function() { return this.state; }; @@ -97,4 +98,5 @@ ol.ImageBase.prototype.getState = function() { * Load not yet loaded URI. * @abstract */ -ol.ImageBase.prototype.load = function() {}; +_ol_ImageBase_.prototype.load = function() {}; +export default _ol_ImageBase_; diff --git a/src/ol/ImageCanvas.js b/src/ol/ImageCanvas.js index 23aff4a0ca..8598f5d89a 100644 --- a/src/ol/ImageCanvas.js +++ b/src/ol/ImageCanvas.js @@ -1,9 +1,9 @@ -goog.provide('ol.ImageCanvas'); - -goog.require('ol'); -goog.require('ol.ImageBase'); -goog.require('ol.ImageState'); - +/** + * @module ol/ImageCanvas + */ +import _ol_ from './index.js'; +import _ol_ImageBase_ from './ImageBase.js'; +import _ol_ImageState_ from './ImageState.js'; /** * @constructor @@ -15,7 +15,7 @@ goog.require('ol.ImageState'); * @param {ol.ImageCanvasLoader=} opt_loader Optional loader function to * support asynchronous canvas drawing. */ -ol.ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) { +var _ol_ImageCanvas_ = function(extent, resolution, pixelRatio, canvas, opt_loader) { /** * Optional canvas loader function. @@ -25,9 +25,9 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) { this.loader_ = opt_loader !== undefined ? opt_loader : null; var state = opt_loader !== undefined ? - ol.ImageState.IDLE : ol.ImageState.LOADED; + _ol_ImageState_.IDLE : _ol_ImageState_.LOADED; - ol.ImageBase.call(this, extent, resolution, pixelRatio, state); + _ol_ImageBase_.call(this, extent, resolution, pixelRatio, state); /** * @private @@ -42,14 +42,15 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) { this.error_ = null; }; -ol.inherits(ol.ImageCanvas, ol.ImageBase); + +_ol_.inherits(_ol_ImageCanvas_, _ol_ImageBase_); /** * Get any error associated with asynchronous rendering. * @return {Error} Any error that occurred during rendering. */ -ol.ImageCanvas.prototype.getError = function() { +_ol_ImageCanvas_.prototype.getError = function() { return this.error_; }; @@ -59,12 +60,12 @@ ol.ImageCanvas.prototype.getError = function() { * @param {Error} err Any error during drawing. * @private */ -ol.ImageCanvas.prototype.handleLoad_ = function(err) { +_ol_ImageCanvas_.prototype.handleLoad_ = function(err) { if (err) { this.error_ = err; - this.state = ol.ImageState.ERROR; + this.state = _ol_ImageState_.ERROR; } else { - this.state = ol.ImageState.LOADED; + this.state = _ol_ImageState_.LOADED; } this.changed(); }; @@ -73,9 +74,9 @@ ol.ImageCanvas.prototype.handleLoad_ = function(err) { /** * @inheritDoc */ -ol.ImageCanvas.prototype.load = function() { - if (this.state == ol.ImageState.IDLE) { - this.state = ol.ImageState.LOADING; +_ol_ImageCanvas_.prototype.load = function() { + if (this.state == _ol_ImageState_.IDLE) { + this.state = _ol_ImageState_.LOADING; this.changed(); this.loader_(this.handleLoad_.bind(this)); } @@ -85,6 +86,7 @@ ol.ImageCanvas.prototype.load = function() { /** * @inheritDoc */ -ol.ImageCanvas.prototype.getImage = function() { +_ol_ImageCanvas_.prototype.getImage = function() { return this.canvas_; }; +export default _ol_ImageCanvas_; diff --git a/src/ol/ImageState.js b/src/ol/ImageState.js index 57b795f652..865680689a 100644 --- a/src/ol/ImageState.js +++ b/src/ol/ImageState.js @@ -1,11 +1,14 @@ -goog.provide('ol.ImageState'); - +/** + * @module ol/ImageState + */ /** * @enum {number} */ -ol.ImageState = { +var _ol_ImageState_ = { IDLE: 0, LOADING: 1, LOADED: 2, ERROR: 3 }; + +export default _ol_ImageState_; diff --git a/src/ol/ImageTile.js b/src/ol/ImageTile.js index acbb67e4b1..6a74473cc0 100644 --- a/src/ol/ImageTile.js +++ b/src/ol/ImageTile.js @@ -1,12 +1,12 @@ -goog.provide('ol.ImageTile'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); - +/** + * @module ol/ImageTile + */ +import _ol_ from './index.js'; +import _ol_Tile_ from './Tile.js'; +import _ol_TileState_ from './TileState.js'; +import _ol_dom_ from './dom.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventType_ from './events/EventType.js'; /** * @constructor @@ -18,9 +18,9 @@ goog.require('ol.events.EventType'); * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {olx.TileOptions=} opt_options Tile options. */ -ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { +var _ol_ImageTile_ = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { - ol.Tile.call(this, tileCoord, state, opt_options); + _ol_Tile_.call(this, tileCoord, state, opt_options); /** * @private @@ -58,23 +58,24 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, op this.tileLoadFunction_ = tileLoadFunction; }; -ol.inherits(ol.ImageTile, ol.Tile); + +_ol_.inherits(_ol_ImageTile_, _ol_Tile_); /** * @inheritDoc */ -ol.ImageTile.prototype.disposeInternal = function() { - if (this.state == ol.TileState.LOADING) { +_ol_ImageTile_.prototype.disposeInternal = function() { + if (this.state == _ol_TileState_.LOADING) { this.unlistenImage_(); - this.image_ = ol.ImageTile.getBlankImage(); + this.image_ = _ol_ImageTile_.getBlankImage(); } if (this.interimTile) { this.interimTile.dispose(); } - this.state = ol.TileState.ABORT; + this.state = _ol_TileState_.ABORT; this.changed(); - ol.Tile.prototype.disposeInternal.call(this); + _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -83,7 +84,7 @@ ol.ImageTile.prototype.disposeInternal = function() { * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. * @api */ -ol.ImageTile.prototype.getImage = function() { +_ol_ImageTile_.prototype.getImage = function() { return this.image_; }; @@ -91,7 +92,7 @@ ol.ImageTile.prototype.getImage = function() { /** * @inheritDoc */ -ol.ImageTile.prototype.getKey = function() { +_ol_ImageTile_.prototype.getKey = function() { return this.src_; }; @@ -101,10 +102,10 @@ ol.ImageTile.prototype.getKey = function() { * * @private */ -ol.ImageTile.prototype.handleImageError_ = function() { - this.state = ol.TileState.ERROR; +_ol_ImageTile_.prototype.handleImageError_ = function() { + this.state = _ol_TileState_.ERROR; this.unlistenImage_(); - this.image_ = ol.ImageTile.getBlankImage(); + this.image_ = _ol_ImageTile_.getBlankImage(); this.changed(); }; @@ -114,11 +115,11 @@ ol.ImageTile.prototype.handleImageError_ = function() { * * @private */ -ol.ImageTile.prototype.handleImageLoad_ = function() { +_ol_ImageTile_.prototype.handleImageLoad_ = function() { if (this.image_.naturalWidth && this.image_.naturalHeight) { - this.state = ol.TileState.LOADED; + this.state = _ol_TileState_.LOADED; } else { - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; } this.unlistenImage_(); this.changed(); @@ -129,21 +130,21 @@ ol.ImageTile.prototype.handleImageLoad_ = function() { * @inheritDoc * @api */ -ol.ImageTile.prototype.load = function() { - if (this.state == ol.TileState.ERROR) { - this.state = ol.TileState.IDLE; +_ol_ImageTile_.prototype.load = function() { + if (this.state == _ol_TileState_.ERROR) { + this.state = _ol_TileState_.IDLE; this.image_ = new Image(); if (this.crossOrigin_ !== null) { this.image_.crossOrigin = this.crossOrigin_; } } - if (this.state == ol.TileState.IDLE) { - this.state = ol.TileState.LOADING; + if (this.state == _ol_TileState_.IDLE) { + this.state = _ol_TileState_.LOADING; this.changed(); this.imageListenerKeys_ = [ - ol.events.listenOnce(this.image_, ol.events.EventType.ERROR, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.ERROR, this.handleImageError_, this), - ol.events.listenOnce(this.image_, ol.events.EventType.LOAD, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.LOAD, this.handleImageLoad_, this) ]; this.tileLoadFunction_(this, this.src_); @@ -156,8 +157,8 @@ ol.ImageTile.prototype.load = function() { * * @private */ -ol.ImageTile.prototype.unlistenImage_ = function() { - this.imageListenerKeys_.forEach(ol.events.unlistenByKey); +_ol_ImageTile_.prototype.unlistenImage_ = function() { + this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey); this.imageListenerKeys_ = null; }; @@ -166,9 +167,10 @@ ol.ImageTile.prototype.unlistenImage_ = function() { * Get a 1-pixel blank image. * @return {HTMLCanvasElement} Blank image. */ -ol.ImageTile.getBlankImage = function() { - var ctx = ol.dom.createCanvasContext2D(1, 1); +_ol_ImageTile_.getBlankImage = function() { + var ctx = _ol_dom_.createCanvasContext2D(1, 1); ctx.fillStyle = 'rgba(0,0,0,0)'; ctx.fillRect(0, 0, 1, 1); return ctx.canvas; }; +export default _ol_ImageTile_; diff --git a/src/ol/Kinetic.js b/src/ol/Kinetic.js index 8af4459f10..449c522b20 100644 --- a/src/ol/Kinetic.js +++ b/src/ol/Kinetic.js @@ -1,6 +1,6 @@ -goog.provide('ol.Kinetic'); - - +/** + * @module ol/Kinetic + */ /** * @classdesc * Implementation of inertial deceleration for map movement. @@ -13,7 +13,7 @@ goog.provide('ol.Kinetic'); * @struct * @api */ -ol.Kinetic = function(decay, minVelocity, delay) { +var _ol_Kinetic_ = function(decay, minVelocity, delay) { /** * @private @@ -56,7 +56,7 @@ ol.Kinetic = function(decay, minVelocity, delay) { /** * FIXME empty description for jsdoc */ -ol.Kinetic.prototype.begin = function() { +_ol_Kinetic_.prototype.begin = function() { this.points_.length = 0; this.angle_ = 0; this.initialVelocity_ = 0; @@ -67,7 +67,7 @@ ol.Kinetic.prototype.begin = function() { * @param {number} x X. * @param {number} y Y. */ -ol.Kinetic.prototype.update = function(x, y) { +_ol_Kinetic_.prototype.update = function(x, y) { this.points_.push(x, y, Date.now()); }; @@ -75,7 +75,7 @@ ol.Kinetic.prototype.update = function(x, y) { /** * @return {boolean} Whether we should do kinetic animation. */ -ol.Kinetic.prototype.end = function() { +_ol_Kinetic_.prototype.end = function() { if (this.points_.length < 6) { // at least 2 points are required (i.e. there must be at least 6 elements // in the array) @@ -114,7 +114,7 @@ ol.Kinetic.prototype.end = function() { /** * @return {number} Total distance travelled (pixels). */ -ol.Kinetic.prototype.getDistance = function() { +_ol_Kinetic_.prototype.getDistance = function() { return (this.minVelocity_ - this.initialVelocity_) / this.decay_; }; @@ -122,6 +122,7 @@ ol.Kinetic.prototype.getDistance = function() { /** * @return {number} Angle of the kinetic panning animation (radians). */ -ol.Kinetic.prototype.getAngle = function() { +_ol_Kinetic_.prototype.getAngle = function() { return this.angle_; }; +export default _ol_Kinetic_; diff --git a/src/ol/LayerType.js b/src/ol/LayerType.js index cab765ef5a..4a932133b5 100644 --- a/src/ol/LayerType.js +++ b/src/ol/LayerType.js @@ -1,12 +1,15 @@ -goog.provide('ol.LayerType'); - +/** + * @module ol/LayerType + */ /** * A layer type used when creating layer renderers. * @enum {string} */ -ol.LayerType = { +var _ol_LayerType_ = { IMAGE: 'IMAGE', TILE: 'TILE', VECTOR_TILE: 'VECTOR_TILE', VECTOR: 'VECTOR' }; + +export default _ol_LayerType_; diff --git a/src/ol/Map.js b/src/ol/Map.js index dbb82b2e99..80b7289e11 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -1,39 +1,40 @@ -goog.provide('ol.Map'); - -goog.require('ol'); -goog.require('ol.PluggableMap'); -goog.require('ol.PluginType'); -goog.require('ol.control'); -goog.require('ol.interaction'); -goog.require('ol.obj'); -goog.require('ol.plugins'); -goog.require('ol.renderer.canvas.ImageLayer'); -goog.require('ol.renderer.canvas.Map'); -goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.renderer.canvas.VectorLayer'); -goog.require('ol.renderer.canvas.VectorTileLayer'); -goog.require('ol.renderer.webgl.ImageLayer'); -goog.require('ol.renderer.webgl.Map'); -goog.require('ol.renderer.webgl.TileLayer'); -goog.require('ol.renderer.webgl.VectorLayer'); +/** + * @module ol/Map + */ +import _ol_ from './index.js'; +import _ol_PluggableMap_ from './PluggableMap.js'; +import _ol_PluginType_ from './PluginType.js'; +import _ol_control_ from './control.js'; +import _ol_interaction_ from './interaction.js'; +import _ol_obj_ from './obj.js'; +import _ol_plugins_ from './plugins.js'; +import _ol_renderer_canvas_ImageLayer_ from './renderer/canvas/ImageLayer.js'; +import _ol_renderer_canvas_Map_ from './renderer/canvas/Map.js'; +import _ol_renderer_canvas_TileLayer_ from './renderer/canvas/TileLayer.js'; +import _ol_renderer_canvas_VectorLayer_ from './renderer/canvas/VectorLayer.js'; +import _ol_renderer_canvas_VectorTileLayer_ from './renderer/canvas/VectorTileLayer.js'; +import _ol_renderer_webgl_ImageLayer_ from './renderer/webgl/ImageLayer.js'; +import _ol_renderer_webgl_Map_ from './renderer/webgl/Map.js'; +import _ol_renderer_webgl_TileLayer_ from './renderer/webgl/TileLayer.js'; +import _ol_renderer_webgl_VectorLayer_ from './renderer/webgl/VectorLayer.js'; -if (ol.ENABLE_CANVAS) { - ol.plugins.register(ol.PluginType.MAP_RENDERER, ol.renderer.canvas.Map); - ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [ - ol.renderer.canvas.ImageLayer, - ol.renderer.canvas.TileLayer, - ol.renderer.canvas.VectorLayer, - ol.renderer.canvas.VectorTileLayer +if (_ol_.ENABLE_CANVAS) { + _ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_canvas_Map_); + _ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ + _ol_renderer_canvas_ImageLayer_, + _ol_renderer_canvas_TileLayer_, + _ol_renderer_canvas_VectorLayer_, + _ol_renderer_canvas_VectorTileLayer_ ]); } -if (ol.ENABLE_WEBGL) { - ol.plugins.register(ol.PluginType.MAP_RENDERER, ol.renderer.webgl.Map); - ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [ - ol.renderer.webgl.ImageLayer, - ol.renderer.webgl.TileLayer, - ol.renderer.webgl.VectorLayer +if (_ol_.ENABLE_WEBGL) { + _ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_webgl_Map_); + _ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ + _ol_renderer_webgl_ImageLayer_, + _ol_renderer_webgl_TileLayer_, + _ol_renderer_webgl_VectorLayer_ ]); } @@ -86,15 +87,17 @@ if (ol.ENABLE_WEBGL) { * @fires ol.render.Event#precompose * @api */ -ol.Map = function(options) { - options = ol.obj.assign({}, options); +var _ol_Map_ = function(options) { + options = _ol_obj_.assign({}, options); if (!options.controls) { - options.controls = ol.control.defaults(); + options.controls = _ol_control_.defaults(); } if (!options.interactions) { - options.interactions = ol.interaction.defaults(); + options.interactions = _ol_interaction_.defaults(); } - ol.PluggableMap.call(this, options); + _ol_PluggableMap_.call(this, options); }; -ol.inherits(ol.Map, ol.PluggableMap); + +_ol_.inherits(_ol_Map_, _ol_PluggableMap_); +export default _ol_Map_; diff --git a/src/ol/MapBrowserEvent.js b/src/ol/MapBrowserEvent.js index 2c705569ab..8eb0534e91 100644 --- a/src/ol/MapBrowserEvent.js +++ b/src/ol/MapBrowserEvent.js @@ -1,8 +1,8 @@ -goog.provide('ol.MapBrowserEvent'); - -goog.require('ol'); -goog.require('ol.MapEvent'); - +/** + * @module ol/MapBrowserEvent + */ +import _ol_ from './index.js'; +import _ol_MapEvent_ from './MapEvent.js'; /** * @classdesc @@ -18,10 +18,10 @@ goog.require('ol.MapEvent'); * @param {boolean=} opt_dragging Is the map currently being dragged? * @param {?olx.FrameState=} opt_frameState Frame state. */ -ol.MapBrowserEvent = function(type, map, browserEvent, opt_dragging, +var _ol_MapBrowserEvent_ = function(type, map, browserEvent, opt_dragging, opt_frameState) { - ol.MapEvent.call(this, type, map, opt_frameState); + _ol_MapEvent_.call(this, type, map, opt_frameState); /** * The original browser event. @@ -55,7 +55,8 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_dragging, this.dragging = opt_dragging !== undefined ? opt_dragging : false; }; -ol.inherits(ol.MapBrowserEvent, ol.MapEvent); + +_ol_.inherits(_ol_MapBrowserEvent_, _ol_MapEvent_); /** @@ -64,8 +65,8 @@ ol.inherits(ol.MapBrowserEvent, ol.MapEvent); * @override * @api */ -ol.MapBrowserEvent.prototype.preventDefault = function() { - ol.MapEvent.prototype.preventDefault.call(this); +_ol_MapBrowserEvent_.prototype.preventDefault = function() { + _ol_MapEvent_.prototype.preventDefault.call(this); this.originalEvent.preventDefault(); }; @@ -76,7 +77,8 @@ ol.MapBrowserEvent.prototype.preventDefault = function() { * @override * @api */ -ol.MapBrowserEvent.prototype.stopPropagation = function() { - ol.MapEvent.prototype.stopPropagation.call(this); +_ol_MapBrowserEvent_.prototype.stopPropagation = function() { + _ol_MapEvent_.prototype.stopPropagation.call(this); this.originalEvent.stopPropagation(); }; +export default _ol_MapBrowserEvent_; diff --git a/src/ol/MapBrowserEventHandler.js b/src/ol/MapBrowserEventHandler.js index 3e71883a17..850f96e038 100644 --- a/src/ol/MapBrowserEventHandler.js +++ b/src/ol/MapBrowserEventHandler.js @@ -1,14 +1,14 @@ -goog.provide('ol.MapBrowserEventHandler'); - -goog.require('ol'); -goog.require('ol.has'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); -goog.require('ol.pointer.EventType'); -goog.require('ol.pointer.PointerEventHandler'); - +/** + * @module ol/MapBrowserEventHandler + */ +import _ol_ from './index.js'; +import _ol_has_ from './has.js'; +import _ol_MapBrowserEventType_ from './MapBrowserEventType.js'; +import _ol_MapBrowserPointerEvent_ from './MapBrowserPointerEvent.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventTarget_ from './events/EventTarget.js'; +import _ol_pointer_EventType_ from './pointer/EventType.js'; +import _ol_pointer_PointerEventHandler_ from './pointer/PointerEventHandler.js'; /** * @param {ol.PluggableMap} map The map with the viewport to listen to events on. @@ -16,9 +16,9 @@ goog.require('ol.pointer.PointerEventHandler'); * @constructor * @extends {ol.events.EventTarget} */ -ol.MapBrowserEventHandler = function(map, moveTolerance) { +var _ol_MapBrowserEventHandler_ = function(map, moveTolerance) { - ol.events.EventTarget.call(this); + _ol_events_EventTarget_.call(this); /** * This is the element that we will listen to the real events on. @@ -50,7 +50,7 @@ ol.MapBrowserEventHandler = function(map, moveTolerance) { * @private */ this.moveTolerance_ = moveTolerance ? - moveTolerance * ol.has.DEVICE_PIXEL_RATIO : ol.has.DEVICE_PIXEL_RATIO; + moveTolerance * _ol_has_.DEVICE_PIXEL_RATIO : _ol_has_.DEVICE_PIXEL_RATIO; /** * The most recent "down" type event (or null if none have occurred). @@ -81,7 +81,7 @@ ol.MapBrowserEventHandler = function(map, moveTolerance) { * @type {ol.pointer.PointerEventHandler} * @private */ - this.pointerEventHandler_ = new ol.pointer.PointerEventHandler(element); + this.pointerEventHandler_ = new _ol_pointer_PointerEventHandler_(element); /** * Event handler which generates pointer events for @@ -96,43 +96,44 @@ ol.MapBrowserEventHandler = function(map, moveTolerance) { * @type {?ol.EventsKey} * @private */ - this.pointerdownListenerKey_ = ol.events.listen(this.pointerEventHandler_, - ol.pointer.EventType.POINTERDOWN, + this.pointerdownListenerKey_ = _ol_events_.listen(this.pointerEventHandler_, + _ol_pointer_EventType_.POINTERDOWN, this.handlePointerDown_, this); /** * @type {?ol.EventsKey} * @private */ - this.relayedListenerKey_ = ol.events.listen(this.pointerEventHandler_, - ol.pointer.EventType.POINTERMOVE, + this.relayedListenerKey_ = _ol_events_.listen(this.pointerEventHandler_, + _ol_pointer_EventType_.POINTERMOVE, this.relayEvent_, this); }; -ol.inherits(ol.MapBrowserEventHandler, ol.events.EventTarget); + +_ol_.inherits(_ol_MapBrowserEventHandler_, _ol_events_EventTarget_); /** * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) { - var newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.CLICK, this.map_, pointerEvent); +_ol_MapBrowserEventHandler_.prototype.emulateClick_ = function(pointerEvent) { + var newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.CLICK, this.map_, pointerEvent); this.dispatchEvent(newEvent); if (this.clickTimeoutId_ !== 0) { // double-click clearTimeout(this.clickTimeoutId_); this.clickTimeoutId_ = 0; - newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.DBLCLICK, this.map_, pointerEvent); + newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.DBLCLICK, this.map_, pointerEvent); this.dispatchEvent(newEvent); } else { // click this.clickTimeoutId_ = setTimeout(function() { this.clickTimeoutId_ = 0; - var newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent); + var newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.SINGLECLICK, this.map_, pointerEvent); this.dispatchEvent(newEvent); }.bind(this), 250); } @@ -145,13 +146,13 @@ ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) { * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.updateActivePointers_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.updateActivePointers_ = function(pointerEvent) { var event = pointerEvent; - if (event.type == ol.MapBrowserEventType.POINTERUP || - event.type == ol.MapBrowserEventType.POINTERCANCEL) { + if (event.type == _ol_MapBrowserEventType_.POINTERUP || + event.type == _ol_MapBrowserEventType_.POINTERCANCEL) { delete this.trackedTouches_[event.pointerId]; - } else if (event.type == ol.MapBrowserEventType.POINTERDOWN) { + } else if (event.type == _ol_MapBrowserEventType_.POINTERDOWN) { this.trackedTouches_[event.pointerId] = true; } this.activePointers_ = Object.keys(this.trackedTouches_).length; @@ -162,10 +163,10 @@ ol.MapBrowserEventHandler.prototype.updateActivePointers_ = function(pointerEven * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.handlePointerUp_ = function(pointerEvent) { this.updateActivePointers_(pointerEvent); - var newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.POINTERUP, this.map_, pointerEvent); + var newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.POINTERUP, this.map_, pointerEvent); this.dispatchEvent(newEvent); // We emulate click events on left mouse button click, touch contact, and pen @@ -179,7 +180,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) { } if (this.activePointers_ === 0) { - this.dragListenerKeys_.forEach(ol.events.unlistenByKey); + this.dragListenerKeys_.forEach(_ol_events_.unlistenByKey); this.dragListenerKeys_.length = 0; this.dragging_ = false; this.down_ = null; @@ -194,7 +195,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) { * @return {boolean} If the left mouse button was pressed. * @private */ -ol.MapBrowserEventHandler.prototype.isMouseActionButton_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.isMouseActionButton_ = function(pointerEvent) { return pointerEvent.button === 0; }; @@ -203,10 +204,10 @@ ol.MapBrowserEventHandler.prototype.isMouseActionButton_ = function(pointerEvent * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.handlePointerDown_ = function(pointerEvent) { this.updateActivePointers_(pointerEvent); - var newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.POINTERDOWN, this.map_, pointerEvent); + var newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.POINTERDOWN, this.map_, pointerEvent); this.dispatchEvent(newEvent); this.down_ = pointerEvent; @@ -217,14 +218,14 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) * the viewport when dragging. */ this.documentPointerEventHandler_ = - new ol.pointer.PointerEventHandler(document); + new _ol_pointer_PointerEventHandler_(document); this.dragListenerKeys_.push( - ol.events.listen(this.documentPointerEventHandler_, - ol.MapBrowserEventType.POINTERMOVE, + _ol_events_.listen(this.documentPointerEventHandler_, + _ol_MapBrowserEventType_.POINTERMOVE, this.handlePointerMove_, this), - ol.events.listen(this.documentPointerEventHandler_, - ol.MapBrowserEventType.POINTERUP, + _ol_events_.listen(this.documentPointerEventHandler_, + _ol_MapBrowserEventType_.POINTERUP, this.handlePointerUp_, this), /* Note that the listener for `pointercancel is set up on * `pointerEventHandler_` and not `documentPointerEventHandler_` like @@ -239,8 +240,8 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) * only receive a `touchcancel` from `pointerEventHandler_`, because it is * only registered there. */ - ol.events.listen(this.pointerEventHandler_, - ol.MapBrowserEventType.POINTERCANCEL, + _ol_events_.listen(this.pointerEventHandler_, + _ol_MapBrowserEventType_.POINTERCANCEL, this.handlePointerUp_, this) ); } @@ -251,14 +252,14 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.handlePointerMove_ = function(pointerEvent) { // Between pointerdown and pointerup, pointermove events are triggered. // To avoid a 'false' touchmove event to be dispatched, we test if the pointer // moved a significant distance. if (this.isMoving_(pointerEvent)) { this.dragging_ = true; - var newEvent = new ol.MapBrowserPointerEvent( - ol.MapBrowserEventType.POINTERDRAG, this.map_, pointerEvent, + var newEvent = new _ol_MapBrowserPointerEvent_( + _ol_MapBrowserEventType_.POINTERDRAG, this.map_, pointerEvent, this.dragging_); this.dispatchEvent(newEvent); } @@ -277,9 +278,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) * @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @private */ -ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.relayEvent_ = function(pointerEvent) { var dragging = !!(this.down_ && this.isMoving_(pointerEvent)); - this.dispatchEvent(new ol.MapBrowserPointerEvent( + this.dispatchEvent(new _ol_MapBrowserPointerEvent_( pointerEvent.type, this.map_, pointerEvent, dragging)); }; @@ -289,7 +290,7 @@ ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) { * @return {boolean} Is moving. * @private */ -ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) { +_ol_MapBrowserEventHandler_.prototype.isMoving_ = function(pointerEvent) { return Math.abs(pointerEvent.clientX - this.down_.clientX) > this.moveTolerance_ || Math.abs(pointerEvent.clientY - this.down_.clientY) > this.moveTolerance_; }; @@ -298,17 +299,17 @@ ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) { /** * @inheritDoc */ -ol.MapBrowserEventHandler.prototype.disposeInternal = function() { +_ol_MapBrowserEventHandler_.prototype.disposeInternal = function() { if (this.relayedListenerKey_) { - ol.events.unlistenByKey(this.relayedListenerKey_); + _ol_events_.unlistenByKey(this.relayedListenerKey_); this.relayedListenerKey_ = null; } if (this.pointerdownListenerKey_) { - ol.events.unlistenByKey(this.pointerdownListenerKey_); + _ol_events_.unlistenByKey(this.pointerdownListenerKey_); this.pointerdownListenerKey_ = null; } - this.dragListenerKeys_.forEach(ol.events.unlistenByKey); + this.dragListenerKeys_.forEach(_ol_events_.unlistenByKey); this.dragListenerKeys_.length = 0; if (this.documentPointerEventHandler_) { @@ -319,5 +320,6 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() { this.pointerEventHandler_.dispose(); this.pointerEventHandler_ = null; } - ol.events.EventTarget.prototype.disposeInternal.call(this); + _ol_events_EventTarget_.prototype.disposeInternal.call(this); }; +export default _ol_MapBrowserEventHandler_; diff --git a/src/ol/MapBrowserEventType.js b/src/ol/MapBrowserEventType.js index 19f6280e87..a33e63645e 100644 --- a/src/ol/MapBrowserEventType.js +++ b/src/ol/MapBrowserEventType.js @@ -1,13 +1,13 @@ -goog.provide('ol.MapBrowserEventType'); - -goog.require('ol.events.EventType'); - +/** + * @module ol/MapBrowserEventType + */ +import _ol_events_EventType_ from './events/EventType.js'; /** * Constants for event names. * @enum {string} */ -ol.MapBrowserEventType = { +var _ol_MapBrowserEventType_ = { /** * A true single click with no dragging and no double click. Note that this @@ -22,14 +22,14 @@ ol.MapBrowserEventType = { * @event ol.MapBrowserEvent#click * @api */ - CLICK: ol.events.EventType.CLICK, + CLICK: _ol_events_EventType_.CLICK, /** * A true double click, with no dragging. * @event ol.MapBrowserEvent#dblclick * @api */ - DBLCLICK: ol.events.EventType.DBLCLICK, + DBLCLICK: _ol_events_EventType_.DBLCLICK, /** * Triggered when a pointer is dragged. @@ -54,3 +54,5 @@ ol.MapBrowserEventType = { POINTERLEAVE: 'pointerleave', POINTERCANCEL: 'pointercancel' }; + +export default _ol_MapBrowserEventType_; diff --git a/src/ol/MapBrowserPointerEvent.js b/src/ol/MapBrowserPointerEvent.js index 1f95493a4f..93c6ff026c 100644 --- a/src/ol/MapBrowserPointerEvent.js +++ b/src/ol/MapBrowserPointerEvent.js @@ -1,8 +1,8 @@ -goog.provide('ol.MapBrowserPointerEvent'); - -goog.require('ol'); -goog.require('ol.MapBrowserEvent'); - +/** + * @module ol/MapBrowserPointerEvent + */ +import _ol_ from './index.js'; +import _ol_MapBrowserEvent_ from './MapBrowserEvent.js'; /** * @constructor @@ -13,10 +13,10 @@ goog.require('ol.MapBrowserEvent'); * @param {boolean=} opt_dragging Is the map currently being dragged? * @param {?olx.FrameState=} opt_frameState Frame state. */ -ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging, +var _ol_MapBrowserPointerEvent_ = function(type, map, pointerEvent, opt_dragging, opt_frameState) { - ol.MapBrowserEvent.call(this, type, map, pointerEvent.originalEvent, opt_dragging, + _ol_MapBrowserEvent_.call(this, type, map, pointerEvent.originalEvent, opt_dragging, opt_frameState); /** @@ -26,4 +26,6 @@ ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging, this.pointerEvent = pointerEvent; }; -ol.inherits(ol.MapBrowserPointerEvent, ol.MapBrowserEvent); + +_ol_.inherits(_ol_MapBrowserPointerEvent_, _ol_MapBrowserEvent_); +export default _ol_MapBrowserPointerEvent_; diff --git a/src/ol/MapEvent.js b/src/ol/MapEvent.js index f0c66d9fb0..e808d5eee0 100644 --- a/src/ol/MapEvent.js +++ b/src/ol/MapEvent.js @@ -1,8 +1,8 @@ -goog.provide('ol.MapEvent'); - -goog.require('ol'); -goog.require('ol.events.Event'); - +/** + * @module ol/MapEvent + */ +import _ol_ from './index.js'; +import _ol_events_Event_ from './events/Event.js'; /** * @classdesc @@ -16,9 +16,9 @@ goog.require('ol.events.Event'); * @param {ol.PluggableMap} map Map. * @param {?olx.FrameState=} opt_frameState Frame state. */ -ol.MapEvent = function(type, map, opt_frameState) { +var _ol_MapEvent_ = function(type, map, opt_frameState) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The map where the event occurred. @@ -35,4 +35,6 @@ ol.MapEvent = function(type, map, opt_frameState) { this.frameState = opt_frameState !== undefined ? opt_frameState : null; }; -ol.inherits(ol.MapEvent, ol.events.Event); + +_ol_.inherits(_ol_MapEvent_, _ol_events_Event_); +export default _ol_MapEvent_; diff --git a/src/ol/MapEventType.js b/src/ol/MapEventType.js index 43d707cb56..dcb161da51 100644 --- a/src/ol/MapEventType.js +++ b/src/ol/MapEventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.MapEventType'); - +/** + * @module ol/MapEventType + */ /** * @enum {string} */ -ol.MapEventType = { +var _ol_MapEventType_ = { /** * Triggered after a map frame is rendered. @@ -27,3 +28,5 @@ ol.MapEventType = { MOVEEND: 'moveend' }; + +export default _ol_MapEventType_; diff --git a/src/ol/MapProperty.js b/src/ol/MapProperty.js index 48d374d4f3..dabdb21b2a 100644 --- a/src/ol/MapProperty.js +++ b/src/ol/MapProperty.js @@ -1,11 +1,14 @@ -goog.provide('ol.MapProperty'); - +/** + * @module ol/MapProperty + */ /** * @enum {string} */ -ol.MapProperty = { +var _ol_MapProperty_ = { LAYERGROUP: 'layergroup', SIZE: 'size', TARGET: 'target', VIEW: 'view' }; + +export default _ol_MapProperty_; diff --git a/src/ol/Object.js b/src/ol/Object.js index 2c9f04ae5e..559507acfc 100644 --- a/src/ol/Object.js +++ b/src/ol/Object.js @@ -1,11 +1,11 @@ -goog.provide('ol.Object'); - -goog.require('ol'); -goog.require('ol.ObjectEventType'); -goog.require('ol.Observable'); -goog.require('ol.events.Event'); -goog.require('ol.obj'); - +/** + * @module ol/Object + */ +import _ol_ from './index.js'; +import _ol_ObjectEventType_ from './ObjectEventType.js'; +import _ol_Observable_ from './Observable.js'; +import _ol_events_Event_ from './events/Event.js'; +import _ol_obj_ from './obj.js'; /** * @classdesc @@ -52,14 +52,14 @@ goog.require('ol.obj'); * @fires ol.Object.Event * @api */ -ol.Object = function(opt_values) { - ol.Observable.call(this); +var _ol_Object_ = function(opt_values) { + _ol_Observable_.call(this); // Call ol.getUid to ensure that the order of objects' ids is the same as // the order in which they were created. This also helps to ensure that // object properties are always added in the same order, which helps many // JavaScript engines generate faster code. - ol.getUid(this); + _ol_.getUid(this); /** * @private @@ -71,24 +71,25 @@ ol.Object = function(opt_values) { this.setProperties(opt_values); } }; -ol.inherits(ol.Object, ol.Observable); + +_ol_.inherits(_ol_Object_, _ol_Observable_); /** * @private * @type {Object.} */ -ol.Object.changeEventTypeCache_ = {}; +_ol_Object_.changeEventTypeCache_ = {}; /** * @param {string} key Key name. * @return {string} Change name. */ -ol.Object.getChangeEventType = function(key) { - return ol.Object.changeEventTypeCache_.hasOwnProperty(key) ? - ol.Object.changeEventTypeCache_[key] : - (ol.Object.changeEventTypeCache_[key] = 'change:' + key); +_ol_Object_.getChangeEventType = function(key) { + return _ol_Object_.changeEventTypeCache_.hasOwnProperty(key) ? + _ol_Object_.changeEventTypeCache_[key] : + (_ol_Object_.changeEventTypeCache_[key] = 'change:' + key); }; @@ -98,7 +99,7 @@ ol.Object.getChangeEventType = function(key) { * @return {*} Value. * @api */ -ol.Object.prototype.get = function(key) { +_ol_Object_.prototype.get = function(key) { var value; if (this.values_.hasOwnProperty(key)) { value = this.values_[key]; @@ -112,7 +113,7 @@ ol.Object.prototype.get = function(key) { * @return {Array.} List of property names. * @api */ -ol.Object.prototype.getKeys = function() { +_ol_Object_.prototype.getKeys = function() { return Object.keys(this.values_); }; @@ -122,8 +123,8 @@ ol.Object.prototype.getKeys = function() { * @return {Object.} Object. * @api */ -ol.Object.prototype.getProperties = function() { - return ol.obj.assign({}, this.values_); +_ol_Object_.prototype.getProperties = function() { + return _ol_obj_.assign({}, this.values_); }; @@ -131,12 +132,12 @@ ol.Object.prototype.getProperties = function() { * @param {string} key Key name. * @param {*} oldValue Old value. */ -ol.Object.prototype.notify = function(key, oldValue) { +_ol_Object_.prototype.notify = function(key, oldValue) { var eventType; - eventType = ol.Object.getChangeEventType(key); - this.dispatchEvent(new ol.Object.Event(eventType, key, oldValue)); - eventType = ol.ObjectEventType.PROPERTYCHANGE; - this.dispatchEvent(new ol.Object.Event(eventType, key, oldValue)); + eventType = _ol_Object_.getChangeEventType(key); + this.dispatchEvent(new _ol_Object_.Event(eventType, key, oldValue)); + eventType = _ol_ObjectEventType_.PROPERTYCHANGE; + this.dispatchEvent(new _ol_Object_.Event(eventType, key, oldValue)); }; @@ -147,7 +148,7 @@ ol.Object.prototype.notify = function(key, oldValue) { * @param {boolean=} opt_silent Update without triggering an event. * @api */ -ol.Object.prototype.set = function(key, value, opt_silent) { +_ol_Object_.prototype.set = function(key, value, opt_silent) { if (opt_silent) { this.values_[key] = value; } else { @@ -167,7 +168,7 @@ ol.Object.prototype.set = function(key, value, opt_silent) { * @param {boolean=} opt_silent Update without triggering an event. * @api */ -ol.Object.prototype.setProperties = function(values, opt_silent) { +_ol_Object_.prototype.setProperties = function(values, opt_silent) { var key; for (key in values) { this.set(key, values[key], opt_silent); @@ -181,7 +182,7 @@ ol.Object.prototype.setProperties = function(values, opt_silent) { * @param {boolean=} opt_silent Unset without triggering an event. * @api */ -ol.Object.prototype.unset = function(key, opt_silent) { +_ol_Object_.prototype.unset = function(key, opt_silent) { if (key in this.values_) { var oldValue = this.values_[key]; delete this.values_[key]; @@ -203,8 +204,8 @@ ol.Object.prototype.unset = function(key, opt_silent) { * @implements {oli.Object.Event} * @constructor */ -ol.Object.Event = function(type, key, oldValue) { - ol.events.Event.call(this, type); +_ol_Object_.Event = function(type, key, oldValue) { + _ol_events_Event_.call(this, type); /** * The name of the property whose value is changing. @@ -222,4 +223,5 @@ ol.Object.Event = function(type, key, oldValue) { this.oldValue = oldValue; }; -ol.inherits(ol.Object.Event, ol.events.Event); +_ol_.inherits(_ol_Object_.Event, _ol_events_Event_); +export default _ol_Object_; diff --git a/src/ol/ObjectEventType.js b/src/ol/ObjectEventType.js index 4f7ab7115d..86b95fe073 100644 --- a/src/ol/ObjectEventType.js +++ b/src/ol/ObjectEventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.ObjectEventType'); - +/** + * @module ol/ObjectEventType + */ /** * @enum {string} */ -ol.ObjectEventType = { +var _ol_ObjectEventType_ = { /** * Triggered when a property is changed. * @event ol.Object.Event#propertychange @@ -11,3 +12,5 @@ ol.ObjectEventType = { */ PROPERTYCHANGE: 'propertychange' }; + +export default _ol_ObjectEventType_; diff --git a/src/ol/Observable.js b/src/ol/Observable.js index f0bde381c4..dbf396ac7a 100644 --- a/src/ol/Observable.js +++ b/src/ol/Observable.js @@ -1,10 +1,10 @@ -goog.provide('ol.Observable'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); -goog.require('ol.events.EventType'); - +/** + * @module ol/Observable + */ +import _ol_ from './index.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventTarget_ from './events/EventTarget.js'; +import _ol_events_EventType_ from './events/EventType.js'; /** * @classdesc @@ -20,9 +20,9 @@ goog.require('ol.events.EventType'); * @struct * @api */ -ol.Observable = function() { +var _ol_Observable_ = function() { - ol.events.EventTarget.call(this); + _ol_events_EventTarget_.call(this); /** * @private @@ -31,7 +31,8 @@ ol.Observable = function() { this.revision_ = 0; }; -ol.inherits(ol.Observable, ol.events.EventTarget); + +_ol_.inherits(_ol_Observable_, _ol_events_EventTarget_); /** @@ -40,13 +41,13 @@ ol.inherits(ol.Observable, ol.events.EventTarget); * or `once()` (or an array of keys). * @api */ -ol.Observable.unByKey = function(key) { +_ol_Observable_.unByKey = function(key) { if (Array.isArray(key)) { for (var i = 0, ii = key.length; i < ii; ++i) { - ol.events.unlistenByKey(key[i]); + _ol_events_.unlistenByKey(key[i]); } } else { - ol.events.unlistenByKey(/** @type {ol.EventsKey} */ (key)); + _ol_events_.unlistenByKey(/** @type {ol.EventsKey} */ (key)); } }; @@ -55,9 +56,9 @@ ol.Observable.unByKey = function(key) { * Increases the revision counter and dispatches a 'change' event. * @api */ -ol.Observable.prototype.changed = function() { +_ol_Observable_.prototype.changed = function() { ++this.revision_; - this.dispatchEvent(ol.events.EventType.CHANGE); + this.dispatchEvent(_ol_events_EventType_.CHANGE); }; @@ -72,7 +73,7 @@ ol.Observable.prototype.changed = function() { * @function * @api */ -ol.Observable.prototype.dispatchEvent; +_ol_Observable_.prototype.dispatchEvent; /** @@ -81,7 +82,7 @@ ol.Observable.prototype.dispatchEvent; * @return {number} Revision. * @api */ -ol.Observable.prototype.getRevision = function() { +_ol_Observable_.prototype.getRevision = function() { return this.revision_; }; @@ -96,16 +97,16 @@ ol.Observable.prototype.getRevision = function() { * will be an array of keys. * @api */ -ol.Observable.prototype.on = function(type, listener, opt_this) { +_ol_Observable_.prototype.on = function(type, listener, opt_this) { if (Array.isArray(type)) { var len = type.length; var keys = new Array(len); for (var i = 0; i < len; ++i) { - keys[i] = ol.events.listen(this, type[i], listener, opt_this); + keys[i] = _ol_events_.listen(this, type[i], listener, opt_this); } return keys; } else { - return ol.events.listen( + return _ol_events_.listen( this, /** @type {string} */ (type), listener, opt_this); } }; @@ -121,16 +122,16 @@ ol.Observable.prototype.on = function(type, listener, opt_this) { * will be an array of keys. * @api */ -ol.Observable.prototype.once = function(type, listener, opt_this) { +_ol_Observable_.prototype.once = function(type, listener, opt_this) { if (Array.isArray(type)) { var len = type.length; var keys = new Array(len); for (var i = 0; i < len; ++i) { - keys[i] = ol.events.listenOnce(this, type[i], listener, opt_this); + keys[i] = _ol_events_.listenOnce(this, type[i], listener, opt_this); } return keys; } else { - return ol.events.listenOnce( + return _ol_events_.listenOnce( this, /** @type {string} */ (type), listener, opt_this); } }; @@ -144,13 +145,14 @@ ol.Observable.prototype.once = function(type, listener, opt_this) { * `listener`. * @api */ -ol.Observable.prototype.un = function(type, listener, opt_this) { +_ol_Observable_.prototype.un = function(type, listener, opt_this) { if (Array.isArray(type)) { for (var i = 0, ii = type.length; i < ii; ++i) { - ol.events.unlisten(this, type[i], listener, opt_this); + _ol_events_.unlisten(this, type[i], listener, opt_this); } return; } else { - ol.events.unlisten(this, /** @type {string} */ (type), listener, opt_this); + _ol_events_.unlisten(this, /** @type {string} */ (type), listener, opt_this); } }; +export default _ol_Observable_; diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index 9e7beac57a..dd775ec240 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -1,14 +1,14 @@ -goog.provide('ol.Overlay'); - -goog.require('ol'); -goog.require('ol.MapEventType'); -goog.require('ol.Object'); -goog.require('ol.OverlayPositioning'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.extent'); - +/** + * @module ol/Overlay + */ +import _ol_ from './index.js'; +import _ol_MapEventType_ from './MapEventType.js'; +import _ol_Object_ from './Object.js'; +import _ol_OverlayPositioning_ from './OverlayPositioning.js'; +import _ol_css_ from './css.js'; +import _ol_dom_ from './dom.js'; +import _ol_events_ from './events.js'; +import _ol_extent_ from './extent.js'; /** * @classdesc @@ -31,9 +31,9 @@ goog.require('ol.extent'); * @param {olx.OverlayOptions} options Overlay options. * @api */ -ol.Overlay = function(options) { +var _ol_Overlay_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @protected @@ -66,7 +66,7 @@ ol.Overlay = function(options) { */ this.element = document.createElement('DIV'); this.element.className = options.className !== undefined ? - options.className : 'ol-overlay-container ' + ol.css.CLASS_SELECTABLE; + options.className : 'ol-overlay-container ' + _ol_css_.CLASS_SELECTABLE; this.element.style.position = 'absolute'; /** @@ -111,24 +111,24 @@ ol.Overlay = function(options) { */ this.mapPostrenderListenerKey = null; - ol.events.listen( - this, ol.Object.getChangeEventType(ol.Overlay.Property.ELEMENT), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.ELEMENT), this.handleElementChanged, this); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.Overlay.Property.MAP), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.MAP), this.handleMapChanged, this); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.Overlay.Property.OFFSET), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.OFFSET), this.handleOffsetChanged, this); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.Overlay.Property.POSITION), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.POSITION), this.handlePositionChanged, this); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.Overlay.Property.POSITIONING), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.POSITIONING), this.handlePositioningChanged, this); if (options.element !== undefined) { @@ -139,14 +139,15 @@ ol.Overlay = function(options) { this.setPositioning(options.positioning !== undefined ? /** @type {ol.OverlayPositioning} */ (options.positioning) : - ol.OverlayPositioning.TOP_LEFT); + _ol_OverlayPositioning_.TOP_LEFT); if (options.position !== undefined) { this.setPosition(options.position); } }; -ol.inherits(ol.Overlay, ol.Object); + +_ol_.inherits(_ol_Overlay_, _ol_Object_); /** @@ -155,9 +156,10 @@ ol.inherits(ol.Overlay, ol.Object); * @observable * @api */ -ol.Overlay.prototype.getElement = function() { - return /** @type {Element|undefined} */ ( - this.get(ol.Overlay.Property.ELEMENT)); +_ol_Overlay_.prototype.getElement = function() { + return ( + /** @type {Element|undefined} */ this.get(_ol_Overlay_.Property.ELEMENT) + ); }; @@ -166,7 +168,7 @@ ol.Overlay.prototype.getElement = function() { * @return {number|string|undefined} Id. * @api */ -ol.Overlay.prototype.getId = function() { +_ol_Overlay_.prototype.getId = function() { return this.id; }; @@ -177,9 +179,10 @@ ol.Overlay.prototype.getId = function() { * @observable * @api */ -ol.Overlay.prototype.getMap = function() { - return /** @type {ol.PluggableMap|undefined} */ ( - this.get(ol.Overlay.Property.MAP)); +_ol_Overlay_.prototype.getMap = function() { + return ( + /** @type {ol.PluggableMap|undefined} */ this.get(_ol_Overlay_.Property.MAP) + ); }; @@ -189,9 +192,10 @@ ol.Overlay.prototype.getMap = function() { * @observable * @api */ -ol.Overlay.prototype.getOffset = function() { - return /** @type {Array.} */ ( - this.get(ol.Overlay.Property.OFFSET)); +_ol_Overlay_.prototype.getOffset = function() { + return ( + /** @type {Array.} */ this.get(_ol_Overlay_.Property.OFFSET) + ); }; @@ -202,9 +206,10 @@ ol.Overlay.prototype.getOffset = function() { * @observable * @api */ -ol.Overlay.prototype.getPosition = function() { - return /** @type {ol.Coordinate|undefined} */ ( - this.get(ol.Overlay.Property.POSITION)); +_ol_Overlay_.prototype.getPosition = function() { + return ( + /** @type {ol.Coordinate|undefined} */ this.get(_ol_Overlay_.Property.POSITION) + ); }; @@ -215,17 +220,18 @@ ol.Overlay.prototype.getPosition = function() { * @observable * @api */ -ol.Overlay.prototype.getPositioning = function() { - return /** @type {ol.OverlayPositioning} */ ( - this.get(ol.Overlay.Property.POSITIONING)); +_ol_Overlay_.prototype.getPositioning = function() { + return ( + /** @type {ol.OverlayPositioning} */ this.get(_ol_Overlay_.Property.POSITIONING) + ); }; /** * @protected */ -ol.Overlay.prototype.handleElementChanged = function() { - ol.dom.removeChildren(this.element); +_ol_Overlay_.prototype.handleElementChanged = function() { + _ol_dom_.removeChildren(this.element); var element = this.getElement(); if (element) { this.element.appendChild(element); @@ -236,16 +242,16 @@ ol.Overlay.prototype.handleElementChanged = function() { /** * @protected */ -ol.Overlay.prototype.handleMapChanged = function() { +_ol_Overlay_.prototype.handleMapChanged = function() { if (this.mapPostrenderListenerKey) { - ol.dom.removeNode(this.element); - ol.events.unlistenByKey(this.mapPostrenderListenerKey); + _ol_dom_.removeNode(this.element); + _ol_events_.unlistenByKey(this.mapPostrenderListenerKey); this.mapPostrenderListenerKey = null; } var map = this.getMap(); if (map) { - this.mapPostrenderListenerKey = ol.events.listen(map, - ol.MapEventType.POSTRENDER, this.render, this); + this.mapPostrenderListenerKey = _ol_events_.listen(map, + _ol_MapEventType_.POSTRENDER, this.render, this); this.updatePixelPosition(); var container = this.stopEvent ? map.getOverlayContainerStopEvent() : map.getOverlayContainer(); @@ -261,7 +267,7 @@ ol.Overlay.prototype.handleMapChanged = function() { /** * @protected */ -ol.Overlay.prototype.render = function() { +_ol_Overlay_.prototype.render = function() { this.updatePixelPosition(); }; @@ -269,7 +275,7 @@ ol.Overlay.prototype.render = function() { /** * @protected */ -ol.Overlay.prototype.handleOffsetChanged = function() { +_ol_Overlay_.prototype.handleOffsetChanged = function() { this.updatePixelPosition(); }; @@ -277,9 +283,9 @@ ol.Overlay.prototype.handleOffsetChanged = function() { /** * @protected */ -ol.Overlay.prototype.handlePositionChanged = function() { +_ol_Overlay_.prototype.handlePositionChanged = function() { this.updatePixelPosition(); - if (this.get(ol.Overlay.Property.POSITION) && this.autoPan) { + if (this.get(_ol_Overlay_.Property.POSITION) && this.autoPan) { this.panIntoView(); } }; @@ -288,7 +294,7 @@ ol.Overlay.prototype.handlePositionChanged = function() { /** * @protected */ -ol.Overlay.prototype.handlePositioningChanged = function() { +_ol_Overlay_.prototype.handlePositioningChanged = function() { this.updatePixelPosition(); }; @@ -299,8 +305,8 @@ ol.Overlay.prototype.handlePositioningChanged = function() { * @observable * @api */ -ol.Overlay.prototype.setElement = function(element) { - this.set(ol.Overlay.Property.ELEMENT, element); +_ol_Overlay_.prototype.setElement = function(element) { + this.set(_ol_Overlay_.Property.ELEMENT, element); }; @@ -310,8 +316,8 @@ ol.Overlay.prototype.setElement = function(element) { * @observable * @api */ -ol.Overlay.prototype.setMap = function(map) { - this.set(ol.Overlay.Property.MAP, map); +_ol_Overlay_.prototype.setMap = function(map) { + this.set(_ol_Overlay_.Property.MAP, map); }; @@ -321,8 +327,8 @@ ol.Overlay.prototype.setMap = function(map) { * @observable * @api */ -ol.Overlay.prototype.setOffset = function(offset) { - this.set(ol.Overlay.Property.OFFSET, offset); +_ol_Overlay_.prototype.setOffset = function(offset) { + this.set(_ol_Overlay_.Property.OFFSET, offset); }; @@ -334,8 +340,8 @@ ol.Overlay.prototype.setOffset = function(offset) { * @observable * @api */ -ol.Overlay.prototype.setPosition = function(position) { - this.set(ol.Overlay.Property.POSITION, position); +_ol_Overlay_.prototype.setPosition = function(position) { + this.set(_ol_Overlay_.Property.POSITION, position); }; @@ -344,7 +350,7 @@ ol.Overlay.prototype.setPosition = function(position) { * (if necessary). * @protected */ -ol.Overlay.prototype.panIntoView = function() { +_ol_Overlay_.prototype.panIntoView = function() { var map = this.getMap(); if (!map || !map.getTargetElement()) { @@ -354,10 +360,10 @@ ol.Overlay.prototype.panIntoView = function() { var mapRect = this.getRect(map.getTargetElement(), map.getSize()); var element = /** @type {!Element} */ (this.getElement()); var overlayRect = this.getRect(element, - [ol.dom.outerWidth(element), ol.dom.outerHeight(element)]); + [_ol_dom_.outerWidth(element), _ol_dom_.outerHeight(element)]); var margin = this.autoPanMargin; - if (!ol.extent.containsExtent(mapRect, overlayRect)) { + if (!_ol_extent_.containsExtent(mapRect, overlayRect)) { // the overlay is not completely inside the viewport, so pan the map var offsetLeft = overlayRect[0] - mapRect[0]; var offsetRight = mapRect[2] - overlayRect[2]; @@ -405,7 +411,7 @@ ol.Overlay.prototype.panIntoView = function() { * @return {ol.Extent} The extent. * @protected */ -ol.Overlay.prototype.getRect = function(element, size) { +_ol_Overlay_.prototype.getRect = function(element, size) { var box = element.getBoundingClientRect(); var offsetX = box.left + window.pageXOffset; var offsetY = box.top + window.pageYOffset; @@ -425,8 +431,8 @@ ol.Overlay.prototype.getRect = function(element, size) { * @observable * @api */ -ol.Overlay.prototype.setPositioning = function(positioning) { - this.set(ol.Overlay.Property.POSITIONING, positioning); +_ol_Overlay_.prototype.setPositioning = function(positioning) { + this.set(_ol_Overlay_.Property.POSITIONING, positioning); }; @@ -435,7 +441,7 @@ ol.Overlay.prototype.setPositioning = function(positioning) { * @param {boolean} visible Element visibility. * @protected */ -ol.Overlay.prototype.setVisible = function(visible) { +_ol_Overlay_.prototype.setVisible = function(visible) { if (this.rendered.visible !== visible) { this.element.style.display = visible ? '' : 'none'; this.rendered.visible = visible; @@ -447,7 +453,7 @@ ol.Overlay.prototype.setVisible = function(visible) { * Update pixel position. * @protected */ -ol.Overlay.prototype.updatePixelPosition = function() { +_ol_Overlay_.prototype.updatePixelPosition = function() { var map = this.getMap(); var position = this.getPosition(); if (!map || !map.isRendered() || !position) { @@ -466,7 +472,7 @@ ol.Overlay.prototype.updatePixelPosition = function() { * @param {ol.Size|undefined} mapSize The map size. * @protected */ -ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { +_ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { var style = this.element.style; var offset = this.getOffset(); @@ -476,9 +482,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { var offsetX = offset[0]; var offsetY = offset[1]; - if (positioning == ol.OverlayPositioning.BOTTOM_RIGHT || - positioning == ol.OverlayPositioning.CENTER_RIGHT || - positioning == ol.OverlayPositioning.TOP_RIGHT) { + if (positioning == _ol_OverlayPositioning_.BOTTOM_RIGHT || + positioning == _ol_OverlayPositioning_.CENTER_RIGHT || + positioning == _ol_OverlayPositioning_.TOP_RIGHT) { if (this.rendered.left_ !== '') { this.rendered.left_ = style.left = ''; } @@ -490,9 +496,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered.right_ !== '') { this.rendered.right_ = style.right = ''; } - if (positioning == ol.OverlayPositioning.BOTTOM_CENTER || - positioning == ol.OverlayPositioning.CENTER_CENTER || - positioning == ol.OverlayPositioning.TOP_CENTER) { + if (positioning == _ol_OverlayPositioning_.BOTTOM_CENTER || + positioning == _ol_OverlayPositioning_.CENTER_CENTER || + positioning == _ol_OverlayPositioning_.TOP_CENTER) { offsetX -= this.element.offsetWidth / 2; } var left = Math.round(pixel[0] + offsetX) + 'px'; @@ -500,9 +506,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { this.rendered.left_ = style.left = left; } } - if (positioning == ol.OverlayPositioning.BOTTOM_LEFT || - positioning == ol.OverlayPositioning.BOTTOM_CENTER || - positioning == ol.OverlayPositioning.BOTTOM_RIGHT) { + if (positioning == _ol_OverlayPositioning_.BOTTOM_LEFT || + positioning == _ol_OverlayPositioning_.BOTTOM_CENTER || + positioning == _ol_OverlayPositioning_.BOTTOM_RIGHT) { if (this.rendered.top_ !== '') { this.rendered.top_ = style.top = ''; } @@ -514,9 +520,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered.bottom_ !== '') { this.rendered.bottom_ = style.bottom = ''; } - if (positioning == ol.OverlayPositioning.CENTER_LEFT || - positioning == ol.OverlayPositioning.CENTER_CENTER || - positioning == ol.OverlayPositioning.CENTER_RIGHT) { + if (positioning == _ol_OverlayPositioning_.CENTER_LEFT || + positioning == _ol_OverlayPositioning_.CENTER_CENTER || + positioning == _ol_OverlayPositioning_.CENTER_RIGHT) { offsetY -= this.element.offsetHeight / 2; } var top = Math.round(pixel[1] + offsetY) + 'px'; @@ -532,7 +538,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { * @public * @return {olx.OverlayOptions} overlay options */ -ol.Overlay.prototype.getOptions = function() { +_ol_Overlay_.prototype.getOptions = function() { return this.options; }; @@ -541,10 +547,11 @@ ol.Overlay.prototype.getOptions = function() { * @enum {string} * @protected */ -ol.Overlay.Property = { +_ol_Overlay_.Property = { ELEMENT: 'element', MAP: 'map', OFFSET: 'offset', POSITION: 'position', POSITIONING: 'positioning' }; +export default _ol_Overlay_; diff --git a/src/ol/OverlayPositioning.js b/src/ol/OverlayPositioning.js index a601f6d6de..f864614e20 100644 --- a/src/ol/OverlayPositioning.js +++ b/src/ol/OverlayPositioning.js @@ -1,12 +1,13 @@ -goog.provide('ol.OverlayPositioning'); - +/** + * @module ol/OverlayPositioning + */ /** * Overlay position: `'bottom-left'`, `'bottom-center'`, `'bottom-right'`, * `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`, * `'top-center'`, `'top-right'` * @enum {string} */ -ol.OverlayPositioning = { +var _ol_OverlayPositioning_ = { BOTTOM_LEFT: 'bottom-left', BOTTOM_CENTER: 'bottom-center', BOTTOM_RIGHT: 'bottom-right', @@ -17,3 +18,5 @@ ol.OverlayPositioning = { TOP_CENTER: 'top-center', TOP_RIGHT: 'top-right' }; + +export default _ol_OverlayPositioning_; diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 2926d4fb7a..1e4f5eaa06 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -1,35 +1,35 @@ -goog.provide('ol.PluggableMap'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); -goog.require('ol.MapBrowserEvent'); -goog.require('ol.MapBrowserEventHandler'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapEvent'); -goog.require('ol.MapEventType'); -goog.require('ol.MapProperty'); -goog.require('ol.Object'); -goog.require('ol.ObjectEventType'); -goog.require('ol.TileQueue'); -goog.require('ol.View'); -goog.require('ol.ViewHint'); -goog.require('ol.asserts'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.has'); -goog.require('ol.layer.Group'); -goog.require('ol.obj'); -goog.require('ol.plugins'); -goog.require('ol.renderer.Type'); -goog.require('ol.size'); -goog.require('ol.structs.PriorityQueue'); -goog.require('ol.transform'); - +/** + * @module ol/PluggableMap + */ +import _ol_ from './index.js'; +import _ol_Collection_ from './Collection.js'; +import _ol_CollectionEventType_ from './CollectionEventType.js'; +import _ol_MapBrowserEvent_ from './MapBrowserEvent.js'; +import _ol_MapBrowserEventHandler_ from './MapBrowserEventHandler.js'; +import _ol_MapBrowserEventType_ from './MapBrowserEventType.js'; +import _ol_MapEvent_ from './MapEvent.js'; +import _ol_MapEventType_ from './MapEventType.js'; +import _ol_MapProperty_ from './MapProperty.js'; +import _ol_Object_ from './Object.js'; +import _ol_ObjectEventType_ from './ObjectEventType.js'; +import _ol_TileQueue_ from './TileQueue.js'; +import _ol_View_ from './View.js'; +import _ol_ViewHint_ from './ViewHint.js'; +import _ol_asserts_ from './asserts.js'; +import _ol_dom_ from './dom.js'; +import _ol_events_ from './events.js'; +import _ol_events_Event_ from './events/Event.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_extent_ from './extent.js'; +import _ol_functions_ from './functions.js'; +import _ol_has_ from './has.js'; +import _ol_layer_Group_ from './layer/Group.js'; +import _ol_obj_ from './obj.js'; +import _ol_plugins_ from './plugins.js'; +import _ol_renderer_Type_ from './renderer/Type.js'; +import _ol_size_ from './size.js'; +import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js'; +import _ol_transform_ from './transform.js'; /** * @constructor @@ -41,11 +41,11 @@ goog.require('ol.transform'); * @fires ol.render.Event#precompose * @api */ -ol.PluggableMap = function(options) { +var _ol_PluggableMap_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); - var optionsInternal = ol.PluggableMap.createOptionsInternal(options); + var optionsInternal = _ol_PluggableMap_.createOptionsInternal(options); /** * @type {boolean} @@ -68,7 +68,7 @@ ol.PluggableMap = function(options) { * @type {number} */ this.pixelRatio_ = options.pixelRatio !== undefined ? - options.pixelRatio : ol.has.DEVICE_PIXEL_RATIO; + options.pixelRatio : _ol_has_.DEVICE_PIXEL_RATIO; /** * @private @@ -94,13 +94,13 @@ ol.PluggableMap = function(options) { * @private * @type {ol.Transform} */ - this.coordinateToPixelTransform_ = ol.transform.create(); + this.coordinateToPixelTransform_ = _ol_transform_.create(); /** * @private * @type {ol.Transform} */ - this.pixelToCoordinateTransform_ = ol.transform.create(); + this.pixelToCoordinateTransform_ = _ol_transform_.create(); /** * @private @@ -144,7 +144,7 @@ ol.PluggableMap = function(options) { * @type {Element} */ this.viewport_ = document.createElement('DIV'); - this.viewport_.className = 'ol-viewport' + (ol.has.TOUCH ? ' ol-touch' : ''); + this.viewport_.className = 'ol-viewport' + (_ol_has_.TOUCH ? ' ol-touch' : ''); this.viewport_.style.position = 'relative'; this.viewport_.style.overflow = 'hidden'; this.viewport_.style.width = '100%'; @@ -168,18 +168,18 @@ ol.PluggableMap = function(options) { this.overlayContainerStopEvent_ = document.createElement('DIV'); this.overlayContainerStopEvent_.className = 'ol-overlaycontainer-stopevent'; var overlayEvents = [ - ol.events.EventType.CLICK, - ol.events.EventType.DBLCLICK, - ol.events.EventType.MOUSEDOWN, - ol.events.EventType.TOUCHSTART, - ol.events.EventType.MSPOINTERDOWN, - ol.MapBrowserEventType.POINTERDOWN, - ol.events.EventType.MOUSEWHEEL, - ol.events.EventType.WHEEL + _ol_events_EventType_.CLICK, + _ol_events_EventType_.DBLCLICK, + _ol_events_EventType_.MOUSEDOWN, + _ol_events_EventType_.TOUCHSTART, + _ol_events_EventType_.MSPOINTERDOWN, + _ol_MapBrowserEventType_.POINTERDOWN, + _ol_events_EventType_.MOUSEWHEEL, + _ol_events_EventType_.WHEEL ]; for (var i = 0, ii = overlayEvents.length; i < ii; ++i) { - ol.events.listen(this.overlayContainerStopEvent_, overlayEvents[i], - ol.events.Event.stopPropagation); + _ol_events_.listen(this.overlayContainerStopEvent_, overlayEvents[i], + _ol_events_Event_.stopPropagation); } this.viewport_.appendChild(this.overlayContainerStopEvent_); @@ -187,9 +187,9 @@ ol.PluggableMap = function(options) { * @private * @type {ol.MapBrowserEventHandler} */ - this.mapBrowserEventHandler_ = new ol.MapBrowserEventHandler(this, options.moveTolerance); - for (var key in ol.MapBrowserEventType) { - ol.events.listen(this.mapBrowserEventHandler_, ol.MapBrowserEventType[key], + this.mapBrowserEventHandler_ = new _ol_MapBrowserEventHandler_(this, options.moveTolerance); + for (var key in _ol_MapBrowserEventType_) { + _ol_events_.listen(this.mapBrowserEventHandler_, _ol_MapBrowserEventType_[key], this.handleMapBrowserEvent, this); } @@ -205,22 +205,22 @@ ol.PluggableMap = function(options) { */ this.keyHandlerKeys_ = null; - ol.events.listen(this.viewport_, ol.events.EventType.WHEEL, + _ol_events_.listen(this.viewport_, _ol_events_EventType_.WHEEL, this.handleBrowserEvent, this); - ol.events.listen(this.viewport_, ol.events.EventType.MOUSEWHEEL, + _ol_events_.listen(this.viewport_, _ol_events_EventType_.MOUSEWHEEL, this.handleBrowserEvent, this); /** * @type {ol.Collection.} * @protected */ - this.controls = optionsInternal.controls || new ol.Collection(); + this.controls = optionsInternal.controls || new _ol_Collection_(); /** * @type {ol.Collection.} * @protected */ - this.interactions = optionsInternal.interactions || new ol.Collection(); + this.interactions = optionsInternal.interactions || new _ol_Collection_(); /** * @type {ol.Collection.} @@ -263,7 +263,7 @@ ol.PluggableMap = function(options) { * @private * @type {ol.TileQueue} */ - this.tileQueue_ = new ol.TileQueue( + this.tileQueue_ = new _ol_TileQueue_( this.getTilePriority.bind(this), this.handleTileChange_.bind(this)); @@ -274,14 +274,14 @@ ol.PluggableMap = function(options) { */ this.skippedFeatureUids_ = {}; - ol.events.listen( - this, ol.Object.getChangeEventType(ol.MapProperty.LAYERGROUP), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_MapProperty_.LAYERGROUP), this.handleLayerGroupChanged_, this); - ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.VIEW), + _ol_events_.listen(this, _ol_Object_.getChangeEventType(_ol_MapProperty_.VIEW), this.handleViewChanged_, this); - ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.SIZE), + _ol_events_.listen(this, _ol_Object_.getChangeEventType(_ol_MapProperty_.SIZE), this.handleSizeChanged_, this); - ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.TARGET), + _ol_events_.listen(this, _ol_Object_.getChangeEventType(_ol_MapProperty_.TARGET), this.handleTargetChanged_, this); // setProperties will trigger the rendering of the map if the map @@ -297,7 +297,7 @@ ol.PluggableMap = function(options) { control.setMap(this); }, this); - ol.events.listen(this.controls, ol.CollectionEventType.ADD, + _ol_events_.listen(this.controls, _ol_CollectionEventType_.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -305,7 +305,7 @@ ol.PluggableMap = function(options) { event.element.setMap(this); }, this); - ol.events.listen(this.controls, ol.CollectionEventType.REMOVE, + _ol_events_.listen(this.controls, _ol_CollectionEventType_.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ @@ -322,7 +322,7 @@ ol.PluggableMap = function(options) { interaction.setMap(this); }, this); - ol.events.listen(this.interactions, ol.CollectionEventType.ADD, + _ol_events_.listen(this.interactions, _ol_CollectionEventType_.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -330,7 +330,7 @@ ol.PluggableMap = function(options) { event.element.setMap(this); }, this); - ol.events.listen(this.interactions, ol.CollectionEventType.REMOVE, + _ol_events_.listen(this.interactions, _ol_CollectionEventType_.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ @@ -340,7 +340,7 @@ ol.PluggableMap = function(options) { this.overlays_.forEach(this.addOverlayInternal_, this); - ol.events.listen(this.overlays_, ol.CollectionEventType.ADD, + _ol_events_.listen(this.overlays_, _ol_CollectionEventType_.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -348,7 +348,7 @@ ol.PluggableMap = function(options) { this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element)); }, this); - ol.events.listen(this.overlays_, ol.CollectionEventType.REMOVE, + _ol_events_.listen(this.overlays_, _ol_CollectionEventType_.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ @@ -362,7 +362,8 @@ ol.PluggableMap = function(options) { }, this); }; -ol.inherits(ol.PluggableMap, ol.Object); + +_ol_.inherits(_ol_PluggableMap_, _ol_Object_); /** @@ -370,7 +371,7 @@ ol.inherits(ol.PluggableMap, ol.Object); * @param {ol.control.Control} control Control. * @api */ -ol.PluggableMap.prototype.addControl = function(control) { +_ol_PluggableMap_.prototype.addControl = function(control) { this.getControls().push(control); }; @@ -380,7 +381,7 @@ ol.PluggableMap.prototype.addControl = function(control) { * @param {ol.interaction.Interaction} interaction Interaction to add. * @api */ -ol.PluggableMap.prototype.addInteraction = function(interaction) { +_ol_PluggableMap_.prototype.addInteraction = function(interaction) { this.getInteractions().push(interaction); }; @@ -392,7 +393,7 @@ ol.PluggableMap.prototype.addInteraction = function(interaction) { * @param {ol.layer.Base} layer Layer. * @api */ -ol.PluggableMap.prototype.addLayer = function(layer) { +_ol_PluggableMap_.prototype.addLayer = function(layer) { var layers = this.getLayerGroup().getLayers(); layers.push(layer); }; @@ -403,7 +404,7 @@ ol.PluggableMap.prototype.addLayer = function(layer) { * @param {ol.Overlay} overlay Overlay. * @api */ -ol.PluggableMap.prototype.addOverlay = function(overlay) { +_ol_PluggableMap_.prototype.addOverlay = function(overlay) { this.getOverlays().push(overlay); }; @@ -413,7 +414,7 @@ ol.PluggableMap.prototype.addOverlay = function(overlay) { * @param {ol.Overlay} overlay Overlay. * @private */ -ol.PluggableMap.prototype.addOverlayInternal_ = function(overlay) { +_ol_PluggableMap_.prototype.addOverlayInternal_ = function(overlay) { var id = overlay.getId(); if (id !== undefined) { this.overlayIdIndex_[id.toString()] = overlay; @@ -426,14 +427,14 @@ ol.PluggableMap.prototype.addOverlayInternal_ = function(overlay) { * * @inheritDoc */ -ol.PluggableMap.prototype.disposeInternal = function() { +_ol_PluggableMap_.prototype.disposeInternal = function() { this.mapBrowserEventHandler_.dispose(); - ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL, + _ol_events_.unlisten(this.viewport_, _ol_events_EventType_.WHEEL, this.handleBrowserEvent, this); - ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL, + _ol_events_.unlisten(this.viewport_, _ol_events_EventType_.MOUSEWHEEL, this.handleBrowserEvent, this); if (this.handleResize_ !== undefined) { - window.removeEventListener(ol.events.EventType.RESIZE, + window.removeEventListener(_ol_events_EventType_.RESIZE, this.handleResize_, false); this.handleResize_ = undefined; } @@ -442,7 +443,7 @@ ol.PluggableMap.prototype.disposeInternal = function() { this.animationDelayKey_ = undefined; } this.setTarget(null); - ol.Object.prototype.disposeInternal.call(this); + _ol_Object_.prototype.disposeInternal.call(this); }; @@ -465,7 +466,7 @@ ol.PluggableMap.prototype.disposeInternal = function() { * @template S,T * @api */ -ol.PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_options) { +_ol_PluggableMap_.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_options) { if (!this.frameState_) { return; } @@ -474,7 +475,7 @@ ol.PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_ var hitTolerance = opt_options.hitTolerance !== undefined ? opt_options.hitTolerance * this.frameState_.pixelRatio : 0; var layerFilter = opt_options.layerFilter !== undefined ? - opt_options.layerFilter : ol.functions.TRUE; + opt_options.layerFilter : _ol_functions_.TRUE; return this.renderer_.forEachFeatureAtCoordinate( coordinate, this.frameState_, hitTolerance, callback, null, layerFilter, null); @@ -489,7 +490,7 @@ ol.PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_ * `null` if none were found. * @api */ -ol.PluggableMap.prototype.getFeaturesAtPixel = function(pixel, opt_options) { +_ol_PluggableMap_.prototype.getFeaturesAtPixel = function(pixel, opt_options) { var features = null; this.forEachFeatureAtPixel(pixel, function(feature) { if (!features) { @@ -524,13 +525,13 @@ ol.PluggableMap.prototype.getFeaturesAtPixel = function(pixel, opt_options) { * @template S,T,U * @api */ -ol.PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, opt_layerFilter, opt_this2) { +_ol_PluggableMap_.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, opt_layerFilter, opt_this2) { if (!this.frameState_) { return; } var thisArg = opt_this !== undefined ? opt_this : null; var layerFilter = opt_layerFilter !== undefined ? - opt_layerFilter : ol.functions.TRUE; + opt_layerFilter : _ol_functions_.TRUE; var thisArg2 = opt_this2 !== undefined ? opt_this2 : null; return this.renderer_.forEachLayerAtPixel( pixel, this.frameState_, callback, thisArg, @@ -547,14 +548,14 @@ ol.PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_th * @template U * @api */ -ol.PluggableMap.prototype.hasFeatureAtPixel = function(pixel, opt_options) { +_ol_PluggableMap_.prototype.hasFeatureAtPixel = function(pixel, opt_options) { if (!this.frameState_) { return false; } var coordinate = this.getCoordinateFromPixel(pixel); opt_options = opt_options !== undefined ? opt_options : {}; var layerFilter = opt_options.layerFilter !== undefined ? - opt_options.layerFilter : ol.functions.TRUE; + opt_options.layerFilter : _ol_functions_.TRUE; var hitTolerance = opt_options.hitTolerance !== undefined ? opt_options.hitTolerance * this.frameState_.pixelRatio : 0; return this.renderer_.hasFeatureAtCoordinate( @@ -568,7 +569,7 @@ ol.PluggableMap.prototype.hasFeatureAtPixel = function(pixel, opt_options) { * @return {ol.Coordinate} Coordinate. * @api */ -ol.PluggableMap.prototype.getEventCoordinate = function(event) { +_ol_PluggableMap_.prototype.getEventCoordinate = function(event) { return this.getCoordinateFromPixel(this.getEventPixel(event)); }; @@ -579,7 +580,7 @@ ol.PluggableMap.prototype.getEventCoordinate = function(event) { * @return {ol.Pixel} Pixel. * @api */ -ol.PluggableMap.prototype.getEventPixel = function(event) { +_ol_PluggableMap_.prototype.getEventPixel = function(event) { var viewportPosition = this.viewport_.getBoundingClientRect(); var eventPosition = event.changedTouches ? event.changedTouches[0] : event; return [ @@ -598,9 +599,10 @@ ol.PluggableMap.prototype.getEventPixel = function(event) { * @observable * @api */ -ol.PluggableMap.prototype.getTarget = function() { - return /** @type {Element|string|undefined} */ ( - this.get(ol.MapProperty.TARGET)); +_ol_PluggableMap_.prototype.getTarget = function() { + return ( + /** @type {Element|string|undefined} */ this.get(_ol_MapProperty_.TARGET) + ); }; @@ -611,7 +613,7 @@ ol.PluggableMap.prototype.getTarget = function() { * @return {Element} The element that the map is rendered in. * @api */ -ol.PluggableMap.prototype.getTargetElement = function() { +_ol_PluggableMap_.prototype.getTargetElement = function() { var target = this.getTarget(); if (target !== undefined) { return typeof target === 'string' ? @@ -630,12 +632,12 @@ ol.PluggableMap.prototype.getTargetElement = function() { * @return {ol.Coordinate} The coordinate for the pixel position. * @api */ -ol.PluggableMap.prototype.getCoordinateFromPixel = function(pixel) { +_ol_PluggableMap_.prototype.getCoordinateFromPixel = function(pixel) { var frameState = this.frameState_; if (!frameState) { return null; } else { - return ol.transform.apply(frameState.pixelToCoordinateTransform, pixel.slice()); + return _ol_transform_.apply(frameState.pixelToCoordinateTransform, pixel.slice()); } }; @@ -646,7 +648,7 @@ ol.PluggableMap.prototype.getCoordinateFromPixel = function(pixel) { * @return {ol.Collection.} Controls. * @api */ -ol.PluggableMap.prototype.getControls = function() { +_ol_PluggableMap_.prototype.getControls = function() { return this.controls; }; @@ -657,7 +659,7 @@ ol.PluggableMap.prototype.getControls = function() { * @return {ol.Collection.} Overlays. * @api */ -ol.PluggableMap.prototype.getOverlays = function() { +_ol_PluggableMap_.prototype.getOverlays = function() { return this.overlays_; }; @@ -670,7 +672,7 @@ ol.PluggableMap.prototype.getOverlays = function() { * @return {ol.Overlay} Overlay. * @api */ -ol.PluggableMap.prototype.getOverlayById = function(id) { +_ol_PluggableMap_.prototype.getOverlayById = function(id) { var overlay = this.overlayIdIndex_[id.toString()]; return overlay !== undefined ? overlay : null; }; @@ -684,7 +686,7 @@ ol.PluggableMap.prototype.getOverlayById = function(id) { * @return {ol.Collection.} Interactions. * @api */ -ol.PluggableMap.prototype.getInteractions = function() { +_ol_PluggableMap_.prototype.getInteractions = function() { return this.interactions; }; @@ -695,8 +697,10 @@ ol.PluggableMap.prototype.getInteractions = function() { * @observable * @api */ -ol.PluggableMap.prototype.getLayerGroup = function() { - return /** @type {ol.layer.Group} */ (this.get(ol.MapProperty.LAYERGROUP)); +_ol_PluggableMap_.prototype.getLayerGroup = function() { + return ( + /** @type {ol.layer.Group} */ this.get(_ol_MapProperty_.LAYERGROUP) + ); }; @@ -705,7 +709,7 @@ ol.PluggableMap.prototype.getLayerGroup = function() { * @return {!ol.Collection.} Layers. * @api */ -ol.PluggableMap.prototype.getLayers = function() { +_ol_PluggableMap_.prototype.getLayers = function() { var layers = this.getLayerGroup().getLayers(); return layers; }; @@ -718,12 +722,12 @@ ol.PluggableMap.prototype.getLayers = function() { * @return {ol.Pixel} A pixel position in the map viewport. * @api */ -ol.PluggableMap.prototype.getPixelFromCoordinate = function(coordinate) { +_ol_PluggableMap_.prototype.getPixelFromCoordinate = function(coordinate) { var frameState = this.frameState_; if (!frameState) { return null; } else { - return ol.transform.apply(frameState.coordinateToPixelTransform, + return _ol_transform_.apply(frameState.coordinateToPixelTransform, coordinate.slice(0, 2)); } }; @@ -733,7 +737,7 @@ ol.PluggableMap.prototype.getPixelFromCoordinate = function(coordinate) { * Get the map renderer. * @return {ol.renderer.Map} Renderer */ -ol.PluggableMap.prototype.getRenderer = function() { +_ol_PluggableMap_.prototype.getRenderer = function() { return this.renderer_; }; @@ -744,8 +748,10 @@ ol.PluggableMap.prototype.getRenderer = function() { * @observable * @api */ -ol.PluggableMap.prototype.getSize = function() { - return /** @type {ol.Size|undefined} */ (this.get(ol.MapProperty.SIZE)); +_ol_PluggableMap_.prototype.getSize = function() { + return ( + /** @type {ol.Size|undefined} */ this.get(_ol_MapProperty_.SIZE) + ); }; @@ -756,8 +762,10 @@ ol.PluggableMap.prototype.getSize = function() { * @observable * @api */ -ol.PluggableMap.prototype.getView = function() { - return /** @type {ol.View} */ (this.get(ol.MapProperty.VIEW)); +_ol_PluggableMap_.prototype.getView = function() { + return ( + /** @type {ol.View} */ this.get(_ol_MapProperty_.VIEW) + ); }; @@ -766,7 +774,7 @@ ol.PluggableMap.prototype.getView = function() { * @return {Element} Viewport. * @api */ -ol.PluggableMap.prototype.getViewport = function() { +_ol_PluggableMap_.prototype.getViewport = function() { return this.viewport_; }; @@ -778,7 +786,7 @@ ol.PluggableMap.prototype.getViewport = function() { * events. * @return {!Element} The map's overlay container. */ -ol.PluggableMap.prototype.getOverlayContainer = function() { +_ol_PluggableMap_.prototype.getOverlayContainer = function() { return this.overlayContainer_; }; @@ -790,7 +798,7 @@ ol.PluggableMap.prototype.getOverlayContainer = function() { * don't trigger any {@link ol.MapBrowserEvent}. * @return {!Element} The map's overlay container that stops events. */ -ol.PluggableMap.prototype.getOverlayContainerStopEvent = function() { +_ol_PluggableMap_.prototype.getOverlayContainerStopEvent = function() { return this.overlayContainerStopEvent_; }; @@ -802,15 +810,15 @@ ol.PluggableMap.prototype.getOverlayContainerStopEvent = function() { * @param {number} tileResolution Tile resolution. * @return {number} Tile priority. */ -ol.PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter, tileResolution) { +_ol_PluggableMap_.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter, tileResolution) { // Filter out tiles at higher zoom levels than the current zoom level, or that // are outside the visible extent. var frameState = this.frameState_; if (!frameState || !(tileSourceKey in frameState.wantedTiles)) { - return ol.structs.PriorityQueue.DROP; + return _ol_structs_PriorityQueue_.DROP; } if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) { - return ol.structs.PriorityQueue.DROP; + return _ol_structs_PriorityQueue_.DROP; } // Prioritize the highest zoom level tiles closest to the focus. // Tiles at higher zoom levels are prioritized using Math.log(tileResolution). @@ -829,9 +837,9 @@ ol.PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCe * @param {Event} browserEvent Browser event. * @param {string=} opt_type Type. */ -ol.PluggableMap.prototype.handleBrowserEvent = function(browserEvent, opt_type) { +_ol_PluggableMap_.prototype.handleBrowserEvent = function(browserEvent, opt_type) { var type = opt_type || browserEvent.type; - var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent); + var mapBrowserEvent = new _ol_MapBrowserEvent_(type, this, browserEvent); this.handleMapBrowserEvent(mapBrowserEvent); }; @@ -839,7 +847,7 @@ ol.PluggableMap.prototype.handleBrowserEvent = function(browserEvent, opt_type) /** * @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle. */ -ol.PluggableMap.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { +_ol_PluggableMap_.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { if (!this.frameState_) { // With no view defined, we cannot translate pixels into geographical // coordinates so interactions cannot be used. @@ -867,7 +875,7 @@ ol.PluggableMap.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { /** * @protected */ -ol.PluggableMap.prototype.handlePostRender = function() { +_ol_PluggableMap_.prototype.handlePostRender = function() { var frameState = this.frameState_; @@ -886,11 +894,11 @@ ol.PluggableMap.prototype.handlePostRender = function() { var maxNewLoads = maxTotalLoading; if (frameState) { var hints = frameState.viewHints; - if (hints[ol.ViewHint.ANIMATING]) { + if (hints[_ol_ViewHint_.ANIMATING]) { maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0; maxNewLoads = 2; } - if (hints[ol.ViewHint.INTERACTING]) { + if (hints[_ol_ViewHint_.INTERACTING]) { maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0; maxNewLoads = 2; } @@ -913,7 +921,7 @@ ol.PluggableMap.prototype.handlePostRender = function() { /** * @private */ -ol.PluggableMap.prototype.handleSizeChanged_ = function() { +_ol_PluggableMap_.prototype.handleSizeChanged_ = function() { this.render(); }; @@ -921,7 +929,7 @@ ol.PluggableMap.prototype.handleSizeChanged_ = function() { /** * @private */ -ol.PluggableMap.prototype.handleTargetChanged_ = function() { +_ol_PluggableMap_.prototype.handleTargetChanged_ = function() { // target may be undefined, null, a string or an Element. // If it's a string we convert it to an Element before proceeding. // If it's not now an Element we remove the viewport from the DOM. @@ -934,16 +942,16 @@ ol.PluggableMap.prototype.handleTargetChanged_ = function() { if (this.keyHandlerKeys_) { for (var i = 0, ii = this.keyHandlerKeys_.length; i < ii; ++i) { - ol.events.unlistenByKey(this.keyHandlerKeys_[i]); + _ol_events_.unlistenByKey(this.keyHandlerKeys_[i]); } this.keyHandlerKeys_ = null; } if (!targetElement) { this.renderer_.removeLayerRenderers(); - ol.dom.removeNode(this.viewport_); + _ol_dom_.removeNode(this.viewport_); if (this.handleResize_ !== undefined) { - window.removeEventListener(ol.events.EventType.RESIZE, + window.removeEventListener(_ol_events_EventType_.RESIZE, this.handleResize_, false); this.handleResize_ = undefined; } @@ -953,15 +961,15 @@ ol.PluggableMap.prototype.handleTargetChanged_ = function() { var keyboardEventTarget = !this.keyboardEventTarget_ ? targetElement : this.keyboardEventTarget_; this.keyHandlerKeys_ = [ - ol.events.listen(keyboardEventTarget, ol.events.EventType.KEYDOWN, + _ol_events_.listen(keyboardEventTarget, _ol_events_EventType_.KEYDOWN, this.handleBrowserEvent, this), - ol.events.listen(keyboardEventTarget, ol.events.EventType.KEYPRESS, + _ol_events_.listen(keyboardEventTarget, _ol_events_EventType_.KEYPRESS, this.handleBrowserEvent, this) ]; if (!this.handleResize_) { this.handleResize_ = this.updateSize.bind(this); - window.addEventListener(ol.events.EventType.RESIZE, + window.addEventListener(_ol_events_EventType_.RESIZE, this.handleResize_, false); } } @@ -975,7 +983,7 @@ ol.PluggableMap.prototype.handleTargetChanged_ = function() { /** * @private */ -ol.PluggableMap.prototype.handleTileChange_ = function() { +_ol_PluggableMap_.prototype.handleTileChange_ = function() { this.render(); }; @@ -983,7 +991,7 @@ ol.PluggableMap.prototype.handleTileChange_ = function() { /** * @private */ -ol.PluggableMap.prototype.handleViewPropertyChanged_ = function() { +_ol_PluggableMap_.prototype.handleViewPropertyChanged_ = function() { this.render(); }; @@ -991,23 +999,23 @@ ol.PluggableMap.prototype.handleViewPropertyChanged_ = function() { /** * @private */ -ol.PluggableMap.prototype.handleViewChanged_ = function() { +_ol_PluggableMap_.prototype.handleViewChanged_ = function() { if (this.viewPropertyListenerKey_) { - ol.events.unlistenByKey(this.viewPropertyListenerKey_); + _ol_events_.unlistenByKey(this.viewPropertyListenerKey_); this.viewPropertyListenerKey_ = null; } if (this.viewChangeListenerKey_) { - ol.events.unlistenByKey(this.viewChangeListenerKey_); + _ol_events_.unlistenByKey(this.viewChangeListenerKey_); this.viewChangeListenerKey_ = null; } var view = this.getView(); if (view) { - this.viewport_.setAttribute('data-view', ol.getUid(view)); - this.viewPropertyListenerKey_ = ol.events.listen( - view, ol.ObjectEventType.PROPERTYCHANGE, + this.viewport_.setAttribute('data-view', _ol_.getUid(view)); + this.viewPropertyListenerKey_ = _ol_events_.listen( + view, _ol_ObjectEventType_.PROPERTYCHANGE, this.handleViewPropertyChanged_, this); - this.viewChangeListenerKey_ = ol.events.listen( - view, ol.events.EventType.CHANGE, + this.viewChangeListenerKey_ = _ol_events_.listen( + view, _ol_events_EventType_.CHANGE, this.handleViewPropertyChanged_, this); } this.render(); @@ -1017,19 +1025,19 @@ ol.PluggableMap.prototype.handleViewChanged_ = function() { /** * @private */ -ol.PluggableMap.prototype.handleLayerGroupChanged_ = function() { +_ol_PluggableMap_.prototype.handleLayerGroupChanged_ = function() { if (this.layerGroupPropertyListenerKeys_) { - this.layerGroupPropertyListenerKeys_.forEach(ol.events.unlistenByKey); + this.layerGroupPropertyListenerKeys_.forEach(_ol_events_.unlistenByKey); this.layerGroupPropertyListenerKeys_ = null; } var layerGroup = this.getLayerGroup(); if (layerGroup) { this.layerGroupPropertyListenerKeys_ = [ - ol.events.listen( - layerGroup, ol.ObjectEventType.PROPERTYCHANGE, + _ol_events_.listen( + layerGroup, _ol_ObjectEventType_.PROPERTYCHANGE, this.render, this), - ol.events.listen( - layerGroup, ol.events.EventType.CHANGE, + _ol_events_.listen( + layerGroup, _ol_events_EventType_.CHANGE, this.render, this) ]; } @@ -1040,7 +1048,7 @@ ol.PluggableMap.prototype.handleLayerGroupChanged_ = function() { /** * @return {boolean} Is rendered. */ -ol.PluggableMap.prototype.isRendered = function() { +_ol_PluggableMap_.prototype.isRendered = function() { return !!this.frameState_; }; @@ -1049,7 +1057,7 @@ ol.PluggableMap.prototype.isRendered = function() { * Requests an immediate render in a synchronous manner. * @api */ -ol.PluggableMap.prototype.renderSync = function() { +_ol_PluggableMap_.prototype.renderSync = function() { if (this.animationDelayKey_) { cancelAnimationFrame(this.animationDelayKey_); } @@ -1061,7 +1069,7 @@ ol.PluggableMap.prototype.renderSync = function() { * Request a map rendering (at the next animation frame). * @api */ -ol.PluggableMap.prototype.render = function() { +_ol_PluggableMap_.prototype.render = function() { if (this.animationDelayKey_ === undefined) { this.animationDelayKey_ = requestAnimationFrame( this.animationDelay_); @@ -1076,7 +1084,7 @@ ol.PluggableMap.prototype.render = function() { * if the control was not found). * @api */ -ol.PluggableMap.prototype.removeControl = function(control) { +_ol_PluggableMap_.prototype.removeControl = function(control) { return this.getControls().remove(control); }; @@ -1088,7 +1096,7 @@ ol.PluggableMap.prototype.removeControl = function(control) { * undefined if the interaction was not found). * @api */ -ol.PluggableMap.prototype.removeInteraction = function(interaction) { +_ol_PluggableMap_.prototype.removeInteraction = function(interaction) { return this.getInteractions().remove(interaction); }; @@ -1100,7 +1108,7 @@ ol.PluggableMap.prototype.removeInteraction = function(interaction) { * layer was not found). * @api */ -ol.PluggableMap.prototype.removeLayer = function(layer) { +_ol_PluggableMap_.prototype.removeLayer = function(layer) { var layers = this.getLayerGroup().getLayers(); return layers.remove(layer); }; @@ -1113,7 +1121,7 @@ ol.PluggableMap.prototype.removeLayer = function(layer) { * if the overlay was not found). * @api */ -ol.PluggableMap.prototype.removeOverlay = function(overlay) { +_ol_PluggableMap_.prototype.removeOverlay = function(overlay) { return this.getOverlays().remove(overlay); }; @@ -1122,21 +1130,21 @@ ol.PluggableMap.prototype.removeOverlay = function(overlay) { * @param {number} time Time. * @private */ -ol.PluggableMap.prototype.renderFrame_ = function(time) { +_ol_PluggableMap_.prototype.renderFrame_ = function(time) { var i, ii, viewState; var size = this.getSize(); var view = this.getView(); - var extent = ol.extent.createEmpty(); + var extent = _ol_extent_.createEmpty(); var previousFrameState = this.frameState_; /** @type {?olx.FrameState} */ var frameState = null; - if (size !== undefined && ol.size.hasArea(size) && view && view.isDef()) { + if (size !== undefined && _ol_size_.hasArea(size) && view && view.isDef()) { var viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined); var layerStatesArray = this.getLayerGroup().getLayerStatesArray(); var layerStates = {}; for (i = 0, ii = layerStatesArray.length; i < ii; ++i) { - layerStates[ol.getUid(layerStatesArray[i].layer)] = layerStatesArray[i]; + layerStates[_ol_.getUid(layerStatesArray[i].layer)] = layerStatesArray[i]; } viewState = view.getState(); var center = viewState.center; @@ -1151,7 +1159,7 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) { index: this.frameIndex_++, layerStates: layerStates, layerStatesArray: layerStatesArray, - logos: ol.obj.assign({}, this.logos_), + logos: _ol_obj_.assign({}, this.logos_), pixelRatio: this.pixelRatio_, pixelToCoordinateTransform: this.pixelToCoordinateTransform_, postRenderFunctions: [], @@ -1167,7 +1175,7 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) { } if (frameState) { - frameState.extent = ol.extent.getForViewAndSize(viewState.center, + frameState.extent = _ol_extent_.getForViewAndSize(viewState.center, viewState.resolution, viewState.rotation, frameState.size, extent); } @@ -1183,29 +1191,29 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) { if (previousFrameState) { var moveStart = !this.previousExtent_ || - (!ol.extent.isEmpty(this.previousExtent_) && - !ol.extent.equals(frameState.extent, this.previousExtent_)); + (!_ol_extent_.isEmpty(this.previousExtent_) && + !_ol_extent_.equals(frameState.extent, this.previousExtent_)); if (moveStart) { this.dispatchEvent( - new ol.MapEvent(ol.MapEventType.MOVESTART, this, previousFrameState)); - this.previousExtent_ = ol.extent.createOrUpdateEmpty(this.previousExtent_); + new _ol_MapEvent_(_ol_MapEventType_.MOVESTART, this, previousFrameState)); + this.previousExtent_ = _ol_extent_.createOrUpdateEmpty(this.previousExtent_); } } var idle = this.previousExtent_ && - !frameState.viewHints[ol.ViewHint.ANIMATING] && - !frameState.viewHints[ol.ViewHint.INTERACTING] && - !ol.extent.equals(frameState.extent, this.previousExtent_); + !frameState.viewHints[_ol_ViewHint_.ANIMATING] && + !frameState.viewHints[_ol_ViewHint_.INTERACTING] && + !_ol_extent_.equals(frameState.extent, this.previousExtent_); if (idle) { this.dispatchEvent( - new ol.MapEvent(ol.MapEventType.MOVEEND, this, frameState)); - ol.extent.clone(frameState.extent, this.previousExtent_); + new _ol_MapEvent_(_ol_MapEventType_.MOVEEND, this, frameState)); + _ol_extent_.clone(frameState.extent, this.previousExtent_); } } this.dispatchEvent( - new ol.MapEvent(ol.MapEventType.POSTRENDER, this, frameState)); + new _ol_MapEvent_(_ol_MapEventType_.POSTRENDER, this, frameState)); setTimeout(this.handlePostRender.bind(this), 0); @@ -1219,8 +1227,8 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) { * @observable * @api */ -ol.PluggableMap.prototype.setLayerGroup = function(layerGroup) { - this.set(ol.MapProperty.LAYERGROUP, layerGroup); +_ol_PluggableMap_.prototype.setLayerGroup = function(layerGroup) { + this.set(_ol_MapProperty_.LAYERGROUP, layerGroup); }; @@ -1230,8 +1238,8 @@ ol.PluggableMap.prototype.setLayerGroup = function(layerGroup) { * @observable * @api */ -ol.PluggableMap.prototype.setSize = function(size) { - this.set(ol.MapProperty.SIZE, size); +_ol_PluggableMap_.prototype.setSize = function(size) { + this.set(_ol_MapProperty_.SIZE, size); }; @@ -1242,8 +1250,8 @@ ol.PluggableMap.prototype.setSize = function(size) { * @observable * @api */ -ol.PluggableMap.prototype.setTarget = function(target) { - this.set(ol.MapProperty.TARGET, target); +_ol_PluggableMap_.prototype.setTarget = function(target) { + this.set(_ol_MapProperty_.TARGET, target); }; @@ -1253,16 +1261,16 @@ ol.PluggableMap.prototype.setTarget = function(target) { * @observable * @api */ -ol.PluggableMap.prototype.setView = function(view) { - this.set(ol.MapProperty.VIEW, view); +_ol_PluggableMap_.prototype.setView = function(view) { + this.set(_ol_MapProperty_.VIEW, view); }; /** * @param {ol.Feature} feature Feature. */ -ol.PluggableMap.prototype.skipFeature = function(feature) { - var featureUid = ol.getUid(feature).toString(); +_ol_PluggableMap_.prototype.skipFeature = function(feature) { + var featureUid = _ol_.getUid(feature).toString(); this.skippedFeatureUids_[featureUid] = true; this.render(); }; @@ -1273,7 +1281,7 @@ ol.PluggableMap.prototype.skipFeature = function(feature) { * third-party code changes the size of the map viewport. * @api */ -ol.PluggableMap.prototype.updateSize = function() { +_ol_PluggableMap_.prototype.updateSize = function() { var targetElement = this.getTargetElement(); if (!targetElement) { @@ -1299,8 +1307,8 @@ ol.PluggableMap.prototype.updateSize = function() { /** * @param {ol.Feature} feature Feature. */ -ol.PluggableMap.prototype.unskipFeature = function(feature) { - var featureUid = ol.getUid(feature).toString(); +_ol_PluggableMap_.prototype.unskipFeature = function(feature) { + var featureUid = _ol_.getUid(feature).toString(); delete this.skippedFeatureUids_[featureUid]; this.render(); }; @@ -1310,9 +1318,9 @@ ol.PluggableMap.prototype.unskipFeature = function(feature) { * @type {Array.} * @const */ -ol.PluggableMap.DEFAULT_RENDERER_TYPES = [ - ol.renderer.Type.CANVAS, - ol.renderer.Type.WEBGL +_ol_PluggableMap_.DEFAULT_RENDERER_TYPES = [ + _ol_renderer_Type_.CANVAS, + _ol_renderer_Type_.WEBGL ]; @@ -1320,7 +1328,7 @@ ol.PluggableMap.DEFAULT_RENDERER_TYPES = [ * @const * @type {string} */ -ol.PluggableMap.LOGO_URL = 'data:image/png;base64,' + +_ol_PluggableMap_.LOGO_URL = 'data:image/png;base64,' + 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAA3NCSVQICAjb4U/gAAAACXBI' + 'WXMAAAHGAAABxgEXwfpGAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAA' + 'AhNQTFRF////AP//AICAgP//AFVVQECA////K1VVSbbbYL/fJ05idsTYJFtbbcjbJllmZszW' + @@ -1348,7 +1356,7 @@ ol.PluggableMap.LOGO_URL = 'data:image/png;base64,' + * @param {olx.MapOptions} options Map options. * @return {ol.MapOptionsInternal} Internal map options. */ -ol.PluggableMap.createOptionsInternal = function(options) { +_ol_PluggableMap_.createOptionsInternal = function(options) { /** * @type {Element|Document} @@ -1368,28 +1376,28 @@ ol.PluggableMap.createOptionsInternal = function(options) { var logos = {}; if (options.logo === undefined || (typeof options.logo === 'boolean' && options.logo)) { - logos[ol.PluggableMap.LOGO_URL] = 'https://openlayers.org/'; + logos[_ol_PluggableMap_.LOGO_URL] = 'https://openlayers.org/'; } else { var logo = options.logo; if (typeof logo === 'string') { logos[logo] = ''; } else if (logo instanceof HTMLElement) { - logos[ol.getUid(logo).toString()] = logo; + logos[_ol_.getUid(logo).toString()] = logo; } else if (logo) { - ol.asserts.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string. - ol.asserts.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string. + _ol_asserts_.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string. + _ol_asserts_.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string. logos[logo.src] = logo.href; } } - var layerGroup = (options.layers instanceof ol.layer.Group) ? - options.layers : new ol.layer.Group({layers: options.layers}); - values[ol.MapProperty.LAYERGROUP] = layerGroup; + var layerGroup = (options.layers instanceof _ol_layer_Group_) ? + options.layers : new _ol_layer_Group_({layers: options.layers}); + values[_ol_MapProperty_.LAYERGROUP] = layerGroup; - values[ol.MapProperty.TARGET] = options.target; + values[_ol_MapProperty_.TARGET] = options.target; - values[ol.MapProperty.VIEW] = options.view !== undefined ? - options.view : new ol.View(); + values[_ol_MapProperty_.VIEW] = options.view !== undefined ? + options.view : new _ol_View_(); /** * @type {Array.} @@ -1402,13 +1410,13 @@ ol.PluggableMap.createOptionsInternal = function(options) { } else if (typeof options.renderer === 'string') { rendererTypes = [options.renderer]; } else { - ol.asserts.assert(false, 46); // Incorrect format for `renderer` option + _ol_asserts_.assert(false, 46); // Incorrect format for `renderer` option } if (rendererTypes.indexOf(/** @type {ol.renderer.Type} */ ('dom')) >= 0) { - rendererTypes = rendererTypes.concat(ol.PluggableMap.DEFAULT_RENDERER_TYPES); + rendererTypes = rendererTypes.concat(_ol_PluggableMap_.DEFAULT_RENDERER_TYPES); } } else { - rendererTypes = ol.PluggableMap.DEFAULT_RENDERER_TYPES; + rendererTypes = _ol_PluggableMap_.DEFAULT_RENDERER_TYPES; } /** @@ -1416,7 +1424,7 @@ ol.PluggableMap.createOptionsInternal = function(options) { */ var mapRendererPlugin; - var mapRendererPlugins = ol.plugins.getMapRendererPlugins(); + var mapRendererPlugins = _ol_plugins_.getMapRendererPlugins(); outer: for (var i = 0, ii = rendererTypes.length; i < ii; ++i) { var rendererType = rendererTypes[i]; for (var j = 0, jj = mapRendererPlugins.length; j < jj; ++j) { @@ -1435,9 +1443,9 @@ ol.PluggableMap.createOptionsInternal = function(options) { var controls; if (options.controls !== undefined) { if (Array.isArray(options.controls)) { - controls = new ol.Collection(options.controls.slice()); + controls = new _ol_Collection_(options.controls.slice()); } else { - ol.asserts.assert(options.controls instanceof ol.Collection, + _ol_asserts_.assert(options.controls instanceof _ol_Collection_, 47); // Expected `controls` to be an array or an `ol.Collection` controls = options.controls; } @@ -1446,9 +1454,9 @@ ol.PluggableMap.createOptionsInternal = function(options) { var interactions; if (options.interactions !== undefined) { if (Array.isArray(options.interactions)) { - interactions = new ol.Collection(options.interactions.slice()); + interactions = new _ol_Collection_(options.interactions.slice()); } else { - ol.asserts.assert(options.interactions instanceof ol.Collection, + _ol_asserts_.assert(options.interactions instanceof _ol_Collection_, 48); // Expected `interactions` to be an array or an `ol.Collection` interactions = options.interactions; } @@ -1457,14 +1465,14 @@ ol.PluggableMap.createOptionsInternal = function(options) { var overlays; if (options.overlays !== undefined) { if (Array.isArray(options.overlays)) { - overlays = new ol.Collection(options.overlays.slice()); + overlays = new _ol_Collection_(options.overlays.slice()); } else { - ol.asserts.assert(options.overlays instanceof ol.Collection, + _ol_asserts_.assert(options.overlays instanceof _ol_Collection_, 49); // Expected `overlays` to be an array or an `ol.Collection` overlays = options.overlays; } } else { - overlays = new ol.Collection(); + overlays = new _ol_Collection_(); } return { @@ -1478,3 +1486,4 @@ ol.PluggableMap.createOptionsInternal = function(options) { }; }; +export default _ol_PluggableMap_; diff --git a/src/ol/PluginType.js b/src/ol/PluginType.js index 817fea5c8a..071c853618 100644 --- a/src/ol/PluginType.js +++ b/src/ol/PluginType.js @@ -1,11 +1,14 @@ -goog.provide('ol.PluginType'); - +/** + * @module ol/PluginType + */ /** * A plugin type used when registering a plugin. The supported plugin types are * 'MAP_RENDERER', and 'LAYER_RENDERER'. * @enum {string} */ -ol.PluginType = { +var _ol_PluginType_ = { MAP_RENDERER: 'MAP_RENDERER', LAYER_RENDERER: 'LAYER_RENDERER' }; + +export default _ol_PluginType_; diff --git a/src/ol/ResolutionConstraint.js b/src/ol/ResolutionConstraint.js index 32bc069eea..cf22947dc8 100644 --- a/src/ol/ResolutionConstraint.js +++ b/src/ol/ResolutionConstraint.js @@ -1,14 +1,16 @@ -goog.provide('ol.ResolutionConstraint'); - -goog.require('ol.array'); -goog.require('ol.math'); +/** + * @module ol/ResolutionConstraint + */ +import _ol_array_ from './array.js'; +import _ol_math_ from './math.js'; +var _ol_ResolutionConstraint_ = {}; /** * @param {Array.} resolutions Resolutions. * @return {ol.ResolutionConstraintType} Zoom function. */ -ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) { +_ol_ResolutionConstraint_.createSnapToResolutions = function(resolutions) { return ( /** * @param {number|undefined} resolution Resolution. @@ -19,8 +21,8 @@ ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) { function(resolution, delta, direction) { if (resolution !== undefined) { var z = - ol.array.linearFindNearest(resolutions, resolution, direction); - z = ol.math.clamp(z + delta, 0, resolutions.length - 1); + _ol_array_.linearFindNearest(resolutions, resolution, direction); + z = _ol_math_.clamp(z + delta, 0, resolutions.length - 1); var index = Math.floor(z); if (z != index && index < resolutions.length - 1) { var power = resolutions[index] / resolutions[index + 1]; @@ -31,7 +33,8 @@ ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) { } else { return undefined; } - }); + } + ); }; @@ -41,7 +44,7 @@ ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) { * @param {number=} opt_maxLevel Maximum level. * @return {ol.ResolutionConstraintType} Zoom function. */ -ol.ResolutionConstraint.createSnapToPower = function(power, maxResolution, opt_maxLevel) { +_ol_ResolutionConstraint_.createSnapToPower = function(power, maxResolution, opt_maxLevel) { return ( /** * @param {number|undefined} resolution Resolution. @@ -64,3 +67,4 @@ ol.ResolutionConstraint.createSnapToPower = function(power, maxResolution, opt_m } }); }; +export default _ol_ResolutionConstraint_; diff --git a/src/ol/RotationConstraint.js b/src/ol/RotationConstraint.js index daafdbd250..a71a82bd75 100644 --- a/src/ol/RotationConstraint.js +++ b/src/ol/RotationConstraint.js @@ -1,6 +1,8 @@ -goog.provide('ol.RotationConstraint'); - -goog.require('ol.math'); +/** + * @module ol/RotationConstraint + */ +import _ol_math_ from './math.js'; +var _ol_RotationConstraint_ = {}; /** @@ -8,7 +10,7 @@ goog.require('ol.math'); * @param {number} delta Delta. * @return {number|undefined} Rotation. */ -ol.RotationConstraint.disable = function(rotation, delta) { +_ol_RotationConstraint_.disable = function(rotation, delta) { if (rotation !== undefined) { return 0; } else { @@ -22,7 +24,7 @@ ol.RotationConstraint.disable = function(rotation, delta) { * @param {number} delta Delta. * @return {number|undefined} Rotation. */ -ol.RotationConstraint.none = function(rotation, delta) { +_ol_RotationConstraint_.none = function(rotation, delta) { if (rotation !== undefined) { return rotation + delta; } else { @@ -35,7 +37,7 @@ ol.RotationConstraint.none = function(rotation, delta) { * @param {number} n N. * @return {ol.RotationConstraintType} Rotation constraint. */ -ol.RotationConstraint.createSnapToN = function(n) { +_ol_RotationConstraint_.createSnapToN = function(n) { var theta = 2 * Math.PI / n; return ( /** @@ -58,8 +60,8 @@ ol.RotationConstraint.createSnapToN = function(n) { * @param {number=} opt_tolerance Tolerance. * @return {ol.RotationConstraintType} Rotation constraint. */ -ol.RotationConstraint.createSnapToZero = function(opt_tolerance) { - var tolerance = opt_tolerance || ol.math.toRadians(5); +_ol_RotationConstraint_.createSnapToZero = function(opt_tolerance) { + var tolerance = opt_tolerance || _ol_math_.toRadians(5); return ( /** * @param {number|undefined} rotation Rotation. @@ -78,3 +80,4 @@ ol.RotationConstraint.createSnapToZero = function(opt_tolerance) { } }); }; +export default _ol_RotationConstraint_; diff --git a/src/ol/Sphere.js b/src/ol/Sphere.js index 4117329172..6fb4472ed7 100644 --- a/src/ol/Sphere.js +++ b/src/ol/Sphere.js @@ -1,3 +1,6 @@ +/** + * @module ol/Sphere + */ /** * @license * Latitude/longitude spherical geodesy formulae taken from @@ -5,11 +8,8 @@ * Licensed under CC-BY-3.0. */ -goog.provide('ol.Sphere'); - -goog.require('ol.math'); -goog.require('ol.geom.GeometryType'); - +import _ol_math_ from './math.js'; +import _ol_geom_GeometryType_ from './geom/GeometryType.js'; /** * @classdesc @@ -27,7 +27,7 @@ goog.require('ol.geom.GeometryType'); * @param {number} radius Radius. * @api */ -ol.Sphere = function(radius) { +var _ol_Sphere_ = function(radius) { /** * @type {number} @@ -51,8 +51,8 @@ ol.Sphere = function(radius) { * @return {number} Area. * @api */ -ol.Sphere.prototype.geodesicArea = function(coordinates) { - return ol.Sphere.getArea_(coordinates, this.radius); +_ol_Sphere_.prototype.geodesicArea = function(coordinates) { + return _ol_Sphere_.getArea_(coordinates, this.radius); }; @@ -64,8 +64,8 @@ ol.Sphere.prototype.geodesicArea = function(coordinates) { * @return {number} Haversine distance. * @api */ -ol.Sphere.prototype.haversineDistance = function(c1, c2) { - return ol.Sphere.getDistance_(c1, c2, this.radius); +_ol_Sphere_.prototype.haversineDistance = function(c1, c2) { + return _ol_Sphere_.getDistance_(c1, c2, this.radius); }; @@ -78,9 +78,9 @@ ol.Sphere.prototype.haversineDistance = function(c1, c2) { * @param {number} bearing The bearing (in radians). * @return {ol.Coordinate} The target point. */ -ol.Sphere.prototype.offset = function(c1, distance, bearing) { - var lat1 = ol.math.toRadians(c1[1]); - var lon1 = ol.math.toRadians(c1[0]); +_ol_Sphere_.prototype.offset = function(c1, distance, bearing) { + var lat1 = _ol_math_.toRadians(c1[1]); + var lon1 = _ol_math_.toRadians(c1[0]); var dByR = distance / this.radius; var lat = Math.asin( Math.sin(lat1) * Math.cos(dByR) + @@ -88,7 +88,7 @@ ol.Sphere.prototype.offset = function(c1, distance, bearing) { var lon = lon1 + Math.atan2( Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1), Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)); - return [ol.math.toDegrees(lon), ol.math.toDegrees(lat)]; + return [_ol_math_.toDegrees(lon), _ol_math_.toDegrees(lat)]; }; @@ -97,7 +97,7 @@ ol.Sphere.prototype.offset = function(c1, distance, bearing) { * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius * @type {number} */ -ol.Sphere.DEFAULT_RADIUS = 6371008.8; +_ol_Sphere_.DEFAULT_RADIUS = 6371008.8; /** @@ -112,47 +112,47 @@ ol.Sphere.DEFAULT_RADIUS = 6371008.8; * @return {number} The spherical length (in meters). * @api */ -ol.Sphere.getLength = function(geometry, opt_options) { +_ol_Sphere_.getLength = function(geometry, opt_options) { var options = opt_options || {}; - var radius = options.radius || ol.Sphere.DEFAULT_RADIUS; + var radius = options.radius || _ol_Sphere_.DEFAULT_RADIUS; var projection = options.projection || 'EPSG:3857'; geometry = geometry.clone().transform(projection, 'EPSG:4326'); var type = geometry.getType(); var length = 0; var coordinates, coords, i, ii, j, jj; switch (type) { - case ol.geom.GeometryType.POINT: - case ol.geom.GeometryType.MULTI_POINT: { + case _ol_geom_GeometryType_.POINT: + case _ol_geom_GeometryType_.MULTI_POINT: { break; } - case ol.geom.GeometryType.LINE_STRING: - case ol.geom.GeometryType.LINEAR_RING: { + case _ol_geom_GeometryType_.LINE_STRING: + case _ol_geom_GeometryType_.LINEAR_RING: { coordinates = /** @type {ol.geom.SimpleGeometry} */ (geometry).getCoordinates(); - length = ol.Sphere.getLength_(coordinates, radius); + length = _ol_Sphere_.getLength_(coordinates, radius); break; } - case ol.geom.GeometryType.MULTI_LINE_STRING: - case ol.geom.GeometryType.POLYGON: { + case _ol_geom_GeometryType_.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.POLYGON: { coordinates = /** @type {ol.geom.SimpleGeometry} */ (geometry).getCoordinates(); for (i = 0, ii = coordinates.length; i < ii; ++i) { - length += ol.Sphere.getLength_(coordinates[i], radius); + length += _ol_Sphere_.getLength_(coordinates[i], radius); } break; } - case ol.geom.GeometryType.MULTI_POLYGON: { + case _ol_geom_GeometryType_.MULTI_POLYGON: { coordinates = /** @type {ol.geom.SimpleGeometry} */ (geometry).getCoordinates(); for (i = 0, ii = coordinates.length; i < ii; ++i) { coords = coordinates[i]; for (j = 0, jj = coords.length; j < jj; ++j) { - length += ol.Sphere.getLength_(coords[j], radius); + length += _ol_Sphere_.getLength_(coords[j], radius); } } break; } - case ol.geom.GeometryType.GEOMETRY_COLLECTION: { + case _ol_geom_GeometryType_.GEOMETRY_COLLECTION: { var geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries(); for (i = 0, ii = geometries.length; i < ii; ++i) { - length += ol.Sphere.getLength(geometries[i], opt_options); + length += _ol_Sphere_.getLength(geometries[i], opt_options); } break; } @@ -170,10 +170,10 @@ ol.Sphere.getLength = function(geometry, opt_options) { * @param {number} radius The sphere radius to use. * @return {number} The length (in meters). */ -ol.Sphere.getLength_ = function(coordinates, radius) { +_ol_Sphere_.getLength_ = function(coordinates, radius) { var length = 0; for (var i = 0, ii = coordinates.length; i < ii - 1; ++i) { - length += ol.Sphere.getDistance_(coordinates[i], coordinates[i + 1], radius); + length += _ol_Sphere_.getDistance_(coordinates[i], coordinates[i + 1], radius); } return length; }; @@ -186,11 +186,11 @@ ol.Sphere.getLength_ = function(coordinates, radius) { * @param {number} radius The sphere radius to use. * @return {number} The great circle distance between the points (in meters). */ -ol.Sphere.getDistance_ = function(c1, c2, radius) { - var lat1 = ol.math.toRadians(c1[1]); - var lat2 = ol.math.toRadians(c2[1]); +_ol_Sphere_.getDistance_ = function(c1, c2, radius) { + var lat1 = _ol_math_.toRadians(c1[1]); + var lat2 = _ol_math_.toRadians(c2[1]); var deltaLatBy2 = (lat2 - lat1) / 2; - var deltaLonBy2 = ol.math.toRadians(c2[0] - c1[0]) / 2; + var deltaLonBy2 = _ol_math_.toRadians(c2[0] - c1[0]) / 2; var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) + Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) * Math.cos(lat1) * Math.cos(lat2); @@ -208,45 +208,45 @@ ol.Sphere.getDistance_ = function(c1, c2, radius) { * @return {number} The spherical area (in square meters). * @api */ -ol.Sphere.getArea = function(geometry, opt_options) { +_ol_Sphere_.getArea = function(geometry, opt_options) { var options = opt_options || {}; - var radius = options.radius || ol.Sphere.DEFAULT_RADIUS; + var radius = options.radius || _ol_Sphere_.DEFAULT_RADIUS; var projection = options.projection || 'EPSG:3857'; geometry = geometry.clone().transform(projection, 'EPSG:4326'); var type = geometry.getType(); var area = 0; var coordinates, coords, i, ii, j, jj; switch (type) { - case ol.geom.GeometryType.POINT: - case ol.geom.GeometryType.MULTI_POINT: - case ol.geom.GeometryType.LINE_STRING: - case ol.geom.GeometryType.MULTI_LINE_STRING: - case ol.geom.GeometryType.LINEAR_RING: { + case _ol_geom_GeometryType_.POINT: + case _ol_geom_GeometryType_.MULTI_POINT: + case _ol_geom_GeometryType_.LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.LINEAR_RING: { break; } - case ol.geom.GeometryType.POLYGON: { + case _ol_geom_GeometryType_.POLYGON: { coordinates = /** @type {ol.geom.Polygon} */ (geometry).getCoordinates(); - area = Math.abs(ol.Sphere.getArea_(coordinates[0], radius)); + area = Math.abs(_ol_Sphere_.getArea_(coordinates[0], radius)); for (i = 1, ii = coordinates.length; i < ii; ++i) { - area -= Math.abs(ol.Sphere.getArea_(coordinates[i], radius)); + area -= Math.abs(_ol_Sphere_.getArea_(coordinates[i], radius)); } break; } - case ol.geom.GeometryType.MULTI_POLYGON: { + case _ol_geom_GeometryType_.MULTI_POLYGON: { coordinates = /** @type {ol.geom.SimpleGeometry} */ (geometry).getCoordinates(); for (i = 0, ii = coordinates.length; i < ii; ++i) { coords = coordinates[i]; - area += Math.abs(ol.Sphere.getArea_(coords[0], radius)); + area += Math.abs(_ol_Sphere_.getArea_(coords[0], radius)); for (j = 1, jj = coords.length; j < jj; ++j) { - area -= Math.abs(ol.Sphere.getArea_(coords[j], radius)); + area -= Math.abs(_ol_Sphere_.getArea_(coords[j], radius)); } } break; } - case ol.geom.GeometryType.GEOMETRY_COLLECTION: { + case _ol_geom_GeometryType_.GEOMETRY_COLLECTION: { var geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries(); for (i = 0, ii = geometries.length; i < ii; ++i) { - area += ol.Sphere.getArea(geometries[i], opt_options); + area += _ol_Sphere_.getArea(geometries[i], opt_options); } break; } @@ -272,17 +272,18 @@ ol.Sphere.getArea = function(geometry, opt_options) { * @param {number} radius The sphere radius. * @return {number} Area (in square meters). */ -ol.Sphere.getArea_ = function(coordinates, radius) { +_ol_Sphere_.getArea_ = function(coordinates, radius) { var area = 0, len = coordinates.length; var x1 = coordinates[len - 1][0]; var y1 = coordinates[len - 1][1]; for (var i = 0; i < len; i++) { var x2 = coordinates[i][0], y2 = coordinates[i][1]; - area += ol.math.toRadians(x2 - x1) * - (2 + Math.sin(ol.math.toRadians(y1)) + - Math.sin(ol.math.toRadians(y2))); + area += _ol_math_.toRadians(x2 - x1) * + (2 + Math.sin(_ol_math_.toRadians(y1)) + + Math.sin(_ol_math_.toRadians(y2))); x1 = x2; y1 = y2; } return area * radius * radius / 2.0; }; +export default _ol_Sphere_; diff --git a/src/ol/Tile.js b/src/ol/Tile.js index aec795d436..095ded43d0 100644 --- a/src/ol/Tile.js +++ b/src/ol/Tile.js @@ -1,11 +1,11 @@ -goog.provide('ol.Tile'); - -goog.require('ol'); -goog.require('ol.TileState'); -goog.require('ol.easing'); -goog.require('ol.events.EventTarget'); -goog.require('ol.events.EventType'); - +/** + * @module ol/Tile + */ +import _ol_ from './index.js'; +import _ol_TileState_ from './TileState.js'; +import _ol_easing_ from './easing.js'; +import _ol_events_EventTarget_ from './events/EventTarget.js'; +import _ol_events_EventType_ from './events/EventType.js'; /** * @classdesc @@ -18,8 +18,8 @@ goog.require('ol.events.EventType'); * @param {ol.TileState} state State. * @param {olx.TileOptions=} opt_options Tile options. */ -ol.Tile = function(tileCoord, state, opt_options) { - ol.events.EventTarget.call(this); +var _ol_Tile_ = function(tileCoord, state, opt_options) { + _ol_events_EventTarget_.call(this); var options = opt_options ? opt_options : {}; @@ -65,21 +65,22 @@ ol.Tile = function(tileCoord, state, opt_options) { this.transitionStarts_ = {}; }; -ol.inherits(ol.Tile, ol.events.EventTarget); + +_ol_.inherits(_ol_Tile_, _ol_events_EventTarget_); /** * @protected */ -ol.Tile.prototype.changed = function() { - this.dispatchEvent(ol.events.EventType.CHANGE); +_ol_Tile_.prototype.changed = function() { + this.dispatchEvent(_ol_events_EventType_.CHANGE); }; /** * @return {string} Key. */ -ol.Tile.prototype.getKey = function() { +_ol_Tile_.prototype.getKey = function() { return this.key + '/' + this.tileCoord; }; @@ -89,7 +90,7 @@ ol.Tile.prototype.getKey = function() { * such tile exists, the original tile is returned. * @return {!ol.Tile} Best tile for rendering. */ -ol.Tile.prototype.getInterimTile = function() { +_ol_Tile_.prototype.getInterimTile = function() { if (!this.interimTile) { //empty chain return this; @@ -101,7 +102,7 @@ ol.Tile.prototype.getInterimTile = function() { // of the list (all those tiles correspond to older requests and will be // cleaned up by refreshInterimChain) do { - if (tile.getState() == ol.TileState.LOADED) { + if (tile.getState() == _ol_TileState_.LOADED) { return tile; } tile = tile.interimTile; @@ -115,7 +116,7 @@ ol.Tile.prototype.getInterimTile = function() { * Goes through the chain of interim tiles and discards sections of the chain * that are no longer relevant. */ -ol.Tile.prototype.refreshInterimChain = function() { +_ol_Tile_.prototype.refreshInterimChain = function() { if (!this.interimTile) { return; } @@ -124,17 +125,17 @@ ol.Tile.prototype.refreshInterimChain = function() { var prev = this; do { - if (tile.getState() == ol.TileState.LOADED) { + if (tile.getState() == _ol_TileState_.LOADED) { //we have a loaded tile, we can discard the rest of the list //we would could abort any LOADING tile request //older than this tile (i.e. any LOADING tile following this entry in the chain) tile.interimTile = null; break; - } else if (tile.getState() == ol.TileState.LOADING) { + } else if (tile.getState() == _ol_TileState_.LOADING) { //keep this LOADING tile any loaded tiles later in the chain are //older than this tile, so we're still interested in the request prev = tile; - } else if (tile.getState() == ol.TileState.IDLE) { + } else if (tile.getState() == _ol_TileState_.IDLE) { //the head of the list is the most current tile, we don't need //to start any other requests for this chain prev.interimTile = tile.interimTile; @@ -150,7 +151,7 @@ ol.Tile.prototype.refreshInterimChain = function() { * @return {ol.TileCoord} The tile coordinate. * @api */ -ol.Tile.prototype.getTileCoord = function() { +_ol_Tile_.prototype.getTileCoord = function() { return this.tileCoord; }; @@ -158,14 +159,14 @@ ol.Tile.prototype.getTileCoord = function() { /** * @return {ol.TileState} State. */ -ol.Tile.prototype.getState = function() { +_ol_Tile_.prototype.getState = function() { return this.state; }; /** * @param {ol.TileState} state State. */ -ol.Tile.prototype.setState = function(state) { +_ol_Tile_.prototype.setState = function(state) { this.state = state; this.changed(); }; @@ -177,7 +178,7 @@ ol.Tile.prototype.setState = function(state) { * @abstract * @api */ -ol.Tile.prototype.load = function() {}; +_ol_Tile_.prototype.load = function() {}; /** * Get the alpha value for rendering. @@ -185,7 +186,7 @@ ol.Tile.prototype.load = function() {}; * @param {number} time The render frame time. * @return {number} A number between 0 and 1. */ -ol.Tile.prototype.getAlpha = function(id, time) { +_ol_Tile_.prototype.getAlpha = function(id, time) { if (!this.transition_) { return 1; } @@ -202,7 +203,7 @@ ol.Tile.prototype.getAlpha = function(id, time) { if (delta >= this.transition_) { return 1; } - return ol.easing.easeIn(delta / this.transition_); + return _ol_easing_.easeIn(delta / this.transition_); }; /** @@ -212,7 +213,7 @@ ol.Tile.prototype.getAlpha = function(id, time) { * @param {number} id An id for the renderer. * @return {boolean} The tile is in transition. */ -ol.Tile.prototype.inTransition = function(id) { +_ol_Tile_.prototype.inTransition = function(id) { if (!this.transition_) { return false; } @@ -223,8 +224,9 @@ ol.Tile.prototype.inTransition = function(id) { * Mark a transition as complete. * @param {number} id An id for the renderer. */ -ol.Tile.prototype.endTransition = function(id) { +_ol_Tile_.prototype.endTransition = function(id) { if (this.transition_) { this.transitionStarts_[id] = -1; } }; +export default _ol_Tile_; diff --git a/src/ol/TileCache.js b/src/ol/TileCache.js index 088d9b1e72..553b04f00e 100644 --- a/src/ol/TileCache.js +++ b/src/ol/TileCache.js @@ -1,9 +1,9 @@ -goog.provide('ol.TileCache'); - -goog.require('ol'); -goog.require('ol.structs.LRUCache'); -goog.require('ol.tilecoord'); - +/** + * @module ol/TileCache + */ +import _ol_ from './index.js'; +import _ol_structs_LRUCache_ from './structs/LRUCache.js'; +import _ol_tilecoord_ from './tilecoord.js'; /** * @constructor @@ -11,18 +11,19 @@ goog.require('ol.tilecoord'); * @param {number=} opt_highWaterMark High water mark. * @struct */ -ol.TileCache = function(opt_highWaterMark) { +var _ol_TileCache_ = function(opt_highWaterMark) { - ol.structs.LRUCache.call(this, opt_highWaterMark); + _ol_structs_LRUCache_.call(this, opt_highWaterMark); }; -ol.inherits(ol.TileCache, ol.structs.LRUCache); + +_ol_.inherits(_ol_TileCache_, _ol_structs_LRUCache_); /** * @param {Object.} usedTiles Used tiles. */ -ol.TileCache.prototype.expireCache = function(usedTiles) { +_ol_TileCache_.prototype.expireCache = function(usedTiles) { var tile, zKey; while (this.canExpireCache()) { tile = this.peekLast(); @@ -39,17 +40,18 @@ ol.TileCache.prototype.expireCache = function(usedTiles) { /** * Prune all tiles from the cache that don't have the same z as the newest tile. */ -ol.TileCache.prototype.pruneExceptNewestZ = function() { +_ol_TileCache_.prototype.pruneExceptNewestZ = function() { if (this.getCount() === 0) { return; } var key = this.peekFirstKey(); - var tileCoord = ol.tilecoord.fromKey(key); + var tileCoord = _ol_tilecoord_.fromKey(key); var z = tileCoord[0]; this.forEach(function(tile) { if (tile.tileCoord[0] !== z) { - this.remove(ol.tilecoord.getKey(tile.tileCoord)); + this.remove(_ol_tilecoord_.getKey(tile.tileCoord)); tile.dispose(); } }, this); }; +export default _ol_TileCache_; diff --git a/src/ol/TileQueue.js b/src/ol/TileQueue.js index 14bb075e90..288738d776 100644 --- a/src/ol/TileQueue.js +++ b/src/ol/TileQueue.js @@ -1,11 +1,11 @@ -goog.provide('ol.TileQueue'); - -goog.require('ol'); -goog.require('ol.TileState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.structs.PriorityQueue'); - +/** + * @module ol/TileQueue + */ +import _ol_ from './index.js'; +import _ol_TileState_ from './TileState.js'; +import _ol_events_ from './events.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js'; /** * @constructor @@ -16,9 +16,9 @@ goog.require('ol.structs.PriorityQueue'); * Function called on each tile change event. * @struct */ -ol.TileQueue = function(tilePriorityFunction, tileChangeCallback) { +var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) { - ol.structs.PriorityQueue.call( + _ol_structs_PriorityQueue_.call( this, /** * @param {Array} element Element. @@ -54,17 +54,18 @@ ol.TileQueue = function(tilePriorityFunction, tileChangeCallback) { this.tilesLoadingKeys_ = {}; }; -ol.inherits(ol.TileQueue, ol.structs.PriorityQueue); + +_ol_.inherits(_ol_TileQueue_, _ol_structs_PriorityQueue_); /** * @inheritDoc */ -ol.TileQueue.prototype.enqueue = function(element) { - var added = ol.structs.PriorityQueue.prototype.enqueue.call(this, element); +_ol_TileQueue_.prototype.enqueue = function(element) { + var added = _ol_structs_PriorityQueue_.prototype.enqueue.call(this, element); if (added) { var tile = element[0]; - ol.events.listen(tile, ol.events.EventType.CHANGE, + _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, this.handleTileChange, this); } return added; @@ -74,7 +75,7 @@ ol.TileQueue.prototype.enqueue = function(element) { /** * @return {number} Number of tiles loading. */ -ol.TileQueue.prototype.getTilesLoading = function() { +_ol_TileQueue_.prototype.getTilesLoading = function() { return this.tilesLoading_; }; @@ -83,12 +84,12 @@ ol.TileQueue.prototype.getTilesLoading = function() { * @param {ol.events.Event} event Event. * @protected */ -ol.TileQueue.prototype.handleTileChange = function(event) { +_ol_TileQueue_.prototype.handleTileChange = function(event) { var tile = /** @type {ol.Tile} */ (event.target); var state = tile.getState(); - if (state === ol.TileState.LOADED || state === ol.TileState.ERROR || - state === ol.TileState.EMPTY || state === ol.TileState.ABORT) { - ol.events.unlisten(tile, ol.events.EventType.CHANGE, + if (state === _ol_TileState_.LOADED || state === _ol_TileState_.ERROR || + state === _ol_TileState_.EMPTY || state === _ol_TileState_.ABORT) { + _ol_events_.unlisten(tile, _ol_events_EventType_.CHANGE, this.handleTileChange, this); var tileKey = tile.getKey(); if (tileKey in this.tilesLoadingKeys_) { @@ -104,7 +105,7 @@ ol.TileQueue.prototype.handleTileChange = function(event) { * @param {number} maxTotalLoading Maximum number tiles to load simultaneously. * @param {number} maxNewLoads Maximum number of new tiles to load. */ -ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { +_ol_TileQueue_.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { var newLoads = 0; var abortedTiles = false; var state, tile, tileKey; @@ -113,9 +114,9 @@ ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { tile = /** @type {ol.Tile} */ (this.dequeue()[0]); tileKey = tile.getKey(); state = tile.getState(); - if (state === ol.TileState.ABORT) { + if (state === _ol_TileState_.ABORT) { abortedTiles = true; - } else if (state === ol.TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) { + } else if (state === _ol_TileState_.IDLE && !(tileKey in this.tilesLoadingKeys_)) { this.tilesLoadingKeys_[tileKey] = true; ++this.tilesLoading_; ++newLoads; @@ -128,3 +129,4 @@ ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { this.tileChangeCallback_(); } }; +export default _ol_TileQueue_; diff --git a/src/ol/TileRange.js b/src/ol/TileRange.js index 8e41f2cea3..1359443a58 100644 --- a/src/ol/TileRange.js +++ b/src/ol/TileRange.js @@ -1,6 +1,6 @@ -goog.provide('ol.TileRange'); - - +/** + * @module ol/TileRange + */ /** * A representation of a contiguous block of tiles. A tile range is specified * by its min/max tile coordinates and is inclusive of coordinates. @@ -12,7 +12,7 @@ goog.provide('ol.TileRange'); * @param {number} maxY Maximum Y. * @struct */ -ol.TileRange = function(minX, maxX, minY, maxY) { +var _ol_TileRange_ = function(minX, maxX, minY, maxY) { /** * @type {number} @@ -45,7 +45,7 @@ ol.TileRange = function(minX, maxX, minY, maxY) { * @param {ol.TileRange|undefined} tileRange TileRange. * @return {ol.TileRange} Tile range. */ -ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) { +_ol_TileRange_.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) { if (tileRange !== undefined) { tileRange.minX = minX; tileRange.maxX = maxX; @@ -53,7 +53,7 @@ ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) { tileRange.maxY = maxY; return tileRange; } else { - return new ol.TileRange(minX, maxX, minY, maxY); + return new _ol_TileRange_(minX, maxX, minY, maxY); } }; @@ -62,7 +62,7 @@ ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) { * @param {ol.TileCoord} tileCoord Tile coordinate. * @return {boolean} Contains tile coordinate. */ -ol.TileRange.prototype.contains = function(tileCoord) { +_ol_TileRange_.prototype.contains = function(tileCoord) { return this.containsXY(tileCoord[1], tileCoord[2]); }; @@ -71,7 +71,7 @@ ol.TileRange.prototype.contains = function(tileCoord) { * @param {ol.TileRange} tileRange Tile range. * @return {boolean} Contains. */ -ol.TileRange.prototype.containsTileRange = function(tileRange) { +_ol_TileRange_.prototype.containsTileRange = function(tileRange) { return this.minX <= tileRange.minX && tileRange.maxX <= this.maxX && this.minY <= tileRange.minY && tileRange.maxY <= this.maxY; }; @@ -82,7 +82,7 @@ ol.TileRange.prototype.containsTileRange = function(tileRange) { * @param {number} y Tile coordinate y. * @return {boolean} Contains coordinate. */ -ol.TileRange.prototype.containsXY = function(x, y) { +_ol_TileRange_.prototype.containsXY = function(x, y) { return this.minX <= x && x <= this.maxX && this.minY <= y && y <= this.maxY; }; @@ -91,7 +91,7 @@ ol.TileRange.prototype.containsXY = function(x, y) { * @param {ol.TileRange} tileRange Tile range. * @return {boolean} Equals. */ -ol.TileRange.prototype.equals = function(tileRange) { +_ol_TileRange_.prototype.equals = function(tileRange) { return this.minX == tileRange.minX && this.minY == tileRange.minY && this.maxX == tileRange.maxX && this.maxY == tileRange.maxY; }; @@ -100,7 +100,7 @@ ol.TileRange.prototype.equals = function(tileRange) { /** * @param {ol.TileRange} tileRange Tile range. */ -ol.TileRange.prototype.extend = function(tileRange) { +_ol_TileRange_.prototype.extend = function(tileRange) { if (tileRange.minX < this.minX) { this.minX = tileRange.minX; } @@ -119,7 +119,7 @@ ol.TileRange.prototype.extend = function(tileRange) { /** * @return {number} Height. */ -ol.TileRange.prototype.getHeight = function() { +_ol_TileRange_.prototype.getHeight = function() { return this.maxY - this.minY + 1; }; @@ -127,7 +127,7 @@ ol.TileRange.prototype.getHeight = function() { /** * @return {ol.Size} Size. */ -ol.TileRange.prototype.getSize = function() { +_ol_TileRange_.prototype.getSize = function() { return [this.getWidth(), this.getHeight()]; }; @@ -135,7 +135,7 @@ ol.TileRange.prototype.getSize = function() { /** * @return {number} Width. */ -ol.TileRange.prototype.getWidth = function() { +_ol_TileRange_.prototype.getWidth = function() { return this.maxX - this.minX + 1; }; @@ -144,9 +144,10 @@ ol.TileRange.prototype.getWidth = function() { * @param {ol.TileRange} tileRange Tile range. * @return {boolean} Intersects. */ -ol.TileRange.prototype.intersects = function(tileRange) { +_ol_TileRange_.prototype.intersects = function(tileRange) { return this.minX <= tileRange.maxX && this.maxX >= tileRange.minX && this.minY <= tileRange.maxY && this.maxY >= tileRange.minY; }; +export default _ol_TileRange_; diff --git a/src/ol/TileState.js b/src/ol/TileState.js index 45854d692e..5fc633f9f5 100644 --- a/src/ol/TileState.js +++ b/src/ol/TileState.js @@ -1,9 +1,10 @@ -goog.provide('ol.TileState'); - +/** + * @module ol/TileState + */ /** * @enum {number} */ -ol.TileState = { +var _ol_TileState_ = { IDLE: 0, LOADING: 1, LOADED: 2, @@ -11,3 +12,5 @@ ol.TileState = { EMPTY: 4, ABORT: 5 }; + +export default _ol_TileState_; diff --git a/src/ol/TileUrlFunction.js b/src/ol/TileUrlFunction.js index 3ab48d7e22..df6bb3fc1e 100644 --- a/src/ol/TileUrlFunction.js +++ b/src/ol/TileUrlFunction.js @@ -1,8 +1,10 @@ -goog.provide('ol.TileUrlFunction'); - -goog.require('ol.asserts'); -goog.require('ol.math'); -goog.require('ol.tilecoord'); +/** + * @module ol/TileUrlFunction + */ +import _ol_asserts_ from './asserts.js'; +import _ol_math_ from './math.js'; +import _ol_tilecoord_ from './tilecoord.js'; +var _ol_TileUrlFunction_ = {}; /** @@ -10,7 +12,7 @@ goog.require('ol.tilecoord'); * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. * @return {ol.TileUrlFunctionType} Tile URL function. */ -ol.TileUrlFunction.createFromTemplate = function(template, tileGrid) { +_ol_TileUrlFunction_.createFromTemplate = function(template, tileGrid) { var zRegEx = /\{z\}/g; var xRegEx = /\{x\}/g; var yRegEx = /\{y\}/g; @@ -35,12 +37,13 @@ ol.TileUrlFunction.createFromTemplate = function(template, tileGrid) { .replace(dashYRegEx, function() { var z = tileCoord[0]; var range = tileGrid.getFullTileRange(z); - ol.asserts.assert(range, 55); // The {-y} placeholder requires a tile grid with extent + _ol_asserts_.assert(range, 55); // The {-y} placeholder requires a tile grid with extent var y = range.getHeight() + tileCoord[2]; return y.toString(); }); } - }); + } + ); }; @@ -49,14 +52,14 @@ ol.TileUrlFunction.createFromTemplate = function(template, tileGrid) { * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. * @return {ol.TileUrlFunctionType} Tile URL function. */ -ol.TileUrlFunction.createFromTemplates = function(templates, tileGrid) { +_ol_TileUrlFunction_.createFromTemplates = function(templates, tileGrid) { var len = templates.length; var tileUrlFunctions = new Array(len); for (var i = 0; i < len; ++i) { - tileUrlFunctions[i] = ol.TileUrlFunction.createFromTemplate( + tileUrlFunctions[i] = _ol_TileUrlFunction_.createFromTemplate( templates[i], tileGrid); } - return ol.TileUrlFunction.createFromTileUrlFunctions(tileUrlFunctions); + return _ol_TileUrlFunction_.createFromTileUrlFunctions(tileUrlFunctions); }; @@ -64,7 +67,7 @@ ol.TileUrlFunction.createFromTemplates = function(templates, tileGrid) { * @param {Array.} tileUrlFunctions Tile URL Functions. * @return {ol.TileUrlFunctionType} Tile URL function. */ -ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { +_ol_TileUrlFunction_.createFromTileUrlFunctions = function(tileUrlFunctions) { if (tileUrlFunctions.length === 1) { return tileUrlFunctions[0]; } @@ -79,11 +82,12 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { if (!tileCoord) { return undefined; } else { - var h = ol.tilecoord.hash(tileCoord); - var index = ol.math.modulo(h, tileUrlFunctions.length); + var h = _ol_tilecoord_.hash(tileCoord); + var index = _ol_math_.modulo(h, tileUrlFunctions.length); return tileUrlFunctions[index](tileCoord, pixelRatio, projection); } - }); + } + ); }; @@ -93,7 +97,7 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) { * @param {ol.proj.Projection} projection Projection. * @return {string|undefined} Tile URL. */ -ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord, pixelRatio, projection) { +_ol_TileUrlFunction_.nullTileUrlFunction = function(tileCoord, pixelRatio, projection) { return undefined; }; @@ -102,7 +106,7 @@ ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord, pixelRatio, project * @param {string} url URL. * @return {Array.} Array of urls. */ -ol.TileUrlFunction.expandUrl = function(url) { +_ol_TileUrlFunction_.expandUrl = function(url) { var urls = []; var match = /\{([a-z])-([a-z])\}/.exec(url); if (match) { @@ -127,3 +131,4 @@ ol.TileUrlFunction.expandUrl = function(url) { urls.push(url); return urls; }; +export default _ol_TileUrlFunction_; diff --git a/src/ol/VectorImageTile.js b/src/ol/VectorImageTile.js index 3c2eb2f34a..4a6266c018 100644 --- a/src/ol/VectorImageTile.js +++ b/src/ol/VectorImageTile.js @@ -1,14 +1,14 @@ -goog.provide('ol.VectorImageTile'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.extent'); -goog.require('ol.events.EventType'); -goog.require('ol.featureloader'); - +/** + * @module ol/VectorImageTile + */ +import _ol_ from './index.js'; +import _ol_Tile_ from './Tile.js'; +import _ol_TileState_ from './TileState.js'; +import _ol_dom_ from './dom.js'; +import _ol_events_ from './events.js'; +import _ol_extent_ from './extent.js'; +import _ol_events_EventType_ from './events/EventType.js'; +import _ol_featureloader_ from './featureloader.js'; /** * @constructor @@ -32,11 +32,11 @@ goog.require('ol.featureloader'); * Function to call when a source tile's state changes. * @param {olx.TileOptions=} opt_options Tile options. */ -ol.VectorImageTile = function(tileCoord, state, sourceRevision, format, +var _ol_VectorImageTile_ = function(tileCoord, state, sourceRevision, format, tileLoadFunction, urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid, sourceTiles, pixelRatio, projection, tileClass, handleTileChange, opt_options) { - ol.Tile.call(this, tileCoord, state, opt_options); + _ol_Tile_.call(this, tileCoord, state, opt_options); /** * @private @@ -93,25 +93,25 @@ ol.VectorImageTile = function(tileCoord, state, sourceRevision, format, var resolution = tileGrid.getResolution(tileCoord[0]); var sourceZ = sourceTileGrid.getZForResolution(resolution); sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) { - var sharedExtent = ol.extent.getIntersection(extent, + var sharedExtent = _ol_extent_.getIntersection(extent, sourceTileGrid.getTileCoordExtent(sourceTileCoord)); var sourceExtent = sourceTileGrid.getExtent(); if (sourceExtent) { - sharedExtent = ol.extent.getIntersection(sharedExtent, sourceExtent); + sharedExtent = _ol_extent_.getIntersection(sharedExtent, sourceExtent); } - if (ol.extent.getWidth(sharedExtent) / resolution >= 0.5 && - ol.extent.getHeight(sharedExtent) / resolution >= 0.5) { + if (_ol_extent_.getWidth(sharedExtent) / resolution >= 0.5 && + _ol_extent_.getHeight(sharedExtent) / resolution >= 0.5) { // only include source tile if overlap is at least 1 pixel var sourceTileKey = sourceTileCoord.toString(); var sourceTile = sourceTiles[sourceTileKey]; if (!sourceTile) { var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection); sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord, - tileUrl == undefined ? ol.TileState.EMPTY : ol.TileState.IDLE, + tileUrl == undefined ? _ol_TileState_.EMPTY : _ol_TileState_.IDLE, tileUrl == undefined ? '' : tileUrl, format, tileLoadFunction); this.sourceTileListenerKeys_.push( - ol.events.listen(sourceTile, ol.events.EventType.CHANGE, handleTileChange)); + _ol_events_.listen(sourceTile, _ol_events_EventType_.CHANGE, handleTileChange)); } sourceTile.consumers++; this.tileKeys.push(sourceTileKey); @@ -120,13 +120,14 @@ ol.VectorImageTile = function(tileCoord, state, sourceRevision, format, } }; -ol.inherits(ol.VectorImageTile, ol.Tile); + +_ol_.inherits(_ol_VectorImageTile_, _ol_Tile_); /** * @inheritDoc */ -ol.VectorImageTile.prototype.disposeInternal = function() { +_ol_VectorImageTile_.prototype.disposeInternal = function() { for (var i = 0, ii = this.tileKeys.length; i < ii; ++i) { var sourceTileKey = this.tileKeys[i]; var sourceTile = this.getTile(sourceTileKey); @@ -138,16 +139,16 @@ ol.VectorImageTile.prototype.disposeInternal = function() { } this.tileKeys.length = 0; this.sourceTiles_ = null; - this.loadListenerKeys_.forEach(ol.events.unlistenByKey); + this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey); this.loadListenerKeys_.length = 0; if (this.interimTile) { this.interimTile.dispose(); } - this.state = ol.TileState.ABORT; + this.state = _ol_TileState_.ABORT; this.changed(); - this.sourceTileListenerKeys_.forEach(ol.events.unlistenByKey); + this.sourceTileListenerKeys_.forEach(_ol_events_.unlistenByKey); this.sourceTileListenerKeys_.length = 0; - ol.Tile.prototype.disposeInternal.call(this); + _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -155,10 +156,10 @@ ol.VectorImageTile.prototype.disposeInternal = function() { * @param {ol.layer.Layer} layer Layer. * @return {CanvasRenderingContext2D} The rendering context. */ -ol.VectorImageTile.prototype.getContext = function(layer) { - var key = ol.getUid(layer).toString(); +_ol_VectorImageTile_.prototype.getContext = function(layer) { + var key = _ol_.getUid(layer).toString(); if (!(key in this.context_)) { - this.context_[key] = ol.dom.createCanvasContext2D(); + this.context_[key] = _ol_dom_.createCanvasContext2D(); } return this.context_[key]; }; @@ -169,7 +170,7 @@ ol.VectorImageTile.prototype.getContext = function(layer) { * @param {ol.layer.Layer} layer Layer. * @return {HTMLCanvasElement} Canvas. */ -ol.VectorImageTile.prototype.getImage = function(layer) { +_ol_VectorImageTile_.prototype.getImage = function(layer) { return this.getReplayState(layer).renderedTileRevision == -1 ? null : this.getContext(layer).canvas; }; @@ -179,8 +180,8 @@ ol.VectorImageTile.prototype.getImage = function(layer) { * @param {ol.layer.Layer} layer Layer. * @return {ol.TileReplayState} The replay state. */ -ol.VectorImageTile.prototype.getReplayState = function(layer) { - var key = ol.getUid(layer).toString(); +_ol_VectorImageTile_.prototype.getReplayState = function(layer) { + var key = _ol_.getUid(layer).toString(); if (!(key in this.replayState_)) { this.replayState_[key] = { dirty: false, @@ -196,7 +197,7 @@ ol.VectorImageTile.prototype.getReplayState = function(layer) { /** * @inheritDoc */ -ol.VectorImageTile.prototype.getKey = function() { +_ol_VectorImageTile_.prototype.getKey = function() { return this.tileKeys.join('/') + '-' + this.sourceRevision_; }; @@ -205,7 +206,7 @@ ol.VectorImageTile.prototype.getKey = function() { * @param {string} tileKey Key (tileCoord) of the source tile. * @return {ol.VectorTile} Source tile. */ -ol.VectorImageTile.prototype.getTile = function(tileKey) { +_ol_VectorImageTile_.prototype.getTile = function(tileKey) { return this.sourceTiles_[tileKey]; }; @@ -213,7 +214,7 @@ ol.VectorImageTile.prototype.getTile = function(tileKey) { /** * @inheritDoc */ -ol.VectorImageTile.prototype.load = function() { +_ol_VectorImageTile_.prototype.load = function() { // Source tiles with LOADED state - we just count them because once they are // loaded, we're no longer listening to state changes. var leftToLoad = 0; @@ -221,23 +222,23 @@ ol.VectorImageTile.prototype.load = function() { // an ERROR state after another load attempt. var errorSourceTiles = {}; - if (this.state == ol.TileState.IDLE) { - this.setState(ol.TileState.LOADING); + if (this.state == _ol_TileState_.IDLE) { + this.setState(_ol_TileState_.LOADING); } - if (this.state == ol.TileState.LOADING) { + if (this.state == _ol_TileState_.LOADING) { this.tileKeys.forEach(function(sourceTileKey) { var sourceTile = this.getTile(sourceTileKey); - if (sourceTile.state == ol.TileState.IDLE) { + if (sourceTile.state == _ol_TileState_.IDLE) { sourceTile.setLoader(this.loader_); sourceTile.load(); } - if (sourceTile.state == ol.TileState.LOADING) { - var key = ol.events.listen(sourceTile, ol.events.EventType.CHANGE, function(e) { + if (sourceTile.state == _ol_TileState_.LOADING) { + var key = _ol_events_.listen(sourceTile, _ol_events_EventType_.CHANGE, function(e) { var state = sourceTile.getState(); - if (state == ol.TileState.LOADED || - state == ol.TileState.ERROR) { - var uid = ol.getUid(sourceTile); - if (state == ol.TileState.ERROR) { + if (state == _ol_TileState_.LOADED || + state == _ol_TileState_.ERROR) { + var uid = _ol_.getUid(sourceTile); + if (state == _ol_TileState_.ERROR) { errorSourceTiles[uid] = true; } else { --leftToLoad; @@ -262,24 +263,24 @@ ol.VectorImageTile.prototype.load = function() { /** * @private */ -ol.VectorImageTile.prototype.finishLoading_ = function() { +_ol_VectorImageTile_.prototype.finishLoading_ = function() { var loaded = this.tileKeys.length; var empty = 0; for (var i = loaded - 1; i >= 0; --i) { var state = this.getTile(this.tileKeys[i]).getState(); - if (state != ol.TileState.LOADED) { + if (state != _ol_TileState_.LOADED) { --loaded; } - if (state == ol.TileState.EMPTY) { + if (state == _ol_TileState_.EMPTY) { ++empty; } } if (loaded == this.tileKeys.length) { - this.loadListenerKeys_.forEach(ol.events.unlistenByKey); + this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey); this.loadListenerKeys_.length = 0; - this.setState(ol.TileState.LOADED); + this.setState(_ol_TileState_.LOADED); } else { - this.setState(empty == this.tileKeys.length ? ol.TileState.EMPTY : ol.TileState.ERROR); + this.setState(empty == this.tileKeys.length ? _ol_TileState_.EMPTY : _ol_TileState_.ERROR); } }; @@ -289,9 +290,10 @@ ol.VectorImageTile.prototype.finishLoading_ = function() { * @param {ol.VectorTile} tile Vector tile. * @param {string} url URL. */ -ol.VectorImageTile.defaultLoadFunction = function(tile, url) { - var loader = ol.featureloader.loadFeaturesXhr( +_ol_VectorImageTile_.defaultLoadFunction = function(tile, url) { + var loader = _ol_featureloader_.loadFeaturesXhr( url, tile.getFormat(), tile.onLoad.bind(tile), tile.onError.bind(tile)); tile.setLoader(loader); }; +export default _ol_VectorImageTile_; diff --git a/src/ol/VectorTile.js b/src/ol/VectorTile.js index 39d2c9be4e..4de2c1803e 100644 --- a/src/ol/VectorTile.js +++ b/src/ol/VectorTile.js @@ -1,9 +1,9 @@ -goog.provide('ol.VectorTile'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); - +/** + * @module ol/VectorTile + */ +import _ol_ from './index.js'; +import _ol_Tile_ from './Tile.js'; +import _ol_TileState_ from './TileState.js'; /** * @constructor @@ -15,9 +15,9 @@ goog.require('ol.TileState'); * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {olx.TileOptions=} opt_options Tile options. */ -ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction, opt_options) { +var _ol_VectorTile_ = function(tileCoord, state, src, format, tileLoadFunction, opt_options) { - ol.Tile.call(this, tileCoord, state, opt_options); + _ol_Tile_.call(this, tileCoord, state, opt_options); /** * @type {number} @@ -74,18 +74,19 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction, opt_op this.url_ = src; }; -ol.inherits(ol.VectorTile, ol.Tile); + +_ol_.inherits(_ol_VectorTile_, _ol_Tile_); /** * @inheritDoc */ -ol.VectorTile.prototype.disposeInternal = function() { +_ol_VectorTile_.prototype.disposeInternal = function() { this.features_ = null; this.replayGroups_ = {}; - this.state = ol.TileState.ABORT; + this.state = _ol_TileState_.ABORT; this.changed(); - ol.Tile.prototype.disposeInternal.call(this); + _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -94,8 +95,8 @@ ol.VectorTile.prototype.disposeInternal = function() { * @return {ol.Extent} The extent. * @api */ -ol.VectorTile.prototype.getExtent = function() { - return this.extent_ || ol.VectorTile.DEFAULT_EXTENT; +_ol_VectorTile_.prototype.getExtent = function() { + return this.extent_ || _ol_VectorTile_.DEFAULT_EXTENT; }; @@ -104,7 +105,7 @@ ol.VectorTile.prototype.getExtent = function() { * @return {ol.format.Feature} Feature format. * @api */ -ol.VectorTile.prototype.getFormat = function() { +_ol_VectorTile_.prototype.getFormat = function() { return this.format_; }; @@ -115,7 +116,7 @@ ol.VectorTile.prototype.getFormat = function() { * @return {Array.} Features. * @api */ -ol.VectorTile.prototype.getFeatures = function() { +_ol_VectorTile_.prototype.getFeatures = function() { return this.features_; }; @@ -123,7 +124,7 @@ ol.VectorTile.prototype.getFeatures = function() { /** * @inheritDoc */ -ol.VectorTile.prototype.getKey = function() { +_ol_VectorTile_.prototype.getKey = function() { return this.url_; }; @@ -134,7 +135,7 @@ ol.VectorTile.prototype.getKey = function() { * @return {ol.proj.Projection} Feature projection. * @api */ -ol.VectorTile.prototype.getProjection = function() { +_ol_VectorTile_.prototype.getProjection = function() { return this.projection_; }; @@ -144,17 +145,17 @@ ol.VectorTile.prototype.getProjection = function() { * @param {string} key Key. * @return {ol.render.ReplayGroup} Replay group. */ -ol.VectorTile.prototype.getReplayGroup = function(layer, key) { - return this.replayGroups_[ol.getUid(layer) + ',' + key]; +_ol_VectorTile_.prototype.getReplayGroup = function(layer, key) { + return this.replayGroups_[_ol_.getUid(layer) + ',' + key]; }; /** * @inheritDoc */ -ol.VectorTile.prototype.load = function() { - if (this.state == ol.TileState.IDLE) { - this.setState(ol.TileState.LOADING); +_ol_VectorTile_.prototype.load = function() { + if (this.state == _ol_TileState_.IDLE) { + this.setState(_ol_TileState_.LOADING); this.tileLoadFunction_(this, this.url_); this.loader_(null, NaN, null); } @@ -167,7 +168,7 @@ ol.VectorTile.prototype.load = function() { * @param {ol.proj.Projection} dataProjection Data projection. * @param {ol.Extent} extent Extent. */ -ol.VectorTile.prototype.onLoad = function(features, dataProjection, extent) { +_ol_VectorTile_.prototype.onLoad = function(features, dataProjection, extent) { this.setProjection(dataProjection); this.setFeatures(features); this.setExtent(extent); @@ -177,8 +178,8 @@ ol.VectorTile.prototype.onLoad = function(features, dataProjection, extent) { /** * Handler for tile load errors. */ -ol.VectorTile.prototype.onError = function() { - this.setState(ol.TileState.ERROR); +_ol_VectorTile_.prototype.onError = function() { + this.setState(_ol_TileState_.ERROR); }; @@ -194,7 +195,7 @@ ol.VectorTile.prototype.onError = function() { * @param {ol.Extent} extent The extent. * @api */ -ol.VectorTile.prototype.setExtent = function(extent) { +_ol_VectorTile_.prototype.setExtent = function(extent) { this.extent_ = extent; }; @@ -205,9 +206,9 @@ ol.VectorTile.prototype.setExtent = function(extent) { * @param {Array.} features Features. * @api */ -ol.VectorTile.prototype.setFeatures = function(features) { +_ol_VectorTile_.prototype.setFeatures = function(features) { this.features_ = features; - this.setState(ol.TileState.LOADED); + this.setState(_ol_TileState_.LOADED); }; @@ -218,7 +219,7 @@ ol.VectorTile.prototype.setFeatures = function(features) { * @param {ol.proj.Projection} projection Feature projection. * @api */ -ol.VectorTile.prototype.setProjection = function(projection) { +_ol_VectorTile_.prototype.setProjection = function(projection) { this.projection_ = projection; }; @@ -228,8 +229,8 @@ ol.VectorTile.prototype.setProjection = function(projection) { * @param {string} key Key. * @param {ol.render.ReplayGroup} replayGroup Replay group. */ -ol.VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) { - this.replayGroups_[ol.getUid(layer) + ',' + key] = replayGroup; +_ol_VectorTile_.prototype.setReplayGroup = function(layer, key, replayGroup) { + this.replayGroups_[_ol_.getUid(layer) + ',' + key] = replayGroup; }; @@ -238,7 +239,7 @@ ol.VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) { * @param {ol.FeatureLoader} loader Feature loader. * @api */ -ol.VectorTile.prototype.setLoader = function(loader) { +_ol_VectorTile_.prototype.setLoader = function(loader) { this.loader_ = loader; }; @@ -247,4 +248,5 @@ ol.VectorTile.prototype.setLoader = function(loader) { * @const * @type {ol.Extent} */ -ol.VectorTile.DEFAULT_EXTENT = [0, 0, 4096, 4096]; +_ol_VectorTile_.DEFAULT_EXTENT = [0, 0, 4096, 4096]; +export default _ol_VectorTile_; diff --git a/src/ol/View.js b/src/ol/View.js index 0df83f32d5..33b9471ace 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -1,25 +1,25 @@ -goog.provide('ol.View'); - -goog.require('ol'); -goog.require('ol.CenterConstraint'); -goog.require('ol.Object'); -goog.require('ol.ResolutionConstraint'); -goog.require('ol.RotationConstraint'); -goog.require('ol.ViewHint'); -goog.require('ol.ViewProperty'); -goog.require('ol.array'); -goog.require('ol.asserts'); -goog.require('ol.coordinate'); -goog.require('ol.easing'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.math'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.proj.Units'); - +/** + * @module ol/View + */ +import _ol_ from './index.js'; +import _ol_CenterConstraint_ from './CenterConstraint.js'; +import _ol_Object_ from './Object.js'; +import _ol_ResolutionConstraint_ from './ResolutionConstraint.js'; +import _ol_RotationConstraint_ from './RotationConstraint.js'; +import _ol_ViewHint_ from './ViewHint.js'; +import _ol_ViewProperty_ from './ViewProperty.js'; +import _ol_array_ from './array.js'; +import _ol_asserts_ from './asserts.js'; +import _ol_coordinate_ from './coordinate.js'; +import _ol_easing_ from './easing.js'; +import _ol_extent_ from './extent.js'; +import _ol_geom_GeometryType_ from './geom/GeometryType.js'; +import _ol_geom_Polygon_ from './geom/Polygon.js'; +import _ol_geom_SimpleGeometry_ from './geom/SimpleGeometry.js'; +import _ol_math_ from './math.js'; +import _ol_obj_ from './obj.js'; +import _ol_proj_ from './proj.js'; +import _ol_proj_Units_ from './proj/Units.js'; /** * @classdesc @@ -78,10 +78,10 @@ goog.require('ol.proj.Units'); * @param {olx.ViewOptions=} opt_options View options. * @api */ -ol.View = function(opt_options) { - ol.Object.call(this); +var _ol_View_ = function(opt_options) { + _ol_Object_.call(this); - var options = ol.obj.assign({}, opt_options); + var options = _ol_obj_.assign({}, opt_options); /** * @private @@ -108,27 +108,28 @@ ol.View = function(opt_options) { * @const * @type {ol.proj.Projection} */ - this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857'); + this.projection_ = _ol_proj_.createProjection(options.projection, 'EPSG:3857'); this.applyOptions_(options); }; -ol.inherits(ol.View, ol.Object); + +_ol_.inherits(_ol_View_, _ol_Object_); /** * Set up the view with the given options. * @param {olx.ViewOptions} options View options. */ -ol.View.prototype.applyOptions_ = function(options) { +_ol_View_.prototype.applyOptions_ = function(options) { /** * @type {Object.} */ var properties = {}; - properties[ol.ViewProperty.CENTER] = options.center !== undefined ? + properties[_ol_ViewProperty_.CENTER] = options.center !== undefined ? options.center : null; - var resolutionConstraintInfo = ol.View.createResolutionConstraint_( + var resolutionConstraintInfo = _ol_View_.createResolutionConstraint_( options); /** @@ -161,9 +162,9 @@ ol.View.prototype.applyOptions_ = function(options) { */ this.minZoom_ = resolutionConstraintInfo.minZoom; - var centerConstraint = ol.View.createCenterConstraint_(options); + var centerConstraint = _ol_View_.createCenterConstraint_(options); var resolutionConstraint = resolutionConstraintInfo.constraint; - var rotationConstraint = ol.View.createRotationConstraint_(options); + var rotationConstraint = _ol_View_.createRotationConstraint_(options); /** * @private @@ -176,18 +177,18 @@ ol.View.prototype.applyOptions_ = function(options) { }; if (options.resolution !== undefined) { - properties[ol.ViewProperty.RESOLUTION] = options.resolution; + properties[_ol_ViewProperty_.RESOLUTION] = options.resolution; } else if (options.zoom !== undefined) { - properties[ol.ViewProperty.RESOLUTION] = this.constrainResolution( + properties[_ol_ViewProperty_.RESOLUTION] = this.constrainResolution( this.maxResolution_, options.zoom - this.minZoom_); if (this.resolutions_) { // in case map zoom is out of min/max zoom range - properties[ol.ViewProperty.RESOLUTION] = ol.math.clamp( - Number(this.getResolution() || properties[ol.ViewProperty.RESOLUTION]), + properties[_ol_ViewProperty_.RESOLUTION] = _ol_math_.clamp( + Number(this.getResolution() || properties[_ol_ViewProperty_.RESOLUTION]), this.minResolution_, this.maxResolution_); } } - properties[ol.ViewProperty.ROTATION] = + properties[_ol_ViewProperty_.ROTATION] = options.rotation !== undefined ? options.rotation : 0; this.setProperties(properties); @@ -207,8 +208,8 @@ ol.View.prototype.applyOptions_ = function(options) { * @param {olx.ViewOptions} newOptions New options to be applied. * @return {olx.ViewOptions} New options updated with the current view state. */ -ol.View.prototype.getUpdatedOptions_ = function(newOptions) { - var options = ol.obj.assign({}, this.options_); +_ol_View_.prototype.getUpdatedOptions_ = function(newOptions) { + var options = _ol_obj_.assign({}, this.options_); // preserve resolution (or zoom) if (options.resolution !== undefined) { @@ -223,7 +224,7 @@ ol.View.prototype.getUpdatedOptions_ = function(newOptions) { // preserve rotation options.rotation = this.getRotation(); - return ol.obj.assign({}, options, newOptions); + return _ol_obj_.assign({}, options, newOptions); }; @@ -260,7 +261,7 @@ ol.View.prototype.getUpdatedOptions_ = function(newOptions) { * the animation completed without being cancelled. * @api */ -ol.View.prototype.animate = function(var_args) { +_ol_View_.prototype.animate = function(var_args) { var animationCount = arguments.length; var callback; if (animationCount > 1 && typeof arguments[animationCount - 1] === 'function') { @@ -297,7 +298,7 @@ ol.View.prototype.animate = function(var_args) { complete: false, anchor: options.anchor, duration: options.duration !== undefined ? options.duration : 1000, - easing: options.easing || ol.easing.inAndOut + easing: options.easing || _ol_easing_.inAndOut }); if (options.center) { @@ -319,7 +320,7 @@ ol.View.prototype.animate = function(var_args) { if (options.rotation !== undefined) { animation.sourceRotation = rotation; - var delta = ol.math.modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI; + var delta = _ol_math_.modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI; animation.targetRotation = rotation + delta; rotation = animation.targetRotation; } @@ -327,7 +328,7 @@ ol.View.prototype.animate = function(var_args) { animation.callback = callback; // check if animation is a no-op - if (ol.View.isNoopAnimation(animation)) { + if (_ol_View_.isNoopAnimation(animation)) { animation.complete = true; // we still push it onto the series for callback handling } else { @@ -336,7 +337,7 @@ ol.View.prototype.animate = function(var_args) { series.push(animation); } this.animations_.push(series); - this.setHint(ol.ViewHint.ANIMATING, 1); + this.setHint(_ol_ViewHint_.ANIMATING, 1); this.updateAnimations_(); }; @@ -346,8 +347,8 @@ ol.View.prototype.animate = function(var_args) { * @return {boolean} The view is being animated. * @api */ -ol.View.prototype.getAnimating = function() { - return this.hints_[ol.ViewHint.ANIMATING] > 0; +_ol_View_.prototype.getAnimating = function() { + return this.hints_[_ol_ViewHint_.ANIMATING] > 0; }; @@ -356,8 +357,8 @@ ol.View.prototype.getAnimating = function() { * @return {boolean} The view is being interacted with. * @api */ -ol.View.prototype.getInteracting = function() { - return this.hints_[ol.ViewHint.INTERACTING] > 0; +_ol_View_.prototype.getInteracting = function() { + return this.hints_[_ol_ViewHint_.INTERACTING] > 0; }; @@ -365,8 +366,8 @@ ol.View.prototype.getInteracting = function() { * Cancel any ongoing animations. * @api */ -ol.View.prototype.cancelAnimations = function() { - this.setHint(ol.ViewHint.ANIMATING, -this.hints_[ol.ViewHint.ANIMATING]); +_ol_View_.prototype.cancelAnimations = function() { + this.setHint(_ol_ViewHint_.ANIMATING, -this.hints_[_ol_ViewHint_.ANIMATING]); for (var i = 0, ii = this.animations_.length; i < ii; ++i) { var series = this.animations_[i]; if (series[0].callback) { @@ -379,7 +380,7 @@ ol.View.prototype.cancelAnimations = function() { /** * Update all animations. */ -ol.View.prototype.updateAnimations_ = function() { +_ol_View_.prototype.updateAnimations_ = function() { if (this.updateAnimationKey_ !== undefined) { cancelAnimationFrame(this.updateAnimationKey_); this.updateAnimationKey_ = undefined; @@ -413,27 +414,27 @@ ol.View.prototype.updateAnimations_ = function() { var y1 = animation.targetCenter[1]; var x = x0 + progress * (x1 - x0); var y = y0 + progress * (y1 - y0); - this.set(ol.ViewProperty.CENTER, [x, y]); + this.set(_ol_ViewProperty_.CENTER, [x, y]); } if (animation.sourceResolution && animation.targetResolution) { var resolution = progress === 1 ? animation.targetResolution : animation.sourceResolution + progress * (animation.targetResolution - animation.sourceResolution); if (animation.anchor) { - this.set(ol.ViewProperty.CENTER, + this.set(_ol_ViewProperty_.CENTER, this.calculateCenterZoom(resolution, animation.anchor)); } - this.set(ol.ViewProperty.RESOLUTION, resolution); + this.set(_ol_ViewProperty_.RESOLUTION, resolution); } if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) { var rotation = progress === 1 ? - ol.math.modulo(animation.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : + _ol_math_.modulo(animation.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation); if (animation.anchor) { - this.set(ol.ViewProperty.CENTER, + this.set(_ol_ViewProperty_.CENTER, this.calculateCenterRotate(rotation, animation.anchor)); } - this.set(ol.ViewProperty.ROTATION, rotation); + this.set(_ol_ViewProperty_.ROTATION, rotation); } more = true; if (!animation.complete) { @@ -442,7 +443,7 @@ ol.View.prototype.updateAnimations_ = function() { } if (seriesComplete) { this.animations_[i] = null; - this.setHint(ol.ViewHint.ANIMATING, -1); + this.setHint(_ol_ViewHint_.ANIMATING, -1); var callback = series[0].callback; if (callback) { callback(true); @@ -461,13 +462,13 @@ ol.View.prototype.updateAnimations_ = function() { * @param {ol.Coordinate} anchor Rotation anchor. * @return {ol.Coordinate|undefined} Center for rotation and anchor. */ -ol.View.prototype.calculateCenterRotate = function(rotation, anchor) { +_ol_View_.prototype.calculateCenterRotate = function(rotation, anchor) { var center; var currentCenter = this.getCenter(); if (currentCenter !== undefined) { center = [currentCenter[0] - anchor[0], currentCenter[1] - anchor[1]]; - ol.coordinate.rotate(center, rotation - this.getRotation()); - ol.coordinate.add(center, anchor); + _ol_coordinate_.rotate(center, rotation - this.getRotation()); + _ol_coordinate_.add(center, anchor); } return center; }; @@ -478,7 +479,7 @@ ol.View.prototype.calculateCenterRotate = function(rotation, anchor) { * @param {ol.Coordinate} anchor Zoom anchor. * @return {ol.Coordinate|undefined} Center for resolution and anchor. */ -ol.View.prototype.calculateCenterZoom = function(resolution, anchor) { +_ol_View_.prototype.calculateCenterZoom = function(resolution, anchor) { var center; var currentCenter = this.getCenter(); var currentResolution = this.getResolution(); @@ -497,9 +498,9 @@ ol.View.prototype.calculateCenterZoom = function(resolution, anchor) { * @private * @return {ol.Size} Viewport size or `[100, 100]` when no viewport is found. */ -ol.View.prototype.getSizeFromViewport_ = function() { +_ol_View_.prototype.getSizeFromViewport_ = function() { var size = [100, 100]; - var selector = '.ol-viewport[data-view="' + ol.getUid(this) + '"]'; + var selector = '.ol-viewport[data-view="' + _ol_.getUid(this) + '"]'; var element = document.querySelector(selector); if (element) { var metrics = getComputedStyle(element); @@ -516,7 +517,7 @@ ol.View.prototype.getSizeFromViewport_ = function() { * @return {ol.Coordinate|undefined} Constrained center. * @api */ -ol.View.prototype.constrainCenter = function(center) { +_ol_View_.prototype.constrainCenter = function(center) { return this.constraints_.center(center); }; @@ -529,7 +530,7 @@ ol.View.prototype.constrainCenter = function(center) { * @return {number|undefined} Constrained resolution. * @api */ -ol.View.prototype.constrainResolution = function( +_ol_View_.prototype.constrainResolution = function( resolution, opt_delta, opt_direction) { var delta = opt_delta || 0; var direction = opt_direction || 0; @@ -544,7 +545,7 @@ ol.View.prototype.constrainResolution = function( * @return {number|undefined} Constrained rotation. * @api */ -ol.View.prototype.constrainRotation = function(rotation, opt_delta) { +_ol_View_.prototype.constrainRotation = function(rotation, opt_delta) { var delta = opt_delta || 0; return this.constraints_.rotation(rotation, delta); }; @@ -556,16 +557,17 @@ ol.View.prototype.constrainRotation = function(rotation, opt_delta) { * @observable * @api */ -ol.View.prototype.getCenter = function() { - return /** @type {ol.Coordinate|undefined} */ ( - this.get(ol.ViewProperty.CENTER)); +_ol_View_.prototype.getCenter = function() { + return ( + /** @type {ol.Coordinate|undefined} */ this.get(_ol_ViewProperty_.CENTER) + ); }; /** * @return {ol.Constraints} Constraints. */ -ol.View.prototype.getConstraints = function() { +_ol_View_.prototype.getConstraints = function() { return this.constraints_; }; @@ -574,7 +576,7 @@ ol.View.prototype.getConstraints = function() { * @param {Array.=} opt_hints Destination array. * @return {Array.} Hint. */ -ol.View.prototype.getHints = function(opt_hints) { +_ol_View_.prototype.getHints = function(opt_hints) { if (opt_hints !== undefined) { opt_hints[0] = this.hints_[0]; opt_hints[1] = this.hints_[1]; @@ -595,16 +597,16 @@ ol.View.prototype.getHints = function(opt_hints) { * @return {ol.Extent} Extent. * @api */ -ol.View.prototype.calculateExtent = function(opt_size) { +_ol_View_.prototype.calculateExtent = function(opt_size) { var size = opt_size || this.getSizeFromViewport_(); var center = /** @type {!ol.Coordinate} */ (this.getCenter()); - ol.asserts.assert(center, 1); // The view center is not defined + _ol_asserts_.assert(center, 1); // The view center is not defined var resolution = /** @type {!number} */ (this.getResolution()); - ol.asserts.assert(resolution !== undefined, 2); // The view resolution is not defined + _ol_asserts_.assert(resolution !== undefined, 2); // The view resolution is not defined var rotation = /** @type {!number} */ (this.getRotation()); - ol.asserts.assert(rotation !== undefined, 3); // The view rotation is not defined + _ol_asserts_.assert(rotation !== undefined, 3); // The view rotation is not defined - return ol.extent.getForViewAndSize(center, resolution, rotation, size); + return _ol_extent_.getForViewAndSize(center, resolution, rotation, size); }; @@ -613,7 +615,7 @@ ol.View.prototype.calculateExtent = function(opt_size) { * @return {number} The maximum resolution of the view. * @api */ -ol.View.prototype.getMaxResolution = function() { +_ol_View_.prototype.getMaxResolution = function() { return this.maxResolution_; }; @@ -623,7 +625,7 @@ ol.View.prototype.getMaxResolution = function() { * @return {number} The minimum resolution of the view. * @api */ -ol.View.prototype.getMinResolution = function() { +_ol_View_.prototype.getMinResolution = function() { return this.minResolution_; }; @@ -633,7 +635,7 @@ ol.View.prototype.getMinResolution = function() { * @return {number} The maximum zoom level. * @api */ -ol.View.prototype.getMaxZoom = function() { +_ol_View_.prototype.getMaxZoom = function() { return /** @type {number} */ (this.getZoomForResolution(this.minResolution_)); }; @@ -643,7 +645,7 @@ ol.View.prototype.getMaxZoom = function() { * @param {number} zoom The maximum zoom level. * @api */ -ol.View.prototype.setMaxZoom = function(zoom) { +_ol_View_.prototype.setMaxZoom = function(zoom) { this.applyOptions_(this.getUpdatedOptions_({maxZoom: zoom})); }; @@ -653,7 +655,7 @@ ol.View.prototype.setMaxZoom = function(zoom) { * @return {number} The minimum zoom level. * @api */ -ol.View.prototype.getMinZoom = function() { +_ol_View_.prototype.getMinZoom = function() { return /** @type {number} */ (this.getZoomForResolution(this.maxResolution_)); }; @@ -663,7 +665,7 @@ ol.View.prototype.getMinZoom = function() { * @param {number} zoom The minimum zoom level. * @api */ -ol.View.prototype.setMinZoom = function(zoom) { +_ol_View_.prototype.setMinZoom = function(zoom) { this.applyOptions_(this.getUpdatedOptions_({minZoom: zoom})); }; @@ -673,7 +675,7 @@ ol.View.prototype.setMinZoom = function(zoom) { * @return {ol.proj.Projection} The projection of the view. * @api */ -ol.View.prototype.getProjection = function() { +_ol_View_.prototype.getProjection = function() { return this.projection_; }; @@ -684,9 +686,10 @@ ol.View.prototype.getProjection = function() { * @observable * @api */ -ol.View.prototype.getResolution = function() { - return /** @type {number|undefined} */ ( - this.get(ol.ViewProperty.RESOLUTION)); +_ol_View_.prototype.getResolution = function() { + return ( + /** @type {number|undefined} */ this.get(_ol_ViewProperty_.RESOLUTION) + ); }; @@ -696,7 +699,7 @@ ol.View.prototype.getResolution = function() { * @return {Array.|undefined} The resolutions of the view. * @api */ -ol.View.prototype.getResolutions = function() { +_ol_View_.prototype.getResolutions = function() { return this.resolutions_; }; @@ -709,10 +712,10 @@ ol.View.prototype.getResolutions = function() { * the given size. * @api */ -ol.View.prototype.getResolutionForExtent = function(extent, opt_size) { +_ol_View_.prototype.getResolutionForExtent = function(extent, opt_size) { var size = opt_size || this.getSizeFromViewport_(); - var xResolution = ol.extent.getWidth(extent) / size[0]; - var yResolution = ol.extent.getHeight(extent) / size[1]; + var xResolution = _ol_extent_.getWidth(extent) / size[0]; + var yResolution = _ol_extent_.getHeight(extent) / size[1]; return Math.max(xResolution, yResolution); }; @@ -723,7 +726,7 @@ ol.View.prototype.getResolutionForExtent = function(extent, opt_size) { * @param {number=} opt_power Power. * @return {function(number): number} Resolution for value function. */ -ol.View.prototype.getResolutionForValueFunction = function(opt_power) { +_ol_View_.prototype.getResolutionForValueFunction = function(opt_power) { var power = opt_power || 2; var maxResolution = this.maxResolution_; var minResolution = this.minResolution_; @@ -746,8 +749,10 @@ ol.View.prototype.getResolutionForValueFunction = function(opt_power) { * @observable * @api */ -ol.View.prototype.getRotation = function() { - return /** @type {number} */ (this.get(ol.ViewProperty.ROTATION)); +_ol_View_.prototype.getRotation = function() { + return ( + /** @type {number} */ this.get(_ol_ViewProperty_.ROTATION) + ); }; @@ -757,7 +762,7 @@ ol.View.prototype.getRotation = function() { * @param {number=} opt_power Power. * @return {function(number): number} Value for resolution function. */ -ol.View.prototype.getValueForResolutionFunction = function(opt_power) { +_ol_View_.prototype.getValueForResolutionFunction = function(opt_power) { var power = opt_power || 2; var maxResolution = this.maxResolution_; var minResolution = this.minResolution_; @@ -778,7 +783,7 @@ ol.View.prototype.getValueForResolutionFunction = function(opt_power) { /** * @return {olx.ViewState} View state. */ -ol.View.prototype.getState = function() { +_ol_View_.prototype.getState = function() { var center = /** @type {ol.Coordinate} */ (this.getCenter()); var projection = this.getProjection(); var resolution = /** @type {number} */ (this.getResolution()); @@ -800,7 +805,7 @@ ol.View.prototype.getState = function() { * @return {number|undefined} Zoom. * @api */ -ol.View.prototype.getZoom = function() { +_ol_View_.prototype.getZoom = function() { var zoom; var resolution = this.getResolution(); if (resolution !== undefined) { @@ -816,11 +821,11 @@ ol.View.prototype.getZoom = function() { * @return {number|undefined} The zoom level for the provided resolution. * @api */ -ol.View.prototype.getZoomForResolution = function(resolution) { +_ol_View_.prototype.getZoomForResolution = function(resolution) { var offset = this.minZoom_ || 0; var max, zoomFactor; if (this.resolutions_) { - var nearest = ol.array.linearFindNearest(this.resolutions_, resolution, 1); + var nearest = _ol_array_.linearFindNearest(this.resolutions_, resolution, 1); offset = nearest; max = this.resolutions_[nearest]; if (nearest == this.resolutions_.length - 1) { @@ -842,7 +847,7 @@ ol.View.prototype.getZoomForResolution = function(resolution) { * @return {number} The view resolution for the provided zoom level. * @api */ -ol.View.prototype.getResolutionForZoom = function(zoom) { +_ol_View_.prototype.getResolutionForZoom = function(zoom) { return /** @type {number} */ (this.constrainResolution( this.maxResolution_, zoom - this.minZoom_, 0)); }; @@ -858,7 +863,7 @@ ol.View.prototype.getResolutionForZoom = function(zoom) { * @param {olx.view.FitOptions=} opt_options Options. * @api */ -ol.View.prototype.fit = function(geometryOrExtent, opt_options) { +_ol_View_.prototype.fit = function(geometryOrExtent, opt_options) { var options = opt_options || {}; var size = options.size; if (!size) { @@ -866,16 +871,16 @@ ol.View.prototype.fit = function(geometryOrExtent, opt_options) { } /** @type {ol.geom.SimpleGeometry} */ var geometry; - if (!(geometryOrExtent instanceof ol.geom.SimpleGeometry)) { - ol.asserts.assert(Array.isArray(geometryOrExtent), + if (!(geometryOrExtent instanceof _ol_geom_SimpleGeometry_)) { + _ol_asserts_.assert(Array.isArray(geometryOrExtent), 24); // Invalid extent or geometry provided as `geometry` - ol.asserts.assert(!ol.extent.isEmpty(geometryOrExtent), + _ol_asserts_.assert(!_ol_extent_.isEmpty(geometryOrExtent), 25); // Cannot fit empty extent provided as `geometry` - geometry = ol.geom.Polygon.fromExtent(geometryOrExtent); - } else if (geometryOrExtent.getType() === ol.geom.GeometryType.CIRCLE) { + geometry = _ol_geom_Polygon_.fromExtent(geometryOrExtent); + } else if (geometryOrExtent.getType() === _ol_geom_GeometryType_.CIRCLE) { geometryOrExtent = geometryOrExtent.getExtent(); - geometry = ol.geom.Polygon.fromExtent(geometryOrExtent); - geometry.rotate(this.getRotation(), ol.extent.getCenter(geometryOrExtent)); + geometry = _ol_geom_Polygon_.fromExtent(geometryOrExtent); + geometry.rotate(this.getRotation(), _ol_extent_.getCenter(geometryOrExtent)); } else { geometry = geometryOrExtent; } @@ -937,7 +942,7 @@ ol.View.prototype.fit = function(geometryOrExtent, opt_options) { var centerX = centerRotX * cosAngle - centerRotY * sinAngle; var centerY = centerRotY * cosAngle + centerRotX * sinAngle; var center = [centerX, centerY]; - var callback = options.callback ? options.callback : ol.nullFunction; + var callback = options.callback ? options.callback : _ol_.nullFunction; if (options.duration !== undefined) { this.animate({ @@ -961,7 +966,7 @@ ol.View.prototype.fit = function(geometryOrExtent, opt_options) { * @param {ol.Pixel} position Position on the view to center on. * @api */ -ol.View.prototype.centerOn = function(coordinate, size, position) { +_ol_View_.prototype.centerOn = function(coordinate, size, position) { // calculate rotated position var rotation = this.getRotation(); var cosAngle = Math.cos(-rotation); @@ -984,7 +989,7 @@ ol.View.prototype.centerOn = function(coordinate, size, position) { /** * @return {boolean} Is defined. */ -ol.View.prototype.isDef = function() { +_ol_View_.prototype.isDef = function() { return !!this.getCenter() && this.getResolution() !== undefined; }; @@ -995,7 +1000,7 @@ ol.View.prototype.isDef = function() { * @param {ol.Coordinate=} opt_anchor The rotation center. * @api */ -ol.View.prototype.rotate = function(rotation, opt_anchor) { +_ol_View_.prototype.rotate = function(rotation, opt_anchor) { if (opt_anchor !== undefined) { var center = this.calculateCenterRotate(rotation, opt_anchor); this.setCenter(center); @@ -1010,8 +1015,8 @@ ol.View.prototype.rotate = function(rotation, opt_anchor) { * @observable * @api */ -ol.View.prototype.setCenter = function(center) { - this.set(ol.ViewProperty.CENTER, center); +_ol_View_.prototype.setCenter = function(center) { + this.set(_ol_ViewProperty_.CENTER, center); if (this.getAnimating()) { this.cancelAnimations(); } @@ -1023,7 +1028,7 @@ ol.View.prototype.setCenter = function(center) { * @param {number} delta Delta. * @return {number} New value. */ -ol.View.prototype.setHint = function(hint, delta) { +_ol_View_.prototype.setHint = function(hint, delta) { this.hints_[hint] += delta; this.changed(); return this.hints_[hint]; @@ -1036,8 +1041,8 @@ ol.View.prototype.setHint = function(hint, delta) { * @observable * @api */ -ol.View.prototype.setResolution = function(resolution) { - this.set(ol.ViewProperty.RESOLUTION, resolution); +_ol_View_.prototype.setResolution = function(resolution) { + this.set(_ol_ViewProperty_.RESOLUTION, resolution); if (this.getAnimating()) { this.cancelAnimations(); } @@ -1050,8 +1055,8 @@ ol.View.prototype.setResolution = function(resolution) { * @observable * @api */ -ol.View.prototype.setRotation = function(rotation) { - this.set(ol.ViewProperty.ROTATION, rotation); +_ol_View_.prototype.setRotation = function(rotation) { + this.set(_ol_ViewProperty_.ROTATION, rotation); if (this.getAnimating()) { this.cancelAnimations(); } @@ -1063,7 +1068,7 @@ ol.View.prototype.setRotation = function(rotation) { * @param {number} zoom Zoom level. * @api */ -ol.View.prototype.setZoom = function(zoom) { +_ol_View_.prototype.setZoom = function(zoom) { this.setResolution(this.getResolutionForZoom(zoom)); }; @@ -1073,11 +1078,11 @@ ol.View.prototype.setZoom = function(zoom) { * @private * @return {ol.CenterConstraintType} The constraint. */ -ol.View.createCenterConstraint_ = function(options) { +_ol_View_.createCenterConstraint_ = function(options) { if (options.extent !== undefined) { - return ol.CenterConstraint.createExtent(options.extent); + return _ol_CenterConstraint_.createExtent(options.extent); } else { - return ol.CenterConstraint.none; + return _ol_CenterConstraint_.none; } }; @@ -1088,7 +1093,7 @@ ol.View.createCenterConstraint_ = function(options) { * @return {{constraint: ol.ResolutionConstraintType, maxResolution: number, * minResolution: number, zoomFactor: number}} The constraint. */ -ol.View.createResolutionConstraint_ = function(options) { +_ol_View_.createResolutionConstraint_ = function(options) { var resolutionConstraint; var maxResolution; var minResolution; @@ -1099,7 +1104,7 @@ ol.View.createResolutionConstraint_ = function(options) { var defaultZoomFactor = 2; var minZoom = options.minZoom !== undefined ? - options.minZoom : ol.DEFAULT_MIN_ZOOM; + options.minZoom : _ol_.DEFAULT_MIN_ZOOM; var maxZoom = options.maxZoom !== undefined ? options.maxZoom : defaultMaxZoom; @@ -1112,23 +1117,23 @@ ol.View.createResolutionConstraint_ = function(options) { maxResolution = resolutions[minZoom]; minResolution = resolutions[maxZoom] !== undefined ? resolutions[maxZoom] : resolutions[resolutions.length - 1]; - resolutionConstraint = ol.ResolutionConstraint.createSnapToResolutions( + resolutionConstraint = _ol_ResolutionConstraint_.createSnapToResolutions( resolutions); } else { // calculate the default min and max resolution - var projection = ol.proj.createProjection(options.projection, 'EPSG:3857'); + var projection = _ol_proj_.createProjection(options.projection, 'EPSG:3857'); var extent = projection.getExtent(); var size = !extent ? // use an extent that can fit the whole world if need be - 360 * ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES] / + 360 * _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES] / projection.getMetersPerUnit() : - Math.max(ol.extent.getWidth(extent), ol.extent.getHeight(extent)); + Math.max(_ol_extent_.getWidth(extent), _ol_extent_.getHeight(extent)); - var defaultMaxResolution = size / ol.DEFAULT_TILE_SIZE / Math.pow( - defaultZoomFactor, ol.DEFAULT_MIN_ZOOM); + var defaultMaxResolution = size / _ol_.DEFAULT_TILE_SIZE / Math.pow( + defaultZoomFactor, _ol_.DEFAULT_MIN_ZOOM); var defaultMinResolution = defaultMaxResolution / Math.pow( - defaultZoomFactor, defaultMaxZoom - ol.DEFAULT_MIN_ZOOM); + defaultZoomFactor, defaultMaxZoom - _ol_.DEFAULT_MIN_ZOOM); // user provided maxResolution takes precedence maxResolution = options.maxResolution; @@ -1157,7 +1162,7 @@ ol.View.createResolutionConstraint_ = function(options) { Math.log(maxResolution / minResolution) / Math.log(zoomFactor)); minResolution = maxResolution / Math.pow(zoomFactor, maxZoom - minZoom); - resolutionConstraint = ol.ResolutionConstraint.createSnapToPower( + resolutionConstraint = _ol_ResolutionConstraint_.createSnapToPower( zoomFactor, maxResolution, maxZoom - minZoom); } return {constraint: resolutionConstraint, maxResolution: maxResolution, @@ -1170,22 +1175,22 @@ ol.View.createResolutionConstraint_ = function(options) { * @param {olx.ViewOptions} options View options. * @return {ol.RotationConstraintType} Rotation constraint. */ -ol.View.createRotationConstraint_ = function(options) { +_ol_View_.createRotationConstraint_ = function(options) { var enableRotation = options.enableRotation !== undefined ? options.enableRotation : true; if (enableRotation) { var constrainRotation = options.constrainRotation; if (constrainRotation === undefined || constrainRotation === true) { - return ol.RotationConstraint.createSnapToZero(); + return _ol_RotationConstraint_.createSnapToZero(); } else if (constrainRotation === false) { - return ol.RotationConstraint.none; + return _ol_RotationConstraint_.none; } else if (typeof constrainRotation === 'number') { - return ol.RotationConstraint.createSnapToN(constrainRotation); + return _ol_RotationConstraint_.createSnapToN(constrainRotation); } else { - return ol.RotationConstraint.none; + return _ol_RotationConstraint_.none; } } else { - return ol.RotationConstraint.disable; + return _ol_RotationConstraint_.disable; } }; @@ -1195,9 +1200,9 @@ ol.View.createRotationConstraint_ = function(options) { * @param {ol.ViewAnimation} animation The animation. * @return {boolean} The animation involves no view change. */ -ol.View.isNoopAnimation = function(animation) { +_ol_View_.isNoopAnimation = function(animation) { if (animation.sourceCenter && animation.targetCenter) { - if (!ol.coordinate.equals(animation.sourceCenter, animation.targetCenter)) { + if (!_ol_coordinate_.equals(animation.sourceCenter, animation.targetCenter)) { return false; } } @@ -1209,3 +1214,4 @@ ol.View.isNoopAnimation = function(animation) { } return true; }; +export default _ol_View_; diff --git a/src/ol/ViewHint.js b/src/ol/ViewHint.js index 8c67e96259..44f30bbba6 100644 --- a/src/ol/ViewHint.js +++ b/src/ol/ViewHint.js @@ -1,9 +1,12 @@ -goog.provide('ol.ViewHint'); - +/** + * @module ol/ViewHint + */ /** * @enum {number} */ -ol.ViewHint = { +var _ol_ViewHint_ = { ANIMATING: 0, INTERACTING: 1 }; + +export default _ol_ViewHint_; diff --git a/src/ol/ViewProperty.js b/src/ol/ViewProperty.js index 7415a2613b..5e14d02988 100644 --- a/src/ol/ViewProperty.js +++ b/src/ol/ViewProperty.js @@ -1,10 +1,13 @@ -goog.provide('ol.ViewProperty'); - +/** + * @module ol/ViewProperty + */ /** * @enum {string} */ -ol.ViewProperty = { +var _ol_ViewProperty_ = { CENTER: 'center', RESOLUTION: 'resolution', ROTATION: 'rotation' }; + +export default _ol_ViewProperty_; diff --git a/src/ol/array.js b/src/ol/array.js index 2524366f0f..3facdba68f 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -1,4 +1,7 @@ -goog.provide('ol.array'); +/** + * @module ol/array + */ +var _ol_array_ = {}; /** @@ -10,9 +13,9 @@ goog.provide('ol.array'); * @param {Function=} opt_comparator Comparator function. * @return {number} The index of the item if found, -1 if not. */ -ol.array.binarySearch = function(haystack, needle, opt_comparator) { +_ol_array_.binarySearch = function(haystack, needle, opt_comparator) { var mid, cmp; - var comparator = opt_comparator || ol.array.numberSafeCompareFunction; + var comparator = opt_comparator || _ol_array_.numberSafeCompareFunction; var low = 0; var high = haystack.length; var found = false; @@ -44,7 +47,7 @@ ol.array.binarySearch = function(haystack, needle, opt_comparator) { * @return {number} A negative number, zero, or a positive number as the first * argument is less than, equal to, or greater than the second. */ -ol.array.numberSafeCompareFunction = function(a, b) { +_ol_array_.numberSafeCompareFunction = function(a, b) { return a > b ? 1 : a < b ? -1 : 0; }; @@ -55,7 +58,7 @@ ol.array.numberSafeCompareFunction = function(a, b) { * @param {*} obj The object for which to test. * @return {boolean} The object is in the array. */ -ol.array.includes = function(arr, obj) { +_ol_array_.includes = function(arr, obj) { return arr.indexOf(obj) >= 0; }; @@ -68,7 +71,7 @@ ol.array.includes = function(arr, obj) { * smallest nearest. * @return {number} Index. */ -ol.array.linearFindNearest = function(arr, target, direction) { +_ol_array_.linearFindNearest = function(arr, target, direction) { var n = arr.length; if (arr[0] <= target) { return 0; @@ -111,7 +114,7 @@ ol.array.linearFindNearest = function(arr, target, direction) { * @param {number} begin Begin index. * @param {number} end End index. */ -ol.array.reverseSubArray = function(arr, begin, end) { +_ol_array_.reverseSubArray = function(arr, begin, end) { while (begin < end) { var tmp = arr[begin]; arr[begin] = arr[end]; @@ -128,7 +131,7 @@ ol.array.reverseSubArray = function(arr, begin, end) { * to add to arr. * @template VALUE */ -ol.array.extend = function(arr, data) { +_ol_array_.extend = function(arr, data) { var i; var extension = Array.isArray(data) ? data : [data]; var length = extension.length; @@ -144,7 +147,7 @@ ol.array.extend = function(arr, data) { * @template VALUE * @return {boolean} If the element was removed. */ -ol.array.remove = function(arr, obj) { +_ol_array_.remove = function(arr, obj) { var i = arr.indexOf(obj); var found = i > -1; if (found) { @@ -160,7 +163,7 @@ ol.array.remove = function(arr, obj) { * @template VALUE * @return {VALUE} The element found. */ -ol.array.find = function(arr, func) { +_ol_array_.find = function(arr, func) { var length = arr.length >>> 0; var value; @@ -179,7 +182,7 @@ ol.array.find = function(arr, func) { * @param {Array|Uint8ClampedArray} arr2 The second array to compare. * @return {boolean} Whether the two arrays are equal. */ -ol.array.equals = function(arr1, arr2) { +_ol_array_.equals = function(arr1, arr2) { var len1 = arr1.length; if (len1 !== arr2.length) { return false; @@ -197,7 +200,7 @@ ol.array.equals = function(arr1, arr2) { * @param {Array.<*>} arr The array to sort (modifies original). * @param {Function} compareFnc Comparison function. */ -ol.array.stableSort = function(arr, compareFnc) { +_ol_array_.stableSort = function(arr, compareFnc) { var length = arr.length; var tmp = Array(arr.length); var i; @@ -218,7 +221,7 @@ ol.array.stableSort = function(arr, compareFnc) { * @param {Function} func Comparison function. * @return {number} Return index. */ -ol.array.findIndex = function(arr, func) { +_ol_array_.findIndex = function(arr, func) { var index; var found = !arr.every(function(el, idx) { index = idx; @@ -234,8 +237,8 @@ ol.array.findIndex = function(arr, func) { * @param {boolean=} opt_strict Strictly sorted (default false). * @return {boolean} Return index. */ -ol.array.isSorted = function(arr, opt_func, opt_strict) { - var compare = opt_func || ol.array.numberSafeCompareFunction; +_ol_array_.isSorted = function(arr, opt_func, opt_strict) { + var compare = opt_func || _ol_array_.numberSafeCompareFunction; return arr.every(function(currentVal, index) { if (index === 0) { return true; @@ -244,3 +247,4 @@ ol.array.isSorted = function(arr, opt_func, opt_strict) { return !(res > 0 || opt_strict && res === 0); }); }; +export default _ol_array_; diff --git a/src/ol/asserts.js b/src/ol/asserts.js index 7d76cba226..e284c80901 100644 --- a/src/ol/asserts.js +++ b/src/ol/asserts.js @@ -1,14 +1,17 @@ -goog.provide('ol.asserts'); - -goog.require('ol.AssertionError'); +/** + * @module ol/asserts + */ +import _ol_AssertionError_ from './AssertionError.js'; +var _ol_asserts_ = {}; /** * @param {*} assertion Assertion we expected to be truthy. * @param {number} errorCode Error code. */ -ol.asserts.assert = function(assertion, errorCode) { +_ol_asserts_.assert = function(assertion, errorCode) { if (!assertion) { - throw new ol.AssertionError(errorCode); + throw new _ol_AssertionError_(errorCode); } }; +export default _ol_asserts_; diff --git a/src/ol/color.js b/src/ol/color.js index 63c2ea755f..398631876a 100644 --- a/src/ol/color.js +++ b/src/ol/color.js @@ -1,7 +1,9 @@ -goog.provide('ol.color'); - -goog.require('ol.asserts'); -goog.require('ol.math'); +/** + * @module ol/color + */ +import _ol_asserts_ from './asserts.js'; +import _ol_math_ from './math.js'; +var _ol_color_ = {}; /** @@ -10,7 +12,7 @@ goog.require('ol.math'); * @type {RegExp} * @private */ -ol.color.HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i; +_ol_color_.HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i; /** @@ -19,7 +21,7 @@ ol.color.HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i; * @type {RegExp} * @private */ -ol.color.NAMED_COLOR_RE_ = /^([a-z]*)$/i; +_ol_color_.NAMED_COLOR_RE_ = /^([a-z]*)$/i; /** @@ -29,11 +31,11 @@ ol.color.NAMED_COLOR_RE_ = /^([a-z]*)$/i; * @return {ol.Color} Color. * @api */ -ol.color.asArray = function(color) { +_ol_color_.asArray = function(color) { if (Array.isArray(color)) { return color; } else { - return ol.color.fromString(/** @type {string} */ (color)); + return _ol_color_.fromString(/** @type {string} */ (color)); } }; @@ -44,11 +46,11 @@ ol.color.asArray = function(color) { * @return {string} Rgba string. * @api */ -ol.color.asString = function(color) { +_ol_color_.asString = function(color) { if (typeof color === 'string') { return color; } else { - return ol.color.toString(color); + return _ol_color_.toString(color); } }; @@ -57,7 +59,7 @@ ol.color.asString = function(color) { * @param {string} color Named color. * @return {string} Rgb string. */ -ol.color.fromNamed = function(color) { +_ol_color_.fromNamed = function(color) { var el = document.createElement('div'); el.style.color = color; document.body.appendChild(el); @@ -71,7 +73,7 @@ ol.color.fromNamed = function(color) { * @param {string} s String. * @return {ol.Color} Color. */ -ol.color.fromString = ( +_ol_color_.fromString = ( function() { // We maintain a small cache of parsed strings. To provide cheap LRU-like @@ -114,12 +116,13 @@ ol.color.fromString = ( } } } - color = ol.color.fromStringInternal_(s); + color = _ol_color_.fromStringInternal_(s); cache[s] = color; ++cacheSize; } return color; - }); + } + ); })(); @@ -129,14 +132,14 @@ ol.color.fromString = ( * @private * @return {ol.Color} Color. */ -ol.color.fromStringInternal_ = function(s) { +_ol_color_.fromStringInternal_ = function(s) { var r, g, b, a, color, parts; - if (ol.color.NAMED_COLOR_RE_.exec(s)) { - s = ol.color.fromNamed(s); + if (_ol_color_.NAMED_COLOR_RE_.exec(s)) { + s = _ol_color_.fromNamed(s); } - if (ol.color.HEX_COLOR_RE_.exec(s)) { // hex + if (_ol_color_.HEX_COLOR_RE_.exec(s)) { // hex var n = s.length - 1; // number of hex digits var d; // number of digits per channel if (n <= 4) { @@ -164,13 +167,13 @@ ol.color.fromStringInternal_ = function(s) { color = [r, g, b, a / 255]; } else if (s.indexOf('rgba(') == 0) { // rgba() parts = s.slice(5, -1).split(',').map(Number); - color = ol.color.normalize(parts); + color = _ol_color_.normalize(parts); } else if (s.indexOf('rgb(') == 0) { // rgb() parts = s.slice(4, -1).split(',').map(Number); parts.push(1); - color = ol.color.normalize(parts); + color = _ol_color_.normalize(parts); } else { - ol.asserts.assert(false, 14); // Invalid color + _ol_asserts_.assert(false, 14); // Invalid color } return /** @type {ol.Color} */ (color); }; @@ -181,12 +184,12 @@ ol.color.fromStringInternal_ = function(s) { * @param {ol.Color=} opt_color Color. * @return {ol.Color} Clamped color. */ -ol.color.normalize = function(color, opt_color) { +_ol_color_.normalize = function(color, opt_color) { var result = opt_color || []; - result[0] = ol.math.clamp((color[0] + 0.5) | 0, 0, 255); - result[1] = ol.math.clamp((color[1] + 0.5) | 0, 0, 255); - result[2] = ol.math.clamp((color[2] + 0.5) | 0, 0, 255); - result[3] = ol.math.clamp(color[3], 0, 1); + result[0] = _ol_math_.clamp((color[0] + 0.5) | 0, 0, 255); + result[1] = _ol_math_.clamp((color[1] + 0.5) | 0, 0, 255); + result[2] = _ol_math_.clamp((color[2] + 0.5) | 0, 0, 255); + result[3] = _ol_math_.clamp(color[3], 0, 1); return result; }; @@ -195,7 +198,7 @@ ol.color.normalize = function(color, opt_color) { * @param {ol.Color} color Color. * @return {string} String. */ -ol.color.toString = function(color) { +_ol_color_.toString = function(color) { var r = color[0]; if (r != (r | 0)) { r = (r + 0.5) | 0; @@ -211,3 +214,4 @@ ol.color.toString = function(color) { var a = color[3] === undefined ? 1 : color[3]; return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; }; +export default _ol_color_; diff --git a/src/ol/colorlike.js b/src/ol/colorlike.js index 07f1e16960..834a2f83d7 100644 --- a/src/ol/colorlike.js +++ b/src/ol/colorlike.js @@ -1,6 +1,8 @@ -goog.provide('ol.colorlike'); - -goog.require('ol.color'); +/** + * @module ol/colorlike + */ +import _ol_color_ from './color.js'; +var _ol_colorlike_ = {}; /** @@ -8,11 +10,11 @@ goog.require('ol.color'); * @return {ol.ColorLike} The color as an ol.ColorLike * @api */ -ol.colorlike.asColorLike = function(color) { - if (ol.colorlike.isColorLike(color)) { +_ol_colorlike_.asColorLike = function(color) { + if (_ol_colorlike_.isColorLike(color)) { return /** @type {string|CanvasPattern|CanvasGradient} */ (color); } else { - return ol.color.asString(/** @type {ol.Color} */ (color)); + return _ol_color_.asString(/** @type {ol.Color} */ (color)); } }; @@ -21,10 +23,11 @@ ol.colorlike.asColorLike = function(color) { * @param {?} color The value that is potentially an ol.ColorLike * @return {boolean} Whether the color is an ol.ColorLike */ -ol.colorlike.isColorLike = function(color) { +_ol_colorlike_.isColorLike = function(color) { return ( typeof color === 'string' || color instanceof CanvasPattern || color instanceof CanvasGradient ); }; +export default _ol_colorlike_; diff --git a/src/ol/control.js b/src/ol/control.js index 88fe299bbc..a0ae3d38ed 100644 --- a/src/ol/control.js +++ b/src/ol/control.js @@ -1,9 +1,11 @@ -goog.provide('ol.control'); - -goog.require('ol.Collection'); -goog.require('ol.control.Attribution'); -goog.require('ol.control.Rotate'); -goog.require('ol.control.Zoom'); +/** + * @module ol/control + */ +import _ol_Collection_ from './Collection.js'; +import _ol_control_Attribution_ from './control/Attribution.js'; +import _ol_control_Rotate_ from './control/Rotate.js'; +import _ol_control_Zoom_ from './control/Zoom.js'; +var _ol_control_ = {}; /** @@ -18,28 +20,29 @@ goog.require('ol.control.Zoom'); * @return {ol.Collection.} Controls. * @api */ -ol.control.defaults = function(opt_options) { +_ol_control_.defaults = function(opt_options) { var options = opt_options ? opt_options : {}; - var controls = new ol.Collection(); + var controls = new _ol_Collection_(); var zoomControl = options.zoom !== undefined ? options.zoom : true; if (zoomControl) { - controls.push(new ol.control.Zoom(options.zoomOptions)); + controls.push(new _ol_control_Zoom_(options.zoomOptions)); } var rotateControl = options.rotate !== undefined ? options.rotate : true; if (rotateControl) { - controls.push(new ol.control.Rotate(options.rotateOptions)); + controls.push(new _ol_control_Rotate_(options.rotateOptions)); } var attributionControl = options.attribution !== undefined ? options.attribution : true; if (attributionControl) { - controls.push(new ol.control.Attribution(options.attributionOptions)); + controls.push(new _ol_control_Attribution_(options.attributionOptions)); } return controls; }; +export default _ol_control_; diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index e6399b8eb7..b6824c9fe2 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -1,17 +1,17 @@ +/** + * @module ol/control/Attribution + */ // FIXME handle date line wrap -goog.provide('ol.control.Attribution'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.control.Control'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.layer.Layer'); -goog.require('ol.obj'); - +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_layer_Layer_ from '../layer/Layer.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -25,7 +25,7 @@ goog.require('ol.obj'); * @param {olx.control.AttributionOptions=} opt_options Attribution options. * @api */ -ol.control.Attribution = function(opt_options) { +var _ol_control_Attribution_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -99,10 +99,10 @@ ol.control.Attribution = function(opt_options) { button.title = tipLabel; button.appendChild(activeLabel); - ol.events.listen(button, ol.events.EventType.CLICK, this.handleClick_, this); + _ol_events_.listen(button, _ol_events_EventType_.CLICK, this.handleClick_, this); - var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + - ol.css.CLASS_CONTROL + + var cssClasses = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + + _ol_css_.CLASS_CONTROL + (this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') + (this.collapsible_ ? '' : ' ol-uncollapsible'); var element = document.createElement('div'); @@ -110,9 +110,9 @@ ol.control.Attribution = function(opt_options) { element.appendChild(this.ulElement_); element.appendChild(button); - var render = options.render ? options.render : ol.control.Attribution.render; + var render = options.render ? options.render : _ol_control_Attribution_.render; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, render: render, target: options.target @@ -138,7 +138,8 @@ ol.control.Attribution = function(opt_options) { this.logoElements_ = {}; }; -ol.inherits(ol.control.Attribution, ol.control.Control); + +_ol_.inherits(_ol_control_Attribution_, _ol_control_Control_); /** @@ -147,7 +148,7 @@ ol.inherits(ol.control.Attribution, ol.control.Control); * @return {Array.} Attributions. * @private */ -ol.control.Attribution.prototype.getSourceAttributions_ = function(frameState) { +_ol_control_Attribution_.prototype.getSourceAttributions_ = function(frameState) { /** * Used to determine if an attribution already exists. * @type {Object.} @@ -164,7 +165,7 @@ ol.control.Attribution.prototype.getSourceAttributions_ = function(frameState) { var resolution = frameState.viewState.resolution; for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) { var layerState = layerStatesArray[i]; - if (!ol.layer.Layer.visibleAtResolution(layerState, resolution)) { + if (!_ol_layer_Layer_.visibleAtResolution(layerState, resolution)) { continue; } @@ -207,7 +208,7 @@ ol.control.Attribution.prototype.getSourceAttributions_ = function(frameState) { * @this {ol.control.Attribution} * @api */ -ol.control.Attribution.render = function(mapEvent) { +_ol_control_Attribution_.render = function(mapEvent) { this.updateElement_(mapEvent.frameState); }; @@ -216,7 +217,7 @@ ol.control.Attribution.render = function(mapEvent) { * @private * @param {?olx.FrameState} frameState Frame state. */ -ol.control.Attribution.prototype.updateElement_ = function(frameState) { +_ol_control_Attribution_.prototype.updateElement_ = function(frameState) { if (!frameState) { if (this.renderedVisible_) { this.element.style.display = 'none'; @@ -226,7 +227,7 @@ ol.control.Attribution.prototype.updateElement_ = function(frameState) { } var attributions = this.getSourceAttributions_(frameState); - if (ol.array.equals(attributions, this.renderedAttributions_)) { + if (_ol_array_.equals(attributions, this.renderedAttributions_)) { return; } @@ -249,7 +250,7 @@ ol.control.Attribution.prototype.updateElement_ = function(frameState) { this.element.classList.remove('ol-logo-only'); } - var visible = attributions.length > 0 || !ol.obj.isEmpty(frameState.logos); + var visible = attributions.length > 0 || !_ol_obj_.isEmpty(frameState.logos); if (this.renderedVisible_ != visible) { this.element.style.display = visible ? '' : 'none'; this.renderedVisible_ = visible; @@ -264,7 +265,7 @@ ol.control.Attribution.prototype.updateElement_ = function(frameState) { * @param {?olx.FrameState} frameState Frame state. * @private */ -ol.control.Attribution.prototype.insertLogos_ = function(frameState) { +_ol_control_Attribution_.prototype.insertLogos_ = function(frameState) { var logo; var logos = frameState.logos; @@ -272,7 +273,7 @@ ol.control.Attribution.prototype.insertLogos_ = function(frameState) { for (logo in logoElements) { if (!(logo in logos)) { - ol.dom.removeNode(logoElements[logo]); + _ol_dom_.removeNode(logoElements[logo]); delete logoElements[logo]; } } @@ -299,7 +300,7 @@ ol.control.Attribution.prototype.insertLogos_ = function(frameState) { } } - this.logoLi_.style.display = !ol.obj.isEmpty(logos) ? '' : 'none'; + this.logoLi_.style.display = !_ol_obj_.isEmpty(logos) ? '' : 'none'; }; @@ -308,7 +309,7 @@ ol.control.Attribution.prototype.insertLogos_ = function(frameState) { * @param {Event} event The event to handle * @private */ -ol.control.Attribution.prototype.handleClick_ = function(event) { +_ol_control_Attribution_.prototype.handleClick_ = function(event) { event.preventDefault(); this.handleToggle_(); }; @@ -317,12 +318,12 @@ ol.control.Attribution.prototype.handleClick_ = function(event) { /** * @private */ -ol.control.Attribution.prototype.handleToggle_ = function() { +_ol_control_Attribution_.prototype.handleToggle_ = function() { this.element.classList.toggle('ol-collapsed'); if (this.collapsed_) { - ol.dom.replaceNode(this.collapseLabel_, this.label_); + _ol_dom_.replaceNode(this.collapseLabel_, this.label_); } else { - ol.dom.replaceNode(this.label_, this.collapseLabel_); + _ol_dom_.replaceNode(this.label_, this.collapseLabel_); } this.collapsed_ = !this.collapsed_; }; @@ -333,7 +334,7 @@ ol.control.Attribution.prototype.handleToggle_ = function() { * @return {boolean} True if the widget is collapsible. * @api */ -ol.control.Attribution.prototype.getCollapsible = function() { +_ol_control_Attribution_.prototype.getCollapsible = function() { return this.collapsible_; }; @@ -343,7 +344,7 @@ ol.control.Attribution.prototype.getCollapsible = function() { * @param {boolean} collapsible True if the widget is collapsible. * @api */ -ol.control.Attribution.prototype.setCollapsible = function(collapsible) { +_ol_control_Attribution_.prototype.setCollapsible = function(collapsible) { if (this.collapsible_ === collapsible) { return; } @@ -362,7 +363,7 @@ ol.control.Attribution.prototype.setCollapsible = function(collapsible) { * @param {boolean} collapsed True if the widget is collapsed. * @api */ -ol.control.Attribution.prototype.setCollapsed = function(collapsed) { +_ol_control_Attribution_.prototype.setCollapsed = function(collapsed) { if (!this.collapsible_ || this.collapsed_ === collapsed) { return; } @@ -376,6 +377,7 @@ ol.control.Attribution.prototype.setCollapsed = function(collapsed) { * @return {boolean} True if the widget is collapsed. * @api */ -ol.control.Attribution.prototype.getCollapsed = function() { +_ol_control_Attribution_.prototype.getCollapsed = function() { return this.collapsed_; }; +export default _ol_control_Attribution_; diff --git a/src/ol/control/Control.js b/src/ol/control/Control.js index 79922655a3..c8085a30e1 100644 --- a/src/ol/control/Control.js +++ b/src/ol/control/Control.js @@ -1,11 +1,11 @@ -goog.provide('ol.control.Control'); - -goog.require('ol'); -goog.require('ol.MapEventType'); -goog.require('ol.Object'); -goog.require('ol.dom'); -goog.require('ol.events'); - +/** + * @module ol/control/Control + */ +import _ol_ from '../index.js'; +import _ol_MapEventType_ from '../MapEventType.js'; +import _ol_Object_ from '../Object.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; /** * @classdesc @@ -36,9 +36,9 @@ goog.require('ol.events'); * @param {olx.control.ControlOptions} options Control options. * @api */ -ol.control.Control = function(options) { +var _ol_control_Control_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @protected @@ -67,22 +67,23 @@ ol.control.Control = function(options) { /** * @type {function(ol.MapEvent)} */ - this.render = options.render ? options.render : ol.nullFunction; + this.render = options.render ? options.render : _ol_.nullFunction; if (options.target) { this.setTarget(options.target); } }; -ol.inherits(ol.control.Control, ol.Object); + +_ol_.inherits(_ol_control_Control_, _ol_Object_); /** * @inheritDoc */ -ol.control.Control.prototype.disposeInternal = function() { - ol.dom.removeNode(this.element); - ol.Object.prototype.disposeInternal.call(this); +_ol_control_Control_.prototype.disposeInternal = function() { + _ol_dom_.removeNode(this.element); + _ol_Object_.prototype.disposeInternal.call(this); }; @@ -91,7 +92,7 @@ ol.control.Control.prototype.disposeInternal = function() { * @return {ol.PluggableMap} Map. * @api */ -ol.control.Control.prototype.getMap = function() { +_ol_control_Control_.prototype.getMap = function() { return this.map_; }; @@ -104,12 +105,12 @@ ol.control.Control.prototype.getMap = function() { * @override * @api */ -ol.control.Control.prototype.setMap = function(map) { +_ol_control_Control_.prototype.setMap = function(map) { if (this.map_) { - ol.dom.removeNode(this.element); + _ol_dom_.removeNode(this.element); } for (var i = 0, ii = this.listenerKeys.length; i < ii; ++i) { - ol.events.unlistenByKey(this.listenerKeys[i]); + _ol_events_.unlistenByKey(this.listenerKeys[i]); } this.listenerKeys.length = 0; this.map_ = map; @@ -117,9 +118,9 @@ ol.control.Control.prototype.setMap = function(map) { var target = this.target_ ? this.target_ : map.getOverlayContainerStopEvent(); target.appendChild(this.element); - if (this.render !== ol.nullFunction) { - this.listenerKeys.push(ol.events.listen(map, - ol.MapEventType.POSTRENDER, this.render, this)); + if (this.render !== _ol_.nullFunction) { + this.listenerKeys.push(_ol_events_.listen(map, + _ol_MapEventType_.POSTRENDER, this.render, this)); } map.render(); } @@ -135,8 +136,9 @@ ol.control.Control.prototype.setMap = function(map) { * @param {Element|string} target Target. * @api */ -ol.control.Control.prototype.setTarget = function(target) { +_ol_control_Control_.prototype.setTarget = function(target) { this.target_ = typeof target === 'string' ? document.getElementById(target) : target; }; +export default _ol_control_Control_; diff --git a/src/ol/control/FullScreen.js b/src/ol/control/FullScreen.js index 4a6cdae3c4..ad0a8caa06 100644 --- a/src/ol/control/FullScreen.js +++ b/src/ol/control/FullScreen.js @@ -1,12 +1,12 @@ -goog.provide('ol.control.FullScreen'); - -goog.require('ol'); -goog.require('ol.control.Control'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); - +/** + * @module ol/control/FullScreen + */ +import _ol_ from '../index.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; /** * @classdesc @@ -25,7 +25,7 @@ goog.require('ol.events.EventType'); * @param {olx.control.FullScreenOptions=} opt_options Options. * @api */ -ol.control.FullScreen = function(opt_options) { +var _ol_control_FullScreen_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -56,22 +56,22 @@ ol.control.FullScreen = function(opt_options) { var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen'; var button = document.createElement('button'); - button.className = this.cssClassName_ + '-' + ol.control.FullScreen.isFullScreen(); + button.className = this.cssClassName_ + '-' + _ol_control_FullScreen_.isFullScreen(); button.setAttribute('type', 'button'); button.title = tipLabel; button.appendChild(this.labelNode_); - ol.events.listen(button, ol.events.EventType.CLICK, + _ol_events_.listen(button, _ol_events_EventType_.CLICK, this.handleClick_, this); - var cssClasses = this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE + - ' ' + ol.css.CLASS_CONTROL + ' ' + - (!ol.control.FullScreen.isFullScreenSupported() ? ol.css.CLASS_UNSUPPORTED : ''); + var cssClasses = this.cssClassName_ + ' ' + _ol_css_.CLASS_UNSELECTABLE + + ' ' + _ol_css_.CLASS_CONTROL + ' ' + + (!_ol_control_FullScreen_.isFullScreenSupported() ? _ol_css_.CLASS_UNSUPPORTED : ''); var element = document.createElement('div'); element.className = cssClasses; element.appendChild(button); - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, target: options.target }); @@ -89,14 +89,15 @@ ol.control.FullScreen = function(opt_options) { this.source_ = options.source; }; -ol.inherits(ol.control.FullScreen, ol.control.Control); + +_ol_.inherits(_ol_control_FullScreen_, _ol_control_Control_); /** * @param {Event} event The event to handle * @private */ -ol.control.FullScreen.prototype.handleClick_ = function(event) { +_ol_control_FullScreen_.prototype.handleClick_ = function(event) { event.preventDefault(); this.handleFullScreen_(); }; @@ -105,16 +106,16 @@ ol.control.FullScreen.prototype.handleClick_ = function(event) { /** * @private */ -ol.control.FullScreen.prototype.handleFullScreen_ = function() { - if (!ol.control.FullScreen.isFullScreenSupported()) { +_ol_control_FullScreen_.prototype.handleFullScreen_ = function() { + if (!_ol_control_FullScreen_.isFullScreenSupported()) { return; } var map = this.getMap(); if (!map) { return; } - if (ol.control.FullScreen.isFullScreen()) { - ol.control.FullScreen.exitFullScreen(); + if (_ol_control_FullScreen_.isFullScreen()) { + _ol_control_FullScreen_.exitFullScreen(); } else { var element; if (this.source_) { @@ -125,10 +126,10 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() { element = map.getTargetElement(); } if (this.keys_) { - ol.control.FullScreen.requestFullScreenWithKeys(element); + _ol_control_FullScreen_.requestFullScreenWithKeys(element); } else { - ol.control.FullScreen.requestFullScreen(element); + _ol_control_FullScreen_.requestFullScreen(element); } } }; @@ -137,15 +138,15 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() { /** * @private */ -ol.control.FullScreen.prototype.handleFullScreenChange_ = function() { +_ol_control_FullScreen_.prototype.handleFullScreenChange_ = function() { var button = this.element.firstElementChild; var map = this.getMap(); - if (ol.control.FullScreen.isFullScreen()) { + if (_ol_control_FullScreen_.isFullScreen()) { button.className = this.cssClassName_ + '-true'; - ol.dom.replaceNode(this.labelActiveNode_, this.labelNode_); + _ol_dom_.replaceNode(this.labelActiveNode_, this.labelNode_); } else { button.className = this.cssClassName_ + '-false'; - ol.dom.replaceNode(this.labelNode_, this.labelActiveNode_); + _ol_dom_.replaceNode(this.labelNode_, this.labelActiveNode_); } if (map) { map.updateSize(); @@ -157,11 +158,11 @@ ol.control.FullScreen.prototype.handleFullScreenChange_ = function() { * @inheritDoc * @api */ -ol.control.FullScreen.prototype.setMap = function(map) { - ol.control.Control.prototype.setMap.call(this, map); +_ol_control_FullScreen_.prototype.setMap = function(map) { + _ol_control_Control_.prototype.setMap.call(this, map); if (map) { - this.listenerKeys.push(ol.events.listen(document, - ol.control.FullScreen.getChangeType_(), + this.listenerKeys.push(_ol_events_.listen(document, + _ol_control_FullScreen_.getChangeType_(), this.handleFullScreenChange_, this) ); } @@ -170,7 +171,7 @@ ol.control.FullScreen.prototype.setMap = function(map) { /** * @return {boolean} Fullscreen is supported by the current platform. */ -ol.control.FullScreen.isFullScreenSupported = function() { +_ol_control_FullScreen_.isFullScreenSupported = function() { var body = document.body; return !!( body.webkitRequestFullscreen || @@ -183,7 +184,7 @@ ol.control.FullScreen.isFullScreenSupported = function() { /** * @return {boolean} Element is currently in fullscreen. */ -ol.control.FullScreen.isFullScreen = function() { +_ol_control_FullScreen_.isFullScreen = function() { return !!( document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement @@ -194,7 +195,7 @@ ol.control.FullScreen.isFullScreen = function() { * Request to fullscreen an element. * @param {Node} element Element to request fullscreen */ -ol.control.FullScreen.requestFullScreen = function(element) { +_ol_control_FullScreen_.requestFullScreen = function(element) { if (element.requestFullscreen) { element.requestFullscreen(); } else if (element.msRequestFullscreen) { @@ -210,20 +211,20 @@ ol.control.FullScreen.requestFullScreen = function(element) { * Request to fullscreen an element with keyboard input. * @param {Node} element Element to request fullscreen */ -ol.control.FullScreen.requestFullScreenWithKeys = function(element) { +_ol_control_FullScreen_.requestFullScreenWithKeys = function(element) { if (element.mozRequestFullScreenWithKeys) { element.mozRequestFullScreenWithKeys(); } else if (element.webkitRequestFullscreen) { element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } else { - ol.control.FullScreen.requestFullScreen(element); + _ol_control_FullScreen_.requestFullScreen(element); } }; /** * Exit fullscreen. */ -ol.control.FullScreen.exitFullScreen = function() { +_ol_control_FullScreen_.exitFullScreen = function() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { @@ -239,7 +240,7 @@ ol.control.FullScreen.exitFullScreen = function() { * @return {string} Change type. * @private */ -ol.control.FullScreen.getChangeType_ = (function() { +_ol_control_FullScreen_.getChangeType_ = (function() { var changeType; return function() { if (!changeType) { @@ -257,3 +258,4 @@ ol.control.FullScreen.getChangeType_ = (function() { return changeType; }; })(); +export default _ol_control_FullScreen_; diff --git a/src/ol/control/MousePosition.js b/src/ol/control/MousePosition.js index b49d8fa37f..4535ac7f1e 100644 --- a/src/ol/control/MousePosition.js +++ b/src/ol/control/MousePosition.js @@ -1,14 +1,14 @@ +/** + * @module ol/control/MousePosition + */ // FIXME should listen on appropriate pane, once it is defined -goog.provide('ol.control.MousePosition'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.Object'); -goog.require('ol.control.Control'); -goog.require('ol.proj'); - +import _ol_ from '../index.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_Object_ from '../Object.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -23,7 +23,7 @@ goog.require('ol.proj'); * options. * @api */ -ol.control.MousePosition = function(opt_options) { +var _ol_control_MousePosition_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -31,16 +31,16 @@ ol.control.MousePosition = function(opt_options) { element.className = options.className !== undefined ? options.className : 'ol-mouse-position'; var render = options.render ? - options.render : ol.control.MousePosition.render; + options.render : _ol_control_MousePosition_.render; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, render: render, target: options.target }); - ol.events.listen(this, - ol.Object.getChangeEventType(ol.control.MousePosition.Property_.PROJECTION), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_control_MousePosition_.Property_.PROJECTION), this.handleProjectionChanged_, this); if (options.coordinateFormat) { @@ -81,7 +81,8 @@ ol.control.MousePosition = function(opt_options) { this.lastMouseMovePixel_ = null; }; -ol.inherits(ol.control.MousePosition, ol.control.Control); + +_ol_.inherits(_ol_control_MousePosition_, _ol_control_Control_); /** @@ -90,7 +91,7 @@ ol.inherits(ol.control.MousePosition, ol.control.Control); * @this {ol.control.MousePosition} * @api */ -ol.control.MousePosition.render = function(mapEvent) { +_ol_control_MousePosition_.render = function(mapEvent) { var frameState = mapEvent.frameState; if (!frameState) { this.mapProjection_ = null; @@ -107,7 +108,7 @@ ol.control.MousePosition.render = function(mapEvent) { /** * @private */ -ol.control.MousePosition.prototype.handleProjectionChanged_ = function() { +_ol_control_MousePosition_.prototype.handleProjectionChanged_ = function() { this.transform_ = null; }; @@ -120,9 +121,10 @@ ol.control.MousePosition.prototype.handleProjectionChanged_ = function() { * @observable * @api */ -ol.control.MousePosition.prototype.getCoordinateFormat = function() { - return /** @type {ol.CoordinateFormatType|undefined} */ ( - this.get(ol.control.MousePosition.Property_.COORDINATE_FORMAT)); +_ol_control_MousePosition_.prototype.getCoordinateFormat = function() { + return ( + /** @type {ol.CoordinateFormatType|undefined} */ this.get(_ol_control_MousePosition_.Property_.COORDINATE_FORMAT) + ); }; @@ -133,9 +135,10 @@ ol.control.MousePosition.prototype.getCoordinateFormat = function() { * @observable * @api */ -ol.control.MousePosition.prototype.getProjection = function() { - return /** @type {ol.proj.Projection|undefined} */ ( - this.get(ol.control.MousePosition.Property_.PROJECTION)); +_ol_control_MousePosition_.prototype.getProjection = function() { + return ( + /** @type {ol.proj.Projection|undefined} */ this.get(_ol_control_MousePosition_.Property_.PROJECTION) + ); }; @@ -143,7 +146,7 @@ ol.control.MousePosition.prototype.getProjection = function() { * @param {Event} event Browser event. * @protected */ -ol.control.MousePosition.prototype.handleMouseMove = function(event) { +_ol_control_MousePosition_.prototype.handleMouseMove = function(event) { var map = this.getMap(); this.lastMouseMovePixel_ = map.getEventPixel(event); this.updateHTML_(this.lastMouseMovePixel_); @@ -154,7 +157,7 @@ ol.control.MousePosition.prototype.handleMouseMove = function(event) { * @param {Event} event Browser event. * @protected */ -ol.control.MousePosition.prototype.handleMouseOut = function(event) { +_ol_control_MousePosition_.prototype.handleMouseOut = function(event) { this.updateHTML_(null); this.lastMouseMovePixel_ = null; }; @@ -164,14 +167,14 @@ ol.control.MousePosition.prototype.handleMouseOut = function(event) { * @inheritDoc * @api */ -ol.control.MousePosition.prototype.setMap = function(map) { - ol.control.Control.prototype.setMap.call(this, map); +_ol_control_MousePosition_.prototype.setMap = function(map) { + _ol_control_Control_.prototype.setMap.call(this, map); if (map) { var viewport = map.getViewport(); this.listenerKeys.push( - ol.events.listen(viewport, ol.events.EventType.MOUSEMOVE, + _ol_events_.listen(viewport, _ol_events_EventType_.MOUSEMOVE, this.handleMouseMove, this), - ol.events.listen(viewport, ol.events.EventType.MOUSEOUT, + _ol_events_.listen(viewport, _ol_events_EventType_.MOUSEOUT, this.handleMouseOut, this) ); } @@ -185,8 +188,8 @@ ol.control.MousePosition.prototype.setMap = function(map) { * @observable * @api */ -ol.control.MousePosition.prototype.setCoordinateFormat = function(format) { - this.set(ol.control.MousePosition.Property_.COORDINATE_FORMAT, format); +_ol_control_MousePosition_.prototype.setCoordinateFormat = function(format) { + this.set(_ol_control_MousePosition_.Property_.COORDINATE_FORMAT, format); }; @@ -197,8 +200,8 @@ ol.control.MousePosition.prototype.setCoordinateFormat = function(format) { * @observable * @api */ -ol.control.MousePosition.prototype.setProjection = function(projection) { - this.set(ol.control.MousePosition.Property_.PROJECTION, ol.proj.get(projection)); +_ol_control_MousePosition_.prototype.setProjection = function(projection) { + this.set(_ol_control_MousePosition_.Property_.PROJECTION, _ol_proj_.get(projection)); }; @@ -206,16 +209,16 @@ ol.control.MousePosition.prototype.setProjection = function(projection) { * @param {?ol.Pixel} pixel Pixel. * @private */ -ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { +_ol_control_MousePosition_.prototype.updateHTML_ = function(pixel) { var html = this.undefinedHTML_; if (pixel && this.mapProjection_) { if (!this.transform_) { var projection = this.getProjection(); if (projection) { - this.transform_ = ol.proj.getTransformFromProjections( + this.transform_ = _ol_proj_.getTransformFromProjections( this.mapProjection_, projection); } else { - this.transform_ = ol.proj.identityTransform; + this.transform_ = _ol_proj_.identityTransform; } } var map = this.getMap(); @@ -241,7 +244,8 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { * @enum {string} * @private */ -ol.control.MousePosition.Property_ = { +_ol_control_MousePosition_.Property_ = { PROJECTION: 'projection', COORDINATE_FORMAT: 'coordinateFormat' }; +export default _ol_control_MousePosition_; diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index a692e53463..7612e400f9 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -1,23 +1,23 @@ -goog.provide('ol.control.OverviewMap'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.PluggableMap'); -goog.require('ol.MapEventType'); -goog.require('ol.MapProperty'); -goog.require('ol.Object'); -goog.require('ol.ObjectEventType'); -goog.require('ol.Overlay'); -goog.require('ol.OverlayPositioning'); -goog.require('ol.ViewProperty'); -goog.require('ol.control.Control'); -goog.require('ol.coordinate'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); - +/** + * @module ol/control/OverviewMap + */ +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_PluggableMap_ from '../PluggableMap.js'; +import _ol_MapEventType_ from '../MapEventType.js'; +import _ol_MapProperty_ from '../MapProperty.js'; +import _ol_Object_ from '../Object.js'; +import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import _ol_Overlay_ from '../Overlay.js'; +import _ol_OverlayPositioning_ from '../OverlayPositioning.js'; +import _ol_ViewProperty_ from '../ViewProperty.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_css_ from '../css.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; /** * Create a new control with a map acting as an overview map for an other @@ -27,7 +27,7 @@ goog.require('ol.extent'); * @param {olx.control.OverviewMapOptions=} opt_options OverviewMap options. * @api */ -ol.control.OverviewMap = function(opt_options) { +var _ol_control_OverviewMap_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -86,7 +86,7 @@ ol.control.OverviewMap = function(opt_options) { button.title = tipLabel; button.appendChild(activeLabel); - ol.events.listen(button, ol.events.EventType.CLICK, + _ol_events_.listen(button, _ol_events_EventType_.CLICK, this.handleClick_, this); /** @@ -100,9 +100,9 @@ ol.control.OverviewMap = function(opt_options) { * @type {ol.PluggableMap} * @private */ - this.ovmap_ = new ol.PluggableMap({ - controls: new ol.Collection(), - interactions: new ol.Collection(), + this.ovmap_ = new _ol_PluggableMap_({ + controls: new _ol_Collection_(), + interactions: new _ol_Collection_(), view: options.view }); var ovmap = this.ovmap_; @@ -125,15 +125,15 @@ ol.control.OverviewMap = function(opt_options) { * @type {ol.Overlay} * @private */ - this.boxOverlay_ = new ol.Overlay({ + this.boxOverlay_ = new _ol_Overlay_({ position: [0, 0], - positioning: ol.OverlayPositioning.BOTTOM_LEFT, + positioning: _ol_OverlayPositioning_.BOTTOM_LEFT, element: box }); this.ovmap_.addOverlay(this.boxOverlay_); - var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + - ol.css.CLASS_CONTROL + + var cssClasses = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + + _ol_css_.CLASS_CONTROL + (this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') + (this.collapsible_ ? '' : ' ol-uncollapsible'); var element = document.createElement('div'); @@ -141,9 +141,9 @@ ol.control.OverviewMap = function(opt_options) { element.appendChild(this.ovmapDiv_); element.appendChild(button); - var render = options.render ? options.render : ol.control.OverviewMap.render; + var render = options.render ? options.render : _ol_control_OverviewMap_.render; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, render: render, target: options.target @@ -187,14 +187,15 @@ ol.control.OverviewMap = function(opt_options) { window.addEventListener('mouseup', endMoving); }); }; -ol.inherits(ol.control.OverviewMap, ol.control.Control); + +_ol_.inherits(_ol_control_OverviewMap_, _ol_control_Control_); /** * @inheritDoc * @api */ -ol.control.OverviewMap.prototype.setMap = function(map) { +_ol_control_OverviewMap_.prototype.setMap = function(map) { var oldMap = this.getMap(); if (map === oldMap) { return; @@ -206,12 +207,12 @@ ol.control.OverviewMap.prototype.setMap = function(map) { } this.ovmap_.setTarget(null); } - ol.control.Control.prototype.setMap.call(this, map); + _ol_control_Control_.prototype.setMap.call(this, map); if (map) { this.ovmap_.setTarget(this.ovmapDiv_); - this.listenerKeys.push(ol.events.listen( - map, ol.ObjectEventType.PROPERTYCHANGE, + this.listenerKeys.push(_ol_events_.listen( + map, _ol_ObjectEventType_.PROPERTYCHANGE, this.handleMapPropertyChange_, this)); // TODO: to really support map switching, this would need to be reworked @@ -236,8 +237,8 @@ ol.control.OverviewMap.prototype.setMap = function(map) { * @param {ol.Object.Event} event The propertychange event. * @private */ -ol.control.OverviewMap.prototype.handleMapPropertyChange_ = function(event) { - if (event.key === ol.MapProperty.VIEW) { +_ol_control_OverviewMap_.prototype.handleMapPropertyChange_ = function(event) { + if (event.key === _ol_MapProperty_.VIEW) { var oldView = /** @type {ol.View} */ (event.oldValue); if (oldView) { this.unbindView_(oldView); @@ -253,9 +254,9 @@ ol.control.OverviewMap.prototype.handleMapPropertyChange_ = function(event) { * @param {ol.View} view The view. * @private */ -ol.control.OverviewMap.prototype.bindView_ = function(view) { - ol.events.listen(view, - ol.Object.getChangeEventType(ol.ViewProperty.ROTATION), +_ol_control_OverviewMap_.prototype.bindView_ = function(view) { + _ol_events_.listen(view, + _ol_Object_.getChangeEventType(_ol_ViewProperty_.ROTATION), this.handleRotationChanged_, this); }; @@ -265,9 +266,9 @@ ol.control.OverviewMap.prototype.bindView_ = function(view) { * @param {ol.View} view The view. * @private */ -ol.control.OverviewMap.prototype.unbindView_ = function(view) { - ol.events.unlisten(view, - ol.Object.getChangeEventType(ol.ViewProperty.ROTATION), +_ol_control_OverviewMap_.prototype.unbindView_ = function(view) { + _ol_events_.unlisten(view, + _ol_Object_.getChangeEventType(_ol_ViewProperty_.ROTATION), this.handleRotationChanged_, this); }; @@ -278,7 +279,7 @@ ol.control.OverviewMap.prototype.unbindView_ = function(view) { * overview map's view. * @private */ -ol.control.OverviewMap.prototype.handleRotationChanged_ = function() { +_ol_control_OverviewMap_.prototype.handleRotationChanged_ = function() { this.ovmap_.getView().setRotation(this.getMap().getView().getRotation()); }; @@ -289,7 +290,7 @@ ol.control.OverviewMap.prototype.handleRotationChanged_ = function() { * @this {ol.control.OverviewMap} * @api */ -ol.control.OverviewMap.render = function(mapEvent) { +_ol_control_OverviewMap_.render = function(mapEvent) { this.validateExtent_(); this.updateBox_(); }; @@ -306,7 +307,7 @@ ol.control.OverviewMap.render = function(mapEvent) { * main map center location. * @private */ -ol.control.OverviewMap.prototype.validateExtent_ = function() { +_ol_control_OverviewMap_.prototype.validateExtent_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -325,9 +326,9 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() { var ovextent = ovview.calculateExtent(ovmapSize); var topLeftPixel = - ovmap.getPixelFromCoordinate(ol.extent.getTopLeft(extent)); + ovmap.getPixelFromCoordinate(_ol_extent_.getTopLeft(extent)); var bottomRightPixel = - ovmap.getPixelFromCoordinate(ol.extent.getBottomRight(extent)); + ovmap.getPixelFromCoordinate(_ol_extent_.getBottomRight(extent)); var boxWidth = Math.abs(topLeftPixel[0] - bottomRightPixel[0]); var boxHeight = Math.abs(topLeftPixel[1] - bottomRightPixel[1]); @@ -335,12 +336,12 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() { var ovmapWidth = ovmapSize[0]; var ovmapHeight = ovmapSize[1]; - if (boxWidth < ovmapWidth * ol.OVERVIEWMAP_MIN_RATIO || - boxHeight < ovmapHeight * ol.OVERVIEWMAP_MIN_RATIO || - boxWidth > ovmapWidth * ol.OVERVIEWMAP_MAX_RATIO || - boxHeight > ovmapHeight * ol.OVERVIEWMAP_MAX_RATIO) { + if (boxWidth < ovmapWidth * _ol_.OVERVIEWMAP_MIN_RATIO || + boxHeight < ovmapHeight * _ol_.OVERVIEWMAP_MIN_RATIO || + boxWidth > ovmapWidth * _ol_.OVERVIEWMAP_MAX_RATIO || + boxHeight > ovmapHeight * _ol_.OVERVIEWMAP_MAX_RATIO) { this.resetExtent_(); - } else if (!ol.extent.containsExtent(ovextent, extent)) { + } else if (!_ol_extent_.containsExtent(ovextent, extent)) { this.recenter_(); } }; @@ -351,8 +352,8 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() { * the extent of the main map. * @private */ -ol.control.OverviewMap.prototype.resetExtent_ = function() { - if (ol.OVERVIEWMAP_MAX_RATIO === 0 || ol.OVERVIEWMAP_MIN_RATIO === 0) { +_ol_control_OverviewMap_.prototype.resetExtent_ = function() { + if (_ol_.OVERVIEWMAP_MAX_RATIO === 0 || _ol_.OVERVIEWMAP_MIN_RATIO === 0) { return; } @@ -370,9 +371,9 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() { // box sizes using the min and max ratio, pick the step in the middle used // to calculate the extent from the main map to set it to the overview map, var steps = Math.log( - ol.OVERVIEWMAP_MAX_RATIO / ol.OVERVIEWMAP_MIN_RATIO) / Math.LN2; - var ratio = 1 / (Math.pow(2, steps / 2) * ol.OVERVIEWMAP_MIN_RATIO); - ol.extent.scaleFromCenter(extent, ratio); + _ol_.OVERVIEWMAP_MAX_RATIO / _ol_.OVERVIEWMAP_MIN_RATIO) / Math.LN2; + var ratio = 1 / (Math.pow(2, steps / 2) * _ol_.OVERVIEWMAP_MIN_RATIO); + _ol_extent_.scaleFromCenter(extent, ratio); ovview.fit(extent); }; @@ -382,7 +383,7 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() { * resolution. * @private */ -ol.control.OverviewMap.prototype.recenter_ = function() { +_ol_control_OverviewMap_.prototype.recenter_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -398,7 +399,7 @@ ol.control.OverviewMap.prototype.recenter_ = function() { * Update the box using the main map extent * @private */ -ol.control.OverviewMap.prototype.updateBox_ = function() { +_ol_control_OverviewMap_.prototype.updateBox_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -418,8 +419,8 @@ ol.control.OverviewMap.prototype.updateBox_ = function() { var box = this.boxOverlay_.getElement(); var extent = view.calculateExtent(mapSize); var ovresolution = ovview.getResolution(); - var bottomLeft = ol.extent.getBottomLeft(extent); - var topRight = ol.extent.getTopRight(extent); + var bottomLeft = _ol_extent_.getBottomLeft(extent); + var topRight = _ol_extent_.getTopRight(extent); // set position using bottom left coordinates var rotateBottomLeft = this.calculateCoordinateRotate_(rotation, bottomLeft); @@ -439,7 +440,7 @@ ol.control.OverviewMap.prototype.updateBox_ = function() { * @return {ol.Coordinate|undefined} Coordinate for rotation and center anchor. * @private */ -ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function( +_ol_control_OverviewMap_.prototype.calculateCoordinateRotate_ = function( rotation, coordinate) { var coordinateRotate; @@ -453,8 +454,8 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function( coordinate[0] - currentCenter[0], coordinate[1] - currentCenter[1] ]; - ol.coordinate.rotate(coordinateRotate, rotation); - ol.coordinate.add(coordinateRotate, currentCenter); + _ol_coordinate_.rotate(coordinateRotate, rotation); + _ol_coordinate_.add(coordinateRotate, currentCenter); } return coordinateRotate; }; @@ -464,7 +465,7 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function( * @param {Event} event The event to handle * @private */ -ol.control.OverviewMap.prototype.handleClick_ = function(event) { +_ol_control_OverviewMap_.prototype.handleClick_ = function(event) { event.preventDefault(); this.handleToggle_(); }; @@ -473,12 +474,12 @@ ol.control.OverviewMap.prototype.handleClick_ = function(event) { /** * @private */ -ol.control.OverviewMap.prototype.handleToggle_ = function() { +_ol_control_OverviewMap_.prototype.handleToggle_ = function() { this.element.classList.toggle('ol-collapsed'); if (this.collapsed_) { - ol.dom.replaceNode(this.collapseLabel_, this.label_); + _ol_dom_.replaceNode(this.collapseLabel_, this.label_); } else { - ol.dom.replaceNode(this.label_, this.collapseLabel_); + _ol_dom_.replaceNode(this.label_, this.collapseLabel_); } this.collapsed_ = !this.collapsed_; @@ -488,7 +489,7 @@ ol.control.OverviewMap.prototype.handleToggle_ = function() { if (!this.collapsed_ && !ovmap.isRendered()) { ovmap.updateSize(); this.resetExtent_(); - ol.events.listenOnce(ovmap, ol.MapEventType.POSTRENDER, + _ol_events_.listenOnce(ovmap, _ol_MapEventType_.POSTRENDER, function(event) { this.updateBox_(); }, @@ -502,7 +503,7 @@ ol.control.OverviewMap.prototype.handleToggle_ = function() { * @return {boolean} True if the widget is collapsible. * @api */ -ol.control.OverviewMap.prototype.getCollapsible = function() { +_ol_control_OverviewMap_.prototype.getCollapsible = function() { return this.collapsible_; }; @@ -512,7 +513,7 @@ ol.control.OverviewMap.prototype.getCollapsible = function() { * @param {boolean} collapsible True if the widget is collapsible. * @api */ -ol.control.OverviewMap.prototype.setCollapsible = function(collapsible) { +_ol_control_OverviewMap_.prototype.setCollapsible = function(collapsible) { if (this.collapsible_ === collapsible) { return; } @@ -531,7 +532,7 @@ ol.control.OverviewMap.prototype.setCollapsible = function(collapsible) { * @param {boolean} collapsed True if the widget is collapsed. * @api */ -ol.control.OverviewMap.prototype.setCollapsed = function(collapsed) { +_ol_control_OverviewMap_.prototype.setCollapsed = function(collapsed) { if (!this.collapsible_ || this.collapsed_ === collapsed) { return; } @@ -544,7 +545,7 @@ ol.control.OverviewMap.prototype.setCollapsed = function(collapsed) { * @return {boolean} The overview map is collapsed. * @api */ -ol.control.OverviewMap.prototype.getCollapsed = function() { +_ol_control_OverviewMap_.prototype.getCollapsed = function() { return this.collapsed_; }; @@ -554,6 +555,7 @@ ol.control.OverviewMap.prototype.getCollapsed = function() { * @return {ol.PluggableMap} Overview map. * @api */ -ol.control.OverviewMap.prototype.getOverviewMap = function() { +_ol_control_OverviewMap_.prototype.getOverviewMap = function() { return this.ovmap_; }; +export default _ol_control_OverviewMap_; diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 7f28097aa0..ce66901566 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -1,12 +1,12 @@ -goog.provide('ol.control.Rotate'); - -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol'); -goog.require('ol.control.Control'); -goog.require('ol.css'); -goog.require('ol.easing'); - +/** + * @module ol/control/Rotate + */ +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_ from '../index.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; +import _ol_easing_ from '../easing.js'; /** * @classdesc @@ -19,7 +19,7 @@ goog.require('ol.easing'); * @param {olx.control.RotateOptions=} opt_options Rotate options. * @api */ -ol.control.Rotate = function(opt_options) { +var _ol_control_Rotate_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -50,20 +50,20 @@ ol.control.Rotate = function(opt_options) { button.title = tipLabel; button.appendChild(this.label_); - ol.events.listen(button, ol.events.EventType.CLICK, - ol.control.Rotate.prototype.handleClick_, this); + _ol_events_.listen(button, _ol_events_EventType_.CLICK, + _ol_control_Rotate_.prototype.handleClick_, this); - var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + - ol.css.CLASS_CONTROL; + var cssClasses = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + + _ol_css_.CLASS_CONTROL; var element = document.createElement('div'); element.className = cssClasses; element.appendChild(button); - var render = options.render ? options.render : ol.control.Rotate.render; + var render = options.render ? options.render : _ol_control_Rotate_.render; this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, render: render, target: options.target @@ -88,18 +88,19 @@ ol.control.Rotate = function(opt_options) { this.rotation_ = undefined; if (this.autoHide_) { - this.element.classList.add(ol.css.CLASS_HIDDEN); + this.element.classList.add(_ol_css_.CLASS_HIDDEN); } }; -ol.inherits(ol.control.Rotate, ol.control.Control); + +_ol_.inherits(_ol_control_Rotate_, _ol_control_Control_); /** * @param {Event} event The event to handle * @private */ -ol.control.Rotate.prototype.handleClick_ = function(event) { +_ol_control_Rotate_.prototype.handleClick_ = function(event) { event.preventDefault(); if (this.callResetNorth_ !== undefined) { this.callResetNorth_(); @@ -112,7 +113,7 @@ ol.control.Rotate.prototype.handleClick_ = function(event) { /** * @private */ -ol.control.Rotate.prototype.resetNorth_ = function() { +_ol_control_Rotate_.prototype.resetNorth_ = function() { var map = this.getMap(); var view = map.getView(); if (!view) { @@ -125,7 +126,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() { view.animate({ rotation: 0, duration: this.duration_, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); } else { view.setRotation(0); @@ -140,7 +141,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() { * @this {ol.control.Rotate} * @api */ -ol.control.Rotate.render = function(mapEvent) { +_ol_control_Rotate_.render = function(mapEvent) { var frameState = mapEvent.frameState; if (!frameState) { return; @@ -149,11 +150,11 @@ ol.control.Rotate.render = function(mapEvent) { if (rotation != this.rotation_) { var transform = 'rotate(' + rotation + 'rad)'; if (this.autoHide_) { - var contains = this.element.classList.contains(ol.css.CLASS_HIDDEN); + var contains = this.element.classList.contains(_ol_css_.CLASS_HIDDEN); if (!contains && rotation === 0) { - this.element.classList.add(ol.css.CLASS_HIDDEN); + this.element.classList.add(_ol_css_.CLASS_HIDDEN); } else if (contains && rotation !== 0) { - this.element.classList.remove(ol.css.CLASS_HIDDEN); + this.element.classList.remove(_ol_css_.CLASS_HIDDEN); } } this.label_.style.msTransform = transform; @@ -162,3 +163,4 @@ ol.control.Rotate.render = function(mapEvent) { } this.rotation_ = rotation; }; +export default _ol_control_Rotate_; diff --git a/src/ol/control/ScaleLine.js b/src/ol/control/ScaleLine.js index 6009641225..21dd4f77a6 100644 --- a/src/ol/control/ScaleLine.js +++ b/src/ol/control/ScaleLine.js @@ -1,15 +1,15 @@ -goog.provide('ol.control.ScaleLine'); - -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.asserts'); -goog.require('ol.control.Control'); -goog.require('ol.control.ScaleLineUnits'); -goog.require('ol.css'); -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.proj.Units'); - +/** + * @module ol/control/ScaleLine + */ +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_control_ScaleLineUnits_ from '../control/ScaleLineUnits.js'; +import _ol_css_ from '../css.js'; +import _ol_events_ from '../events.js'; +import _ol_proj_ from '../proj.js'; +import _ol_proj_Units_ from '../proj/Units.js'; /** * @classdesc @@ -26,7 +26,7 @@ goog.require('ol.proj.Units'); * @param {olx.control.ScaleLineOptions=} opt_options Scale line options. * @api */ -ol.control.ScaleLine = function(opt_options) { +var _ol_control_ScaleLine_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -44,7 +44,7 @@ ol.control.ScaleLine = function(opt_options) { * @type {Element} */ this.element_ = document.createElement('DIV'); - this.element_.className = className + ' ' + ol.css.CLASS_UNSELECTABLE; + this.element_.className = className + ' ' + _ol_css_.CLASS_UNSELECTABLE; this.element_.appendChild(this.innerElement_); /** @@ -77,30 +77,31 @@ ol.control.ScaleLine = function(opt_options) { */ this.renderedHTML_ = ''; - var render = options.render ? options.render : ol.control.ScaleLine.render; + var render = options.render ? options.render : _ol_control_ScaleLine_.render; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: this.element_, render: render, target: options.target }); - ol.events.listen( - this, ol.Object.getChangeEventType(ol.control.ScaleLine.Property_.UNITS), + _ol_events_.listen( + this, _ol_Object_.getChangeEventType(_ol_control_ScaleLine_.Property_.UNITS), this.handleUnitsChanged_, this); this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) || - ol.control.ScaleLineUnits.METRIC); + _ol_control_ScaleLineUnits_.METRIC); }; -ol.inherits(ol.control.ScaleLine, ol.control.Control); + +_ol_.inherits(_ol_control_ScaleLine_, _ol_control_Control_); /** * @const * @type {Array.} */ -ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5]; +_ol_control_ScaleLine_.LEADING_DIGITS = [1, 2, 5]; /** @@ -110,9 +111,10 @@ ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5]; * @observable * @api */ -ol.control.ScaleLine.prototype.getUnits = function() { - return /** @type {ol.control.ScaleLineUnits|undefined} */ ( - this.get(ol.control.ScaleLine.Property_.UNITS)); +_ol_control_ScaleLine_.prototype.getUnits = function() { + return ( + /** @type {ol.control.ScaleLineUnits|undefined} */ this.get(_ol_control_ScaleLine_.Property_.UNITS) + ); }; @@ -122,7 +124,7 @@ ol.control.ScaleLine.prototype.getUnits = function() { * @this {ol.control.ScaleLine} * @api */ -ol.control.ScaleLine.render = function(mapEvent) { +_ol_control_ScaleLine_.render = function(mapEvent) { var frameState = mapEvent.frameState; if (!frameState) { this.viewState_ = null; @@ -136,7 +138,7 @@ ol.control.ScaleLine.render = function(mapEvent) { /** * @private */ -ol.control.ScaleLine.prototype.handleUnitsChanged_ = function() { +_ol_control_ScaleLine_.prototype.handleUnitsChanged_ = function() { this.updateElement_(); }; @@ -147,15 +149,15 @@ ol.control.ScaleLine.prototype.handleUnitsChanged_ = function() { * @observable * @api */ -ol.control.ScaleLine.prototype.setUnits = function(units) { - this.set(ol.control.ScaleLine.Property_.UNITS, units); +_ol_control_ScaleLine_.prototype.setUnits = function(units) { + this.set(_ol_control_ScaleLine_.Property_.UNITS, units); }; /** * @private */ -ol.control.ScaleLine.prototype.updateElement_ = function() { +_ol_control_ScaleLine_.prototype.updateElement_ = function() { var viewState = this.viewState_; if (!viewState) { @@ -169,20 +171,20 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { var center = viewState.center; var projection = viewState.projection; var units = this.getUnits(); - var pointResolutionUnits = units == ol.control.ScaleLineUnits.DEGREES ? - ol.proj.Units.DEGREES : - ol.proj.Units.METERS; + var pointResolutionUnits = units == _ol_control_ScaleLineUnits_.DEGREES ? + _ol_proj_Units_.DEGREES : + _ol_proj_Units_.METERS; var pointResolution = - ol.proj.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits); - if (units != ol.control.ScaleLineUnits.DEGREES) { + _ol_proj_.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits); + if (units != _ol_control_ScaleLineUnits_.DEGREES) { pointResolution *= projection.getMetersPerUnit(); } var nominalCount = this.minWidth_ * pointResolution; var suffix = ''; - if (units == ol.control.ScaleLineUnits.DEGREES) { - var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES]; - if (projection.getUnits() == ol.proj.Units.DEGREES) { + if (units == _ol_control_ScaleLineUnits_.DEGREES) { + var metersPerDegree = _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES]; + if (projection.getUnits() == _ol_proj_Units_.DEGREES) { nominalCount *= metersPerDegree; } else { pointResolution /= metersPerDegree; @@ -196,7 +198,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { } else { suffix = '\u00b0'; // degrees } - } else if (units == ol.control.ScaleLineUnits.IMPERIAL) { + } else if (units == _ol_control_ScaleLineUnits_.IMPERIAL) { if (nominalCount < 0.9144) { suffix = 'in'; pointResolution /= 0.0254; @@ -207,10 +209,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { suffix = 'mi'; pointResolution /= 1609.344; } - } else if (units == ol.control.ScaleLineUnits.NAUTICAL) { + } else if (units == _ol_control_ScaleLineUnits_.NAUTICAL) { pointResolution /= 1852; suffix = 'nm'; - } else if (units == ol.control.ScaleLineUnits.METRIC) { + } else if (units == _ol_control_ScaleLineUnits_.METRIC) { if (nominalCount < 0.001) { suffix = 'μm'; pointResolution *= 1000000; @@ -223,7 +225,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { suffix = 'km'; pointResolution /= 1000; } - } else if (units == ol.control.ScaleLineUnits.US) { + } else if (units == _ol_control_ScaleLineUnits_.US) { if (nominalCount < 0.9144) { suffix = 'in'; pointResolution *= 39.37; @@ -235,14 +237,14 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { pointResolution /= 1609.3472; } } else { - ol.asserts.assert(false, 33); // Invalid units + _ol_asserts_.assert(false, 33); // Invalid units } var i = 3 * Math.floor( Math.log(this.minWidth_ * pointResolution) / Math.log(10)); var count, width; while (true) { - count = ol.control.ScaleLine.LEADING_DIGITS[((i % 3) + 3) % 3] * + count = _ol_control_ScaleLine_.LEADING_DIGITS[((i % 3) + 3) % 3] * Math.pow(10, Math.floor(i / 3)); width = Math.round(count / pointResolution); if (isNaN(width)) { @@ -278,6 +280,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { * @enum {string} * @private */ -ol.control.ScaleLine.Property_ = { +_ol_control_ScaleLine_.Property_ = { UNITS: 'units' }; +export default _ol_control_ScaleLine_; diff --git a/src/ol/control/ScaleLineUnits.js b/src/ol/control/ScaleLineUnits.js index 308c45d6e7..2722a01cbb 100644 --- a/src/ol/control/ScaleLineUnits.js +++ b/src/ol/control/ScaleLineUnits.js @@ -1,14 +1,17 @@ -goog.provide('ol.control.ScaleLineUnits'); - +/** + * @module ol/control/ScaleLineUnits + */ /** * Units for the scale line. Supported values are `'degrees'`, `'imperial'`, * `'nautical'`, `'metric'`, `'us'`. * @enum {string} */ -ol.control.ScaleLineUnits = { +var _ol_control_ScaleLineUnits_ = { DEGREES: 'degrees', IMPERIAL: 'imperial', NAUTICAL: 'nautical', METRIC: 'metric', US: 'us' }; + +export default _ol_control_ScaleLineUnits_; diff --git a/src/ol/control/Zoom.js b/src/ol/control/Zoom.js index 4b06e6e0c5..6b0e48093c 100644 --- a/src/ol/control/Zoom.js +++ b/src/ol/control/Zoom.js @@ -1,12 +1,12 @@ -goog.provide('ol.control.Zoom'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.control.Control'); -goog.require('ol.css'); -goog.require('ol.easing'); - +/** + * @module ol/control/Zoom + */ +import _ol_ from '../index.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; +import _ol_easing_ from '../easing.js'; /** * @classdesc @@ -19,7 +19,7 @@ goog.require('ol.easing'); * @param {olx.control.ZoomOptions=} opt_options Zoom options. * @api */ -ol.control.Zoom = function(opt_options) { +var _ol_control_Zoom_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -43,8 +43,8 @@ ol.control.Zoom = function(opt_options) { typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel ); - ol.events.listen(inElement, ol.events.EventType.CLICK, - ol.control.Zoom.prototype.handleClick_.bind(this, delta)); + _ol_events_.listen(inElement, _ol_events_EventType_.CLICK, + _ol_control_Zoom_.prototype.handleClick_.bind(this, delta)); var outElement = document.createElement('button'); outElement.className = className + '-out'; @@ -54,17 +54,17 @@ ol.control.Zoom = function(opt_options) { typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel ); - ol.events.listen(outElement, ol.events.EventType.CLICK, - ol.control.Zoom.prototype.handleClick_.bind(this, -delta)); + _ol_events_.listen(outElement, _ol_events_EventType_.CLICK, + _ol_control_Zoom_.prototype.handleClick_.bind(this, -delta)); - var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + - ol.css.CLASS_CONTROL; + var cssClasses = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + + _ol_css_.CLASS_CONTROL; var element = document.createElement('div'); element.className = cssClasses; element.appendChild(inElement); element.appendChild(outElement); - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, target: options.target }); @@ -76,7 +76,8 @@ ol.control.Zoom = function(opt_options) { this.duration_ = options.duration !== undefined ? options.duration : 250; }; -ol.inherits(ol.control.Zoom, ol.control.Control); + +_ol_.inherits(_ol_control_Zoom_, _ol_control_Control_); /** @@ -84,7 +85,7 @@ ol.inherits(ol.control.Zoom, ol.control.Control); * @param {Event} event The event to handle * @private */ -ol.control.Zoom.prototype.handleClick_ = function(delta, event) { +_ol_control_Zoom_.prototype.handleClick_ = function(delta, event) { event.preventDefault(); this.zoomByDelta_(delta); }; @@ -94,7 +95,7 @@ ol.control.Zoom.prototype.handleClick_ = function(delta, event) { * @param {number} delta Zoom delta. * @private */ -ol.control.Zoom.prototype.zoomByDelta_ = function(delta) { +_ol_control_Zoom_.prototype.zoomByDelta_ = function(delta) { var map = this.getMap(); var view = map.getView(); if (!view) { @@ -112,10 +113,11 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta) { view.animate({ resolution: newResolution, duration: this.duration_, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); } else { view.setResolution(newResolution); } } }; +export default _ol_control_Zoom_; diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index a206561f9c..b68377cb8f 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -1,19 +1,19 @@ +/** + * @module ol/control/ZoomSlider + */ // FIXME should possibly show tooltip when dragging? -goog.provide('ol.control.ZoomSlider'); - -goog.require('ol'); -goog.require('ol.ViewHint'); -goog.require('ol.control.Control'); -goog.require('ol.css'); -goog.require('ol.easing'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.math'); -goog.require('ol.pointer.EventType'); -goog.require('ol.pointer.PointerEventHandler'); - +import _ol_ from '../index.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; +import _ol_easing_ from '../easing.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_math_ from '../math.js'; +import _ol_pointer_EventType_ from '../pointer/EventType.js'; +import _ol_pointer_PointerEventHandler_ from '../pointer/PointerEventHandler.js'; /** * @classdesc @@ -28,7 +28,7 @@ goog.require('ol.pointer.PointerEventHandler'); * @param {olx.control.ZoomSliderOptions=} opt_options Zoom slider options. * @api */ -ol.control.ZoomSlider = function(opt_options) { +var _ol_control_ZoomSlider_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -47,7 +47,7 @@ ol.control.ZoomSlider = function(opt_options) { * @type {ol.control.ZoomSlider.Direction_} * @private */ - this.direction_ = ol.control.ZoomSlider.Direction_.VERTICAL; + this.direction_ = _ol_control_ZoomSlider_.Direction_.VERTICAL; /** * @type {boolean} @@ -103,44 +103,45 @@ ol.control.ZoomSlider = function(opt_options) { var className = options.className !== undefined ? options.className : 'ol-zoomslider'; var thumbElement = document.createElement('button'); thumbElement.setAttribute('type', 'button'); - thumbElement.className = className + '-thumb ' + ol.css.CLASS_UNSELECTABLE; + thumbElement.className = className + '-thumb ' + _ol_css_.CLASS_UNSELECTABLE; var containerElement = document.createElement('div'); - containerElement.className = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + ol.css.CLASS_CONTROL; + containerElement.className = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + _ol_css_.CLASS_CONTROL; containerElement.appendChild(thumbElement); /** * @type {ol.pointer.PointerEventHandler} * @private */ - this.dragger_ = new ol.pointer.PointerEventHandler(containerElement); + this.dragger_ = new _ol_pointer_PointerEventHandler_(containerElement); - ol.events.listen(this.dragger_, ol.pointer.EventType.POINTERDOWN, + _ol_events_.listen(this.dragger_, _ol_pointer_EventType_.POINTERDOWN, this.handleDraggerStart_, this); - ol.events.listen(this.dragger_, ol.pointer.EventType.POINTERMOVE, + _ol_events_.listen(this.dragger_, _ol_pointer_EventType_.POINTERMOVE, this.handleDraggerDrag_, this); - ol.events.listen(this.dragger_, ol.pointer.EventType.POINTERUP, + _ol_events_.listen(this.dragger_, _ol_pointer_EventType_.POINTERUP, this.handleDraggerEnd_, this); - ol.events.listen(containerElement, ol.events.EventType.CLICK, + _ol_events_.listen(containerElement, _ol_events_EventType_.CLICK, this.handleContainerClick_, this); - ol.events.listen(thumbElement, ol.events.EventType.CLICK, - ol.events.Event.stopPropagation); + _ol_events_.listen(thumbElement, _ol_events_EventType_.CLICK, + _ol_events_Event_.stopPropagation); - var render = options.render ? options.render : ol.control.ZoomSlider.render; + var render = options.render ? options.render : _ol_control_ZoomSlider_.render; - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: containerElement, render: render }); }; -ol.inherits(ol.control.ZoomSlider, ol.control.Control); + +_ol_.inherits(_ol_control_ZoomSlider_, _ol_control_Control_); /** * @inheritDoc */ -ol.control.ZoomSlider.prototype.disposeInternal = function() { +_ol_control_ZoomSlider_.prototype.disposeInternal = function() { this.dragger_.dispose(); - ol.control.Control.prototype.disposeInternal.call(this); + _ol_control_Control_.prototype.disposeInternal.call(this); }; @@ -150,7 +151,7 @@ ol.control.ZoomSlider.prototype.disposeInternal = function() { * @enum {number} * @private */ -ol.control.ZoomSlider.Direction_ = { +_ol_control_ZoomSlider_.Direction_ = { VERTICAL: 0, HORIZONTAL: 1 }; @@ -159,8 +160,8 @@ ol.control.ZoomSlider.Direction_ = { /** * @inheritDoc */ -ol.control.ZoomSlider.prototype.setMap = function(map) { - ol.control.Control.prototype.setMap.call(this, map); +_ol_control_ZoomSlider_.prototype.setMap = function(map) { + _ol_control_Control_.prototype.setMap.call(this, map); if (map) { map.render(); } @@ -174,7 +175,7 @@ ol.control.ZoomSlider.prototype.setMap = function(map) { * * @private */ -ol.control.ZoomSlider.prototype.initSlider_ = function() { +_ol_control_ZoomSlider_.prototype.initSlider_ = function() { var container = this.element; var containerSize = { width: container.offsetWidth, height: container.offsetHeight @@ -191,10 +192,10 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() { this.thumbSize_ = [thumbWidth, thumbHeight]; if (containerSize.width > containerSize.height) { - this.direction_ = ol.control.ZoomSlider.Direction_.HORIZONTAL; + this.direction_ = _ol_control_ZoomSlider_.Direction_.HORIZONTAL; this.widthLimit_ = containerSize.width - thumbWidth; } else { - this.direction_ = ol.control.ZoomSlider.Direction_.VERTICAL; + this.direction_ = _ol_control_ZoomSlider_.Direction_.VERTICAL; this.heightLimit_ = containerSize.height - thumbHeight; } this.sliderInitialized_ = true; @@ -207,7 +208,7 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() { * @this {ol.control.ZoomSlider} * @api */ -ol.control.ZoomSlider.render = function(mapEvent) { +_ol_control_ZoomSlider_.render = function(mapEvent) { if (!mapEvent.frameState) { return; } @@ -226,7 +227,7 @@ ol.control.ZoomSlider.render = function(mapEvent) { * @param {Event} event The browser event to handle. * @private */ -ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) { +_ol_control_ZoomSlider_.prototype.handleContainerClick_ = function(event) { var view = this.getMap().getView(); var relativePosition = this.getRelativePosition_( @@ -238,7 +239,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) { view.animate({ resolution: view.constrainResolution(resolution), duration: this.duration_, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); }; @@ -248,9 +249,9 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) { * @param {ol.pointer.PointerEvent} event The drag event. * @private */ -ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) { +_ol_control_ZoomSlider_.prototype.handleDraggerStart_ = function(event) { if (!this.dragging_ && event.originalEvent.target === this.element.firstElementChild) { - this.getMap().getView().setHint(ol.ViewHint.INTERACTING, 1); + this.getMap().getView().setHint(_ol_ViewHint_.INTERACTING, 1); this.previousX_ = event.clientX; this.previousY_ = event.clientY; this.dragging_ = true; @@ -264,7 +265,7 @@ ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) { * @param {ol.pointer.PointerEvent|Event} event The drag event. * @private */ -ol.control.ZoomSlider.prototype.handleDraggerDrag_ = function(event) { +_ol_control_ZoomSlider_.prototype.handleDraggerDrag_ = function(event) { if (this.dragging_) { var element = this.element.firstElementChild; var deltaX = event.clientX - this.previousX_ + parseInt(element.style.left, 10); @@ -284,15 +285,15 @@ ol.control.ZoomSlider.prototype.handleDraggerDrag_ = function(event) { * @param {ol.pointer.PointerEvent|Event} event The drag event. * @private */ -ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) { +_ol_control_ZoomSlider_.prototype.handleDraggerEnd_ = function(event) { if (this.dragging_) { var view = this.getMap().getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); view.animate({ resolution: view.constrainResolution(this.currentResolution_), duration: this.duration_, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); this.dragging_ = false; @@ -308,11 +309,11 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) { * @param {number} res The res. * @private */ -ol.control.ZoomSlider.prototype.setThumbPosition_ = function(res) { +_ol_control_ZoomSlider_.prototype.setThumbPosition_ = function(res) { var position = this.getPositionForResolution_(res); var thumb = this.element.firstElementChild; - if (this.direction_ == ol.control.ZoomSlider.Direction_.HORIZONTAL) { + if (this.direction_ == _ol_control_ZoomSlider_.Direction_.HORIZONTAL) { thumb.style.left = this.widthLimit_ * position + 'px'; } else { thumb.style.top = this.heightLimit_ * position + 'px'; @@ -330,14 +331,14 @@ ol.control.ZoomSlider.prototype.setThumbPosition_ = function(res) { * @return {number} The relative position of the thumb. * @private */ -ol.control.ZoomSlider.prototype.getRelativePosition_ = function(x, y) { +_ol_control_ZoomSlider_.prototype.getRelativePosition_ = function(x, y) { var amount; - if (this.direction_ === ol.control.ZoomSlider.Direction_.HORIZONTAL) { + if (this.direction_ === _ol_control_ZoomSlider_.Direction_.HORIZONTAL) { amount = x / this.widthLimit_; } else { amount = y / this.heightLimit_; } - return ol.math.clamp(amount, 0, 1); + return _ol_math_.clamp(amount, 0, 1); }; @@ -349,7 +350,7 @@ ol.control.ZoomSlider.prototype.getRelativePosition_ = function(x, y) { * @return {number} The corresponding resolution. * @private */ -ol.control.ZoomSlider.prototype.getResolutionForPosition_ = function(position) { +_ol_control_ZoomSlider_.prototype.getResolutionForPosition_ = function(position) { var fn = this.getMap().getView().getResolutionForValueFunction(); return fn(1 - position); }; @@ -364,7 +365,8 @@ ol.control.ZoomSlider.prototype.getResolutionForPosition_ = function(position) { * @return {number} The relative position value (between 0 and 1). * @private */ -ol.control.ZoomSlider.prototype.getPositionForResolution_ = function(res) { +_ol_control_ZoomSlider_.prototype.getPositionForResolution_ = function(res) { var fn = this.getMap().getView().getValueForResolutionFunction(); return 1 - fn(res); }; +export default _ol_control_ZoomSlider_; diff --git a/src/ol/control/ZoomToExtent.js b/src/ol/control/ZoomToExtent.js index 811c6b28d6..172e9103eb 100644 --- a/src/ol/control/ZoomToExtent.js +++ b/src/ol/control/ZoomToExtent.js @@ -1,11 +1,11 @@ -goog.provide('ol.control.ZoomToExtent'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.control.Control'); -goog.require('ol.css'); - +/** + * @module ol/control/ZoomToExtent + */ +import _ol_ from '../index.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_control_Control_ from '../control/Control.js'; +import _ol_css_ from '../css.js'; /** * @classdesc @@ -17,7 +17,7 @@ goog.require('ol.css'); * @param {olx.control.ZoomToExtentOptions=} opt_options Options. * @api */ -ol.control.ZoomToExtent = function(opt_options) { +var _ol_control_ZoomToExtent_ = function(opt_options) { var options = opt_options ? opt_options : {}; /** @@ -39,28 +39,29 @@ ol.control.ZoomToExtent = function(opt_options) { typeof label === 'string' ? document.createTextNode(label) : label ); - ol.events.listen(button, ol.events.EventType.CLICK, + _ol_events_.listen(button, _ol_events_EventType_.CLICK, this.handleClick_, this); - var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' + - ol.css.CLASS_CONTROL; + var cssClasses = className + ' ' + _ol_css_.CLASS_UNSELECTABLE + ' ' + + _ol_css_.CLASS_CONTROL; var element = document.createElement('div'); element.className = cssClasses; element.appendChild(button); - ol.control.Control.call(this, { + _ol_control_Control_.call(this, { element: element, target: options.target }); }; -ol.inherits(ol.control.ZoomToExtent, ol.control.Control); + +_ol_.inherits(_ol_control_ZoomToExtent_, _ol_control_Control_); /** * @param {Event} event The event to handle * @private */ -ol.control.ZoomToExtent.prototype.handleClick_ = function(event) { +_ol_control_ZoomToExtent_.prototype.handleClick_ = function(event) { event.preventDefault(); this.handleZoomToExtent(); }; @@ -69,9 +70,10 @@ ol.control.ZoomToExtent.prototype.handleClick_ = function(event) { /** * @protected */ -ol.control.ZoomToExtent.prototype.handleZoomToExtent = function() { +_ol_control_ZoomToExtent_.prototype.handleZoomToExtent = function() { var map = this.getMap(); var view = map.getView(); var extent = !this.extent ? view.getProjection().getExtent() : this.extent; view.fit(extent); }; +export default _ol_control_ZoomToExtent_; diff --git a/src/ol/coordinate.js b/src/ol/coordinate.js index 42c324fd09..bf72f45883 100644 --- a/src/ol/coordinate.js +++ b/src/ol/coordinate.js @@ -1,7 +1,9 @@ -goog.provide('ol.coordinate'); - -goog.require('ol.math'); -goog.require('ol.string'); +/** + * @module ol/coordinate + */ +import _ol_math_ from './math.js'; +import _ol_string_ from './string.js'; +var _ol_coordinate_ = {}; /** @@ -19,7 +21,7 @@ goog.require('ol.string'); * @return {ol.Coordinate} The input coordinate adjusted by the given delta. * @api */ -ol.coordinate.add = function(coordinate, delta) { +_ol_coordinate_.add = function(coordinate, delta) { coordinate[0] += delta[0]; coordinate[1] += delta[1]; return coordinate; @@ -33,7 +35,7 @@ ol.coordinate.add = function(coordinate, delta) { * @param {ol.geom.Circle} circle The circle. * @return {ol.Coordinate} Closest point on the circumference */ -ol.coordinate.closestOnCircle = function(coordinate, circle) { +_ol_coordinate_.closestOnCircle = function(coordinate, circle) { var r = circle.getRadius(); var center = circle.getCenter(); var x0 = center[0]; @@ -68,7 +70,7 @@ ol.coordinate.closestOnCircle = function(coordinate, circle) { * @return {ol.Coordinate} The foot of the perpendicular of the coordinate to * the segment. */ -ol.coordinate.closestOnSegment = function(coordinate, segment) { +_ol_coordinate_.closestOnSegment = function(coordinate, segment) { var x0 = coordinate[0]; var y0 = coordinate[1]; var start = segment[0]; @@ -119,15 +121,16 @@ ol.coordinate.closestOnSegment = function(coordinate, segment) { * @return {ol.CoordinateFormatType} Coordinate format. * @api */ -ol.coordinate.createStringXY = function(opt_fractionDigits) { +_ol_coordinate_.createStringXY = function(opt_fractionDigits) { return ( /** * @param {ol.Coordinate|undefined} coordinate Coordinate. * @return {string} String XY. */ function(coordinate) { - return ol.coordinate.toStringXY(coordinate, opt_fractionDigits); - }); + return _ol_coordinate_.toStringXY(coordinate, opt_fractionDigits); + } + ); }; @@ -138,8 +141,8 @@ ol.coordinate.createStringXY = function(opt_fractionDigits) { * after the decimal point. Default is `0`. * @return {string} String. */ -ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) { - var normalizedDegrees = ol.math.modulo(degrees + 180, 360) - 180; +_ol_coordinate_.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) { + var normalizedDegrees = _ol_math_.modulo(degrees + 180, 360) - 180; var x = Math.abs(3600 * normalizedDegrees); var dflPrecision = opt_fractionDigits || 0; var precision = Math.pow(10, dflPrecision); @@ -159,8 +162,8 @@ ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionD deg += 1; } - return deg + '\u00b0 ' + ol.string.padNumber(min, 2) + '\u2032 ' + - ol.string.padNumber(sec, 2, dflPrecision) + '\u2033' + + return deg + '\u00b0 ' + _ol_string_.padNumber(min, 2) + '\u2032 ' + + _ol_string_.padNumber(sec, 2, dflPrecision) + '\u2033' + (normalizedDegrees == 0 ? '' : ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0)); }; @@ -192,7 +195,7 @@ ol.coordinate.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionD * @return {string} Formatted coordinate. * @api */ -ol.coordinate.format = function(coordinate, template, opt_fractionDigits) { +_ol_coordinate_.format = function(coordinate, template, opt_fractionDigits) { if (coordinate) { return template .replace('{x}', coordinate[0].toFixed(opt_fractionDigits)) @@ -208,7 +211,7 @@ ol.coordinate.format = function(coordinate, template, opt_fractionDigits) { * @param {ol.Coordinate} coordinate2 Second coordinate. * @return {boolean} Whether the passed coordinates are equal. */ -ol.coordinate.equals = function(coordinate1, coordinate2) { +_ol_coordinate_.equals = function(coordinate1, coordinate2) { var equals = true; for (var i = coordinate1.length - 1; i >= 0; --i) { if (coordinate1[i] != coordinate2[i]) { @@ -236,7 +239,7 @@ ol.coordinate.equals = function(coordinate1, coordinate2) { * @return {ol.Coordinate} Coordinate. * @api */ -ol.coordinate.rotate = function(coordinate, angle) { +_ol_coordinate_.rotate = function(coordinate, angle) { var cosAngle = Math.cos(angle); var sinAngle = Math.sin(angle); var x = coordinate[0] * cosAngle - coordinate[1] * sinAngle; @@ -262,7 +265,7 @@ ol.coordinate.rotate = function(coordinate, angle) { * @param {number} scale Scale factor. * @return {ol.Coordinate} Coordinate. */ -ol.coordinate.scale = function(coordinate, scale) { +_ol_coordinate_.scale = function(coordinate, scale) { coordinate[0] *= scale; coordinate[1] *= scale; return coordinate; @@ -277,7 +280,7 @@ ol.coordinate.scale = function(coordinate, scale) { * @param {ol.Coordinate} delta Delta. * @return {ol.Coordinate} Coordinate. */ -ol.coordinate.sub = function(coordinate, delta) { +_ol_coordinate_.sub = function(coordinate, delta) { coordinate[0] -= delta[0]; coordinate[1] -= delta[1]; return coordinate; @@ -289,7 +292,7 @@ ol.coordinate.sub = function(coordinate, delta) { * @param {ol.Coordinate} coord2 Second coordinate. * @return {number} Squared distance between coord1 and coord2. */ -ol.coordinate.squaredDistance = function(coord1, coord2) { +_ol_coordinate_.squaredDistance = function(coord1, coord2) { var dx = coord1[0] - coord2[0]; var dy = coord1[1] - coord2[1]; return dx * dx + dy * dy; @@ -301,8 +304,8 @@ ol.coordinate.squaredDistance = function(coord1, coord2) { * @param {ol.Coordinate} coord2 Second coordinate. * @return {number} Distance between coord1 and coord2. */ -ol.coordinate.distance = function(coord1, coord2) { - return Math.sqrt(ol.coordinate.squaredDistance(coord1, coord2)); +_ol_coordinate_.distance = function(coord1, coord2) { + return Math.sqrt(_ol_coordinate_.squaredDistance(coord1, coord2)); }; @@ -313,9 +316,9 @@ ol.coordinate.distance = function(coord1, coord2) { * @param {Array.} segment Line segment (2 coordinates). * @return {number} Squared distance from the point to the line segment. */ -ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) { - return ol.coordinate.squaredDistance(coordinate, - ol.coordinate.closestOnSegment(coordinate, segment)); +_ol_coordinate_.squaredDistanceToSegment = function(coordinate, segment) { + return _ol_coordinate_.squaredDistance(coordinate, + _ol_coordinate_.closestOnSegment(coordinate, segment)); }; @@ -341,10 +344,10 @@ ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) { * @return {string} Hemisphere, degrees, minutes and seconds. * @api */ -ol.coordinate.toStringHDMS = function(coordinate, opt_fractionDigits) { +_ol_coordinate_.toStringHDMS = function(coordinate, opt_fractionDigits) { if (coordinate) { - return ol.coordinate.degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) + ' ' + - ol.coordinate.degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits); + return _ol_coordinate_.degreesToStringHDMS('NS', coordinate[1], opt_fractionDigits) + ' ' + + _ol_coordinate_.degreesToStringHDMS('EW', coordinate[0], opt_fractionDigits); } else { return ''; } @@ -372,6 +375,7 @@ ol.coordinate.toStringHDMS = function(coordinate, opt_fractionDigits) { * @return {string} XY. * @api */ -ol.coordinate.toStringXY = function(coordinate, opt_fractionDigits) { - return ol.coordinate.format(coordinate, '{x}, {y}', opt_fractionDigits); +_ol_coordinate_.toStringXY = function(coordinate, opt_fractionDigits) { + return _ol_coordinate_.format(coordinate, '{x}, {y}', opt_fractionDigits); }; +export default _ol_coordinate_; diff --git a/src/ol/css.js b/src/ol/css.js index 599bdacc4f..4ecabcded3 100644 --- a/src/ol/css.js +++ b/src/ol/css.js @@ -1,4 +1,7 @@ -goog.provide('ol.css'); +/** + * @module ol/css + */ +var _ol_css_ = {}; /** @@ -7,7 +10,7 @@ goog.provide('ol.css'); * @const * @type {string} */ -ol.css.CLASS_HIDDEN = 'ol-hidden'; +_ol_css_.CLASS_HIDDEN = 'ol-hidden'; /** @@ -16,7 +19,7 @@ ol.css.CLASS_HIDDEN = 'ol-hidden'; * @const * @type {string} */ -ol.css.CLASS_SELECTABLE = 'ol-selectable'; +_ol_css_.CLASS_SELECTABLE = 'ol-selectable'; /** * The CSS class that we'll give the DOM elements to have them unselectable. @@ -24,7 +27,7 @@ ol.css.CLASS_SELECTABLE = 'ol-selectable'; * @const * @type {string} */ -ol.css.CLASS_UNSELECTABLE = 'ol-unselectable'; +_ol_css_.CLASS_UNSELECTABLE = 'ol-unselectable'; /** @@ -33,7 +36,7 @@ ol.css.CLASS_UNSELECTABLE = 'ol-unselectable'; * @const * @type {string} */ -ol.css.CLASS_UNSUPPORTED = 'ol-unsupported'; +_ol_css_.CLASS_UNSUPPORTED = 'ol-unsupported'; /** @@ -42,7 +45,7 @@ ol.css.CLASS_UNSUPPORTED = 'ol-unsupported'; * @const * @type {string} */ -ol.css.CLASS_CONTROL = 'ol-control'; +_ol_css_.CLASS_CONTROL = 'ol-control'; /** @@ -51,7 +54,7 @@ ol.css.CLASS_CONTROL = 'ol-control'; * @param {string} The CSS font property. * @return {Object.} The font families (or null if the input spec is invalid). */ -ol.css.getFontFamilies = (function() { +_ol_css_.getFontFamilies = (function() { var style; var cache = {}; return function(font) { @@ -70,3 +73,4 @@ ol.css.getFontFamilies = (function() { return cache[font]; }; })(); +export default _ol_css_; diff --git a/src/ol/dom.js b/src/ol/dom.js index 2d2a672bd9..b2bc7ee2dd 100644 --- a/src/ol/dom.js +++ b/src/ol/dom.js @@ -1,4 +1,7 @@ -goog.provide('ol.dom'); +/** + * @module ol/dom + */ +var _ol_dom_ = {}; /** @@ -7,7 +10,7 @@ goog.provide('ol.dom'); * @param {number=} opt_height Canvas height. * @return {CanvasRenderingContext2D} The context. */ -ol.dom.createCanvasContext2D = function(opt_width, opt_height) { +_ol_dom_.createCanvasContext2D = function(opt_width, opt_height) { var canvas = document.createElement('CANVAS'); if (opt_width) { canvas.width = opt_width; @@ -26,7 +29,7 @@ ol.dom.createCanvasContext2D = function(opt_width, opt_height) { * @param {!Element} element Element. * @return {number} The width. */ -ol.dom.outerWidth = function(element) { +_ol_dom_.outerWidth = function(element) { var width = element.offsetWidth; var style = getComputedStyle(element); width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10); @@ -42,7 +45,7 @@ ol.dom.outerWidth = function(element) { * @param {!Element} element Element. * @return {number} The height. */ -ol.dom.outerHeight = function(element) { +_ol_dom_.outerHeight = function(element) { var height = element.offsetHeight; var style = getComputedStyle(element); height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10); @@ -54,7 +57,7 @@ ol.dom.outerHeight = function(element) { * @param {Node} newNode Node to replace old node * @param {Node} oldNode The node to be replaced */ -ol.dom.replaceNode = function(newNode, oldNode) { +_ol_dom_.replaceNode = function(newNode, oldNode) { var parent = oldNode.parentNode; if (parent) { parent.replaceChild(newNode, oldNode); @@ -65,15 +68,16 @@ ol.dom.replaceNode = function(newNode, oldNode) { * @param {Node} node The node to remove. * @returns {Node} The node that was removed or null. */ -ol.dom.removeNode = function(node) { +_ol_dom_.removeNode = function(node) { return node && node.parentNode ? node.parentNode.removeChild(node) : null; }; /** * @param {Node} node The node to remove the children from. */ -ol.dom.removeChildren = function(node) { +_ol_dom_.removeChildren = function(node) { while (node.lastChild) { node.removeChild(node.lastChild); } }; +export default _ol_dom_; diff --git a/src/ol/easing.js b/src/ol/easing.js index 266bbdad38..39a265dc15 100644 --- a/src/ol/easing.js +++ b/src/ol/easing.js @@ -1,4 +1,7 @@ -goog.provide('ol.easing'); +/** + * @module ol/easing + */ +var _ol_easing_ = {}; /** @@ -7,7 +10,7 @@ goog.provide('ol.easing'); * @return {number} Output between 0 and 1. * @api */ -ol.easing.easeIn = function(t) { +_ol_easing_.easeIn = function(t) { return Math.pow(t, 3); }; @@ -18,8 +21,8 @@ ol.easing.easeIn = function(t) { * @return {number} Output between 0 and 1. * @api */ -ol.easing.easeOut = function(t) { - return 1 - ol.easing.easeIn(1 - t); +_ol_easing_.easeOut = function(t) { + return 1 - _ol_easing_.easeIn(1 - t); }; @@ -29,7 +32,7 @@ ol.easing.easeOut = function(t) { * @return {number} Output between 0 and 1. * @api */ -ol.easing.inAndOut = function(t) { +_ol_easing_.inAndOut = function(t) { return 3 * t * t - 2 * t * t * t; }; @@ -40,7 +43,7 @@ ol.easing.inAndOut = function(t) { * @return {number} Output between 0 and 1. * @api */ -ol.easing.linear = function(t) { +_ol_easing_.linear = function(t) { return t; }; @@ -53,10 +56,11 @@ ol.easing.linear = function(t) { * @return {number} Output between 0 and 1. * @api */ -ol.easing.upAndDown = function(t) { +_ol_easing_.upAndDown = function(t) { if (t < 0.5) { - return ol.easing.inAndOut(2 * t); + return _ol_easing_.inAndOut(2 * t); } else { - return 1 - ol.easing.inAndOut(2 * (t - 0.5)); + return 1 - _ol_easing_.inAndOut(2 * (t - 0.5)); } }; +export default _ol_easing_; diff --git a/src/ol/events.js b/src/ol/events.js index fd2f96fb20..50ce11b443 100644 --- a/src/ol/events.js +++ b/src/ol/events.js @@ -1,18 +1,20 @@ -goog.provide('ol.events'); - -goog.require('ol.obj'); +/** + * @module ol/events + */ +import _ol_obj_ from './obj.js'; +var _ol_events_ = {}; /** * @param {ol.EventsKey} listenerObj Listener object. * @return {ol.EventsListenerFunctionType} Bound listener. */ -ol.events.bindListener_ = function(listenerObj) { +_ol_events_.bindListener_ = function(listenerObj) { var boundListener = function(evt) { var listener = listenerObj.listener; var bindTo = listenerObj.bindTo || listenerObj.target; if (listenerObj.callOnce) { - ol.events.unlistenByKey(listenerObj); + _ol_events_.unlistenByKey(listenerObj); } return listener.call(bindTo, evt); }; @@ -33,7 +35,7 @@ ol.events.bindListener_ = function(listenerObj) { * @return {ol.EventsKey|undefined} The matching listener object. * @private */ -ol.events.findListener_ = function(listeners, listener, opt_this, +_ol_events_.findListener_ = function(listeners, listener, opt_this, opt_setDeleteIndex) { var listenerObj; for (var i = 0, ii = listeners.length; i < ii; ++i) { @@ -55,7 +57,7 @@ ol.events.findListener_ = function(listeners, listener, opt_this, * @param {string} type Type. * @return {Array.|undefined} Listeners. */ -ol.events.getListeners = function(target, type) { +_ol_events_.getListeners = function(target, type) { var listenerMap = target.ol_lm; return listenerMap ? listenerMap[type] : undefined; }; @@ -69,7 +71,7 @@ ol.events.getListeners = function(target, type) { * listeners by event type. * @private */ -ol.events.getListenerMap_ = function(target) { +_ol_events_.getListenerMap_ = function(target) { var listenerMap = target.ol_lm; if (!listenerMap) { listenerMap = target.ol_lm = {}; @@ -86,12 +88,12 @@ ol.events.getListenerMap_ = function(target) { * @param {string} type Type. * @private */ -ol.events.removeListeners_ = function(target, type) { - var listeners = ol.events.getListeners(target, type); +_ol_events_.removeListeners_ = function(target, type) { + var listeners = _ol_events_.getListeners(target, type); if (listeners) { for (var i = 0, ii = listeners.length; i < ii; ++i) { target.removeEventListener(type, listeners[i].boundListener); - ol.obj.clear(listeners[i]); + _ol_obj_.clear(listeners[i]); } listeners.length = 0; var listenerMap = target.ol_lm; @@ -120,13 +122,13 @@ ol.events.removeListeners_ = function(target, type) { * @param {boolean=} opt_once If true, add the listener as one-off listener. * @return {ol.EventsKey} Unique key for the listener. */ -ol.events.listen = function(target, type, listener, opt_this, opt_once) { - var listenerMap = ol.events.getListenerMap_(target); +_ol_events_.listen = function(target, type, listener, opt_this, opt_once) { + var listenerMap = _ol_events_.getListenerMap_(target); var listeners = listenerMap[type]; if (!listeners) { listeners = listenerMap[type] = []; } - var listenerObj = ol.events.findListener_(listeners, listener, opt_this, + var listenerObj = _ol_events_.findListener_(listeners, listener, opt_this, false); if (listenerObj) { if (!opt_once) { @@ -141,7 +143,7 @@ ol.events.listen = function(target, type, listener, opt_this, opt_once) { target: target, type: type }); - target.addEventListener(type, ol.events.bindListener_(listenerObj)); + target.addEventListener(type, _ol_events_.bindListener_(listenerObj)); listeners.push(listenerObj); } @@ -169,8 +171,8 @@ ol.events.listen = function(target, type, listener, opt_this, opt_once) { * listener. Default is the `target`. * @return {ol.EventsKey} Key for unlistenByKey. */ -ol.events.listenOnce = function(target, type, listener, opt_this) { - return ol.events.listen(target, type, listener, opt_this, true); +_ol_events_.listenOnce = function(target, type, listener, opt_this) { + return _ol_events_.listen(target, type, listener, opt_this, true); }; @@ -187,13 +189,13 @@ ol.events.listenOnce = function(target, type, listener, opt_this) { * @param {Object=} opt_this Object referenced by the `this` keyword in the * listener. Default is the `target`. */ -ol.events.unlisten = function(target, type, listener, opt_this) { - var listeners = ol.events.getListeners(target, type); +_ol_events_.unlisten = function(target, type, listener, opt_this) { + var listeners = _ol_events_.getListeners(target, type); if (listeners) { - var listenerObj = ol.events.findListener_(listeners, listener, opt_this, + var listenerObj = _ol_events_.findListener_(listeners, listener, opt_this, true); if (listenerObj) { - ol.events.unlistenByKey(listenerObj); + _ol_events_.unlistenByKey(listenerObj); } } }; @@ -208,20 +210,20 @@ ol.events.unlisten = function(target, type, listener, opt_this) { * * @param {ol.EventsKey} key The key. */ -ol.events.unlistenByKey = function(key) { +_ol_events_.unlistenByKey = function(key) { if (key && key.target) { key.target.removeEventListener(key.type, key.boundListener); - var listeners = ol.events.getListeners(key.target, key.type); + var listeners = _ol_events_.getListeners(key.target, key.type); if (listeners) { var i = 'deleteIndex' in key ? key.deleteIndex : listeners.indexOf(key); if (i !== -1) { listeners.splice(i, 1); } if (listeners.length === 0) { - ol.events.removeListeners_(key.target, key.type); + _ol_events_.removeListeners_(key.target, key.type); } } - ol.obj.clear(key); + _ol_obj_.clear(key); } }; @@ -232,9 +234,10 @@ ol.events.unlistenByKey = function(key) { * * @param {ol.EventTargetLike} target Target. */ -ol.events.unlistenAll = function(target) { - var listenerMap = ol.events.getListenerMap_(target); +_ol_events_.unlistenAll = function(target) { + var listenerMap = _ol_events_.getListenerMap_(target); for (var type in listenerMap) { - ol.events.removeListeners_(target, type); + _ol_events_.removeListeners_(target, type); } }; +export default _ol_events_; diff --git a/src/ol/events/Event.js b/src/ol/events/Event.js index c7c7713ba8..54b48c89af 100644 --- a/src/ol/events/Event.js +++ b/src/ol/events/Event.js @@ -1,6 +1,6 @@ -goog.provide('ol.events.Event'); - - +/** + * @module ol/events/Event + */ /** * @classdesc * Stripped down implementation of the W3C DOM Level 2 Event interface. @@ -15,7 +15,7 @@ goog.provide('ol.events.Event'); * @implements {oli.events.Event} * @param {string} type Type. */ -ol.events.Event = function(type) { +var _ol_events_Event_ = function(type) { /** * @type {boolean} @@ -45,7 +45,7 @@ ol.events.Event = function(type) { * @override * @api */ -ol.events.Event.prototype.preventDefault = +_ol_events_Event_.prototype.preventDefault = /** * Stop event propagation. @@ -53,7 +53,7 @@ ol.events.Event.prototype.preventDefault = * @override * @api */ - ol.events.Event.prototype.stopPropagation = function() { + _ol_events_Event_.prototype.stopPropagation = function() { this.propagationStopped = true; }; @@ -61,7 +61,7 @@ ol.events.Event.prototype.preventDefault = /** * @param {Event|ol.events.Event} evt Event */ -ol.events.Event.stopPropagation = function(evt) { +_ol_events_Event_.stopPropagation = function(evt) { evt.stopPropagation(); }; @@ -69,6 +69,7 @@ ol.events.Event.stopPropagation = function(evt) { /** * @param {Event|ol.events.Event} evt Event */ -ol.events.Event.preventDefault = function(evt) { +_ol_events_Event_.preventDefault = function(evt) { evt.preventDefault(); }; +export default _ol_events_Event_; diff --git a/src/ol/events/EventTarget.js b/src/ol/events/EventTarget.js index 5e13f71161..3b5b2cafdc 100644 --- a/src/ol/events/EventTarget.js +++ b/src/ol/events/EventTarget.js @@ -1,10 +1,10 @@ -goog.provide('ol.events.EventTarget'); - -goog.require('ol'); -goog.require('ol.Disposable'); -goog.require('ol.events'); -goog.require('ol.events.Event'); - +/** + * @module ol/events/EventTarget + */ +import _ol_ from '../index.js'; +import _ol_Disposable_ from '../Disposable.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; /** * @classdesc @@ -24,9 +24,9 @@ goog.require('ol.events.Event'); * @constructor * @extends {ol.Disposable} */ -ol.events.EventTarget = function() { +var _ol_events_EventTarget_ = function() { - ol.Disposable.call(this); + _ol_Disposable_.call(this); /** * @private @@ -47,14 +47,15 @@ ol.events.EventTarget = function() { this.listeners_ = {}; }; -ol.inherits(ol.events.EventTarget, ol.Disposable); + +_ol_.inherits(_ol_events_EventTarget_, _ol_Disposable_); /** * @param {string} type Type. * @param {ol.EventsListenerFunctionType} listener Listener. */ -ol.events.EventTarget.prototype.addEventListener = function(type, listener) { +_ol_events_EventTarget_.prototype.addEventListener = function(type, listener) { var listeners = this.listeners_[type]; if (!listeners) { listeners = this.listeners_[type] = []; @@ -72,8 +73,8 @@ ol.events.EventTarget.prototype.addEventListener = function(type, listener) { * @return {boolean|undefined} `false` if anyone called preventDefault on the * event object or if any of the listeners returned false. */ -ol.events.EventTarget.prototype.dispatchEvent = function(event) { - var evt = typeof event === 'string' ? new ol.events.Event(event) : event; +_ol_events_EventTarget_.prototype.dispatchEvent = function(event) { + var evt = typeof event === 'string' ? new _ol_events_Event_(event) : event; var type = evt.type; evt.target = this; var listeners = this.listeners_[type]; @@ -95,7 +96,7 @@ ol.events.EventTarget.prototype.dispatchEvent = function(event) { var pendingRemovals = this.pendingRemovals_[type]; delete this.pendingRemovals_[type]; while (pendingRemovals--) { - this.removeEventListener(type, ol.nullFunction); + this.removeEventListener(type, _ol_.nullFunction); } delete this.dispatching_[type]; } @@ -107,8 +108,8 @@ ol.events.EventTarget.prototype.dispatchEvent = function(event) { /** * @inheritDoc */ -ol.events.EventTarget.prototype.disposeInternal = function() { - ol.events.unlistenAll(this); +_ol_events_EventTarget_.prototype.disposeInternal = function() { + _ol_events_.unlistenAll(this); }; @@ -119,7 +120,7 @@ ol.events.EventTarget.prototype.disposeInternal = function() { * @param {string} type Type. * @return {Array.} Listeners. */ -ol.events.EventTarget.prototype.getListeners = function(type) { +_ol_events_EventTarget_.prototype.getListeners = function(type) { return this.listeners_[type]; }; @@ -129,7 +130,7 @@ ol.events.EventTarget.prototype.getListeners = function(type) { * `true` will be returned if this EventTarget has any listeners. * @return {boolean} Has listeners. */ -ol.events.EventTarget.prototype.hasListener = function(opt_type) { +_ol_events_EventTarget_.prototype.hasListener = function(opt_type) { return opt_type ? opt_type in this.listeners_ : Object.keys(this.listeners_).length > 0; @@ -140,13 +141,13 @@ ol.events.EventTarget.prototype.hasListener = function(opt_type) { * @param {string} type Type. * @param {ol.EventsListenerFunctionType} listener Listener. */ -ol.events.EventTarget.prototype.removeEventListener = function(type, listener) { +_ol_events_EventTarget_.prototype.removeEventListener = function(type, listener) { var listeners = this.listeners_[type]; if (listeners) { var index = listeners.indexOf(listener); if (type in this.pendingRemovals_) { // make listener a no-op, and remove later in #dispatchEvent() - listeners[index] = ol.nullFunction; + listeners[index] = _ol_.nullFunction; ++this.pendingRemovals_[type]; } else { listeners.splice(index, 1); @@ -156,3 +157,4 @@ ol.events.EventTarget.prototype.removeEventListener = function(type, listener) { } } }; +export default _ol_events_EventTarget_; diff --git a/src/ol/events/EventType.js b/src/ol/events/EventType.js index a7d11a0541..327be7a7a3 100644 --- a/src/ol/events/EventType.js +++ b/src/ol/events/EventType.js @@ -1,10 +1,11 @@ -goog.provide('ol.events.EventType'); - +/** + * @module ol/events/EventType + */ /** * @enum {string} * @const */ -ol.events.EventType = { +var _ol_events_EventType_ = { /** * Generic change event. Triggered when the revision counter is increased. * @event ol.events.Event#change @@ -34,3 +35,5 @@ ol.events.EventType = { TOUCHEND: 'touchend', WHEEL: 'wheel' }; + +export default _ol_events_EventType_; diff --git a/src/ol/events/KeyCode.js b/src/ol/events/KeyCode.js index 5a6ec4535a..ceb2014fde 100644 --- a/src/ol/events/KeyCode.js +++ b/src/ol/events/KeyCode.js @@ -1,12 +1,15 @@ -goog.provide('ol.events.KeyCode'); - +/** + * @module ol/events/KeyCode + */ /** * @enum {number} * @const */ -ol.events.KeyCode = { +var _ol_events_KeyCode_ = { LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40 }; + +export default _ol_events_KeyCode_; diff --git a/src/ol/events/condition.js b/src/ol/events/condition.js index 46b2730510..e64295121e 100644 --- a/src/ol/events/condition.js +++ b/src/ol/events/condition.js @@ -1,9 +1,11 @@ -goog.provide('ol.events.condition'); - -goog.require('ol.MapBrowserEventType'); -goog.require('ol.asserts'); -goog.require('ol.functions'); -goog.require('ol.has'); +/** + * @module ol/events/condition + */ +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_functions_ from '../functions.js'; +import _ol_has_ from '../has.js'; +var _ol_events_condition_ = {}; /** @@ -14,7 +16,7 @@ goog.require('ol.has'); * @return {boolean} True if only the alt key is pressed. * @api */ -ol.events.condition.altKeyOnly = function(mapBrowserEvent) { +_ol_events_condition_.altKeyOnly = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; return ( originalEvent.altKey && @@ -31,7 +33,7 @@ ol.events.condition.altKeyOnly = function(mapBrowserEvent) { * @return {boolean} True if only the alt and shift keys are pressed. * @api */ -ol.events.condition.altShiftKeysOnly = function(mapBrowserEvent) { +_ol_events_condition_.altShiftKeysOnly = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; return ( originalEvent.altKey && @@ -48,7 +50,7 @@ ol.events.condition.altShiftKeysOnly = function(mapBrowserEvent) { * @function * @api */ -ol.events.condition.always = ol.functions.TRUE; +_ol_events_condition_.always = _ol_functions_.TRUE; /** @@ -58,8 +60,8 @@ ol.events.condition.always = ol.functions.TRUE; * @return {boolean} True if the event is a map `click` event. * @api */ -ol.events.condition.click = function(mapBrowserEvent) { - return mapBrowserEvent.type == ol.MapBrowserEventType.CLICK; +_ol_events_condition_.click = function(mapBrowserEvent) { + return mapBrowserEvent.type == _ol_MapBrowserEventType_.CLICK; }; @@ -72,10 +74,10 @@ ol.events.condition.click = function(mapBrowserEvent) { * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} The result. */ -ol.events.condition.mouseActionButton = function(mapBrowserEvent) { +_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; return originalEvent.button == 0 && - !(ol.has.WEBKIT && ol.has.MAC && originalEvent.ctrlKey); + !(_ol_has_.WEBKIT && _ol_has_.MAC && originalEvent.ctrlKey); }; @@ -87,7 +89,7 @@ ol.events.condition.mouseActionButton = function(mapBrowserEvent) { * @function * @api */ -ol.events.condition.never = ol.functions.FALSE; +_ol_events_condition_.never = _ol_functions_.FALSE; /** @@ -98,7 +100,7 @@ ol.events.condition.never = ol.functions.FALSE; * @return {boolean} True if the browser event is a `pointermove` event. * @api */ -ol.events.condition.pointerMove = function(mapBrowserEvent) { +_ol_events_condition_.pointerMove = function(mapBrowserEvent) { return mapBrowserEvent.type == 'pointermove'; }; @@ -110,8 +112,8 @@ ol.events.condition.pointerMove = function(mapBrowserEvent) { * @return {boolean} True if the event is a map `singleclick` event. * @api */ -ol.events.condition.singleClick = function(mapBrowserEvent) { - return mapBrowserEvent.type == ol.MapBrowserEventType.SINGLECLICK; +_ol_events_condition_.singleClick = function(mapBrowserEvent) { + return mapBrowserEvent.type == _ol_MapBrowserEventType_.SINGLECLICK; }; @@ -122,8 +124,8 @@ ol.events.condition.singleClick = function(mapBrowserEvent) { * @return {boolean} True if the event is a map `dblclick` event. * @api */ -ol.events.condition.doubleClick = function(mapBrowserEvent) { - return mapBrowserEvent.type == ol.MapBrowserEventType.DBLCLICK; +_ol_events_condition_.doubleClick = function(mapBrowserEvent) { + return mapBrowserEvent.type == _ol_MapBrowserEventType_.DBLCLICK; }; @@ -135,7 +137,7 @@ ol.events.condition.doubleClick = function(mapBrowserEvent) { * @return {boolean} True only if there no modifier keys are pressed. * @api */ -ol.events.condition.noModifierKeys = function(mapBrowserEvent) { +_ol_events_condition_.noModifierKeys = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; return ( !originalEvent.altKey && @@ -153,12 +155,11 @@ ol.events.condition.noModifierKeys = function(mapBrowserEvent) { * @return {boolean} True if only the platform modifier key is pressed. * @api */ -ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) { +_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; - return ( - !originalEvent.altKey && - (ol.has.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) && - !originalEvent.shiftKey); + return !originalEvent.altKey && + (_ol_has_.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) && + !originalEvent.shiftKey; }; @@ -170,7 +171,7 @@ ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) { * @return {boolean} True if only the shift key is pressed. * @api */ -ol.events.condition.shiftKeyOnly = function(mapBrowserEvent) { +_ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) { var originalEvent = mapBrowserEvent.originalEvent; return ( !originalEvent.altKey && @@ -187,7 +188,7 @@ ol.events.condition.shiftKeyOnly = function(mapBrowserEvent) { * @return {boolean} True only if the target element is not editable. * @api */ -ol.events.condition.targetNotEditable = function(mapBrowserEvent) { +_ol_events_condition_.targetNotEditable = function(mapBrowserEvent) { var target = mapBrowserEvent.originalEvent.target; var tagName = target.tagName; return ( @@ -204,8 +205,8 @@ ol.events.condition.targetNotEditable = function(mapBrowserEvent) { * @return {boolean} True if the event originates from a mouse device. * @api */ -ol.events.condition.mouseOnly = function(mapBrowserEvent) { - ol.asserts.assert(mapBrowserEvent.pointerEvent, 56); // mapBrowserEvent must originate from a pointer event +_ol_events_condition_.mouseOnly = function(mapBrowserEvent) { + _ol_asserts_.assert(mapBrowserEvent.pointerEvent, 56); // mapBrowserEvent must originate from a pointer event // see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType return /** @type {ol.MapBrowserEvent} */ (mapBrowserEvent).pointerEvent.pointerType == 'mouse'; }; @@ -220,7 +221,8 @@ ol.events.condition.mouseOnly = function(mapBrowserEvent) { * @return {boolean} True if the event originates from a primary pointer. * @api */ -ol.events.condition.primaryAction = function(mapBrowserEvent) { +_ol_events_condition_.primaryAction = function(mapBrowserEvent) { var pointerEvent = mapBrowserEvent.pointerEvent; return pointerEvent.isPrimary && pointerEvent.button === 0; }; +export default _ol_events_condition_; diff --git a/src/ol/extent.js b/src/ol/extent.js index ae67c8a120..be11961c53 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -1,8 +1,10 @@ -goog.provide('ol.extent'); - -goog.require('ol.asserts'); -goog.require('ol.extent.Corner'); -goog.require('ol.extent.Relationship'); +/** + * @module ol/extent + */ +import _ol_asserts_ from './asserts.js'; +import _ol_extent_Corner_ from './extent/Corner.js'; +import _ol_extent_Relationship_ from './extent/Relationship.js'; +var _ol_extent_ = {}; /** @@ -12,10 +14,10 @@ goog.require('ol.extent.Relationship'); * @return {ol.Extent} Bounding extent. * @api */ -ol.extent.boundingExtent = function(coordinates) { - var extent = ol.extent.createEmpty(); +_ol_extent_.boundingExtent = function(coordinates) { + var extent = _ol_extent_.createEmpty(); for (var i = 0, ii = coordinates.length; i < ii; ++i) { - ol.extent.extendCoordinate(extent, coordinates[i]); + _ol_extent_.extendCoordinate(extent, coordinates[i]); } return extent; }; @@ -28,12 +30,12 @@ ol.extent.boundingExtent = function(coordinates) { * @private * @return {ol.Extent} Extent. */ -ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) { +_ol_extent_.boundingExtentXYs_ = function(xs, ys, opt_extent) { var minX = Math.min.apply(null, xs); var minY = Math.min.apply(null, ys); var maxX = Math.max.apply(null, xs); var maxY = Math.max.apply(null, ys); - return ol.extent.createOrUpdate(minX, minY, maxX, maxY, opt_extent); + return _ol_extent_.createOrUpdate(minX, minY, maxX, maxY, opt_extent); }; @@ -45,7 +47,7 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) { * @return {ol.Extent} Extent. * @api */ -ol.extent.buffer = function(extent, value, opt_extent) { +_ol_extent_.buffer = function(extent, value, opt_extent) { if (opt_extent) { opt_extent[0] = extent[0] - value; opt_extent[1] = extent[1] - value; @@ -70,7 +72,7 @@ ol.extent.buffer = function(extent, value, opt_extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} The clone. */ -ol.extent.clone = function(extent, opt_extent) { +_ol_extent_.clone = function(extent, opt_extent) { if (opt_extent) { opt_extent[0] = extent[0]; opt_extent[1] = extent[1]; @@ -89,7 +91,7 @@ ol.extent.clone = function(extent, opt_extent) { * @param {number} y Y. * @return {number} Closest squared distance. */ -ol.extent.closestSquaredDistanceXY = function(extent, x, y) { +_ol_extent_.closestSquaredDistanceXY = function(extent, x, y) { var dx, dy; if (x < extent[0]) { dx = extent[0] - x; @@ -117,8 +119,8 @@ ol.extent.closestSquaredDistanceXY = function(extent, x, y) { * @return {boolean} The coordinate is contained in the extent. * @api */ -ol.extent.containsCoordinate = function(extent, coordinate) { - return ol.extent.containsXY(extent, coordinate[0], coordinate[1]); +_ol_extent_.containsCoordinate = function(extent, coordinate) { + return _ol_extent_.containsXY(extent, coordinate[0], coordinate[1]); }; @@ -134,7 +136,7 @@ ol.extent.containsCoordinate = function(extent, coordinate) { * first. * @api */ -ol.extent.containsExtent = function(extent1, extent2) { +_ol_extent_.containsExtent = function(extent1, extent2) { return extent1[0] <= extent2[0] && extent2[2] <= extent1[2] && extent1[1] <= extent2[1] && extent2[3] <= extent1[3]; }; @@ -149,7 +151,7 @@ ol.extent.containsExtent = function(extent1, extent2) { * @return {boolean} The x, y values are contained in the extent. * @api */ -ol.extent.containsXY = function(extent, x, y) { +_ol_extent_.containsXY = function(extent, x, y) { return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3]; }; @@ -161,26 +163,26 @@ ol.extent.containsXY = function(extent, x, y) { * @return {number} The relationship (bitwise compare with * ol.extent.Relationship). */ -ol.extent.coordinateRelationship = function(extent, coordinate) { +_ol_extent_.coordinateRelationship = function(extent, coordinate) { var minX = extent[0]; var minY = extent[1]; var maxX = extent[2]; var maxY = extent[3]; var x = coordinate[0]; var y = coordinate[1]; - var relationship = ol.extent.Relationship.UNKNOWN; + var relationship = _ol_extent_Relationship_.UNKNOWN; if (x < minX) { - relationship = relationship | ol.extent.Relationship.LEFT; + relationship = relationship | _ol_extent_Relationship_.LEFT; } else if (x > maxX) { - relationship = relationship | ol.extent.Relationship.RIGHT; + relationship = relationship | _ol_extent_Relationship_.RIGHT; } if (y < minY) { - relationship = relationship | ol.extent.Relationship.BELOW; + relationship = relationship | _ol_extent_Relationship_.BELOW; } else if (y > maxY) { - relationship = relationship | ol.extent.Relationship.ABOVE; + relationship = relationship | _ol_extent_Relationship_.ABOVE; } - if (relationship === ol.extent.Relationship.UNKNOWN) { - relationship = ol.extent.Relationship.INTERSECTING; + if (relationship === _ol_extent_Relationship_.UNKNOWN) { + relationship = _ol_extent_Relationship_.INTERSECTING; } return relationship; }; @@ -191,7 +193,7 @@ ol.extent.coordinateRelationship = function(extent, coordinate) { * @return {ol.Extent} Empty extent. * @api */ -ol.extent.createEmpty = function() { +_ol_extent_.createEmpty = function() { return [Infinity, Infinity, -Infinity, -Infinity]; }; @@ -205,7 +207,7 @@ ol.extent.createEmpty = function() { * @param {ol.Extent=} opt_extent Destination extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) { +_ol_extent_.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) { if (opt_extent) { opt_extent[0] = minX; opt_extent[1] = minY; @@ -223,8 +225,8 @@ ol.extent.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdateEmpty = function(opt_extent) { - return ol.extent.createOrUpdate( +_ol_extent_.createOrUpdateEmpty = function(opt_extent) { + return _ol_extent_.createOrUpdate( Infinity, Infinity, -Infinity, -Infinity, opt_extent); }; @@ -234,10 +236,10 @@ ol.extent.createOrUpdateEmpty = function(opt_extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdateFromCoordinate = function(coordinate, opt_extent) { +_ol_extent_.createOrUpdateFromCoordinate = function(coordinate, opt_extent) { var x = coordinate[0]; var y = coordinate[1]; - return ol.extent.createOrUpdate(x, y, x, y, opt_extent); + return _ol_extent_.createOrUpdate(x, y, x, y, opt_extent); }; @@ -246,9 +248,9 @@ ol.extent.createOrUpdateFromCoordinate = function(coordinate, opt_extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdateFromCoordinates = function(coordinates, opt_extent) { - var extent = ol.extent.createOrUpdateEmpty(opt_extent); - return ol.extent.extendCoordinates(extent, coordinates); +_ol_extent_.createOrUpdateFromCoordinates = function(coordinates, opt_extent) { + var extent = _ol_extent_.createOrUpdateEmpty(opt_extent); + return _ol_extent_.extendCoordinates(extent, coordinates); }; @@ -260,9 +262,9 @@ ol.extent.createOrUpdateFromCoordinates = function(coordinates, opt_extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdateFromFlatCoordinates = function(flatCoordinates, offset, end, stride, opt_extent) { - var extent = ol.extent.createOrUpdateEmpty(opt_extent); - return ol.extent.extendFlatCoordinates( +_ol_extent_.createOrUpdateFromFlatCoordinates = function(flatCoordinates, offset, end, stride, opt_extent) { + var extent = _ol_extent_.createOrUpdateEmpty(opt_extent); + return _ol_extent_.extendFlatCoordinates( extent, flatCoordinates, offset, end, stride); }; @@ -272,9 +274,9 @@ ol.extent.createOrUpdateFromFlatCoordinates = function(flatCoordinates, offset, * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.createOrUpdateFromRings = function(rings, opt_extent) { - var extent = ol.extent.createOrUpdateEmpty(opt_extent); - return ol.extent.extendRings(extent, rings); +_ol_extent_.createOrUpdateFromRings = function(rings, opt_extent) { + var extent = _ol_extent_.createOrUpdateEmpty(opt_extent); + return _ol_extent_.extendRings(extent, rings); }; @@ -285,7 +287,7 @@ ol.extent.createOrUpdateFromRings = function(rings, opt_extent) { * @return {boolean} The two extents are equivalent. * @api */ -ol.extent.equals = function(extent1, extent2) { +_ol_extent_.equals = function(extent1, extent2) { return extent1[0] == extent2[0] && extent1[2] == extent2[2] && extent1[1] == extent2[1] && extent1[3] == extent2[3]; }; @@ -298,7 +300,7 @@ ol.extent.equals = function(extent1, extent2) { * @return {ol.Extent} A reference to the first (extended) extent. * @api */ -ol.extent.extend = function(extent1, extent2) { +_ol_extent_.extend = function(extent1, extent2) { if (extent2[0] < extent1[0]) { extent1[0] = extent2[0]; } @@ -319,7 +321,7 @@ ol.extent.extend = function(extent1, extent2) { * @param {ol.Extent} extent Extent. * @param {ol.Coordinate} coordinate Coordinate. */ -ol.extent.extendCoordinate = function(extent, coordinate) { +_ol_extent_.extendCoordinate = function(extent, coordinate) { if (coordinate[0] < extent[0]) { extent[0] = coordinate[0]; } @@ -340,10 +342,10 @@ ol.extent.extendCoordinate = function(extent, coordinate) { * @param {Array.} coordinates Coordinates. * @return {ol.Extent} Extent. */ -ol.extent.extendCoordinates = function(extent, coordinates) { +_ol_extent_.extendCoordinates = function(extent, coordinates) { var i, ii; for (i = 0, ii = coordinates.length; i < ii; ++i) { - ol.extent.extendCoordinate(extent, coordinates[i]); + _ol_extent_.extendCoordinate(extent, coordinates[i]); } return extent; }; @@ -357,9 +359,9 @@ ol.extent.extendCoordinates = function(extent, coordinates) { * @param {number} stride Stride. * @return {ol.Extent} Extent. */ -ol.extent.extendFlatCoordinates = function(extent, flatCoordinates, offset, end, stride) { +_ol_extent_.extendFlatCoordinates = function(extent, flatCoordinates, offset, end, stride) { for (; offset < end; offset += stride) { - ol.extent.extendXY( + _ol_extent_.extendXY( extent, flatCoordinates[offset], flatCoordinates[offset + 1]); } return extent; @@ -371,10 +373,10 @@ ol.extent.extendFlatCoordinates = function(extent, flatCoordinates, offset, end, * @param {Array.>} rings Rings. * @return {ol.Extent} Extent. */ -ol.extent.extendRings = function(extent, rings) { +_ol_extent_.extendRings = function(extent, rings) { var i, ii; for (i = 0, ii = rings.length; i < ii; ++i) { - ol.extent.extendCoordinates(extent, rings[i]); + _ol_extent_.extendCoordinates(extent, rings[i]); } return extent; }; @@ -385,7 +387,7 @@ ol.extent.extendRings = function(extent, rings) { * @param {number} x X. * @param {number} y Y. */ -ol.extent.extendXY = function(extent, x, y) { +_ol_extent_.extendXY = function(extent, x, y) { extent[0] = Math.min(extent[0], x); extent[1] = Math.min(extent[1], y); extent[2] = Math.max(extent[2], x); @@ -403,21 +405,21 @@ ol.extent.extendXY = function(extent, x, y) { * @return {S|boolean} Value. * @template S, T */ -ol.extent.forEachCorner = function(extent, callback, opt_this) { +_ol_extent_.forEachCorner = function(extent, callback, opt_this) { var val; - val = callback.call(opt_this, ol.extent.getBottomLeft(extent)); + val = callback.call(opt_this, _ol_extent_.getBottomLeft(extent)); if (val) { return val; } - val = callback.call(opt_this, ol.extent.getBottomRight(extent)); + val = callback.call(opt_this, _ol_extent_.getBottomRight(extent)); if (val) { return val; } - val = callback.call(opt_this, ol.extent.getTopRight(extent)); + val = callback.call(opt_this, _ol_extent_.getTopRight(extent)); if (val) { return val; } - val = callback.call(opt_this, ol.extent.getTopLeft(extent)); + val = callback.call(opt_this, _ol_extent_.getTopLeft(extent)); if (val) { return val; } @@ -431,10 +433,10 @@ ol.extent.forEachCorner = function(extent, callback, opt_this) { * @return {number} Area. * @api */ -ol.extent.getArea = function(extent) { +_ol_extent_.getArea = function(extent) { var area = 0; - if (!ol.extent.isEmpty(extent)) { - area = ol.extent.getWidth(extent) * ol.extent.getHeight(extent); + if (!_ol_extent_.isEmpty(extent)) { + area = _ol_extent_.getWidth(extent) * _ol_extent_.getHeight(extent); } return area; }; @@ -446,7 +448,7 @@ ol.extent.getArea = function(extent) { * @return {ol.Coordinate} Bottom left coordinate. * @api */ -ol.extent.getBottomLeft = function(extent) { +_ol_extent_.getBottomLeft = function(extent) { return [extent[0], extent[1]]; }; @@ -457,7 +459,7 @@ ol.extent.getBottomLeft = function(extent) { * @return {ol.Coordinate} Bottom right coordinate. * @api */ -ol.extent.getBottomRight = function(extent) { +_ol_extent_.getBottomRight = function(extent) { return [extent[2], extent[1]]; }; @@ -468,7 +470,7 @@ ol.extent.getBottomRight = function(extent) { * @return {ol.Coordinate} Center. * @api */ -ol.extent.getCenter = function(extent) { +_ol_extent_.getCenter = function(extent) { return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2]; }; @@ -479,18 +481,18 @@ ol.extent.getCenter = function(extent) { * @param {ol.extent.Corner} corner Corner. * @return {ol.Coordinate} Corner coordinate. */ -ol.extent.getCorner = function(extent, corner) { +_ol_extent_.getCorner = function(extent, corner) { var coordinate; - if (corner === ol.extent.Corner.BOTTOM_LEFT) { - coordinate = ol.extent.getBottomLeft(extent); - } else if (corner === ol.extent.Corner.BOTTOM_RIGHT) { - coordinate = ol.extent.getBottomRight(extent); - } else if (corner === ol.extent.Corner.TOP_LEFT) { - coordinate = ol.extent.getTopLeft(extent); - } else if (corner === ol.extent.Corner.TOP_RIGHT) { - coordinate = ol.extent.getTopRight(extent); + if (corner === _ol_extent_Corner_.BOTTOM_LEFT) { + coordinate = _ol_extent_.getBottomLeft(extent); + } else if (corner === _ol_extent_Corner_.BOTTOM_RIGHT) { + coordinate = _ol_extent_.getBottomRight(extent); + } else if (corner === _ol_extent_Corner_.TOP_LEFT) { + coordinate = _ol_extent_.getTopLeft(extent); + } else if (corner === _ol_extent_Corner_.TOP_RIGHT) { + coordinate = _ol_extent_.getTopRight(extent); } else { - ol.asserts.assert(false, 13); // Invalid corner + _ol_asserts_.assert(false, 13); // Invalid corner } return /** @type {!ol.Coordinate} */ (coordinate); }; @@ -501,7 +503,7 @@ ol.extent.getCorner = function(extent, corner) { * @param {ol.Extent} extent2 Extent 2. * @return {number} Enlarged area. */ -ol.extent.getEnlargedArea = function(extent1, extent2) { +_ol_extent_.getEnlargedArea = function(extent1, extent2) { var minX = Math.min(extent1[0], extent2[0]); var minY = Math.min(extent1[1], extent2[1]); var maxX = Math.max(extent1[2], extent2[2]); @@ -518,7 +520,7 @@ ol.extent.getEnlargedArea = function(extent1, extent2) { * @param {ol.Extent=} opt_extent Destination extent. * @return {ol.Extent} Extent. */ -ol.extent.getForViewAndSize = function(center, resolution, rotation, size, opt_extent) { +_ol_extent_.getForViewAndSize = function(center, resolution, rotation, size, opt_extent) { var dx = resolution * size[0] / 2; var dy = resolution * size[1] / 2; var cosRotation = Math.cos(rotation); @@ -537,7 +539,7 @@ ol.extent.getForViewAndSize = function(center, resolution, rotation, size, opt_e var y1 = y - xSin + yCos; var y2 = y + xSin + yCos; var y3 = y + xSin - yCos; - return ol.extent.createOrUpdate( + return _ol_extent_.createOrUpdate( Math.min(x0, x1, x2, x3), Math.min(y0, y1, y2, y3), Math.max(x0, x1, x2, x3), Math.max(y0, y1, y2, y3), opt_extent); @@ -550,7 +552,7 @@ ol.extent.getForViewAndSize = function(center, resolution, rotation, size, opt_e * @return {number} Height. * @api */ -ol.extent.getHeight = function(extent) { +_ol_extent_.getHeight = function(extent) { return extent[3] - extent[1]; }; @@ -560,9 +562,9 @@ ol.extent.getHeight = function(extent) { * @param {ol.Extent} extent2 Extent 2. * @return {number} Intersection area. */ -ol.extent.getIntersectionArea = function(extent1, extent2) { - var intersection = ol.extent.getIntersection(extent1, extent2); - return ol.extent.getArea(intersection); +_ol_extent_.getIntersectionArea = function(extent1, extent2) { + var intersection = _ol_extent_.getIntersection(extent1, extent2); + return _ol_extent_.getArea(intersection); }; @@ -574,9 +576,9 @@ ol.extent.getIntersectionArea = function(extent1, extent2) { * @return {ol.Extent} Intersecting extent. * @api */ -ol.extent.getIntersection = function(extent1, extent2, opt_extent) { - var intersection = opt_extent ? opt_extent : ol.extent.createEmpty(); - if (ol.extent.intersects(extent1, extent2)) { +_ol_extent_.getIntersection = function(extent1, extent2, opt_extent) { + var intersection = opt_extent ? opt_extent : _ol_extent_.createEmpty(); + if (_ol_extent_.intersects(extent1, extent2)) { if (extent1[0] > extent2[0]) { intersection[0] = extent1[0]; } else { @@ -606,8 +608,8 @@ ol.extent.getIntersection = function(extent1, extent2, opt_extent) { * @param {ol.Extent} extent Extent. * @return {number} Margin. */ -ol.extent.getMargin = function(extent) { - return ol.extent.getWidth(extent) + ol.extent.getHeight(extent); +_ol_extent_.getMargin = function(extent) { + return _ol_extent_.getWidth(extent) + _ol_extent_.getHeight(extent); }; @@ -617,7 +619,7 @@ ol.extent.getMargin = function(extent) { * @return {ol.Size} The extent size. * @api */ -ol.extent.getSize = function(extent) { +_ol_extent_.getSize = function(extent) { return [extent[2] - extent[0], extent[3] - extent[1]]; }; @@ -628,7 +630,7 @@ ol.extent.getSize = function(extent) { * @return {ol.Coordinate} Top left coordinate. * @api */ -ol.extent.getTopLeft = function(extent) { +_ol_extent_.getTopLeft = function(extent) { return [extent[0], extent[3]]; }; @@ -639,7 +641,7 @@ ol.extent.getTopLeft = function(extent) { * @return {ol.Coordinate} Top right coordinate. * @api */ -ol.extent.getTopRight = function(extent) { +_ol_extent_.getTopRight = function(extent) { return [extent[2], extent[3]]; }; @@ -650,7 +652,7 @@ ol.extent.getTopRight = function(extent) { * @return {number} Width. * @api */ -ol.extent.getWidth = function(extent) { +_ol_extent_.getWidth = function(extent) { return extent[2] - extent[0]; }; @@ -662,7 +664,7 @@ ol.extent.getWidth = function(extent) { * @return {boolean} The two extents intersect. * @api */ -ol.extent.intersects = function(extent1, extent2) { +_ol_extent_.intersects = function(extent1, extent2) { return extent1[0] <= extent2[2] && extent1[2] >= extent2[0] && extent1[1] <= extent2[3] && @@ -676,7 +678,7 @@ ol.extent.intersects = function(extent1, extent2) { * @return {boolean} Is empty. * @api */ -ol.extent.isEmpty = function(extent) { +_ol_extent_.isEmpty = function(extent) { return extent[2] < extent[0] || extent[3] < extent[1]; }; @@ -686,7 +688,7 @@ ol.extent.isEmpty = function(extent) { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.extent.returnOrUpdate = function(extent, opt_extent) { +_ol_extent_.returnOrUpdate = function(extent, opt_extent) { if (opt_extent) { opt_extent[0] = extent[0]; opt_extent[1] = extent[1]; @@ -703,7 +705,7 @@ ol.extent.returnOrUpdate = function(extent, opt_extent) { * @param {ol.Extent} extent Extent. * @param {number} value Value. */ -ol.extent.scaleFromCenter = function(extent, value) { +_ol_extent_.scaleFromCenter = function(extent, value) { var deltaX = ((extent[2] - extent[0]) / 2) * (value - 1); var deltaY = ((extent[3] - extent[1]) / 2) * (value - 1); extent[0] -= deltaX; @@ -721,12 +723,12 @@ ol.extent.scaleFromCenter = function(extent, value) { * @param {ol.Coordinate} end Segment end coordinate. * @return {boolean} The segment intersects the extent. */ -ol.extent.intersectsSegment = function(extent, start, end) { +_ol_extent_.intersectsSegment = function(extent, start, end) { var intersects = false; - var startRel = ol.extent.coordinateRelationship(extent, start); - var endRel = ol.extent.coordinateRelationship(extent, end); - if (startRel === ol.extent.Relationship.INTERSECTING || - endRel === ol.extent.Relationship.INTERSECTING) { + var startRel = _ol_extent_.coordinateRelationship(extent, start); + var endRel = _ol_extent_.coordinateRelationship(extent, end); + if (startRel === _ol_extent_Relationship_.INTERSECTING || + endRel === _ol_extent_Relationship_.INTERSECTING) { intersects = true; } else { var minX = extent[0]; @@ -739,26 +741,26 @@ ol.extent.intersectsSegment = function(extent, start, end) { var endY = end[1]; var slope = (endY - startY) / (endX - startX); var x, y; - if (!!(endRel & ol.extent.Relationship.ABOVE) && - !(startRel & ol.extent.Relationship.ABOVE)) { + if (!!(endRel & _ol_extent_Relationship_.ABOVE) && + !(startRel & _ol_extent_Relationship_.ABOVE)) { // potentially intersects top x = endX - ((endY - maxY) / slope); intersects = x >= minX && x <= maxX; } - if (!intersects && !!(endRel & ol.extent.Relationship.RIGHT) && - !(startRel & ol.extent.Relationship.RIGHT)) { + if (!intersects && !!(endRel & _ol_extent_Relationship_.RIGHT) && + !(startRel & _ol_extent_Relationship_.RIGHT)) { // potentially intersects right y = endY - ((endX - maxX) * slope); intersects = y >= minY && y <= maxY; } - if (!intersects && !!(endRel & ol.extent.Relationship.BELOW) && - !(startRel & ol.extent.Relationship.BELOW)) { + if (!intersects && !!(endRel & _ol_extent_Relationship_.BELOW) && + !(startRel & _ol_extent_Relationship_.BELOW)) { // potentially intersects bottom x = endX - ((endY - minY) / slope); intersects = x >= minX && x <= maxX; } - if (!intersects && !!(endRel & ol.extent.Relationship.LEFT) && - !(startRel & ol.extent.Relationship.LEFT)) { + if (!intersects && !!(endRel & _ol_extent_Relationship_.LEFT) && + !(startRel & _ol_extent_Relationship_.LEFT)) { // potentially intersects left y = endY - ((endX - minX) * slope); intersects = y >= minY && y <= maxY; @@ -778,7 +780,7 @@ ol.extent.intersectsSegment = function(extent, start, end) { * @return {ol.Extent} Extent. * @api */ -ol.extent.applyTransform = function(extent, transformFn, opt_extent) { +_ol_extent_.applyTransform = function(extent, transformFn, opt_extent) { var coordinates = [ extent[0], extent[1], extent[0], extent[3], @@ -788,5 +790,6 @@ ol.extent.applyTransform = function(extent, transformFn, opt_extent) { transformFn(coordinates, coordinates, 2); var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]]; var ys = [coordinates[1], coordinates[3], coordinates[5], coordinates[7]]; - return ol.extent.boundingExtentXYs_(xs, ys, opt_extent); + return _ol_extent_.boundingExtentXYs_(xs, ys, opt_extent); }; +export default _ol_extent_; diff --git a/src/ol/extent/Corner.js b/src/ol/extent/Corner.js index 6c808c47a6..174026a98e 100644 --- a/src/ol/extent/Corner.js +++ b/src/ol/extent/Corner.js @@ -1,12 +1,15 @@ -goog.provide('ol.extent.Corner'); - +/** + * @module ol/extent/Corner + */ /** * Extent corner. * @enum {string} */ -ol.extent.Corner = { +var _ol_extent_Corner_ = { BOTTOM_LEFT: 'bottom-left', BOTTOM_RIGHT: 'bottom-right', TOP_LEFT: 'top-left', TOP_RIGHT: 'top-right' }; + +export default _ol_extent_Corner_; diff --git a/src/ol/extent/Relationship.js b/src/ol/extent/Relationship.js index ac359b3661..2c993f1a17 100644 --- a/src/ol/extent/Relationship.js +++ b/src/ol/extent/Relationship.js @@ -1,11 +1,11 @@ -goog.provide('ol.extent.Relationship'); - - +/** + * @module ol/extent/Relationship + */ /** * Relationship to an extent. * @enum {number} */ -ol.extent.Relationship = { +var _ol_extent_Relationship_ = { UNKNOWN: 0, INTERSECTING: 1, ABOVE: 2, @@ -13,3 +13,5 @@ ol.extent.Relationship = { BELOW: 8, LEFT: 16 }; + +export default _ol_extent_Relationship_; diff --git a/src/ol/featureloader.js b/src/ol/featureloader.js index a85b8ab2e8..152331e94f 100644 --- a/src/ol/featureloader.js +++ b/src/ol/featureloader.js @@ -1,8 +1,10 @@ -goog.provide('ol.featureloader'); - -goog.require('ol'); -goog.require('ol.format.FormatType'); -goog.require('ol.xml'); +/** + * @module ol/featureloader + */ +import _ol_ from './index.js'; +import _ol_format_FormatType_ from './format/FormatType.js'; +import _ol_xml_ from './xml.js'; +var _ol_featureloader_ = {}; /** @@ -16,7 +18,7 @@ goog.require('ol.xml'); * source as `this`. * @return {ol.FeatureLoader} The feature loader. */ -ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) { +_ol_featureloader_.loadFeaturesXhr = function(url, format, success, failure) { return ( /** * @param {ol.Extent} extent Extent. @@ -29,7 +31,7 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) { xhr.open('GET', typeof url === 'function' ? url(extent, resolution, projection) : url, true); - if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) { + if (format.getType() == _ol_format_FormatType_.ARRAY_BUFFER) { xhr.responseType = 'arraybuffer'; } /** @@ -42,15 +44,15 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) { var type = format.getType(); /** @type {Document|Node|Object|string|undefined} */ var source; - if (type == ol.format.FormatType.JSON || - type == ol.format.FormatType.TEXT) { + if (type == _ol_format_FormatType_.JSON || + type == _ol_format_FormatType_.TEXT) { source = xhr.responseText; - } else if (type == ol.format.FormatType.XML) { + } else if (type == _ol_format_FormatType_.XML) { source = xhr.responseXML; if (!source) { - source = ol.xml.parse(xhr.responseText); + source = _ol_xml_.parse(xhr.responseText); } - } else if (type == ol.format.FormatType.ARRAY_BUFFER) { + } else if (type == _ol_format_FormatType_.ARRAY_BUFFER) { source = /** @type {ArrayBuffer} */ (xhr.response); } if (source) { @@ -71,7 +73,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) { failure.call(this); }.bind(this); xhr.send(); - }); + } + ); }; @@ -84,8 +87,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) { * @return {ol.FeatureLoader} The feature loader. * @api */ -ol.featureloader.xhr = function(url, format) { - return ol.featureloader.loadFeaturesXhr(url, format, +_ol_featureloader_.xhr = function(url, format) { + return _ol_featureloader_.loadFeaturesXhr(url, format, /** * @param {Array.} features The loaded features. * @param {ol.proj.Projection} dataProjection Data projection. @@ -93,5 +96,6 @@ ol.featureloader.xhr = function(url, format) { */ function(features, dataProjection) { this.addFeatures(features); - }, /* FIXME handle error */ ol.nullFunction); + }, /* FIXME handle error */ _ol_.nullFunction); }; +export default _ol_featureloader_; diff --git a/src/ol/format/EsriJSON.js b/src/ol/format/EsriJSON.js index 6e590f0faf..9eaa808565 100644 --- a/src/ol/format/EsriJSON.js +++ b/src/ol/format/EsriJSON.js @@ -1,25 +1,25 @@ -goog.provide('ol.format.EsriJSON'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.asserts'); -goog.require('ol.extent'); -goog.require('ol.format.Feature'); -goog.require('ol.format.JSONFeature'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.obj'); -goog.require('ol.proj'); - +/** + * @module ol/format/EsriJSON + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_extent_ from '../extent.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_JSONFeature_ from '../format/JSONFeature.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_LinearRing_ from '../geom/LinearRing.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -30,11 +30,11 @@ goog.require('ol.proj'); * @param {olx.format.EsriJSONOptions=} opt_options Options. * @api */ -ol.format.EsriJSON = function(opt_options) { +var _ol_format_EsriJSON_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.JSONFeature.call(this); + _ol_format_JSONFeature_.call(this); /** * Name of the geometry attribute for features. @@ -44,7 +44,8 @@ ol.format.EsriJSON = function(opt_options) { this.geometryName_ = options.geometryName; }; -ol.inherits(ol.format.EsriJSON, ol.format.JSONFeature); + +_ol_.inherits(_ol_format_EsriJSON_, _ol_format_JSONFeature_); /** @@ -53,38 +54,39 @@ ol.inherits(ol.format.EsriJSON, ol.format.JSONFeature); * @private * @return {ol.geom.Geometry} Geometry. */ -ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { +_ol_format_EsriJSON_.readGeometry_ = function(object, opt_options) { if (!object) { return null; } /** @type {ol.geom.GeometryType} */ var type; if (typeof object.x === 'number' && typeof object.y === 'number') { - type = ol.geom.GeometryType.POINT; + type = _ol_geom_GeometryType_.POINT; } else if (object.points) { - type = ol.geom.GeometryType.MULTI_POINT; + type = _ol_geom_GeometryType_.MULTI_POINT; } else if (object.paths) { if (object.paths.length === 1) { - type = ol.geom.GeometryType.LINE_STRING; + type = _ol_geom_GeometryType_.LINE_STRING; } else { - type = ol.geom.GeometryType.MULTI_LINE_STRING; + type = _ol_geom_GeometryType_.MULTI_LINE_STRING; } } else if (object.rings) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - var rings = ol.format.EsriJSON.convertRings_(object.rings, layout); - object = /** @type {EsriJSONGeometry} */(ol.obj.assign({}, object)); + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + var rings = _ol_format_EsriJSON_.convertRings_(object.rings, layout); + object = /** @type {EsriJSONGeometry} */(_ol_obj_.assign({}, object)); if (rings.length === 1) { - type = ol.geom.GeometryType.POLYGON; + type = _ol_geom_GeometryType_.POLYGON; object.rings = rings[0]; } else { - type = ol.geom.GeometryType.MULTI_POLYGON; + type = _ol_geom_GeometryType_.MULTI_POLYGON; object.rings = rings; } } - var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type]; - return /** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions( - geometryReader(object), false, opt_options)); + var geometryReader = _ol_format_EsriJSON_.GEOMETRY_READERS_[type]; + return ( + /** @type {ol.geom.Geometry} */ _ol_format_Feature_.transformWithOptions( + geometryReader(object), false, opt_options) + ); }; @@ -98,16 +100,16 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { * @private * @return {Array.>>} Transformed rings. */ -ol.format.EsriJSON.convertRings_ = function(rings, layout) { +_ol_format_EsriJSON_.convertRings_ = function(rings, layout) { var flatRing = []; var outerRings = []; var holes = []; var i, ii; for (i = 0, ii = rings.length; i < ii; ++i) { flatRing.length = 0; - ol.geom.flat.deflate.coordinates(flatRing, 0, rings[i], layout.length); + _ol_geom_flat_deflate_.coordinates(flatRing, 0, rings[i], layout.length); // is this ring an outer ring? is it clockwise? - var clockwise = ol.geom.flat.orient.linearRingIsClockwise(flatRing, 0, + var clockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatRing, 0, flatRing.length, layout.length); if (clockwise) { outerRings.push([rings[i]]); @@ -121,9 +123,9 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) { // loop over all outer rings and see if they contain our hole. for (i = outerRings.length - 1; i >= 0; i--) { var outerRing = outerRings[i][0]; - var containsHole = ol.extent.containsExtent( - new ol.geom.LinearRing(outerRing).getExtent(), - new ol.geom.LinearRing(hole).getExtent() + var containsHole = _ol_extent_.containsExtent( + new _ol_geom_LinearRing_(outerRing).getExtent(), + new _ol_geom_LinearRing_(hole).getExtent() ); if (containsHole) { // the hole is contained push it into our polygon @@ -147,19 +149,19 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) { * @private * @return {ol.geom.Geometry} Point. */ -ol.format.EsriJSON.readPointGeometry_ = function(object) { +_ol_format_EsriJSON_.readPointGeometry_ = function(object) { var point; if (object.m !== undefined && object.z !== undefined) { - point = new ol.geom.Point([object.x, object.y, object.z, object.m], - ol.geom.GeometryLayout.XYZM); + point = new _ol_geom_Point_([object.x, object.y, object.z, object.m], + _ol_geom_GeometryLayout_.XYZM); } else if (object.z !== undefined) { - point = new ol.geom.Point([object.x, object.y, object.z], - ol.geom.GeometryLayout.XYZ); + point = new _ol_geom_Point_([object.x, object.y, object.z], + _ol_geom_GeometryLayout_.XYZ); } else if (object.m !== undefined) { - point = new ol.geom.Point([object.x, object.y, object.m], - ol.geom.GeometryLayout.XYM); + point = new _ol_geom_Point_([object.x, object.y, object.m], + _ol_geom_GeometryLayout_.XYM); } else { - point = new ol.geom.Point([object.x, object.y]); + point = new _ol_geom_Point_([object.x, object.y]); } return point; }; @@ -170,9 +172,9 @@ ol.format.EsriJSON.readPointGeometry_ = function(object) { * @private * @return {ol.geom.Geometry} LineString. */ -ol.format.EsriJSON.readLineStringGeometry_ = function(object) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - return new ol.geom.LineString(object.paths[0], layout); +_ol_format_EsriJSON_.readLineStringGeometry_ = function(object) { + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + return new _ol_geom_LineString_(object.paths[0], layout); }; @@ -181,9 +183,9 @@ ol.format.EsriJSON.readLineStringGeometry_ = function(object) { * @private * @return {ol.geom.Geometry} MultiLineString. */ -ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - return new ol.geom.MultiLineString(object.paths, layout); +_ol_format_EsriJSON_.readMultiLineStringGeometry_ = function(object) { + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + return new _ol_geom_MultiLineString_(object.paths, layout); }; @@ -192,14 +194,14 @@ ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) { * @private * @return {ol.geom.GeometryLayout} The geometry layout to use. */ -ol.format.EsriJSON.getGeometryLayout_ = function(object) { - var layout = ol.geom.GeometryLayout.XY; +_ol_format_EsriJSON_.getGeometryLayout_ = function(object) { + var layout = _ol_geom_GeometryLayout_.XY; if (object.hasZ === true && object.hasM === true) { - layout = ol.geom.GeometryLayout.XYZM; + layout = _ol_geom_GeometryLayout_.XYZM; } else if (object.hasZ === true) { - layout = ol.geom.GeometryLayout.XYZ; + layout = _ol_geom_GeometryLayout_.XYZ; } else if (object.hasM === true) { - layout = ol.geom.GeometryLayout.XYM; + layout = _ol_geom_GeometryLayout_.XYM; } return layout; }; @@ -210,9 +212,9 @@ ol.format.EsriJSON.getGeometryLayout_ = function(object) { * @private * @return {ol.geom.Geometry} MultiPoint. */ -ol.format.EsriJSON.readMultiPointGeometry_ = function(object) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - return new ol.geom.MultiPoint(object.points, layout); +_ol_format_EsriJSON_.readMultiPointGeometry_ = function(object) { + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + return new _ol_geom_MultiPoint_(object.points, layout); }; @@ -221,9 +223,9 @@ ol.format.EsriJSON.readMultiPointGeometry_ = function(object) { * @private * @return {ol.geom.Geometry} MultiPolygon. */ -ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - return new ol.geom.MultiPolygon( +_ol_format_EsriJSON_.readMultiPolygonGeometry_ = function(object) { + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + return new _ol_geom_MultiPolygon_( /** @type {Array.>>>} */(object.rings), layout); }; @@ -234,9 +236,9 @@ ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) { * @private * @return {ol.geom.Geometry} Polygon. */ -ol.format.EsriJSON.readPolygonGeometry_ = function(object) { - var layout = ol.format.EsriJSON.getGeometryLayout_(object); - return new ol.geom.Polygon(object.rings, layout); +_ol_format_EsriJSON_.readPolygonGeometry_ = function(object) { + var layout = _ol_format_EsriJSON_.getGeometryLayout_(object); + return new _ol_geom_Polygon_(object.rings, layout); }; @@ -246,36 +248,36 @@ ol.format.EsriJSON.readPolygonGeometry_ = function(object) { * @private * @return {EsriJSONGeometry} EsriJSON geometry. */ -ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) { +_ol_format_EsriJSON_.writePointGeometry_ = function(geometry, opt_options) { var coordinates = /** @type {ol.geom.Point} */ (geometry).getCoordinates(); var esriJSON; var layout = /** @type {ol.geom.Point} */ (geometry).getLayout(); - if (layout === ol.geom.GeometryLayout.XYZ) { + if (layout === _ol_geom_GeometryLayout_.XYZ) { esriJSON = /** @type {EsriJSONPoint} */ ({ x: coordinates[0], y: coordinates[1], z: coordinates[2] }); - } else if (layout === ol.geom.GeometryLayout.XYM) { + } else if (layout === _ol_geom_GeometryLayout_.XYM) { esriJSON = /** @type {EsriJSONPoint} */ ({ x: coordinates[0], y: coordinates[1], m: coordinates[2] }); - } else if (layout === ol.geom.GeometryLayout.XYZM) { + } else if (layout === _ol_geom_GeometryLayout_.XYZM) { esriJSON = /** @type {EsriJSONPoint} */ ({ x: coordinates[0], y: coordinates[1], z: coordinates[2], m: coordinates[3] }); - } else if (layout === ol.geom.GeometryLayout.XY) { + } else if (layout === _ol_geom_GeometryLayout_.XY) { esriJSON = /** @type {EsriJSONPoint} */ ({ x: coordinates[0], y: coordinates[1] }); } else { - ol.asserts.assert(false, 34); // Invalid geometry layout + _ol_asserts_.assert(false, 34); // Invalid geometry layout } return /** @type {EsriJSONGeometry} */ (esriJSON); }; @@ -286,13 +288,13 @@ ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) { * @private * @return {Object} Object with boolean hasZ and hasM keys. */ -ol.format.EsriJSON.getHasZM_ = function(geometry) { +_ol_format_EsriJSON_.getHasZM_ = function(geometry) { var layout = geometry.getLayout(); return { - hasZ: (layout === ol.geom.GeometryLayout.XYZ || - layout === ol.geom.GeometryLayout.XYZM), - hasM: (layout === ol.geom.GeometryLayout.XYM || - layout === ol.geom.GeometryLayout.XYZM) + hasZ: (layout === _ol_geom_GeometryLayout_.XYZ || + layout === _ol_geom_GeometryLayout_.XYZM), + hasM: (layout === _ol_geom_GeometryLayout_.XYM || + layout === _ol_geom_GeometryLayout_.XYZM) }; }; @@ -303,8 +305,8 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) { * @private * @return {EsriJSONPolyline} EsriJSON geometry. */ -ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) { - var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */(geometry)); +_ol_format_EsriJSON_.writeLineStringGeometry_ = function(geometry, opt_options) { + var hasZM = _ol_format_EsriJSON_.getHasZM_(/** @type {ol.geom.LineString} */(geometry)); return /** @type {EsriJSONPolyline} */ ({ hasZ: hasZM.hasZ, hasM: hasZM.hasM, @@ -321,9 +323,9 @@ ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) { * @private * @return {EsriJSONPolygon} EsriJSON geometry. */ -ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) { +_ol_format_EsriJSON_.writePolygonGeometry_ = function(geometry, opt_options) { // Esri geometries use the left-hand rule - var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */(geometry)); + var hasZM = _ol_format_EsriJSON_.getHasZM_(/** @type {ol.geom.Polygon} */(geometry)); return /** @type {EsriJSONPolygon} */ ({ hasZ: hasZM.hasZ, hasM: hasZM.hasM, @@ -338,8 +340,8 @@ ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) { * @private * @return {EsriJSONPolyline} EsriJSON geometry. */ -ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) { - var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry)); +_ol_format_EsriJSON_.writeMultiLineStringGeometry_ = function(geometry, opt_options) { + var hasZM = _ol_format_EsriJSON_.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry)); return /** @type {EsriJSONPolyline} */ ({ hasZ: hasZM.hasZ, hasM: hasZM.hasM, @@ -354,8 +356,8 @@ ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_option * @private * @return {EsriJSONMultipoint} EsriJSON geometry. */ -ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) { - var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry)); +_ol_format_EsriJSON_.writeMultiPointGeometry_ = function(geometry, opt_options) { + var hasZM = _ol_format_EsriJSON_.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry)); return /** @type {EsriJSONMultipoint} */ ({ hasZ: hasZM.hasZ, hasM: hasZM.hasM, @@ -370,9 +372,9 @@ ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) { * @private * @return {EsriJSONPolygon} EsriJSON geometry. */ -ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry, +_ol_format_EsriJSON_.writeMultiPolygonGeometry_ = function(geometry, opt_options) { - var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry)); + var hasZM = _ol_format_EsriJSON_.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry)); var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false); var output = []; for (var i = 0; i < coordinates.length; i++) { @@ -393,19 +395,19 @@ ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry, * @private * @type {Object.} */ -ol.format.EsriJSON.GEOMETRY_READERS_ = {}; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POINT] = - ol.format.EsriJSON.readPointGeometry_; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.LINE_STRING] = - ol.format.EsriJSON.readLineStringGeometry_; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POLYGON] = - ol.format.EsriJSON.readPolygonGeometry_; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POINT] = - ol.format.EsriJSON.readMultiPointGeometry_; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_LINE_STRING] = - ol.format.EsriJSON.readMultiLineStringGeometry_; -ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] = - ol.format.EsriJSON.readMultiPolygonGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_ = {}; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.POINT] = + _ol_format_EsriJSON_.readPointGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.LINE_STRING] = + _ol_format_EsriJSON_.readLineStringGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.POLYGON] = + _ol_format_EsriJSON_.readPolygonGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.MULTI_POINT] = + _ol_format_EsriJSON_.readMultiPointGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.MULTI_LINE_STRING] = + _ol_format_EsriJSON_.readMultiLineStringGeometry_; +_ol_format_EsriJSON_.GEOMETRY_READERS_[_ol_geom_GeometryType_.MULTI_POLYGON] = + _ol_format_EsriJSON_.readMultiPolygonGeometry_; /** @@ -413,19 +415,19 @@ ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] = * @private * @type {Object.} */ -ol.format.EsriJSON.GEOMETRY_WRITERS_ = {}; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POINT] = - ol.format.EsriJSON.writePointGeometry_; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.LINE_STRING] = - ol.format.EsriJSON.writeLineStringGeometry_; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POLYGON] = - ol.format.EsriJSON.writePolygonGeometry_; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POINT] = - ol.format.EsriJSON.writeMultiPointGeometry_; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_LINE_STRING] = - ol.format.EsriJSON.writeMultiLineStringGeometry_; -ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] = - ol.format.EsriJSON.writeMultiPolygonGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_ = {}; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.POINT] = + _ol_format_EsriJSON_.writePointGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.LINE_STRING] = + _ol_format_EsriJSON_.writeLineStringGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.POLYGON] = + _ol_format_EsriJSON_.writePolygonGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.MULTI_POINT] = + _ol_format_EsriJSON_.writeMultiPointGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.MULTI_LINE_STRING] = + _ol_format_EsriJSON_.writeMultiLineStringGeometry_; +_ol_format_EsriJSON_.GEOMETRY_WRITERS_[_ol_geom_GeometryType_.MULTI_POLYGON] = + _ol_format_EsriJSON_.writeMultiPolygonGeometry_; /** @@ -438,7 +440,7 @@ ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] = * @return {ol.Feature} Feature. * @api */ -ol.format.EsriJSON.prototype.readFeature; +_ol_format_EsriJSON_.prototype.readFeature; /** @@ -451,18 +453,18 @@ ol.format.EsriJSON.prototype.readFeature; * @return {Array.} Features. * @api */ -ol.format.EsriJSON.prototype.readFeatures; +_ol_format_EsriJSON_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.EsriJSON.prototype.readFeatureFromObject = function( +_ol_format_EsriJSON_.prototype.readFeatureFromObject = function( object, opt_options) { var esriJSONFeature = /** @type {EsriJSONFeature} */ (object); - var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry, + var geometry = _ol_format_EsriJSON_.readGeometry_(esriJSONFeature.geometry, opt_options); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } @@ -482,7 +484,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function( /** * @inheritDoc */ -ol.format.EsriJSON.prototype.readFeaturesFromObject = function( +_ol_format_EsriJSON_.prototype.readFeaturesFromObject = function( object, opt_options) { var esriJSONObject = /** @type {EsriJSONObject} */ (object); var options = opt_options ? opt_options : {}; @@ -514,15 +516,15 @@ ol.format.EsriJSON.prototype.readFeaturesFromObject = function( * @return {ol.geom.Geometry} Geometry. * @api */ -ol.format.EsriJSON.prototype.readGeometry; +_ol_format_EsriJSON_.prototype.readGeometry; /** * @inheritDoc */ -ol.format.EsriJSON.prototype.readGeometryFromObject = function( +_ol_format_EsriJSON_.prototype.readGeometryFromObject = function( object, opt_options) { - return ol.format.EsriJSON.readGeometry_( + return _ol_format_EsriJSON_.readGeometry_( /** @type {EsriJSONGeometry} */(object), opt_options); }; @@ -535,17 +537,17 @@ ol.format.EsriJSON.prototype.readGeometryFromObject = function( * @return {ol.proj.Projection} Projection. * @api */ -ol.format.EsriJSON.prototype.readProjection; +_ol_format_EsriJSON_.prototype.readProjection; /** * @inheritDoc */ -ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) { +_ol_format_EsriJSON_.prototype.readProjectionFromObject = function(object) { var esriJSONObject = /** @type {EsriJSONObject} */ (object); if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) { var crs = esriJSONObject.spatialReference.wkid; - return ol.proj.get('EPSG:' + crs); + return _ol_proj_.get('EPSG:' + crs); } else { return null; } @@ -558,10 +560,10 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) { * @private * @return {EsriJSONGeometry} EsriJSON geometry. */ -ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { - var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()]; +_ol_format_EsriJSON_.writeGeometry_ = function(geometry, opt_options) { + var geometryWriter = _ol_format_EsriJSON_.GEOMETRY_WRITERS_[geometry.getType()]; return geometryWriter(/** @type {ol.geom.Geometry} */( - ol.format.Feature.transformWithOptions(geometry, true, opt_options)), + _ol_format_Feature_.transformWithOptions(geometry, true, opt_options)), opt_options); }; @@ -575,7 +577,7 @@ ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { * @return {string} EsriJSON. * @api */ -ol.format.EsriJSON.prototype.writeGeometry; +_ol_format_EsriJSON_.prototype.writeGeometry; /** @@ -587,9 +589,9 @@ ol.format.EsriJSON.prototype.writeGeometry; * @override * @api */ -ol.format.EsriJSON.prototype.writeGeometryObject = function(geometry, +_ol_format_EsriJSON_.prototype.writeGeometryObject = function(geometry, opt_options) { - return ol.format.EsriJSON.writeGeometry_(geometry, + return _ol_format_EsriJSON_.writeGeometry_(geometry, this.adaptOptions(opt_options)); }; @@ -603,7 +605,7 @@ ol.format.EsriJSON.prototype.writeGeometryObject = function(geometry, * @return {string} EsriJSON. * @api */ -ol.format.EsriJSON.prototype.writeFeature; +_ol_format_EsriJSON_.prototype.writeFeature; /** @@ -615,24 +617,24 @@ ol.format.EsriJSON.prototype.writeFeature; * @override * @api */ -ol.format.EsriJSON.prototype.writeFeatureObject = function( +_ol_format_EsriJSON_.prototype.writeFeatureObject = function( feature, opt_options) { opt_options = this.adaptOptions(opt_options); var object = {}; var geometry = feature.getGeometry(); if (geometry) { object['geometry'] = - ol.format.EsriJSON.writeGeometry_(geometry, opt_options); + _ol_format_EsriJSON_.writeGeometry_(geometry, opt_options); if (opt_options && opt_options.featureProjection) { object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({ - wkid: ol.proj.get( + wkid: _ol_proj_.get( opt_options.featureProjection).getCode().split(':').pop() }); } } var properties = feature.getProperties(); delete properties[feature.getGeometryName()]; - if (!ol.obj.isEmpty(properties)) { + if (!_ol_obj_.isEmpty(properties)) { object['attributes'] = properties; } else { object['attributes'] = {}; @@ -650,7 +652,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function( * @return {string} EsriJSON. * @api */ -ol.format.EsriJSON.prototype.writeFeatures; +_ol_format_EsriJSON_.prototype.writeFeatures; /** @@ -662,7 +664,7 @@ ol.format.EsriJSON.prototype.writeFeatures; * @override * @api */ -ol.format.EsriJSON.prototype.writeFeaturesObject = function(features, opt_options) { +_ol_format_EsriJSON_.prototype.writeFeaturesObject = function(features, opt_options) { opt_options = this.adaptOptions(opt_options); var objects = []; var i, ii; @@ -673,3 +675,4 @@ ol.format.EsriJSON.prototype.writeFeaturesObject = function(features, opt_option 'features': objects }); }; +export default _ol_format_EsriJSON_; diff --git a/src/ol/format/Feature.js b/src/ol/format/Feature.js index 622700ca9b..d1b94a11bd 100644 --- a/src/ol/format/Feature.js +++ b/src/ol/format/Feature.js @@ -1,9 +1,9 @@ -goog.provide('ol.format.Feature'); - -goog.require('ol.geom.Geometry'); -goog.require('ol.obj'); -goog.require('ol.proj'); - +/** + * @module ol/format/Feature + */ +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -18,7 +18,7 @@ goog.require('ol.proj'); * @abstract * @api */ -ol.format.Feature = function() { +var _ol_format_Feature_ = function() { /** * @protected @@ -42,7 +42,7 @@ ol.format.Feature = function() { * @return {olx.format.ReadOptions|undefined} Options. * @protected */ -ol.format.Feature.prototype.getReadOptions = function(source, opt_options) { +_ol_format_Feature_.prototype.getReadOptions = function(source, opt_options) { var options; if (opt_options) { options = { @@ -64,8 +64,8 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) { * @return {olx.format.WriteOptions|olx.format.ReadOptions|undefined} * Updated options. */ -ol.format.Feature.prototype.adaptOptions = function(options) { - return ol.obj.assign({ +_ol_format_Feature_.prototype.adaptOptions = function(options) { + return _ol_obj_.assign({ dataProjection: this.defaultDataProjection, featureProjection: this.defaultFeatureProjection }, options); @@ -76,7 +76,7 @@ ol.format.Feature.prototype.adaptOptions = function(options) { * Get the extent from the source of the last {@link readFeatures} call. * @return {ol.Extent} Tile extent. */ -ol.format.Feature.prototype.getLastExtent = function() { +_ol_format_Feature_.prototype.getLastExtent = function() { return null; }; @@ -85,7 +85,7 @@ ol.format.Feature.prototype.getLastExtent = function() { * @abstract * @return {ol.format.FormatType} Format. */ -ol.format.Feature.prototype.getType = function() {}; +_ol_format_Feature_.prototype.getType = function() {}; /** @@ -96,7 +96,7 @@ ol.format.Feature.prototype.getType = function() {}; * @param {olx.format.ReadOptions=} opt_options Read options. * @return {ol.Feature} Feature. */ -ol.format.Feature.prototype.readFeature = function(source, opt_options) {}; +_ol_format_Feature_.prototype.readFeature = function(source, opt_options) {}; /** @@ -107,7 +107,7 @@ ol.format.Feature.prototype.readFeature = function(source, opt_options) {}; * @param {olx.format.ReadOptions=} opt_options Read options. * @return {Array.} Features. */ -ol.format.Feature.prototype.readFeatures = function(source, opt_options) {}; +_ol_format_Feature_.prototype.readFeatures = function(source, opt_options) {}; /** @@ -118,7 +118,7 @@ ol.format.Feature.prototype.readFeatures = function(source, opt_options) {}; * @param {olx.format.ReadOptions=} opt_options Read options. * @return {ol.geom.Geometry} Geometry. */ -ol.format.Feature.prototype.readGeometry = function(source, opt_options) {}; +_ol_format_Feature_.prototype.readGeometry = function(source, opt_options) {}; /** @@ -128,7 +128,7 @@ ol.format.Feature.prototype.readGeometry = function(source, opt_options) {}; * @param {Document|Node|Object|string} source Source. * @return {ol.proj.Projection} Projection. */ -ol.format.Feature.prototype.readProjection = function(source) {}; +_ol_format_Feature_.prototype.readProjection = function(source) {}; /** @@ -139,7 +139,7 @@ ol.format.Feature.prototype.readProjection = function(source) {}; * @param {olx.format.WriteOptions=} opt_options Write options. * @return {string} Result. */ -ol.format.Feature.prototype.writeFeature = function(feature, opt_options) {}; +_ol_format_Feature_.prototype.writeFeature = function(feature, opt_options) {}; /** @@ -150,7 +150,7 @@ ol.format.Feature.prototype.writeFeature = function(feature, opt_options) {}; * @param {olx.format.WriteOptions=} opt_options Write options. * @return {string} Result. */ -ol.format.Feature.prototype.writeFeatures = function(features, opt_options) {}; +_ol_format_Feature_.prototype.writeFeatures = function(features, opt_options) {}; /** @@ -161,7 +161,7 @@ ol.format.Feature.prototype.writeFeatures = function(features, opt_options) {}; * @param {olx.format.WriteOptions=} opt_options Write options. * @return {string} Result. */ -ol.format.Feature.prototype.writeGeometry = function(geometry, opt_options) {}; +_ol_format_Feature_.prototype.writeGeometry = function(geometry, opt_options) {}; /** @@ -172,26 +172,26 @@ ol.format.Feature.prototype.writeGeometry = function(geometry, opt_options) {}; * @return {ol.geom.Geometry|ol.Extent} Transformed geometry. * @protected */ -ol.format.Feature.transformWithOptions = function( +_ol_format_Feature_.transformWithOptions = function( geometry, write, opt_options) { var featureProjection = opt_options ? - ol.proj.get(opt_options.featureProjection) : null; + _ol_proj_.get(opt_options.featureProjection) : null; var dataProjection = opt_options ? - ol.proj.get(opt_options.dataProjection) : null; + _ol_proj_.get(opt_options.dataProjection) : null; /** * @type {ol.geom.Geometry|ol.Extent} */ var transformed; if (featureProjection && dataProjection && - !ol.proj.equivalent(featureProjection, dataProjection)) { - if (geometry instanceof ol.geom.Geometry) { + !_ol_proj_.equivalent(featureProjection, dataProjection)) { + if (geometry instanceof _ol_geom_Geometry_) { transformed = (write ? geometry.clone() : geometry).transform( write ? featureProjection : dataProjection, write ? dataProjection : featureProjection); } else { // FIXME this is necessary because ol.format.GML treats extents // as geometries - transformed = ol.proj.transformExtent( + transformed = _ol_proj_.transformExtent( geometry, dataProjection, featureProjection); @@ -219,3 +219,4 @@ ol.format.Feature.transformWithOptions = function( } return transformed; }; +export default _ol_format_Feature_; diff --git a/src/ol/format/FormatType.js b/src/ol/format/FormatType.js index 3fa3586e3f..e1373f99a0 100644 --- a/src/ol/format/FormatType.js +++ b/src/ol/format/FormatType.js @@ -1,12 +1,14 @@ -goog.provide('ol.format.FormatType'); - - +/** + * @module ol/format/FormatType + */ /** * @enum {string} */ -ol.format.FormatType = { +var _ol_format_FormatType_ = { ARRAY_BUFFER: 'arraybuffer', JSON: 'json', TEXT: 'text', XML: 'xml' }; + +export default _ol_format_FormatType_; diff --git a/src/ol/format/GML.js b/src/ol/format/GML.js index 25e538e8e2..edcf6ce97b 100644 --- a/src/ol/format/GML.js +++ b/src/ol/format/GML.js @@ -1,7 +1,7 @@ -goog.provide('ol.format.GML'); - -goog.require('ol.format.GML3'); - +/** + * @module ol/format/GML + */ +import _ol_format_GML3_ from '../format/GML3.js'; /** * @classdesc @@ -15,7 +15,7 @@ goog.require('ol.format.GML3'); * @extends {ol.format.GMLBase} * @api */ -ol.format.GML = ol.format.GML3; +var _ol_format_GML_ = _ol_format_GML3_; /** @@ -27,7 +27,7 @@ ol.format.GML = ol.format.GML3; * @return {string} Result. * @api */ -ol.format.GML.prototype.writeFeatures; +_ol_format_GML_.prototype.writeFeatures; /** @@ -39,4 +39,5 @@ ol.format.GML.prototype.writeFeatures; * @return {Node} Node. * @api */ -ol.format.GML.prototype.writeFeaturesNode; +_ol_format_GML_.prototype.writeFeaturesNode; +export default _ol_format_GML_; diff --git a/src/ol/format/GML2.js b/src/ol/format/GML2.js index fb7661e5fd..5be784b5b1 100644 --- a/src/ol/format/GML2.js +++ b/src/ol/format/GML2.js @@ -1,15 +1,15 @@ -goog.provide('ol.format.GML2'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.format.Feature'); -goog.require('ol.format.GMLBase'); -goog.require('ol.format.XSD'); -goog.require('ol.geom.Geometry'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +/** + * @module ol/format/GML2 + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_GMLBase_ from '../format/GMLBase.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -21,24 +21,25 @@ goog.require('ol.xml'); * @extends {ol.format.GMLBase} * @api */ -ol.format.GML2 = function(opt_options) { +var _ol_format_GML2_ = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ (opt_options ? opt_options : {}); - ol.format.GMLBase.call(this, options); + _ol_format_GMLBase_.call(this, options); - this.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ + this.FEATURE_COLLECTION_PARSERS[_ol_format_GMLBase_.GMLNS][ 'featureMember'] = - ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readFeaturesInternal); + _ol_xml_.makeArrayPusher(_ol_format_GMLBase_.prototype.readFeaturesInternal); /** * @inheritDoc */ this.schemaLocation = options.schemaLocation ? - options.schemaLocation : ol.format.GML2.schemaLocation_; + options.schemaLocation : _ol_format_GML2_.schemaLocation_; }; -ol.inherits(ol.format.GML2, ol.format.GMLBase); + +_ol_.inherits(_ol_format_GML2_, _ol_format_GMLBase_); /** @@ -46,7 +47,7 @@ ol.inherits(ol.format.GML2, ol.format.GMLBase); * @type {string} * @private */ -ol.format.GML2.schemaLocation_ = ol.format.GMLBase.GMLNS + +_ol_format_GML2_.schemaLocation_ = _ol_format_GMLBase_.GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd'; @@ -56,13 +57,13 @@ ol.format.GML2.schemaLocation_ = ol.format.GMLBase.GMLNS + * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) { - var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); +_ol_format_GML2_.prototype.readFlatCoordinates_ = function(node, objectStack) { + var s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]); var containerSrs = context['srsName']; var axisOrientation = 'enu'; if (containerSrs) { - var proj = ol.proj.get(containerSrs); + var proj = _ol_proj_.get(containerSrs); if (proj) { axisOrientation = proj.getAxisOrientation(); } @@ -91,11 +92,11 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) { * @private * @return {ol.Extent|undefined} Envelope. */ -ol.format.GML2.prototype.readBox_ = function(node, objectStack) { +_ol_format_GML2_.prototype.readBox_ = function(node, objectStack) { /** @type {Array.} */ - var flatCoordinates = ol.xml.pushParseAndPop([null], + var flatCoordinates = _ol_xml_.pushParseAndPop([null], this.BOX_PARSERS_, node, objectStack, this); - return ol.extent.createOrUpdate(flatCoordinates[1][0], + return _ol_extent_.createOrUpdate(flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[1][3], flatCoordinates[1][4]); }; @@ -106,9 +107,9 @@ ol.format.GML2.prototype.readBox_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) { +_ol_format_GML2_.prototype.innerBoundaryIsParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ @@ -123,9 +124,9 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) { +_ol_format_GML2_.prototype.outerBoundaryIsParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ @@ -140,10 +141,10 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +_ol_format_GML2_.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { 'http://www.opengis.net/gml': { - 'coordinates': ol.xml.makeReplacer( - ol.format.GML2.prototype.readFlatCoordinates_) + 'coordinates': _ol_xml_.makeReplacer( + _ol_format_GML2_.prototype.readFlatCoordinates_) } }; @@ -153,10 +154,10 @@ ol.format.GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { +_ol_format_GML2_.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { 'http://www.opengis.net/gml': { - 'innerBoundaryIs': ol.format.GML2.prototype.innerBoundaryIsParser_, - 'outerBoundaryIs': ol.format.GML2.prototype.outerBoundaryIsParser_ + 'innerBoundaryIs': _ol_format_GML2_.prototype.innerBoundaryIsParser_, + 'outerBoundaryIs': _ol_format_GML2_.prototype.outerBoundaryIsParser_ } }; @@ -166,10 +167,10 @@ ol.format.GML2.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.prototype.BOX_PARSERS_ = { +_ol_format_GML2_.prototype.BOX_PARSERS_ = { 'http://www.opengis.net/gml': { - 'coordinates': ol.xml.makeArrayPusher( - ol.format.GML2.prototype.readFlatCoordinates_) + 'coordinates': _ol_xml_.makeArrayPusher( + _ol_format_GML2_.prototype.readFlatCoordinates_) } }; @@ -179,21 +180,21 @@ ol.format.GML2.prototype.BOX_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.prototype.GEOMETRY_PARSERS_ = { +_ol_format_GML2_.prototype.GEOMETRY_PARSERS_ = { 'http://www.opengis.net/gml': { - 'Point': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPoint), - 'MultiPoint': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiPoint), - 'LineString': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readLineString), - 'MultiLineString': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiLineString), - 'LinearRing': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readLinearRing), - 'Polygon': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPolygon), - 'MultiPolygon': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiPolygon), - 'Box': ol.xml.makeReplacer(ol.format.GML2.prototype.readBox_) + 'Point': _ol_xml_.makeReplacer(_ol_format_GMLBase_.prototype.readPoint), + 'MultiPoint': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiPoint), + 'LineString': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readLineString), + 'MultiLineString': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiLineString), + 'LinearRing': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readLinearRing), + 'Polygon': _ol_xml_.makeReplacer(_ol_format_GMLBase_.prototype.readPolygon), + 'MultiPolygon': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiPolygon), + 'Box': _ol_xml_.makeReplacer(_ol_format_GML2_.prototype.readBox_) } }; @@ -206,7 +207,7 @@ ol.format.GML2.prototype.GEOMETRY_PARSERS_ = { * @return {Node|undefined} Node. * @private */ -ol.format.GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML2_.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; var multiSurface = context['multiSurface']; var surface = context['surface']; @@ -224,7 +225,7 @@ ol.format.GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o } else { nodeName = 'Envelope'; } - return ol.xml.createElementNS('http://www.opengis.net/gml', + return _ol_xml_.createElementNS('http://www.opengis.net/gml', nodeName); }; @@ -234,7 +235,7 @@ ol.format.GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o * @param {ol.Feature} feature Feature. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML2.prototype.writeFeatureElement = function(node, feature, objectStack) { +_ol_format_GML2_.prototype.writeFeatureElement = function(node, feature, objectStack) { var fid = feature.getId(); if (fid) { node.setAttribute('fid', fid); @@ -253,24 +254,24 @@ ol.format.GML2.prototype.writeFeatureElement = function(node, feature, objectSta if (value !== null) { keys.push(key); values.push(value); - if (key == geometryName || value instanceof ol.geom.Geometry) { + if (key == geometryName || value instanceof _ol_geom_Geometry_) { if (!(key in context.serializers[featureNS])) { - context.serializers[featureNS][key] = ol.xml.makeChildAppender( + context.serializers[featureNS][key] = _ol_xml_.makeChildAppender( this.writeGeometryElement, this); } } else { if (!(key in context.serializers[featureNS])) { - context.serializers[featureNS][key] = ol.xml.makeChildAppender( - ol.format.XSD.writeStringTextNode); + context.serializers[featureNS][key] = _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeStringTextNode); } } } } - var item = ol.obj.assign({}, context); + var item = _ol_obj_.assign({}, context); item.node = node; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (item), context.serializers, - ol.xml.makeSimpleNodeFactory(undefined, featureNS), + _ol_xml_.makeSimpleNodeFactory(undefined, featureNS), values, objectStack, keys); }; @@ -281,24 +282,24 @@ ol.format.GML2.prototype.writeFeatureElement = function(node, feature, objectSta * @param {ol.geom.Geometry|ol.Extent} geometry Geometry. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML2.prototype.writeGeometryElement = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeGeometryElement = function(node, geometry, objectStack) { var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]); - var item = ol.obj.assign({}, context); + var item = _ol_obj_.assign({}, context); item.node = node; var value; if (Array.isArray(geometry)) { if (context.dataProjection) { - value = ol.proj.transformExtent( + value = _ol_proj_.transformExtent( geometry, context.featureProjection, context.dataProjection); } else { value = geometry; } } else { value = - ol.format.Feature.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context); + _ol_format_Feature_.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context); } - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ - (item), ol.format.GML2.GEOMETRY_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + (item), _ol_format_GML2_.GEOMETRY_SERIALIZERS_, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, undefined, this); }; @@ -310,7 +311,7 @@ ol.format.GML2.prototype.writeGeometryElement = function(node, geometry, objectS * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (node.nodeName !== 'LineStringSegment' && srsName) { @@ -322,7 +323,7 @@ ol.format.GML2.prototype.writeCurveOrLineString_ = function(node, geometry, obje node.appendChild(coordinates); this.writeCoordinates_(coordinates, geometry, objectStack); } else if (node.nodeName === 'Curve') { - var segments = ol.xml.createElementNS(node.namespaceURI, 'segments'); + var segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments'); node.appendChild(segments); this.writeCurveSegments_(segments, geometry, objectStack); @@ -335,8 +336,8 @@ ol.format.GML2.prototype.writeCurveOrLineString_ = function(node, geometry, obje * @returns {Node} coordinates node. * @private */ -ol.format.GML2.prototype.createCoordinatesNode_ = function(namespaceURI) { - var coordinates = ol.xml.createElementNS(namespaceURI, 'coordinates'); +_ol_format_GML2_.prototype.createCoordinatesNode_ = function(namespaceURI) { + var coordinates = _ol_xml_.createElementNS(namespaceURI, 'coordinates'); coordinates.setAttribute('decimal', '.'); coordinates.setAttribute('cs', ','); coordinates.setAttribute('ts', ' '); @@ -351,7 +352,7 @@ ol.format.GML2.prototype.createCoordinatesNode_ = function(namespaceURI) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) { +_ol_format_GML2_.prototype.writeCoordinates_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -364,7 +365,7 @@ ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) point = points[i]; parts[i] = this.getCoords_(point, srsName, hasZ); } - ol.format.XSD.writeStringTextNode(node, parts.join(' ')); + _ol_format_XSD_.writeStringTextNode(node, parts.join(' ')); }; @@ -374,8 +375,8 @@ ol.format.GML2.prototype.writeCoordinates_ = function(node, value, objectStack) * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, +_ol_format_GML2_.prototype.writeCurveSegments_ = function(node, line, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'LineStringSegment'); node.appendChild(child); this.writeCurveOrLineString_(child, line, objectStack); @@ -388,7 +389,7 @@ ol.format.GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -397,13 +398,13 @@ ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec } if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') { var rings = geometry.getLinearRings(); - ol.xml.pushSerializeAndPop( + _ol_xml_.pushSerializeAndPop( {node: node, hasZ: hasZ, srsName: srsName}, - ol.format.GML2.RING_SERIALIZERS_, + _ol_format_GML2_.RING_SERIALIZERS_, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this); } else if (node.nodeName === 'Surface') { - var patches = ol.xml.createElementNS(node.namespaceURI, 'patches'); + var patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches'); node.appendChild(patches); this.writeSurfacePatches_( patches, geometry, objectStack); @@ -418,14 +419,14 @@ ol.format.GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec * @return {Node} Node. * @private */ -ol.format.GML2.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML2_.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; var parentNode = context.node; var exteriorWritten = context['exteriorWritten']; if (exteriorWritten === undefined) { context['exteriorWritten'] = true; } - return ol.xml.createElementNS(parentNode.namespaceURI, + return _ol_xml_.createElementNS(parentNode.namespaceURI, exteriorWritten !== undefined ? 'innerBoundaryIs' : 'outerBoundaryIs'); }; @@ -436,8 +437,8 @@ ol.format.GML2.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_n * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, 'PolygonPatch'); +_ol_format_GML2_.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch'); node.appendChild(child); this.writeSurfaceOrPolygon_(child, polygon, objectStack); }; @@ -449,8 +450,8 @@ ol.format.GML2.prototype.writeSurfacePatches_ = function(node, polygon, objectSt * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeRing_ = function(node, ring, objectStack) { - var linearRing = ol.xml.createElementNS(node.namespaceURI, 'LinearRing'); +_ol_format_GML2_.prototype.writeRing_ = function(node, ring, objectStack) { + var linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing'); node.appendChild(linearRing); this.writeLinearRing_(linearRing, ring, objectStack); }; @@ -463,10 +464,10 @@ ol.format.GML2.prototype.writeRing_ = function(node, ring, objectStack) { * @return {string} The coords string. * @private */ -ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { +_ol_format_GML2_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { var axisOrientation = 'enu'; if (opt_srsName) { - axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation(); + axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation(); } var coords = ((axisOrientation.substr(0, 2) === 'en') ? point[0] + ',' + point[1] : @@ -487,7 +488,7 @@ ol.format.GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -496,8 +497,8 @@ ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, node.setAttribute('srsName', srsName); } var lines = geometry.getLineStrings(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, - ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, + _ol_format_GML2_.LINESTRINGORCURVEMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this); }; @@ -509,7 +510,7 @@ ol.format.GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writePoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -520,7 +521,7 @@ ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { node.appendChild(coordinates); var point = geometry.getCoordinates(); var coord = this.getCoords_(point, srsName, hasZ); - ol.format.XSD.writeStringTextNode(coordinates, coord); + _ol_format_XSD_.writeStringTextNode(coordinates, coord); }; @@ -530,7 +531,7 @@ ol.format.GML2.prototype.writePoint_ = function(node, geometry, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeMultiPoint_ = function(node, geometry, +_ol_format_GML2_.prototype.writeMultiPoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; @@ -539,9 +540,9 @@ ol.format.GML2.prototype.writeMultiPoint_ = function(node, geometry, node.setAttribute('srsName', srsName); } var points = geometry.getPoints(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, - ol.format.GML2.POINTMEMBER_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('pointMember'), points, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, + _ol_format_GML2_.POINTMEMBER_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this); }; @@ -552,8 +553,8 @@ ol.format.GML2.prototype.writeMultiPoint_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writePointMember_ = function(node, point, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, 'Point'); +_ol_format_GML2_.prototype.writePointMember_ = function(node, point, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'Point'); node.appendChild(child); this.writePoint_(child, point, objectStack); }; @@ -565,7 +566,7 @@ ol.format.GML2.prototype.writePointMember_ = function(node, point, objectStack) * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) { +_ol_format_GML2_.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) { var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); if (child) { node.appendChild(child); @@ -580,7 +581,7 @@ ol.format.GML2.prototype.writeLineStringOrCurveMember_ = function(node, line, ob * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeLinearRing_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (srsName) { @@ -598,7 +599,7 @@ ol.format.GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { +_ol_format_GML2_.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -607,8 +608,8 @@ ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, node.setAttribute('srsName', srsName); } var polygons = geometry.getPolygons(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, - ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, + _ol_format_GML2_.SURFACEORPOLYGONMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this); }; @@ -620,7 +621,7 @@ ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) { +_ol_format_GML2_.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) { var child = this.GEOMETRY_NODE_FACTORY_( polygon, objectStack); if (child) { @@ -636,7 +637,7 @@ ol.format.GML2.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML2.prototype.writeEnvelope = function(node, extent, objectStack) { +_ol_format_GML2_.prototype.writeEnvelope = function(node, extent, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (srsName) { @@ -644,9 +645,9 @@ ol.format.GML2.prototype.writeEnvelope = function(node, extent, objectStack) { } var keys = ['lowerCorner', 'upperCorner']; var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]]; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ - ({node: node}), ol.format.GML2.ENVELOPE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + ({node: node}), _ol_format_GML2_.ENVELOPE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this); }; @@ -657,31 +658,31 @@ ol.format.GML2.prototype.writeEnvelope = function(node, extent, objectStack) { * @type {Object.>} * @private */ -ol.format.GML2.GEOMETRY_SERIALIZERS_ = { +_ol_format_GML2_.GEOMETRY_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'Curve': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeCurveOrLineString_), - 'MultiCurve': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeMultiCurveOrLineString_), - 'Point': ol.xml.makeChildAppender(ol.format.GML2.prototype.writePoint_), - 'MultiPoint': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeMultiPoint_), - 'LineString': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeCurveOrLineString_), - 'MultiLineString': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeMultiCurveOrLineString_), - 'LinearRing': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeLinearRing_), - 'Polygon': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeSurfaceOrPolygon_), - 'MultiPolygon': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_), - 'Surface': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeSurfaceOrPolygon_), - 'MultiSurface': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeMultiSurfaceOrPolygon_), - 'Envelope': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeEnvelope) + 'Curve': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeCurveOrLineString_), + 'MultiCurve': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeMultiCurveOrLineString_), + 'Point': _ol_xml_.makeChildAppender(_ol_format_GML2_.prototype.writePoint_), + 'MultiPoint': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeMultiPoint_), + 'LineString': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeCurveOrLineString_), + 'MultiLineString': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeMultiCurveOrLineString_), + 'LinearRing': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeLinearRing_), + 'Polygon': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeSurfaceOrPolygon_), + 'MultiPolygon': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeMultiSurfaceOrPolygon_), + 'Surface': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeSurfaceOrPolygon_), + 'MultiSurface': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeMultiSurfaceOrPolygon_), + 'Envelope': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeEnvelope) } }; @@ -690,10 +691,10 @@ ol.format.GML2.GEOMETRY_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.RING_SERIALIZERS_ = { +_ol_format_GML2_.RING_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'outerBoundaryIs': ol.xml.makeChildAppender(ol.format.GML2.prototype.writeRing_), - 'innerBoundaryIs': ol.xml.makeChildAppender(ol.format.GML2.prototype.writeRing_) + 'outerBoundaryIs': _ol_xml_.makeChildAppender(_ol_format_GML2_.prototype.writeRing_), + 'innerBoundaryIs': _ol_xml_.makeChildAppender(_ol_format_GML2_.prototype.writeRing_) } }; @@ -702,10 +703,10 @@ ol.format.GML2.RING_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.POINTMEMBER_SERIALIZERS_ = { +_ol_format_GML2_.POINTMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'pointMember': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writePointMember_) + 'pointMember': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writePointMember_) } }; @@ -714,12 +715,12 @@ ol.format.GML2.POINTMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { +_ol_format_GML2_.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'lineStringMember': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeLineStringOrCurveMember_), - 'curveMember': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeLineStringOrCurveMember_) + 'lineStringMember': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeLineStringOrCurveMember_), + 'curveMember': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeLineStringOrCurveMember_) } }; @@ -732,10 +733,10 @@ ol.format.GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { * @return {Node|undefined} Node. * @private */ -ol.format.GML2.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML2_.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var parentNode = objectStack[objectStack.length - 1].node; - return ol.xml.createElementNS('http://www.opengis.net/gml', - ol.format.GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); + return _ol_xml_.createElementNS('http://www.opengis.net/gml', + _ol_format_GML2_.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); }; /** @@ -743,7 +744,7 @@ ol.format.GML2.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, ob * @type {Object.} * @private */ -ol.format.GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { +_ol_format_GML2_.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { 'MultiLineString': 'lineStringMember', 'MultiCurve': 'curveMember', 'MultiPolygon': 'polygonMember', @@ -756,12 +757,12 @@ ol.format.GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { * @type {Object.>} * @private */ -ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { +_ol_format_GML2_.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'surfaceMember': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeSurfaceOrPolygonMember_), - 'polygonMember': ol.xml.makeChildAppender( - ol.format.GML2.prototype.writeSurfaceOrPolygonMember_) + 'surfaceMember': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeSurfaceOrPolygonMember_), + 'polygonMember': _ol_xml_.makeChildAppender( + _ol_format_GML2_.prototype.writeSurfaceOrPolygonMember_) } }; @@ -770,9 +771,10 @@ ol.format.GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML2.ENVELOPE_SERIALIZERS_ = { +_ol_format_GML2_.ENVELOPE_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'lowerCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'upperCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) + 'lowerCorner': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'upperCorner': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode) } }; +export default _ol_format_GML2_; diff --git a/src/ol/format/GML3.js b/src/ol/format/GML3.js index 6a3542e177..0c5490ec1d 100644 --- a/src/ol/format/GML3.js +++ b/src/ol/format/GML3.js @@ -1,21 +1,21 @@ -goog.provide('ol.format.GML3'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.format.Feature'); -goog.require('ol.format.GMLBase'); -goog.require('ol.format.XSD'); -goog.require('ol.geom.Geometry'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +/** + * @module ol/format/GML3 + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_GMLBase_ from '../format/GMLBase.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -29,11 +29,11 @@ goog.require('ol.xml'); * @extends {ol.format.GMLBase} * @api */ -ol.format.GML3 = function(opt_options) { +var _ol_format_GML3_ = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ (opt_options ? opt_options : {}); - ol.format.GMLBase.call(this, options); + _ol_format_GMLBase_.call(this, options); /** * @private @@ -65,7 +65,7 @@ ol.format.GML3 = function(opt_options) { * @inheritDoc */ this.schemaLocation = options.schemaLocation ? - options.schemaLocation : ol.format.GML3.schemaLocation_; + options.schemaLocation : _ol_format_GML3_.schemaLocation_; /** * @private @@ -75,7 +75,8 @@ ol.format.GML3 = function(opt_options) { options.hasZ : false; }; -ol.inherits(ol.format.GML3, ol.format.GMLBase); + +_ol_.inherits(_ol_format_GML3_, _ol_format_GMLBase_); /** @@ -83,7 +84,7 @@ ol.inherits(ol.format.GML3, ol.format.GMLBase); * @type {string} * @private */ -ol.format.GML3.schemaLocation_ = ol.format.GMLBase.GMLNS + +_ol_format_GML3_.schemaLocation_ = _ol_format_GMLBase_.GMLNS + ' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' + '1.0.0/gmlsf.xsd'; @@ -94,12 +95,12 @@ ol.format.GML3.schemaLocation_ = ol.format.GMLBase.GMLNS + * @private * @return {ol.geom.MultiLineString|undefined} MultiLineString. */ -ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) { +_ol_format_GML3_.prototype.readMultiCurve_ = function(node, objectStack) { /** @type {Array.} */ - var lineStrings = ol.xml.pushParseAndPop([], + var lineStrings = _ol_xml_.pushParseAndPop([], this.MULTICURVE_PARSERS_, node, objectStack, this); if (lineStrings) { - var multiLineString = new ol.geom.MultiLineString(null); + var multiLineString = new _ol_geom_MultiLineString_(null); multiLineString.setLineStrings(lineStrings); return multiLineString; } else { @@ -114,12 +115,12 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) { * @private * @return {ol.geom.MultiPolygon|undefined} MultiPolygon. */ -ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) { +_ol_format_GML3_.prototype.readMultiSurface_ = function(node, objectStack) { /** @type {Array.} */ - var polygons = ol.xml.pushParseAndPop([], + var polygons = _ol_xml_.pushParseAndPop([], this.MULTISURFACE_PARSERS_, node, objectStack, this); if (polygons) { - var multiPolygon = new ol.geom.MultiPolygon(null); + var multiPolygon = new _ol_geom_MultiPolygon_(null); multiPolygon.setPolygons(polygons); return multiPolygon; } else { @@ -133,8 +134,8 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) { - ol.xml.parseNode(this.CURVEMEMBER_PARSERS_, node, objectStack, this); +_ol_format_GML3_.prototype.curveMemberParser_ = function(node, objectStack) { + _ol_xml_.parseNode(this.CURVEMEMBER_PARSERS_, node, objectStack, this); }; @@ -143,8 +144,8 @@ ol.format.GML3.prototype.curveMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) { - ol.xml.parseNode(this.SURFACEMEMBER_PARSERS_, +_ol_format_GML3_.prototype.surfaceMemberParser_ = function(node, objectStack) { + _ol_xml_.parseNode(this.SURFACEMEMBER_PARSERS_, node, objectStack, this); }; @@ -155,8 +156,8 @@ ol.format.GML3.prototype.surfaceMemberParser_ = function(node, objectStack) { * @private * @return {Array.<(Array.)>|undefined} flat coordinates. */ -ol.format.GML3.prototype.readPatch_ = function(node, objectStack) { - return ol.xml.pushParseAndPop([null], +_ol_format_GML3_.prototype.readPatch_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop([null], this.PATCHES_PARSERS_, node, objectStack, this); }; @@ -167,8 +168,8 @@ ol.format.GML3.prototype.readPatch_ = function(node, objectStack) { * @private * @return {Array.|undefined} flat coordinates. */ -ol.format.GML3.prototype.readSegment_ = function(node, objectStack) { - return ol.xml.pushParseAndPop([null], +_ol_format_GML3_.prototype.readSegment_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop([null], this.SEGMENTS_PARSERS_, node, objectStack, this); }; @@ -179,8 +180,8 @@ ol.format.GML3.prototype.readSegment_ = function(node, objectStack) { * @private * @return {Array.<(Array.)>|undefined} flat coordinates. */ -ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) { - return ol.xml.pushParseAndPop([null], +_ol_format_GML3_.prototype.readPolygonPatch_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop([null], this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); }; @@ -191,8 +192,8 @@ ol.format.GML3.prototype.readPolygonPatch_ = function(node, objectStack) { * @private * @return {Array.|undefined} flat coordinates. */ -ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) { - return ol.xml.pushParseAndPop([null], +_ol_format_GML3_.prototype.readLineStringSegment_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop([null], this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack, this); }; @@ -203,9 +204,9 @@ ol.format.GML3.prototype.readLineStringSegment_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) { +_ol_format_GML3_.prototype.interiorParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ @@ -220,9 +221,9 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) { +_ol_format_GML3_.prototype.exteriorParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ @@ -238,21 +239,21 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) { * @private * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.GML3.prototype.readSurface_ = function(node, objectStack) { +_ol_format_GML3_.prototype.readSurface_ = function(node, objectStack) { /** @type {Array.>} */ - var flatLinearRings = ol.xml.pushParseAndPop([null], + var flatLinearRings = _ol_xml_.pushParseAndPop([null], this.SURFACE_PARSERS_, node, objectStack, this); if (flatLinearRings && flatLinearRings[0]) { - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); var flatCoordinates = flatLinearRings[0]; var ends = [flatCoordinates.length]; var i, ii; for (i = 1, ii = flatLinearRings.length; i < ii; ++i) { - ol.array.extend(flatCoordinates, flatLinearRings[i]); + _ol_array_.extend(flatCoordinates, flatLinearRings[i]); ends.push(flatCoordinates.length); } polygon.setFlatCoordinates( - ol.geom.GeometryLayout.XYZ, flatCoordinates, ends); + _ol_geom_GeometryLayout_.XYZ, flatCoordinates, ends); return polygon; } else { return undefined; @@ -266,13 +267,13 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) { * @private * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.GML3.prototype.readCurve_ = function(node, objectStack) { +_ol_format_GML3_.prototype.readCurve_ = function(node, objectStack) { /** @type {Array.} */ - var flatCoordinates = ol.xml.pushParseAndPop([null], + var flatCoordinates = _ol_xml_.pushParseAndPop([null], this.CURVE_PARSERS_, node, objectStack, this); if (flatCoordinates) { - var lineString = new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var lineString = new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); return lineString; } else { return undefined; @@ -286,11 +287,11 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) { * @private * @return {ol.Extent|undefined} Envelope. */ -ol.format.GML3.prototype.readEnvelope_ = function(node, objectStack) { +_ol_format_GML3_.prototype.readEnvelope_ = function(node, objectStack) { /** @type {Array.} */ - var flatCoordinates = ol.xml.pushParseAndPop([null], + var flatCoordinates = _ol_xml_.pushParseAndPop([null], this.ENVELOPE_PARSERS_, node, objectStack, this); - return ol.extent.createOrUpdate(flatCoordinates[1][0], + return _ol_extent_.createOrUpdate(flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[2][0], flatCoordinates[2][1]); }; @@ -302,8 +303,8 @@ ol.format.GML3.prototype.readEnvelope_ = function(node, objectStack) { * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) { - var s = ol.xml.getAllTextContent(node, false); +_ol_format_GML3_.prototype.readFlatPos_ = function(node, objectStack) { + var s = _ol_xml_.getAllTextContent(node, false); var re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/; /** @type {Array.} */ var flatCoordinates = []; @@ -319,7 +320,7 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) { var containerSrs = context['srsName']; var axisOrientation = 'enu'; if (containerSrs) { - var proj = ol.proj.get(containerSrs); + var proj = _ol_proj_.get(containerSrs); axisOrientation = proj.getAxisOrientation(); } if (axisOrientation === 'neu') { @@ -348,30 +349,30 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) { * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) { - var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); +_ol_format_GML3_.prototype.readFlatPosList_ = function(node, objectStack) { + var s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var context = objectStack[0]; var containerSrs = context['srsName']; var contextDimension = context['srsDimension']; var axisOrientation = 'enu'; if (containerSrs) { - var proj = ol.proj.get(containerSrs); + var proj = _ol_proj_.get(containerSrs); axisOrientation = proj.getAxisOrientation(); } var coords = s.split(/\s+/); // The "dimension" attribute is from the GML 3.0.1 spec. var dim = 2; if (node.getAttribute('srsDimension')) { - dim = ol.format.XSD.readNonNegativeIntegerString( + dim = _ol_format_XSD_.readNonNegativeIntegerString( node.getAttribute('srsDimension')); } else if (node.getAttribute('dimension')) { - dim = ol.format.XSD.readNonNegativeIntegerString( + dim = _ol_format_XSD_.readNonNegativeIntegerString( node.getAttribute('dimension')); } else if (node.parentNode.getAttribute('srsDimension')) { - dim = ol.format.XSD.readNonNegativeIntegerString( + dim = _ol_format_XSD_.readNonNegativeIntegerString( node.parentNode.getAttribute('srsDimension')); } else if (contextDimension) { - dim = ol.format.XSD.readNonNegativeIntegerString(contextDimension); + dim = _ol_format_XSD_.readNonNegativeIntegerString(contextDimension); } var x, y, z; var flatCoordinates = []; @@ -394,10 +395,10 @@ ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { +_ol_format_GML3_.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { 'http://www.opengis.net/gml': { - 'pos': ol.xml.makeReplacer(ol.format.GML3.prototype.readFlatPos_), - 'posList': ol.xml.makeReplacer(ol.format.GML3.prototype.readFlatPosList_) + 'pos': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readFlatPos_), + 'posList': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readFlatPosList_) } }; @@ -407,10 +408,10 @@ ol.format.GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { +_ol_format_GML3_.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { 'http://www.opengis.net/gml': { - 'interior': ol.format.GML3.prototype.interiorParser_, - 'exterior': ol.format.GML3.prototype.exteriorParser_ + 'interior': _ol_format_GML3_.prototype.interiorParser_, + 'exterior': _ol_format_GML3_.prototype.exteriorParser_ } }; @@ -420,27 +421,27 @@ ol.format.GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.GEOMETRY_PARSERS_ = { +_ol_format_GML3_.prototype.GEOMETRY_PARSERS_ = { 'http://www.opengis.net/gml': { - 'Point': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPoint), - 'MultiPoint': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiPoint), - 'LineString': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readLineString), - 'MultiLineString': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiLineString), - 'LinearRing': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readLinearRing), - 'Polygon': ol.xml.makeReplacer(ol.format.GMLBase.prototype.readPolygon), - 'MultiPolygon': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readMultiPolygon), - 'Surface': ol.xml.makeReplacer(ol.format.GML3.prototype.readSurface_), - 'MultiSurface': ol.xml.makeReplacer( - ol.format.GML3.prototype.readMultiSurface_), - 'Curve': ol.xml.makeReplacer(ol.format.GML3.prototype.readCurve_), - 'MultiCurve': ol.xml.makeReplacer( - ol.format.GML3.prototype.readMultiCurve_), - 'Envelope': ol.xml.makeReplacer(ol.format.GML3.prototype.readEnvelope_) + 'Point': _ol_xml_.makeReplacer(_ol_format_GMLBase_.prototype.readPoint), + 'MultiPoint': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiPoint), + 'LineString': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readLineString), + 'MultiLineString': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiLineString), + 'LinearRing': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readLinearRing), + 'Polygon': _ol_xml_.makeReplacer(_ol_format_GMLBase_.prototype.readPolygon), + 'MultiPolygon': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readMultiPolygon), + 'Surface': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readSurface_), + 'MultiSurface': _ol_xml_.makeReplacer( + _ol_format_GML3_.prototype.readMultiSurface_), + 'Curve': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readCurve_), + 'MultiCurve': _ol_xml_.makeReplacer( + _ol_format_GML3_.prototype.readMultiCurve_), + 'Envelope': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readEnvelope_) } }; @@ -450,12 +451,12 @@ ol.format.GML3.prototype.GEOMETRY_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.MULTICURVE_PARSERS_ = { +_ol_format_GML3_.prototype.MULTICURVE_PARSERS_ = { 'http://www.opengis.net/gml': { - 'curveMember': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.curveMemberParser_), - 'curveMembers': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.curveMemberParser_) + 'curveMember': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.curveMemberParser_), + 'curveMembers': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.curveMemberParser_) } }; @@ -465,12 +466,12 @@ ol.format.GML3.prototype.MULTICURVE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.MULTISURFACE_PARSERS_ = { +_ol_format_GML3_.prototype.MULTISURFACE_PARSERS_ = { 'http://www.opengis.net/gml': { - 'surfaceMember': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.surfaceMemberParser_), - 'surfaceMembers': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.surfaceMemberParser_) + 'surfaceMember': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.surfaceMemberParser_), + 'surfaceMembers': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.surfaceMemberParser_) } }; @@ -480,11 +481,11 @@ ol.format.GML3.prototype.MULTISURFACE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.CURVEMEMBER_PARSERS_ = { +_ol_format_GML3_.prototype.CURVEMEMBER_PARSERS_ = { 'http://www.opengis.net/gml': { - 'LineString': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.readLineString), - 'Curve': ol.xml.makeArrayPusher(ol.format.GML3.prototype.readCurve_) + 'LineString': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.readLineString), + 'Curve': _ol_xml_.makeArrayPusher(_ol_format_GML3_.prototype.readCurve_) } }; @@ -494,10 +495,10 @@ ol.format.GML3.prototype.CURVEMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.SURFACEMEMBER_PARSERS_ = { +_ol_format_GML3_.prototype.SURFACEMEMBER_PARSERS_ = { 'http://www.opengis.net/gml': { - 'Polygon': ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readPolygon), - 'Surface': ol.xml.makeArrayPusher(ol.format.GML3.prototype.readSurface_) + 'Polygon': _ol_xml_.makeArrayPusher(_ol_format_GMLBase_.prototype.readPolygon), + 'Surface': _ol_xml_.makeArrayPusher(_ol_format_GML3_.prototype.readSurface_) } }; @@ -507,9 +508,9 @@ ol.format.GML3.prototype.SURFACEMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.SURFACE_PARSERS_ = { +_ol_format_GML3_.prototype.SURFACE_PARSERS_ = { 'http://www.opengis.net/gml': { - 'patches': ol.xml.makeReplacer(ol.format.GML3.prototype.readPatch_) + 'patches': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readPatch_) } }; @@ -519,9 +520,9 @@ ol.format.GML3.prototype.SURFACE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.CURVE_PARSERS_ = { +_ol_format_GML3_.prototype.CURVE_PARSERS_ = { 'http://www.opengis.net/gml': { - 'segments': ol.xml.makeReplacer(ol.format.GML3.prototype.readSegment_) + 'segments': _ol_xml_.makeReplacer(_ol_format_GML3_.prototype.readSegment_) } }; @@ -531,12 +532,12 @@ ol.format.GML3.prototype.CURVE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.ENVELOPE_PARSERS_ = { +_ol_format_GML3_.prototype.ENVELOPE_PARSERS_ = { 'http://www.opengis.net/gml': { - 'lowerCorner': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.readFlatPosList_), - 'upperCorner': ol.xml.makeArrayPusher( - ol.format.GML3.prototype.readFlatPosList_) + 'lowerCorner': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.readFlatPosList_), + 'upperCorner': _ol_xml_.makeArrayPusher( + _ol_format_GML3_.prototype.readFlatPosList_) } }; @@ -546,10 +547,10 @@ ol.format.GML3.prototype.ENVELOPE_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.PATCHES_PARSERS_ = { +_ol_format_GML3_.prototype.PATCHES_PARSERS_ = { 'http://www.opengis.net/gml': { - 'PolygonPatch': ol.xml.makeReplacer( - ol.format.GML3.prototype.readPolygonPatch_) + 'PolygonPatch': _ol_xml_.makeReplacer( + _ol_format_GML3_.prototype.readPolygonPatch_) } }; @@ -559,10 +560,10 @@ ol.format.GML3.prototype.PATCHES_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.prototype.SEGMENTS_PARSERS_ = { +_ol_format_GML3_.prototype.SEGMENTS_PARSERS_ = { 'http://www.opengis.net/gml': { - 'LineStringSegment': ol.xml.makeReplacer( - ol.format.GML3.prototype.readLineStringSegment_) + 'LineStringSegment': _ol_xml_.makeReplacer( + _ol_format_GML3_.prototype.readLineStringSegment_) } }; @@ -573,7 +574,7 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { +_ol_format_GML3_.prototype.writePos_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsDimension = hasZ ? 3 : 2; @@ -581,7 +582,7 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { var srsName = context['srsName']; var axisOrientation = 'enu'; if (srsName) { - axisOrientation = ol.proj.get(srsName).getAxisOrientation(); + axisOrientation = _ol_proj_.get(srsName).getAxisOrientation(); } var point = value.getCoordinates(); var coords; @@ -596,7 +597,7 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { var z = point[2] || 0; coords += ' ' + z; } - ol.format.XSD.writeStringTextNode(node, coords); + _ol_format_XSD_.writeStringTextNode(node, coords); }; @@ -607,10 +608,10 @@ ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { * @return {string} The coords string. * @private */ -ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { +_ol_format_GML3_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { var axisOrientation = 'enu'; if (opt_srsName) { - axisOrientation = ol.proj.get(opt_srsName).getAxisOrientation(); + axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation(); } var coords = ((axisOrientation.substr(0, 2) === 'en') ? point[0] + ' ' + point[1] : @@ -631,7 +632,7 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { +_ol_format_GML3_.prototype.writePosList_ = function(node, value, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsDimension = hasZ ? 3 : 2; @@ -646,7 +647,7 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { point = points[i]; parts[i] = this.getCoords_(point, srsName, hasZ); } - ol.format.XSD.writeStringTextNode(node, parts.join(' ')); + _ol_format_XSD_.writeStringTextNode(node, parts.join(' ')); }; @@ -656,13 +657,13 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writePoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (srsName) { node.setAttribute('srsName', srsName); } - var pos = ol.xml.createElementNS(node.namespaceURI, 'pos'); + var pos = _ol_xml_.createElementNS(node.namespaceURI, 'pos'); node.appendChild(pos); this.writePos_(pos, geometry, objectStack); }; @@ -672,10 +673,10 @@ ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) { * @type {Object.>} * @private */ -ol.format.GML3.ENVELOPE_SERIALIZERS_ = { +_ol_format_GML3_.ENVELOPE_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'lowerCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'upperCorner': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) + 'lowerCorner': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'upperCorner': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode) } }; @@ -685,7 +686,7 @@ ol.format.GML3.ENVELOPE_SERIALIZERS_ = { * @param {ol.Extent} extent Extent. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { +_ol_format_GML3_.prototype.writeEnvelope = function(node, extent, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (srsName) { @@ -693,9 +694,9 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { } var keys = ['lowerCorner', 'upperCorner']; var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]]; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ - ({node: node}), ol.format.GML3.ENVELOPE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + ({node: node}), _ol_format_GML3_.ENVELOPE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this); }; @@ -707,13 +708,13 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeLinearRing_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (srsName) { node.setAttribute('srsName', srsName); } - var posList = ol.xml.createElementNS(node.namespaceURI, 'posList'); + var posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList'); node.appendChild(posList); this.writePosList_(posList, geometry, objectStack); }; @@ -726,14 +727,14 @@ ol.format.GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack * @return {Node} Node. * @private */ -ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML3_.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; var parentNode = context.node; var exteriorWritten = context['exteriorWritten']; if (exteriorWritten === undefined) { context['exteriorWritten'] = true; } - return ol.xml.createElementNS(parentNode.namespaceURI, + return _ol_xml_.createElementNS(parentNode.namespaceURI, exteriorWritten !== undefined ? 'interior' : 'exterior'); }; @@ -744,7 +745,7 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_n * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -753,13 +754,13 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec } if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') { var rings = geometry.getLinearRings(); - ol.xml.pushSerializeAndPop( + _ol_xml_.pushSerializeAndPop( {node: node, hasZ: hasZ, srsName: srsName}, - ol.format.GML3.RING_SERIALIZERS_, + _ol_format_GML3_.RING_SERIALIZERS_, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this); } else if (node.nodeName === 'Surface') { - var patches = ol.xml.createElementNS(node.namespaceURI, 'patches'); + var patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches'); node.appendChild(patches); this.writeSurfacePatches_( patches, geometry, objectStack); @@ -773,7 +774,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objec * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; if (node.nodeName !== 'LineStringSegment' && srsName) { @@ -781,11 +782,11 @@ ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, obje } if (node.nodeName === 'LineString' || node.nodeName === 'LineStringSegment') { - var posList = ol.xml.createElementNS(node.namespaceURI, 'posList'); + var posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList'); node.appendChild(posList); this.writePosList_(posList, geometry, objectStack); } else if (node.nodeName === 'Curve') { - var segments = ol.xml.createElementNS(node.namespaceURI, 'segments'); + var segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments'); node.appendChild(segments); this.writeCurveSegments_(segments, geometry, objectStack); @@ -799,7 +800,7 @@ ol.format.GML3.prototype.writeCurveOrLineString_ = function(node, geometry, obje * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -808,8 +809,8 @@ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, node.setAttribute('srsName', srsName); } var polygons = geometry.getPolygons(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, - ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface}, + _ol_format_GML3_.SURFACEORPOLYGONMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this); }; @@ -821,7 +822,7 @@ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, +_ol_format_GML3_.prototype.writeMultiPoint_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var srsName = context['srsName']; @@ -830,9 +831,9 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, node.setAttribute('srsName', srsName); } var points = geometry.getPoints(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, - ol.format.GML3.POINTMEMBER_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('pointMember'), points, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName}, + _ol_format_GML3_.POINTMEMBER_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this); }; @@ -843,7 +844,7 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) { var context = objectStack[objectStack.length - 1]; var hasZ = context['hasZ']; var srsName = context['srsName']; @@ -852,8 +853,8 @@ ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, node.setAttribute('srsName', srsName); } var lines = geometry.getLineStrings(); - ol.xml.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, - ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve}, + _ol_format_GML3_.LINESTRINGORCURVEMEMBER_SERIALIZERS_, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this); }; @@ -865,8 +866,8 @@ ol.format.GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeRing_ = function(node, ring, objectStack) { - var linearRing = ol.xml.createElementNS(node.namespaceURI, 'LinearRing'); +_ol_format_GML3_.prototype.writeRing_ = function(node, ring, objectStack) { + var linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing'); node.appendChild(linearRing); this.writeLinearRing_(linearRing, ring, objectStack); }; @@ -878,7 +879,7 @@ ol.format.GML3.prototype.writeRing_ = function(node, ring, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) { +_ol_format_GML3_.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) { var child = this.GEOMETRY_NODE_FACTORY_( polygon, objectStack); if (child) { @@ -894,8 +895,8 @@ ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writePointMember_ = function(node, point, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, 'Point'); +_ol_format_GML3_.prototype.writePointMember_ = function(node, point, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'Point'); node.appendChild(child); this.writePoint_(child, point, objectStack); }; @@ -907,7 +908,7 @@ ol.format.GML3.prototype.writePointMember_ = function(node, point, objectStack) * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) { +_ol_format_GML3_.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) { var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); if (child) { node.appendChild(child); @@ -922,8 +923,8 @@ ol.format.GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, ob * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, 'PolygonPatch'); +_ol_format_GML3_.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch'); node.appendChild(child); this.writeSurfaceOrPolygon_(child, polygon, objectStack); }; @@ -935,8 +936,8 @@ ol.format.GML3.prototype.writeSurfacePatches_ = function(node, polygon, objectSt * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeCurveSegments_ = function(node, line, objectStack) { - var child = ol.xml.createElementNS(node.namespaceURI, +_ol_format_GML3_.prototype.writeCurveSegments_ = function(node, line, objectStack) { + var child = _ol_xml_.createElementNS(node.namespaceURI, 'LineStringSegment'); node.appendChild(child); this.writeCurveOrLineString_(child, line, objectStack); @@ -948,24 +949,24 @@ ol.format.GML3.prototype.writeCurveSegments_ = function(node, line, objectStack) * @param {ol.geom.Geometry|ol.Extent} geometry Geometry. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) { +_ol_format_GML3_.prototype.writeGeometryElement = function(node, geometry, objectStack) { var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]); - var item = ol.obj.assign({}, context); + var item = _ol_obj_.assign({}, context); item.node = node; var value; if (Array.isArray(geometry)) { if (context.dataProjection) { - value = ol.proj.transformExtent( + value = _ol_proj_.transformExtent( geometry, context.featureProjection, context.dataProjection); } else { value = geometry; } } else { value = - ol.format.Feature.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context); + _ol_format_Feature_.transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context); } - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ - (item), ol.format.GML3.GEOMETRY_SERIALIZERS_, + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + (item), _ol_format_GML3_.GEOMETRY_SERIALIZERS_, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, undefined, this); }; @@ -976,7 +977,7 @@ ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectS * @param {ol.Feature} feature Feature. * @param {Array.<*>} objectStack Node stack. */ -ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectStack) { +_ol_format_GML3_.prototype.writeFeatureElement = function(node, feature, objectStack) { var fid = feature.getId(); if (fid) { node.setAttribute('fid', fid); @@ -995,24 +996,24 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta if (value !== null) { keys.push(key); values.push(value); - if (key == geometryName || value instanceof ol.geom.Geometry) { + if (key == geometryName || value instanceof _ol_geom_Geometry_) { if (!(key in context.serializers[featureNS])) { - context.serializers[featureNS][key] = ol.xml.makeChildAppender( + context.serializers[featureNS][key] = _ol_xml_.makeChildAppender( this.writeGeometryElement, this); } } else { if (!(key in context.serializers[featureNS])) { - context.serializers[featureNS][key] = ol.xml.makeChildAppender( - ol.format.XSD.writeStringTextNode); + context.serializers[featureNS][key] = _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeStringTextNode); } } } } - var item = ol.obj.assign({}, context); + var item = _ol_obj_.assign({}, context); item.node = node; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (item), context.serializers, - ol.xml.makeSimpleNodeFactory(undefined, featureNS), + _ol_xml_.makeSimpleNodeFactory(undefined, featureNS), values, objectStack, keys); }; @@ -1024,20 +1025,20 @@ ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectSta * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) { +_ol_format_GML3_.prototype.writeFeatureMembers_ = function(node, features, objectStack) { var context = /** @type {Object} */ (objectStack[objectStack.length - 1]); var featureType = context['featureType']; var featureNS = context['featureNS']; var serializers = {}; serializers[featureNS] = {}; - serializers[featureNS][featureType] = ol.xml.makeChildAppender( + serializers[featureNS][featureType] = _ol_xml_.makeChildAppender( this.writeFeatureElement, this); - var item = ol.obj.assign({}, context); + var item = _ol_obj_.assign({}, context); item.node = node; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ (item), serializers, - ol.xml.makeSimpleNodeFactory(featureType, featureNS), features, + _ol_xml_.makeSimpleNodeFactory(featureType, featureNS), features, objectStack); }; @@ -1046,12 +1047,12 @@ ol.format.GML3.prototype.writeFeatureMembers_ = function(node, features, objectS * @type {Object.>} * @private */ -ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { +_ol_format_GML3_.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'surfaceMember': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeSurfaceOrPolygonMember_), - 'polygonMember': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeSurfaceOrPolygonMember_) + 'surfaceMember': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeSurfaceOrPolygonMember_), + 'polygonMember': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeSurfaceOrPolygonMember_) } }; @@ -1060,10 +1061,10 @@ ol.format.GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.POINTMEMBER_SERIALIZERS_ = { +_ol_format_GML3_.POINTMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'pointMember': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writePointMember_) + 'pointMember': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writePointMember_) } }; @@ -1072,12 +1073,12 @@ ol.format.GML3.POINTMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { +_ol_format_GML3_.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'lineStringMember': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeLineStringOrCurveMember_), - 'curveMember': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeLineStringOrCurveMember_) + 'lineStringMember': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeLineStringOrCurveMember_), + 'curveMember': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeLineStringOrCurveMember_) } }; @@ -1086,10 +1087,10 @@ ol.format.GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.RING_SERIALIZERS_ = { +_ol_format_GML3_.RING_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'exterior': ol.xml.makeChildAppender(ol.format.GML3.prototype.writeRing_), - 'interior': ol.xml.makeChildAppender(ol.format.GML3.prototype.writeRing_) + 'exterior': _ol_xml_.makeChildAppender(_ol_format_GML3_.prototype.writeRing_), + 'interior': _ol_xml_.makeChildAppender(_ol_format_GML3_.prototype.writeRing_) } }; @@ -1098,31 +1099,31 @@ ol.format.GML3.RING_SERIALIZERS_ = { * @type {Object.>} * @private */ -ol.format.GML3.GEOMETRY_SERIALIZERS_ = { +_ol_format_GML3_.GEOMETRY_SERIALIZERS_ = { 'http://www.opengis.net/gml': { - 'Curve': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeCurveOrLineString_), - 'MultiCurve': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeMultiCurveOrLineString_), - 'Point': ol.xml.makeChildAppender(ol.format.GML3.prototype.writePoint_), - 'MultiPoint': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeMultiPoint_), - 'LineString': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeCurveOrLineString_), - 'MultiLineString': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeMultiCurveOrLineString_), - 'LinearRing': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeLinearRing_), - 'Polygon': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeSurfaceOrPolygon_), - 'MultiPolygon': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_), - 'Surface': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeSurfaceOrPolygon_), - 'MultiSurface': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_), - 'Envelope': ol.xml.makeChildAppender( - ol.format.GML3.prototype.writeEnvelope) + 'Curve': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeCurveOrLineString_), + 'MultiCurve': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeMultiCurveOrLineString_), + 'Point': _ol_xml_.makeChildAppender(_ol_format_GML3_.prototype.writePoint_), + 'MultiPoint': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeMultiPoint_), + 'LineString': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeCurveOrLineString_), + 'MultiLineString': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeMultiCurveOrLineString_), + 'LinearRing': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeLinearRing_), + 'Polygon': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeSurfaceOrPolygon_), + 'MultiPolygon': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeMultiSurfaceOrPolygon_), + 'Surface': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeSurfaceOrPolygon_), + 'MultiSurface': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeMultiSurfaceOrPolygon_), + 'Envelope': _ol_xml_.makeChildAppender( + _ol_format_GML3_.prototype.writeEnvelope) } }; @@ -1132,7 +1133,7 @@ ol.format.GML3.GEOMETRY_SERIALIZERS_ = { * @type {Object.} * @private */ -ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { +_ol_format_GML3_.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { 'MultiLineString': 'lineStringMember', 'MultiCurve': 'curveMember', 'MultiPolygon': 'polygonMember', @@ -1148,10 +1149,10 @@ ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = { * @return {Node|undefined} Node. * @private */ -ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML3_.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var parentNode = objectStack[objectStack.length - 1].node; - return ol.xml.createElementNS('http://www.opengis.net/gml', - ol.format.GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); + return _ol_xml_.createElementNS('http://www.opengis.net/gml', + _ol_format_GML3_.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]); }; @@ -1163,7 +1164,7 @@ ol.format.GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, ob * @return {Node|undefined} Node. * @private */ -ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GML3_.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var context = objectStack[objectStack.length - 1]; var multiSurface = context['multiSurface']; var surface = context['surface']; @@ -1184,7 +1185,7 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o } else { nodeName = 'Envelope'; } - return ol.xml.createElementNS('http://www.opengis.net/gml', + return _ol_xml_.createElementNS('http://www.opengis.net/gml', nodeName); }; @@ -1198,14 +1199,14 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o * @override * @api */ -ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { +_ol_format_GML3_.prototype.writeGeometryNode = function(geometry, opt_options) { opt_options = this.adaptOptions(opt_options); - var geom = ol.xml.createElementNS('http://www.opengis.net/gml', 'geom'); + var geom = _ol_xml_.createElementNS('http://www.opengis.net/gml', 'geom'); var context = {node: geom, hasZ: this.hasZ, srsName: this.srsName, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; if (opt_options) { - ol.obj.assign(context, opt_options); + _ol_obj_.assign(context, opt_options); } this.writeGeometryElement(geom, geometry, [context]); return geom; @@ -1221,7 +1222,7 @@ ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { * @return {string} Result. * @api */ -ol.format.GML3.prototype.writeFeatures; +_ol_format_GML3_.prototype.writeFeatures; /** @@ -1233,11 +1234,11 @@ ol.format.GML3.prototype.writeFeatures; * @override * @api */ -ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { +_ol_format_GML3_.prototype.writeFeaturesNode = function(features, opt_options) { opt_options = this.adaptOptions(opt_options); - var node = ol.xml.createElementNS('http://www.opengis.net/gml', + var node = _ol_xml_.createElementNS('http://www.opengis.net/gml', 'featureMembers'); - ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', + _ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', this.schemaLocation); var context = { srsName: this.srsName, @@ -1250,8 +1251,9 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { featureType: this.featureType }; if (opt_options) { - ol.obj.assign(context, opt_options); + _ol_obj_.assign(context, opt_options); } this.writeFeatureMembers_(node, features, [context]); return node; }; +export default _ol_format_GML3_; diff --git a/src/ol/format/GMLBase.js b/src/ol/format/GMLBase.js index 2d68b65aa7..14be28588e 100644 --- a/src/ol/format/GMLBase.js +++ b/src/ol/format/GMLBase.js @@ -1,25 +1,25 @@ +/** + * @module ol/format/GMLBase + */ // FIXME Envelopes should not be treated as geometries! readEnvelope_ is part // of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect // envelopes/extents, only geometries! -goog.provide('ol.format.GMLBase'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_LinearRing_ from '../geom/LinearRing.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -36,7 +36,7 @@ goog.require('ol.xml'); * Optional configuration object. * @extends {ol.format.XMLFeature} */ -ol.format.GMLBase = function(opt_options) { +var _ol_format_GMLBase_ = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ (opt_options ? opt_options : {}); @@ -68,23 +68,24 @@ ol.format.GMLBase = function(opt_options) { * @type {Object.>} */ this.FEATURE_COLLECTION_PARSERS = {}; - this.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS] = { - 'featureMember': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readFeaturesInternal), - 'featureMembers': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readFeaturesInternal) + this.FEATURE_COLLECTION_PARSERS[_ol_format_GMLBase_.GMLNS] = { + 'featureMember': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readFeaturesInternal), + 'featureMembers': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readFeaturesInternal) }; - ol.format.XMLFeature.call(this); + _ol_format_XMLFeature_.call(this); }; -ol.inherits(ol.format.GMLBase, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_GMLBase_, _ol_format_XMLFeature_); /** * @const * @type {string} */ -ol.format.GMLBase.GMLNS = 'http://www.opengis.net/gml'; +_ol_format_GMLBase_.GMLNS = 'http://www.opengis.net/gml'; /** @@ -99,7 +100,7 @@ ol.format.GMLBase.GMLNS = 'http://www.opengis.net/gml'; * @type {RegExp} * @private */ -ol.format.GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/; +_ol_format_GMLBase_.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/; /** @@ -107,16 +108,16 @@ ol.format.GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/; * @param {Array.<*>} objectStack Object stack. * @return {Array. | undefined} Features. */ -ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readFeaturesInternal = function(node, objectStack) { var localName = node.localName; var features = null; if (localName == 'FeatureCollection') { if (node.namespaceURI === 'http://www.opengis.net/wfs') { - features = ol.xml.pushParseAndPop([], + features = _ol_xml_.pushParseAndPop([], this.FEATURE_COLLECTION_PARSERS, node, objectStack, this); } else { - features = ol.xml.pushParseAndPop(null, + features = _ol_xml_.pushParseAndPop(null, this.FEATURE_COLLECTION_PARSERS, node, objectStack, this); } @@ -171,16 +172,16 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { if (featurePrefix === p) { parsers[featureTypes[i].split(':').pop()] = (localName == 'featureMembers') ? - ol.xml.makeArrayPusher(this.readFeatureElement, this) : - ol.xml.makeReplacer(this.readFeatureElement, this); + _ol_xml_.makeArrayPusher(this.readFeatureElement, this) : + _ol_xml_.makeReplacer(this.readFeatureElement, this); } } parsersNS[featureNS[p]] = parsers; } if (localName == 'featureMember') { - features = ol.xml.pushParseAndPop(undefined, parsersNS, node, objectStack); + features = _ol_xml_.pushParseAndPop(undefined, parsersNS, node, objectStack); } else { - features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack); + features = _ol_xml_.pushParseAndPop([], parsersNS, node, objectStack); } } if (features === null) { @@ -195,16 +196,17 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Geometry|undefined} Geometry. */ -ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readGeometryElement = function(node, objectStack) { var context = /** @type {Object} */ (objectStack[0]); context['srsName'] = node.firstElementChild.getAttribute('srsName'); context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension'); /** @type {ol.geom.Geometry} */ - var geometry = ol.xml.pushParseAndPop(null, + var geometry = _ol_xml_.pushParseAndPop(null, this.GEOMETRY_PARSERS_, node, objectStack, this); if (geometry) { - return /** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions(geometry, false, context)); + return ( + /** @type {ol.geom.Geometry} */ _ol_format_Feature_.transformWithOptions(geometry, false, context) + ); } else { return undefined; } @@ -216,10 +218,10 @@ ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.Feature} Feature. */ -ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readFeatureElement = function(node, objectStack) { var n; var fid = node.getAttribute('fid') || - ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id'); + _ol_xml_.getAttributeNS(node, _ol_format_GMLBase_.GMLNS, 'id'); var values = {}, geometryName; for (n = node.firstElementChild; n; n = n.nextElementSibling) { var localName = n.localName; @@ -229,8 +231,8 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { if (n.childNodes.length === 0 || (n.childNodes.length === 1 && (n.firstChild.nodeType === 3 || n.firstChild.nodeType === 4))) { - var value = ol.xml.getAllTextContent(n, false); - if (ol.format.GMLBase.ONLY_WHITESPACE_RE_.test(value)) { + var value = _ol_xml_.getAllTextContent(n, false); + if (_ol_format_GMLBase_.ONLY_WHITESPACE_RE_.test(value)) { value = undefined; } values[localName] = value; @@ -242,7 +244,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { values[localName] = this.readGeometryElement(n, objectStack); } } - var feature = new ol.Feature(values); + var feature = new _ol_Feature_(values); if (geometryName) { feature.setGeometryName(geometryName); } @@ -258,12 +260,12 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Point|undefined} Point. */ -ol.format.GMLBase.prototype.readPoint = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readPoint = function(node, objectStack) { var flatCoordinates = this.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var point = new ol.geom.Point(null); - point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var point = new _ol_geom_Point_(null); + point.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); return point; } }; @@ -274,12 +276,12 @@ ol.format.GMLBase.prototype.readPoint = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiPoint|undefined} MultiPoint. */ -ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readMultiPoint = function(node, objectStack) { /** @type {Array.>} */ - var coordinates = ol.xml.pushParseAndPop([], + var coordinates = _ol_xml_.pushParseAndPop([], this.MULTIPOINT_PARSERS_, node, objectStack, this); if (coordinates) { - return new ol.geom.MultiPoint(coordinates); + return new _ol_geom_MultiPoint_(coordinates); } else { return undefined; } @@ -291,12 +293,12 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiLineString|undefined} MultiLineString. */ -ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readMultiLineString = function(node, objectStack) { /** @type {Array.} */ - var lineStrings = ol.xml.pushParseAndPop([], + var lineStrings = _ol_xml_.pushParseAndPop([], this.MULTILINESTRING_PARSERS_, node, objectStack, this); if (lineStrings) { - var multiLineString = new ol.geom.MultiLineString(null); + var multiLineString = new _ol_geom_MultiLineString_(null); multiLineString.setLineStrings(lineStrings); return multiLineString; } else { @@ -310,12 +312,12 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.MultiPolygon|undefined} MultiPolygon. */ -ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readMultiPolygon = function(node, objectStack) { /** @type {Array.} */ - var polygons = ol.xml.pushParseAndPop([], + var polygons = _ol_xml_.pushParseAndPop([], this.MULTIPOLYGON_PARSERS_, node, objectStack, this); if (polygons) { - var multiPolygon = new ol.geom.MultiPolygon(null); + var multiPolygon = new _ol_geom_MultiPolygon_(null); multiPolygon.setPolygons(polygons); return multiPolygon; } else { @@ -329,8 +331,8 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) { - ol.xml.parseNode(this.POINTMEMBER_PARSERS_, +_ol_format_GMLBase_.prototype.pointMemberParser_ = function(node, objectStack) { + _ol_xml_.parseNode(this.POINTMEMBER_PARSERS_, node, objectStack, this); }; @@ -340,8 +342,8 @@ ol.format.GMLBase.prototype.pointMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack) { - ol.xml.parseNode(this.LINESTRINGMEMBER_PARSERS_, +_ol_format_GMLBase_.prototype.lineStringMemberParser_ = function(node, objectStack) { + _ol_xml_.parseNode(this.LINESTRINGMEMBER_PARSERS_, node, objectStack, this); }; @@ -351,8 +353,8 @@ ol.format.GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) { - ol.xml.parseNode(this.POLYGONMEMBER_PARSERS_, node, +_ol_format_GMLBase_.prototype.polygonMemberParser_ = function(node, objectStack) { + _ol_xml_.parseNode(this.POLYGONMEMBER_PARSERS_, node, objectStack, this); }; @@ -362,12 +364,12 @@ ol.format.GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.GMLBase.prototype.readLineString = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readLineString = function(node, objectStack) { var flatCoordinates = this.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var lineString = new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var lineString = new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); return lineString; } else { return undefined; @@ -381,8 +383,8 @@ ol.format.GMLBase.prototype.readLineString = function(node, objectStack) { * @private * @return {Array.|undefined} LinearRing flat coordinates. */ -ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) { - var ring = ol.xml.pushParseAndPop(null, +_ol_format_GMLBase_.prototype.readFlatLinearRing_ = function(node, objectStack) { + var ring = _ol_xml_.pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack, this); if (ring) { @@ -398,12 +400,12 @@ ol.format.GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.LinearRing|undefined} LinearRing. */ -ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readLinearRing = function(node, objectStack) { var flatCoordinates = this.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var ring = new ol.geom.LinearRing(null); - ring.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var ring = new _ol_geom_LinearRing_(null); + ring.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); return ring; } else { return undefined; @@ -416,21 +418,21 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) { +_ol_format_GMLBase_.prototype.readPolygon = function(node, objectStack) { /** @type {Array.>} */ - var flatLinearRings = ol.xml.pushParseAndPop([null], + var flatLinearRings = _ol_xml_.pushParseAndPop([null], this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); if (flatLinearRings && flatLinearRings[0]) { - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); var flatCoordinates = flatLinearRings[0]; var ends = [flatCoordinates.length]; var i, ii; for (i = 1, ii = flatLinearRings.length; i < ii; ++i) { - ol.array.extend(flatCoordinates, flatLinearRings[i]); + _ol_array_.extend(flatCoordinates, flatLinearRings[i]); ends.push(flatCoordinates.length); } polygon.setFlatCoordinates( - ol.geom.GeometryLayout.XYZ, flatCoordinates, ends); + _ol_geom_GeometryLayout_.XYZ, flatCoordinates, ends); return polygon; } else { return undefined; @@ -444,8 +446,8 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) { * @private * @return {Array.} Flat coordinates. */ -ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) { - return ol.xml.pushParseAndPop(null, +_ol_format_GMLBase_.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack, this); }; @@ -456,12 +458,12 @@ ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, object * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.MULTIPOINT_PARSERS_ = { +_ol_format_GMLBase_.prototype.MULTIPOINT_PARSERS_ = { 'http://www.opengis.net/gml': { - 'pointMember': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.pointMemberParser_), - 'pointMembers': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.pointMemberParser_) + 'pointMember': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.pointMemberParser_), + 'pointMembers': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.pointMemberParser_) } }; @@ -471,12 +473,12 @@ ol.format.GMLBase.prototype.MULTIPOINT_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.MULTILINESTRING_PARSERS_ = { +_ol_format_GMLBase_.prototype.MULTILINESTRING_PARSERS_ = { 'http://www.opengis.net/gml': { - 'lineStringMember': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.lineStringMemberParser_), - 'lineStringMembers': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.lineStringMemberParser_) + 'lineStringMember': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.lineStringMemberParser_), + 'lineStringMembers': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.lineStringMemberParser_) } }; @@ -486,12 +488,12 @@ ol.format.GMLBase.prototype.MULTILINESTRING_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.MULTIPOLYGON_PARSERS_ = { +_ol_format_GMLBase_.prototype.MULTIPOLYGON_PARSERS_ = { 'http://www.opengis.net/gml': { - 'polygonMember': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.polygonMemberParser_), - 'polygonMembers': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.polygonMemberParser_) + 'polygonMember': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.polygonMemberParser_), + 'polygonMembers': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.polygonMemberParser_) } }; @@ -501,10 +503,10 @@ ol.format.GMLBase.prototype.MULTIPOLYGON_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.POINTMEMBER_PARSERS_ = { +_ol_format_GMLBase_.prototype.POINTMEMBER_PARSERS_ = { 'http://www.opengis.net/gml': { - 'Point': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.readFlatCoordinatesFromNode_) + 'Point': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.readFlatCoordinatesFromNode_) } }; @@ -514,10 +516,10 @@ ol.format.GMLBase.prototype.POINTMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.LINESTRINGMEMBER_PARSERS_ = { +_ol_format_GMLBase_.prototype.LINESTRINGMEMBER_PARSERS_ = { 'http://www.opengis.net/gml': { - 'LineString': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.readLineString) + 'LineString': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.readLineString) } }; @@ -527,10 +529,10 @@ ol.format.GMLBase.prototype.LINESTRINGMEMBER_PARSERS_ = { * @type {Object.>} * @private */ -ol.format.GMLBase.prototype.POLYGONMEMBER_PARSERS_ = { +_ol_format_GMLBase_.prototype.POLYGONMEMBER_PARSERS_ = { 'http://www.opengis.net/gml': { - 'Polygon': ol.xml.makeArrayPusher( - ol.format.GMLBase.prototype.readPolygon) + 'Polygon': _ol_xml_.makeArrayPusher( + _ol_format_GMLBase_.prototype.readPolygon) } }; @@ -540,10 +542,10 @@ ol.format.GMLBase.prototype.POLYGONMEMBER_PARSERS_ = { * @type {Object.>} * @protected */ -ol.format.GMLBase.prototype.RING_PARSERS = { +_ol_format_GMLBase_.prototype.RING_PARSERS = { 'http://www.opengis.net/gml': { - 'LinearRing': ol.xml.makeReplacer( - ol.format.GMLBase.prototype.readFlatLinearRing_) + 'LinearRing': _ol_xml_.makeReplacer( + _ol_format_GMLBase_.prototype.readFlatLinearRing_) } }; @@ -551,7 +553,7 @@ ol.format.GMLBase.prototype.RING_PARSERS = { /** * @inheritDoc */ -ol.format.GMLBase.prototype.readGeometryFromNode = function(node, opt_options) { +_ol_format_GMLBase_.prototype.readGeometryFromNode = function(node, opt_options) { var geometry = this.readGeometryElement(node, [this.getReadOptions(node, opt_options ? opt_options : {})]); return geometry ? geometry : null; @@ -567,19 +569,19 @@ ol.format.GMLBase.prototype.readGeometryFromNode = function(node, opt_options) { * @return {Array.} Features. * @api */ -ol.format.GMLBase.prototype.readFeatures; +_ol_format_GMLBase_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.GMLBase.prototype.readFeaturesFromNode = function(node, opt_options) { +_ol_format_GMLBase_.prototype.readFeaturesFromNode = function(node, opt_options) { var options = { featureType: this.featureType, featureNS: this.featureNS }; if (opt_options) { - ol.obj.assign(options, this.getReadOptions(node, opt_options)); + _ol_obj_.assign(options, this.getReadOptions(node, opt_options)); } var features = this.readFeaturesInternal(node, [options]); return features || []; @@ -589,7 +591,8 @@ ol.format.GMLBase.prototype.readFeaturesFromNode = function(node, opt_options) { /** * @inheritDoc */ -ol.format.GMLBase.prototype.readProjectionFromNode = function(node) { - return ol.proj.get(this.srsName ? this.srsName : +_ol_format_GMLBase_.prototype.readProjectionFromNode = function(node) { + return _ol_proj_.get(this.srsName ? this.srsName : node.firstElementChild.getAttribute('srsName')); }; +export default _ol_format_GMLBase_; diff --git a/src/ol/format/GPX.js b/src/ol/format/GPX.js index d9ec341f26..02744f40f2 100644 --- a/src/ol/format/GPX.js +++ b/src/ol/format/GPX.js @@ -1,18 +1,18 @@ -goog.provide('ol.format.GPX'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.array'); -goog.require('ol.format.Feature'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.format.XSD'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.Point'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +/** + * @module ol/format/GPX + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_array_ from '../array.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -23,16 +23,16 @@ goog.require('ol.xml'); * @param {olx.format.GPXOptions=} opt_options Options. * @api */ -ol.format.GPX = function(opt_options) { +var _ol_format_GPX_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.XMLFeature.call(this); + _ol_format_XMLFeature_.call(this); /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get('EPSG:4326'); + this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); /** * @type {function(ol.Feature, Node)|undefined} @@ -40,7 +40,8 @@ ol.format.GPX = function(opt_options) { */ this.readExtensions_ = options.readExtensions; }; -ol.inherits(ol.format.GPX, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_GPX_, _ol_format_XMLFeature_); /** @@ -48,7 +49,7 @@ ol.inherits(ol.format.GPX, ol.format.XMLFeature); * @private * @type {Array.} */ -ol.format.GPX.NAMESPACE_URIS_ = [ +_ol_format_GPX_.NAMESPACE_URIS_ = [ null, 'http://www.topografix.com/GPX/1/0', 'http://www.topografix.com/GPX/1/1' @@ -60,7 +61,7 @@ ol.format.GPX.NAMESPACE_URIS_ = [ * @type {string} * @private */ -ol.format.GPX.SCHEMA_LOCATION_ = 'http://www.topografix.com/GPX/1/1 ' + +_ol_format_GPX_.SCHEMA_LOCATION_ = 'http://www.topografix.com/GPX/1/1 ' + 'http://www.topografix.com/GPX/1/1/gpx.xsd'; @@ -72,7 +73,7 @@ ol.format.GPX.SCHEMA_LOCATION_ = 'http://www.topografix.com/GPX/1/1 ' + * @private * @return {Array.} Flat coordinates. */ -ol.format.GPX.appendCoordinate_ = function(flatCoordinates, layoutOptions, node, values) { +_ol_format_GPX_.appendCoordinate_ = function(flatCoordinates, layoutOptions, node, values) { flatCoordinates.push( parseFloat(node.getAttribute('lon')), parseFloat(node.getAttribute('lat'))); @@ -103,17 +104,17 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, layoutOptions, node, * @param {Array.=} ends Ends. * @return {ol.geom.GeometryLayout} Layout. */ -ol.format.GPX.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, ends) { - var layout = ol.geom.GeometryLayout.XY; +_ol_format_GPX_.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, ends) { + var layout = _ol_geom_GeometryLayout_.XY; var stride = 2; if (layoutOptions.hasZ && layoutOptions.hasM) { - layout = ol.geom.GeometryLayout.XYZM; + layout = _ol_geom_GeometryLayout_.XYZM; stride = 4; } else if (layoutOptions.hasZ) { - layout = ol.geom.GeometryLayout.XYZ; + layout = _ol_geom_GeometryLayout_.XYZ; stride = 3; } else if (layoutOptions.hasM) { - layout = ol.geom.GeometryLayout.XYM; + layout = _ol_geom_GeometryLayout_.XYM; stride = 3; } if (stride !== 4) { @@ -144,13 +145,13 @@ ol.format.GPX.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, end * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.parseLink_ = function(node, objectStack) { +_ol_format_GPX_.parseLink_ = function(node, objectStack) { var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var href = node.getAttribute('href'); if (href !== null) { values['link'] = href; } - ol.xml.parseNode(ol.format.GPX.LINK_PARSERS_, node, objectStack); + _ol_xml_.parseNode(_ol_format_GPX_.LINK_PARSERS_, node, objectStack); }; @@ -159,7 +160,7 @@ ol.format.GPX.parseLink_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.parseExtensions_ = function(node, objectStack) { +_ol_format_GPX_.parseExtensions_ = function(node, objectStack) { var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); values['extensionsNode_'] = node; }; @@ -170,16 +171,16 @@ ol.format.GPX.parseExtensions_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.parseRtePt_ = function(node, objectStack) { - var values = ol.xml.pushParseAndPop( - {}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack); +_ol_format_GPX_.parseRtePt_ = function(node, objectStack) { + var values = _ol_xml_.pushParseAndPop( + {}, _ol_format_GPX_.RTEPT_PARSERS_, node, objectStack); if (values) { var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (rteValues['flatCoordinates']); var layoutOptions = /** @type {ol.LayoutOptions} */ (rteValues['layoutOptions']); - ol.format.GPX.appendCoordinate_(flatCoordinates, layoutOptions, node, values); + _ol_format_GPX_.appendCoordinate_(flatCoordinates, layoutOptions, node, values); } }; @@ -189,16 +190,16 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.parseTrkPt_ = function(node, objectStack) { - var values = ol.xml.pushParseAndPop( - {}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack); +_ol_format_GPX_.parseTrkPt_ = function(node, objectStack) { + var values = _ol_xml_.pushParseAndPop( + {}, _ol_format_GPX_.TRKPT_PARSERS_, node, objectStack); if (values) { var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (trkValues['flatCoordinates']); var layoutOptions = /** @type {ol.LayoutOptions} */ (trkValues['layoutOptions']); - ol.format.GPX.appendCoordinate_(flatCoordinates, layoutOptions, node, values); + _ol_format_GPX_.appendCoordinate_(flatCoordinates, layoutOptions, node, values); } }; @@ -208,9 +209,9 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.parseTrkSeg_ = function(node, objectStack) { +_ol_format_GPX_.parseTrkSeg_ = function(node, objectStack) { var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); - ol.xml.parseNode(ol.format.GPX.TRKSEG_PARSERS_, node, objectStack); + _ol_xml_.parseNode(_ol_format_GPX_.TRKSEG_PARSERS_, node, objectStack); var flatCoordinates = /** @type {Array.} */ (values['flatCoordinates']); var ends = /** @type {Array.} */ (values['ends']); @@ -224,12 +225,12 @@ ol.format.GPX.parseTrkSeg_ = function(node, objectStack) { * @private * @return {ol.Feature|undefined} Track. */ -ol.format.GPX.readRte_ = function(node, objectStack) { +_ol_format_GPX_.readRte_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); - var values = ol.xml.pushParseAndPop({ + var values = _ol_xml_.pushParseAndPop({ 'flatCoordinates': [], 'layoutOptions': {} - }, ol.format.GPX.RTE_PARSERS_, node, objectStack); + }, _ol_format_GPX_.RTE_PARSERS_, node, objectStack); if (!values) { return undefined; } @@ -238,11 +239,11 @@ ol.format.GPX.readRte_ = function(node, objectStack) { delete values['flatCoordinates']; var layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']); delete values['layoutOptions']; - var layout = ol.format.GPX.applyLayoutOptions_(layoutOptions, flatCoordinates); - var geometry = new ol.geom.LineString(null); + var layout = _ol_format_GPX_.applyLayoutOptions_(layoutOptions, flatCoordinates); + var geometry = new _ol_geom_LineString_(null); geometry.setFlatCoordinates(layout, flatCoordinates); - ol.format.Feature.transformWithOptions(geometry, false, options); - var feature = new ol.Feature(geometry); + _ol_format_Feature_.transformWithOptions(geometry, false, options); + var feature = new _ol_Feature_(geometry); feature.setProperties(values); return feature; }; @@ -254,13 +255,13 @@ ol.format.GPX.readRte_ = function(node, objectStack) { * @private * @return {ol.Feature|undefined} Track. */ -ol.format.GPX.readTrk_ = function(node, objectStack) { +_ol_format_GPX_.readTrk_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); - var values = ol.xml.pushParseAndPop({ + var values = _ol_xml_.pushParseAndPop({ 'flatCoordinates': [], 'ends': [], 'layoutOptions': {} - }, ol.format.GPX.TRK_PARSERS_, node, objectStack); + }, _ol_format_GPX_.TRK_PARSERS_, node, objectStack); if (!values) { return undefined; } @@ -271,11 +272,11 @@ ol.format.GPX.readTrk_ = function(node, objectStack) { delete values['ends']; var layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']); delete values['layoutOptions']; - var layout = ol.format.GPX.applyLayoutOptions_(layoutOptions, flatCoordinates, ends); - var geometry = new ol.geom.MultiLineString(null); + var layout = _ol_format_GPX_.applyLayoutOptions_(layoutOptions, flatCoordinates, ends); + var geometry = new _ol_geom_MultiLineString_(null); geometry.setFlatCoordinates(layout, flatCoordinates, ends); - ol.format.Feature.transformWithOptions(geometry, false, options); - var feature = new ol.Feature(geometry); + _ol_format_Feature_.transformWithOptions(geometry, false, options); + var feature = new _ol_Feature_(geometry); feature.setProperties(values); return feature; }; @@ -287,19 +288,19 @@ ol.format.GPX.readTrk_ = function(node, objectStack) { * @private * @return {ol.Feature|undefined} Waypoint. */ -ol.format.GPX.readWpt_ = function(node, objectStack) { +_ol_format_GPX_.readWpt_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); - var values = ol.xml.pushParseAndPop( - {}, ol.format.GPX.WPT_PARSERS_, node, objectStack); + var values = _ol_xml_.pushParseAndPop( + {}, _ol_format_GPX_.WPT_PARSERS_, node, objectStack); if (!values) { return undefined; } var layoutOptions = /** @type {ol.LayoutOptions} */ ({}); - var coordinates = ol.format.GPX.appendCoordinate_([], layoutOptions, node, values); - var layout = ol.format.GPX.applyLayoutOptions_(layoutOptions, coordinates); - var geometry = new ol.geom.Point(coordinates, layout); - ol.format.Feature.transformWithOptions(geometry, false, options); - var feature = new ol.Feature(geometry); + var coordinates = _ol_format_GPX_.appendCoordinate_([], layoutOptions, node, values); + var layout = _ol_format_GPX_.applyLayoutOptions_(layoutOptions, coordinates); + var geometry = new _ol_geom_Point_(coordinates, layout); + _ol_format_Feature_.transformWithOptions(geometry, false, options); + var feature = new _ol_Feature_(geometry); feature.setProperties(values); return feature; }; @@ -310,10 +311,10 @@ ol.format.GPX.readWpt_ = function(node, objectStack) { * @type {Object.): (ol.Feature|undefined)>} * @private */ -ol.format.GPX.FEATURE_READER_ = { - 'rte': ol.format.GPX.readRte_, - 'trk': ol.format.GPX.readTrk_, - 'wpt': ol.format.GPX.readWpt_ +_ol_format_GPX_.FEATURE_READER_ = { + 'rte': _ol_format_GPX_.readRte_, + 'trk': _ol_format_GPX_.readTrk_, + 'wpt': _ol_format_GPX_.readWpt_ }; @@ -322,11 +323,11 @@ ol.format.GPX.FEATURE_READER_ = { * @type {Object.>} * @private */ -ol.format.GPX.GPX_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'rte': ol.xml.makeArrayPusher(ol.format.GPX.readRte_), - 'trk': ol.xml.makeArrayPusher(ol.format.GPX.readTrk_), - 'wpt': ol.xml.makeArrayPusher(ol.format.GPX.readWpt_) +_ol_format_GPX_.GPX_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'rte': _ol_xml_.makeArrayPusher(_ol_format_GPX_.readRte_), + 'trk': _ol_xml_.makeArrayPusher(_ol_format_GPX_.readTrk_), + 'wpt': _ol_xml_.makeArrayPusher(_ol_format_GPX_.readWpt_) }); @@ -335,12 +336,12 @@ ol.format.GPX.GPX_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.LINK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { +_ol_format_GPX_.LINK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { 'text': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'linkText'), + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString, 'linkText'), 'type': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'linkType') + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString, 'linkType') }); @@ -349,18 +350,18 @@ ol.format.GPX.LINK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.RTE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'desc': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'src': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'link': ol.format.GPX.parseLink_, +_ol_format_GPX_.RTE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'cmt': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'desc': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'src': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'link': _ol_format_GPX_.parseLink_, 'number': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger), - 'extensions': ol.format.GPX.parseExtensions_, - 'type': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'rtept': ol.format.GPX.parseRtePt_ + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readNonNegativeInteger), + 'extensions': _ol_format_GPX_.parseExtensions_, + 'type': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'rtept': _ol_format_GPX_.parseRtePt_ }); @@ -369,10 +370,10 @@ ol.format.GPX.RTE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.RTEPT_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime) +_ol_format_GPX_.RTEPT_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'ele': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'time': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDateTime) }); @@ -381,18 +382,18 @@ ol.format.GPX.RTEPT_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.TRK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'desc': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'src': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'link': ol.format.GPX.parseLink_, +_ol_format_GPX_.TRK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'cmt': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'desc': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'src': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'link': _ol_format_GPX_.parseLink_, 'number': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger), - 'type': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'extensions': ol.format.GPX.parseExtensions_, - 'trkseg': ol.format.GPX.parseTrkSeg_ + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readNonNegativeInteger), + 'type': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'extensions': _ol_format_GPX_.parseExtensions_, + 'trkseg': _ol_format_GPX_.parseTrkSeg_ }); @@ -401,9 +402,9 @@ ol.format.GPX.TRK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.TRKSEG_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'trkpt': ol.format.GPX.parseTrkPt_ +_ol_format_GPX_.TRKSEG_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'trkpt': _ol_format_GPX_.parseTrkPt_ }); @@ -412,10 +413,10 @@ ol.format.GPX.TRKSEG_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.TRKPT_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime) +_ol_format_GPX_.TRKPT_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'ele': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'time': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDateTime) }); @@ -424,30 +425,30 @@ ol.format.GPX.TRKPT_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.WPT_PARSERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime), - 'magvar': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'geoidheight': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'desc': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'src': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'link': ol.format.GPX.parseLink_, - 'sym': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'type': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'fix': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'sat': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'hdop': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'vdop': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'pdop': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), +_ol_format_GPX_.WPT_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'ele': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'time': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDateTime), + 'magvar': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'geoidheight': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'cmt': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'desc': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'src': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'link': _ol_format_GPX_.parseLink_, + 'sym': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'type': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'fix': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'sat': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'hdop': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'vdop': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'pdop': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), 'ageofdgpsdata': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), 'dgpsid': - ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger), - 'extensions': ol.format.GPX.parseExtensions_ + _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readNonNegativeInteger), + 'extensions': _ol_format_GPX_.parseExtensions_ }); @@ -455,7 +456,7 @@ ol.format.GPX.WPT_PARSERS_ = ol.xml.makeStructureNS( * @param {Array.} features List of features. * @private */ -ol.format.GPX.prototype.handleReadExtensions_ = function(features) { +_ol_format_GPX_.prototype.handleReadExtensions_ = function(features) { if (!features) { features = []; } @@ -481,17 +482,17 @@ ol.format.GPX.prototype.handleReadExtensions_ = function(features) { * @return {ol.Feature} Feature. * @api */ -ol.format.GPX.prototype.readFeature; +_ol_format_GPX_.prototype.readFeature; /** * @inheritDoc */ -ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) { - if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { +_ol_format_GPX_.prototype.readFeatureFromNode = function(node, opt_options) { + if (!_ol_array_.includes(_ol_format_GPX_.NAMESPACE_URIS_, node.namespaceURI)) { return null; } - var featureReader = ol.format.GPX.FEATURE_READER_[node.localName]; + var featureReader = _ol_format_GPX_.FEATURE_READER_[node.localName]; if (!featureReader) { return null; } @@ -515,19 +516,19 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) { * @return {Array.} Features. * @api */ -ol.format.GPX.prototype.readFeatures; +_ol_format_GPX_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) { - if (!ol.array.includes(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) { +_ol_format_GPX_.prototype.readFeaturesFromNode = function(node, opt_options) { + if (!_ol_array_.includes(_ol_format_GPX_.NAMESPACE_URIS_, node.namespaceURI)) { return []; } if (node.localName == 'gpx') { /** @type {Array.} */ - var features = ol.xml.pushParseAndPop([], ol.format.GPX.GPX_PARSERS_, + var features = _ol_xml_.pushParseAndPop([], _ol_format_GPX_.GPX_PARSERS_, node, [this.getReadOptions(node, opt_options)]); if (features) { this.handleReadExtensions_(features); @@ -548,7 +549,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) { * @return {ol.proj.Projection} Projection. * @api */ -ol.format.GPX.prototype.readProjection; +_ol_format_GPX_.prototype.readProjection; /** @@ -557,7 +558,7 @@ ol.format.GPX.prototype.readProjection; * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.GPX.writeLink_ = function(node, value, objectStack) { +_ol_format_GPX_.writeLink_ = function(node, value, objectStack) { node.setAttribute('href', value); var context = objectStack[objectStack.length - 1]; var properties = context['properties']; @@ -565,9 +566,9 @@ ol.format.GPX.writeLink_ = function(node, value, objectStack) { properties['linkText'], properties['linkType'] ]; - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ({node: node}), - ol.format.GPX.LINK_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, - link, objectStack, ol.format.GPX.LINK_SEQUENCE_); + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ({node: node}), + _ol_format_GPX_.LINK_SERIALIZERS_, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, + link, objectStack, _ol_format_GPX_.LINK_SEQUENCE_); }; @@ -577,27 +578,27 @@ ol.format.GPX.writeLink_ = function(node, value, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) { +_ol_format_GPX_.writeWptType_ = function(node, coordinate, objectStack) { var context = objectStack[objectStack.length - 1]; var parentNode = context.node; var namespaceURI = parentNode.namespaceURI; var properties = context['properties']; //FIXME Projection handling - ol.xml.setAttributeNS(node, null, 'lat', coordinate[1]); - ol.xml.setAttributeNS(node, null, 'lon', coordinate[0]); + _ol_xml_.setAttributeNS(node, null, 'lat', coordinate[1]); + _ol_xml_.setAttributeNS(node, null, 'lon', coordinate[0]); var geometryLayout = context['geometryLayout']; switch (geometryLayout) { - case ol.geom.GeometryLayout.XYZM: + case _ol_geom_GeometryLayout_.XYZM: if (coordinate[3] !== 0) { properties['time'] = coordinate[3]; } // fall through - case ol.geom.GeometryLayout.XYZ: + case _ol_geom_GeometryLayout_.XYZ: if (coordinate[2] !== 0) { properties['ele'] = coordinate[2]; } break; - case ol.geom.GeometryLayout.XYM: + case _ol_geom_GeometryLayout_.XYM: if (coordinate[2] !== 0) { properties['time'] = coordinate[2]; } @@ -606,12 +607,12 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) { // pass } var orderedKeys = (node.nodeName == 'rtept') ? - ol.format.GPX.RTEPT_TYPE_SEQUENCE_[namespaceURI] : - ol.format.GPX.WPT_TYPE_SEQUENCE_[namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + _ol_format_GPX_.RTEPT_TYPE_SEQUENCE_[namespaceURI] : + _ol_format_GPX_.WPT_TYPE_SEQUENCE_[namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ({node: node, 'properties': properties}), - ol.format.GPX.WPT_TYPE_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + _ol_format_GPX_.WPT_TYPE_SERIALIZERS_, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -622,22 +623,22 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.writeRte_ = function(node, feature, objectStack) { +_ol_format_GPX_.writeRte_ = function(node, feature, objectStack) { var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]); var properties = feature.getProperties(); var context = {node: node, 'properties': properties}; var geometry = feature.getGeometry(); if (geometry) { geometry = /** @type {ol.geom.LineString} */ - (ol.format.Feature.transformWithOptions(geometry, true, options)); + (_ol_format_Feature_.transformWithOptions(geometry, true, options)); context['geometryLayout'] = geometry.getLayout(); properties['rtept'] = geometry.getCoordinates(); } var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.GPX.RTE_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, - ol.format.GPX.RTE_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + var orderedKeys = _ol_format_GPX_.RTE_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, + _ol_format_GPX_.RTE_SERIALIZERS_, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -648,7 +649,7 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.writeTrk_ = function(node, feature, objectStack) { +_ol_format_GPX_.writeTrk_ = function(node, feature, objectStack) { var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]); var properties = feature.getProperties(); /** @type {ol.XmlNodeStackItem} */ @@ -656,14 +657,14 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) { var geometry = feature.getGeometry(); if (geometry) { geometry = /** @type {ol.geom.MultiLineString} */ - (ol.format.Feature.transformWithOptions(geometry, true, options)); + (_ol_format_Feature_.transformWithOptions(geometry, true, options)); properties['trkseg'] = geometry.getLineStrings(); } var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.GPX.TRK_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, - ol.format.GPX.TRK_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + var orderedKeys = _ol_format_GPX_.TRK_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, + _ol_format_GPX_.TRK_SERIALIZERS_, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -674,12 +675,12 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.writeTrkSeg_ = function(node, lineString, objectStack) { +_ol_format_GPX_.writeTrkSeg_ = function(node, lineString, objectStack) { /** @type {ol.XmlNodeStackItem} */ var context = {node: node, 'geometryLayout': lineString.getLayout(), 'properties': {}}; - ol.xml.pushSerializeAndPop(context, - ol.format.GPX.TRKSEG_SERIALIZERS_, ol.format.GPX.TRKSEG_NODE_FACTORY_, + _ol_xml_.pushSerializeAndPop(context, + _ol_format_GPX_.TRKSEG_SERIALIZERS_, _ol_format_GPX_.TRKSEG_NODE_FACTORY_, lineString.getCoordinates(), objectStack); }; @@ -690,16 +691,16 @@ ol.format.GPX.writeTrkSeg_ = function(node, lineString, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.GPX.writeWpt_ = function(node, feature, objectStack) { +_ol_format_GPX_.writeWpt_ = function(node, feature, objectStack) { var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]); var context = objectStack[objectStack.length - 1]; context['properties'] = feature.getProperties(); var geometry = feature.getGeometry(); if (geometry) { geometry = /** @type {ol.geom.Point} */ - (ol.format.Feature.transformWithOptions(geometry, true, options)); + (_ol_format_Feature_.transformWithOptions(geometry, true, options)); context['geometryLayout'] = geometry.getLayout(); - ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack); + _ol_format_GPX_.writeWptType_(node, geometry.getCoordinates(), objectStack); } }; @@ -709,17 +710,17 @@ ol.format.GPX.writeWpt_ = function(node, feature, objectStack) { * @type {Array.} * @private */ -ol.format.GPX.LINK_SEQUENCE_ = ['text', 'type']; +_ol_format_GPX_.LINK_SEQUENCE_ = ['text', 'type']; /** * @type {Object.>} * @private */ -ol.format.GPX.LINK_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'text': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'type': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) +_ol_format_GPX_.LINK_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'text': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'type': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode) }); @@ -728,8 +729,8 @@ ol.format.GPX.LINK_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.RTE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, [ +_ol_format_GPX_.RTE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, [ 'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'rtept' ]); @@ -739,18 +740,18 @@ ol.format.GPX.RTE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.RTE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'name': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'cmt': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'desc': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'src': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'link': ol.xml.makeChildAppender(ol.format.GPX.writeLink_), - 'number': ol.xml.makeChildAppender( - ol.format.XSD.writeNonNegativeIntegerTextNode), - 'type': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'rtept': ol.xml.makeArraySerializer(ol.xml.makeChildAppender( - ol.format.GPX.writeWptType_)) +_ol_format_GPX_.RTE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'name': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'cmt': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'desc': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'src': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'link': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeLink_), + 'number': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeNonNegativeIntegerTextNode), + 'type': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'rtept': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender( + _ol_format_GPX_.writeWptType_)) }); @@ -759,8 +760,8 @@ ol.format.GPX.RTE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.RTEPT_TYPE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, [ +_ol_format_GPX_.RTEPT_TYPE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, [ 'ele', 'time' ]); @@ -770,8 +771,8 @@ ol.format.GPX.RTEPT_TYPE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.TRK_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, [ +_ol_format_GPX_.TRK_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, [ 'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'trkseg' ]); @@ -781,18 +782,18 @@ ol.format.GPX.TRK_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.TRK_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'name': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'cmt': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'desc': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'src': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'link': ol.xml.makeChildAppender(ol.format.GPX.writeLink_), - 'number': ol.xml.makeChildAppender( - ol.format.XSD.writeNonNegativeIntegerTextNode), - 'type': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'trkseg': ol.xml.makeArraySerializer(ol.xml.makeChildAppender( - ol.format.GPX.writeTrkSeg_)) +_ol_format_GPX_.TRK_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'name': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'cmt': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'desc': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'src': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'link': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeLink_), + 'number': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeNonNegativeIntegerTextNode), + 'type': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'trkseg': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender( + _ol_format_GPX_.writeTrkSeg_)) }); @@ -801,7 +802,7 @@ ol.format.GPX.TRK_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.GPX.TRKSEG_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('trkpt'); +_ol_format_GPX_.TRKSEG_NODE_FACTORY_ = _ol_xml_.makeSimpleNodeFactory('trkpt'); /** @@ -809,9 +810,9 @@ ol.format.GPX.TRKSEG_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('trkpt'); * @type {Object.>} * @private */ -ol.format.GPX.TRKSEG_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'trkpt': ol.xml.makeChildAppender(ol.format.GPX.writeWptType_) +_ol_format_GPX_.TRKSEG_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'trkpt': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeWptType_) }); @@ -820,8 +821,8 @@ ol.format.GPX.TRKSEG_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.WPT_TYPE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, [ +_ol_format_GPX_.WPT_TYPE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, [ 'ele', 'time', 'magvar', 'geoidheight', 'name', 'cmt', 'desc', 'src', 'link', 'sym', 'type', 'fix', 'sat', 'hdop', 'vdop', 'pdop', 'ageofdgpsdata', 'dgpsid' @@ -832,30 +833,30 @@ ol.format.GPX.WPT_TYPE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.GPX.WPT_TYPE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'ele': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'time': ol.xml.makeChildAppender(ol.format.XSD.writeDateTimeTextNode), - 'magvar': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'geoidheight': ol.xml.makeChildAppender( - ol.format.XSD.writeDecimalTextNode), - 'name': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'cmt': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'desc': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'src': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'link': ol.xml.makeChildAppender(ol.format.GPX.writeLink_), - 'sym': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'type': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'fix': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'sat': ol.xml.makeChildAppender( - ol.format.XSD.writeNonNegativeIntegerTextNode), - 'hdop': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'vdop': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'pdop': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'ageofdgpsdata': ol.xml.makeChildAppender( - ol.format.XSD.writeDecimalTextNode), - 'dgpsid': ol.xml.makeChildAppender( - ol.format.XSD.writeNonNegativeIntegerTextNode) +_ol_format_GPX_.WPT_TYPE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'ele': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'time': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDateTimeTextNode), + 'magvar': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'geoidheight': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeDecimalTextNode), + 'name': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'cmt': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'desc': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'src': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'link': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeLink_), + 'sym': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'type': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'fix': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'sat': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeNonNegativeIntegerTextNode), + 'hdop': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'vdop': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'pdop': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'ageofdgpsdata': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeDecimalTextNode), + 'dgpsid': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeNonNegativeIntegerTextNode) }); @@ -864,7 +865,7 @@ ol.format.GPX.WPT_TYPE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.} * @private */ -ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_ = { +_ol_format_GPX_.GEOMETRY_TYPE_TO_NODENAME_ = { 'Point': 'wpt', 'LineString': 'rte', 'MultiLineString': 'trk' @@ -879,13 +880,13 @@ ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_ = { * @return {Node|undefined} Node. * @private */ -ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { +_ol_format_GPX_.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var geometry = /** @type {ol.Feature} */ (value).getGeometry(); if (geometry) { - var nodeName = ol.format.GPX.GEOMETRY_TYPE_TO_NODENAME_[geometry.getType()]; + var nodeName = _ol_format_GPX_.GEOMETRY_TYPE_TO_NODENAME_[geometry.getType()]; if (nodeName) { var parentNode = objectStack[objectStack.length - 1].node; - return ol.xml.createElementNS(parentNode.namespaceURI, nodeName); + return _ol_xml_.createElementNS(parentNode.namespaceURI, nodeName); } } }; @@ -896,11 +897,11 @@ ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { * @type {Object.>} * @private */ -ol.format.GPX.GPX_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.GPX.NAMESPACE_URIS_, { - 'rte': ol.xml.makeChildAppender(ol.format.GPX.writeRte_), - 'trk': ol.xml.makeChildAppender(ol.format.GPX.writeTrk_), - 'wpt': ol.xml.makeChildAppender(ol.format.GPX.writeWpt_) +_ol_format_GPX_.GPX_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_GPX_.NAMESPACE_URIS_, { + 'rte': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeRte_), + 'trk': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeTrk_), + 'wpt': _ol_xml_.makeChildAppender(_ol_format_GPX_.writeWpt_) }); @@ -915,7 +916,7 @@ ol.format.GPX.GPX_SERIALIZERS_ = ol.xml.makeStructureNS( * @return {string} Result. * @api */ -ol.format.GPX.prototype.writeFeatures; +_ol_format_GPX_.prototype.writeFeatures; /** @@ -929,20 +930,21 @@ ol.format.GPX.prototype.writeFeatures; * @override * @api */ -ol.format.GPX.prototype.writeFeaturesNode = function(features, opt_options) { +_ol_format_GPX_.prototype.writeFeaturesNode = function(features, opt_options) { opt_options = this.adaptOptions(opt_options); //FIXME Serialize metadata - var gpx = ol.xml.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx'); + var gpx = _ol_xml_.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx'); var xmlnsUri = 'http://www.w3.org/2000/xmlns/'; var xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance'; - ol.xml.setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri); - ol.xml.setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', - ol.format.GPX.SCHEMA_LOCATION_); + _ol_xml_.setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri); + _ol_xml_.setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation', + _ol_format_GPX_.SCHEMA_LOCATION_); gpx.setAttribute('version', '1.1'); gpx.setAttribute('creator', 'OpenLayers'); - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ - ({node: gpx}), ol.format.GPX.GPX_SERIALIZERS_, - ol.format.GPX.GPX_NODE_FACTORY_, features, [opt_options]); + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ + ({node: gpx}), _ol_format_GPX_.GPX_SERIALIZERS_, + _ol_format_GPX_.GPX_NODE_FACTORY_, features, [opt_options]); return gpx; }; +export default _ol_format_GPX_; diff --git a/src/ol/format/GeoJSON.js b/src/ol/format/GeoJSON.js index 8efd112b29..5aa8e46591 100644 --- a/src/ol/format/GeoJSON.js +++ b/src/ol/format/GeoJSON.js @@ -1,23 +1,23 @@ +/** + * @module ol/format/GeoJSON + */ // TODO: serialize dataProjection as crs member when writing // see https://github.com/openlayers/openlayers/issues/2078 -goog.provide('ol.format.GeoJSON'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.JSONFeature'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.obj'); -goog.require('ol.proj'); - +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_JSONFeature_ from '../format/JSONFeature.js'; +import _ol_geom_GeometryCollection_ from '../geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -28,22 +28,22 @@ goog.require('ol.proj'); * @param {olx.format.GeoJSONOptions=} opt_options Options. * @api */ -ol.format.GeoJSON = function(opt_options) { +var _ol_format_GeoJSON_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.JSONFeature.call(this); + _ol_format_JSONFeature_.call(this); /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get( + this.defaultDataProjection = _ol_proj_.get( options.defaultDataProjection ? options.defaultDataProjection : 'EPSG:4326'); if (options.featureProjection) { - this.defaultFeatureProjection = ol.proj.get(options.featureProjection); + this.defaultFeatureProjection = _ol_proj_.get(options.featureProjection); } /** @@ -61,7 +61,8 @@ ol.format.GeoJSON = function(opt_options) { this.extractGeometryName_ = options.extractGeometryName; }; -ol.inherits(ol.format.GeoJSON, ol.format.JSONFeature); + +_ol_.inherits(_ol_format_GeoJSON_, _ol_format_JSONFeature_); /** @@ -70,14 +71,15 @@ ol.inherits(ol.format.GeoJSON, ol.format.JSONFeature); * @private * @return {ol.geom.Geometry} Geometry. */ -ol.format.GeoJSON.readGeometry_ = function(object, opt_options) { +_ol_format_GeoJSON_.readGeometry_ = function(object, opt_options) { if (!object) { return null; } - var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type]; - return /** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions( - geometryReader(object), false, opt_options)); + var geometryReader = _ol_format_GeoJSON_.GEOMETRY_READERS_[object.type]; + return ( + /** @type {ol.geom.Geometry} */ _ol_format_Feature_.transformWithOptions( + geometryReader(object), false, opt_options) + ); }; @@ -87,7 +89,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) { * @private * @return {ol.geom.GeometryCollection} Geometry collection. */ -ol.format.GeoJSON.readGeometryCollectionGeometry_ = function( +_ol_format_GeoJSON_.readGeometryCollectionGeometry_ = function( object, opt_options) { var geometries = object.geometries.map( /** @@ -95,9 +97,9 @@ ol.format.GeoJSON.readGeometryCollectionGeometry_ = function( * @return {ol.geom.Geometry} geometry Geometry. */ function(geometry) { - return ol.format.GeoJSON.readGeometry_(geometry, opt_options); + return _ol_format_GeoJSON_.readGeometry_(geometry, opt_options); }); - return new ol.geom.GeometryCollection(geometries); + return new _ol_geom_GeometryCollection_(geometries); }; @@ -106,8 +108,8 @@ ol.format.GeoJSON.readGeometryCollectionGeometry_ = function( * @private * @return {ol.geom.Point} Point. */ -ol.format.GeoJSON.readPointGeometry_ = function(object) { - return new ol.geom.Point(object.coordinates); +_ol_format_GeoJSON_.readPointGeometry_ = function(object) { + return new _ol_geom_Point_(object.coordinates); }; @@ -116,8 +118,8 @@ ol.format.GeoJSON.readPointGeometry_ = function(object) { * @private * @return {ol.geom.LineString} LineString. */ -ol.format.GeoJSON.readLineStringGeometry_ = function(object) { - return new ol.geom.LineString(object.coordinates); +_ol_format_GeoJSON_.readLineStringGeometry_ = function(object) { + return new _ol_geom_LineString_(object.coordinates); }; @@ -126,8 +128,8 @@ ol.format.GeoJSON.readLineStringGeometry_ = function(object) { * @private * @return {ol.geom.MultiLineString} MultiLineString. */ -ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) { - return new ol.geom.MultiLineString(object.coordinates); +_ol_format_GeoJSON_.readMultiLineStringGeometry_ = function(object) { + return new _ol_geom_MultiLineString_(object.coordinates); }; @@ -136,8 +138,8 @@ ol.format.GeoJSON.readMultiLineStringGeometry_ = function(object) { * @private * @return {ol.geom.MultiPoint} MultiPoint. */ -ol.format.GeoJSON.readMultiPointGeometry_ = function(object) { - return new ol.geom.MultiPoint(object.coordinates); +_ol_format_GeoJSON_.readMultiPointGeometry_ = function(object) { + return new _ol_geom_MultiPoint_(object.coordinates); }; @@ -146,8 +148,8 @@ ol.format.GeoJSON.readMultiPointGeometry_ = function(object) { * @private * @return {ol.geom.MultiPolygon} MultiPolygon. */ -ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) { - return new ol.geom.MultiPolygon(object.coordinates); +_ol_format_GeoJSON_.readMultiPolygonGeometry_ = function(object) { + return new _ol_geom_MultiPolygon_(object.coordinates); }; @@ -156,8 +158,8 @@ ol.format.GeoJSON.readMultiPolygonGeometry_ = function(object) { * @private * @return {ol.geom.Polygon} Polygon. */ -ol.format.GeoJSON.readPolygonGeometry_ = function(object) { - return new ol.geom.Polygon(object.coordinates); +_ol_format_GeoJSON_.readPolygonGeometry_ = function(object) { + return new _ol_geom_Polygon_(object.coordinates); }; @@ -167,10 +169,10 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) { * @private * @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry. */ -ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) { - var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()]; +_ol_format_GeoJSON_.writeGeometry_ = function(geometry, opt_options) { + var geometryWriter = _ol_format_GeoJSON_.GEOMETRY_WRITERS_[geometry.getType()]; return geometryWriter(/** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions(geometry, true, opt_options)), + _ol_format_Feature_.transformWithOptions(geometry, true, opt_options)), opt_options); }; @@ -180,7 +182,7 @@ ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) { * @private * @return {GeoJSONGeometryCollection} Empty GeoJSON geometry collection. */ -ol.format.GeoJSON.writeEmptyGeometryCollectionGeometry_ = function(geometry) { +_ol_format_GeoJSON_.writeEmptyGeometryCollectionGeometry_ = function(geometry) { return /** @type {GeoJSONGeometryCollection} */ ({ type: 'GeometryCollection', geometries: [] @@ -194,12 +196,12 @@ ol.format.GeoJSON.writeEmptyGeometryCollectionGeometry_ = function(geometry) { * @private * @return {GeoJSONGeometryCollection} GeoJSON geometry collection. */ -ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function( +_ol_format_GeoJSON_.writeGeometryCollectionGeometry_ = function( geometry, opt_options) { var geometries = geometry.getGeometriesArray().map(function(geometry) { - var options = ol.obj.assign({}, opt_options); + var options = _ol_obj_.assign({}, opt_options); delete options.featureProjection; - return ol.format.GeoJSON.writeGeometry_(geometry, options); + return _ol_format_GeoJSON_.writeGeometry_(geometry, options); }); return /** @type {GeoJSONGeometryCollection} */ ({ type: 'GeometryCollection', @@ -214,7 +216,7 @@ ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function( * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writeLineStringGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writeLineStringGeometry_ = function(geometry, opt_options) { return /** @type {GeoJSONGeometry} */ ({ type: 'LineString', coordinates: geometry.getCoordinates() @@ -228,7 +230,7 @@ ol.format.GeoJSON.writeLineStringGeometry_ = function(geometry, opt_options) { * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writeMultiLineStringGeometry_ = function(geometry, opt_options) { return /** @type {GeoJSONGeometry} */ ({ type: 'MultiLineString', coordinates: geometry.getCoordinates() @@ -242,7 +244,7 @@ ol.format.GeoJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writeMultiPointGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writeMultiPointGeometry_ = function(geometry, opt_options) { return /** @type {GeoJSONGeometry} */ ({ type: 'MultiPoint', coordinates: geometry.getCoordinates() @@ -256,7 +258,7 @@ ol.format.GeoJSON.writeMultiPointGeometry_ = function(geometry, opt_options) { * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writeMultiPolygonGeometry_ = function(geometry, opt_options) { var right; if (opt_options) { right = opt_options.rightHanded; @@ -274,7 +276,7 @@ ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) { * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writePointGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writePointGeometry_ = function(geometry, opt_options) { return /** @type {GeoJSONGeometry} */ ({ type: 'Point', coordinates: geometry.getCoordinates() @@ -288,7 +290,7 @@ ol.format.GeoJSON.writePointGeometry_ = function(geometry, opt_options) { * @private * @return {GeoJSONGeometry} GeoJSON geometry. */ -ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) { +_ol_format_GeoJSON_.writePolygonGeometry_ = function(geometry, opt_options) { var right; if (opt_options) { right = opt_options.rightHanded; @@ -305,14 +307,14 @@ ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) { * @private * @type {Object.} */ -ol.format.GeoJSON.GEOMETRY_READERS_ = { - 'Point': ol.format.GeoJSON.readPointGeometry_, - 'LineString': ol.format.GeoJSON.readLineStringGeometry_, - 'Polygon': ol.format.GeoJSON.readPolygonGeometry_, - 'MultiPoint': ol.format.GeoJSON.readMultiPointGeometry_, - 'MultiLineString': ol.format.GeoJSON.readMultiLineStringGeometry_, - 'MultiPolygon': ol.format.GeoJSON.readMultiPolygonGeometry_, - 'GeometryCollection': ol.format.GeoJSON.readGeometryCollectionGeometry_ +_ol_format_GeoJSON_.GEOMETRY_READERS_ = { + 'Point': _ol_format_GeoJSON_.readPointGeometry_, + 'LineString': _ol_format_GeoJSON_.readLineStringGeometry_, + 'Polygon': _ol_format_GeoJSON_.readPolygonGeometry_, + 'MultiPoint': _ol_format_GeoJSON_.readMultiPointGeometry_, + 'MultiLineString': _ol_format_GeoJSON_.readMultiLineStringGeometry_, + 'MultiPolygon': _ol_format_GeoJSON_.readMultiPolygonGeometry_, + 'GeometryCollection': _ol_format_GeoJSON_.readGeometryCollectionGeometry_ }; @@ -321,15 +323,15 @@ ol.format.GeoJSON.GEOMETRY_READERS_ = { * @private * @type {Object.} */ -ol.format.GeoJSON.GEOMETRY_WRITERS_ = { - 'Point': ol.format.GeoJSON.writePointGeometry_, - 'LineString': ol.format.GeoJSON.writeLineStringGeometry_, - 'Polygon': ol.format.GeoJSON.writePolygonGeometry_, - 'MultiPoint': ol.format.GeoJSON.writeMultiPointGeometry_, - 'MultiLineString': ol.format.GeoJSON.writeMultiLineStringGeometry_, - 'MultiPolygon': ol.format.GeoJSON.writeMultiPolygonGeometry_, - 'GeometryCollection': ol.format.GeoJSON.writeGeometryCollectionGeometry_, - 'Circle': ol.format.GeoJSON.writeEmptyGeometryCollectionGeometry_ +_ol_format_GeoJSON_.GEOMETRY_WRITERS_ = { + 'Point': _ol_format_GeoJSON_.writePointGeometry_, + 'LineString': _ol_format_GeoJSON_.writeLineStringGeometry_, + 'Polygon': _ol_format_GeoJSON_.writePolygonGeometry_, + 'MultiPoint': _ol_format_GeoJSON_.writeMultiPointGeometry_, + 'MultiLineString': _ol_format_GeoJSON_.writeMultiLineStringGeometry_, + 'MultiPolygon': _ol_format_GeoJSON_.writeMultiPolygonGeometry_, + 'GeometryCollection': _ol_format_GeoJSON_.writeGeometryCollectionGeometry_, + 'Circle': _ol_format_GeoJSON_.writeEmptyGeometryCollectionGeometry_ }; @@ -345,7 +347,7 @@ ol.format.GeoJSON.GEOMETRY_WRITERS_ = { * @return {ol.Feature} Feature. * @api */ -ol.format.GeoJSON.prototype.readFeature; +_ol_format_GeoJSON_.prototype.readFeature; /** @@ -359,13 +361,13 @@ ol.format.GeoJSON.prototype.readFeature; * @return {Array.} Features. * @api */ -ol.format.GeoJSON.prototype.readFeatures; +_ol_format_GeoJSON_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.GeoJSON.prototype.readFeatureFromObject = function( +_ol_format_GeoJSON_.prototype.readFeatureFromObject = function( object, opt_options) { /** * @type {GeoJSONFeature} @@ -380,8 +382,8 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function( }); } - var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry, opt_options); - var feature = new ol.Feature(); + var geometry = _ol_format_GeoJSON_.readGeometry_(geoJSONFeature.geometry, opt_options); + var feature = new _ol_Feature_(); if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } else if (this.extractGeometryName_ && geoJSONFeature.geometry_name !== undefined) { @@ -401,7 +403,7 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function( /** * @inheritDoc */ -ol.format.GeoJSON.prototype.readFeaturesFromObject = function( +_ol_format_GeoJSON_.prototype.readFeaturesFromObject = function( object, opt_options) { var geoJSONObject = /** @type {GeoJSONObject} */ (object); /** @type {Array.} */ @@ -432,15 +434,15 @@ ol.format.GeoJSON.prototype.readFeaturesFromObject = function( * @return {ol.geom.Geometry} Geometry. * @api */ -ol.format.GeoJSON.prototype.readGeometry; +_ol_format_GeoJSON_.prototype.readGeometry; /** * @inheritDoc */ -ol.format.GeoJSON.prototype.readGeometryFromObject = function( +_ol_format_GeoJSON_.prototype.readGeometryFromObject = function( object, opt_options) { - return ol.format.GeoJSON.readGeometry_( + return _ol_format_GeoJSON_.readGeometry_( /** @type {GeoJSONGeometry} */ (object), opt_options); }; @@ -453,21 +455,21 @@ ol.format.GeoJSON.prototype.readGeometryFromObject = function( * @return {ol.proj.Projection} Projection. * @api */ -ol.format.GeoJSON.prototype.readProjection; +_ol_format_GeoJSON_.prototype.readProjection; /** * @inheritDoc */ -ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) { +_ol_format_GeoJSON_.prototype.readProjectionFromObject = function(object) { var geoJSONObject = /** @type {GeoJSONObject} */ (object); var crs = geoJSONObject.crs; var projection; if (crs) { if (crs.type == 'name') { - projection = ol.proj.get(crs.properties.name); + projection = _ol_proj_.get(crs.properties.name); } else { - ol.asserts.assert(false, 36); // Unknown SRS type + _ol_asserts_.assert(false, 36); // Unknown SRS type } } else { projection = this.defaultDataProjection; @@ -486,7 +488,7 @@ ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) { * @override * @api */ -ol.format.GeoJSON.prototype.writeFeature; +_ol_format_GeoJSON_.prototype.writeFeature; /** @@ -498,7 +500,7 @@ ol.format.GeoJSON.prototype.writeFeature; * @override * @api */ -ol.format.GeoJSON.prototype.writeFeatureObject = function(feature, opt_options) { +_ol_format_GeoJSON_.prototype.writeFeatureObject = function(feature, opt_options) { opt_options = this.adaptOptions(opt_options); var object = /** @type {GeoJSONFeature} */ ({ @@ -511,13 +513,13 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(feature, opt_options) var geometry = feature.getGeometry(); if (geometry) { object.geometry = - ol.format.GeoJSON.writeGeometry_(geometry, opt_options); + _ol_format_GeoJSON_.writeGeometry_(geometry, opt_options); } else { object.geometry = null; } var properties = feature.getProperties(); delete properties[feature.getGeometryName()]; - if (!ol.obj.isEmpty(properties)) { + if (!_ol_obj_.isEmpty(properties)) { object.properties = properties; } else { object.properties = null; @@ -535,7 +537,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(feature, opt_options) * @return {string} GeoJSON. * @api */ -ol.format.GeoJSON.prototype.writeFeatures; +_ol_format_GeoJSON_.prototype.writeFeatures; /** @@ -547,7 +549,7 @@ ol.format.GeoJSON.prototype.writeFeatures; * @override * @api */ -ol.format.GeoJSON.prototype.writeFeaturesObject = function(features, opt_options) { +_ol_format_GeoJSON_.prototype.writeFeaturesObject = function(features, opt_options) { opt_options = this.adaptOptions(opt_options); var objects = []; var i, ii; @@ -570,7 +572,7 @@ ol.format.GeoJSON.prototype.writeFeaturesObject = function(features, opt_options * @return {string} GeoJSON. * @api */ -ol.format.GeoJSON.prototype.writeGeometry; +_ol_format_GeoJSON_.prototype.writeGeometry; /** @@ -582,8 +584,9 @@ ol.format.GeoJSON.prototype.writeGeometry; * @override * @api */ -ol.format.GeoJSON.prototype.writeGeometryObject = function(geometry, +_ol_format_GeoJSON_.prototype.writeGeometryObject = function(geometry, opt_options) { - return ol.format.GeoJSON.writeGeometry_(geometry, + return _ol_format_GeoJSON_.writeGeometry_(geometry, this.adaptOptions(opt_options)); }; +export default _ol_format_GeoJSON_; diff --git a/src/ol/format/IGC.js b/src/ol/format/IGC.js index f052b0ffa9..4defa8c89d 100644 --- a/src/ol/format/IGC.js +++ b/src/ol/format/IGC.js @@ -1,14 +1,14 @@ -goog.provide('ol.format.IGC'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.IGCZ'); -goog.require('ol.format.TextFeature'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.proj'); - +/** + * @module ol/format/IGC + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_IGCZ_ from '../format/IGCZ.js'; +import _ol_format_TextFeature_ from '../format/TextFeature.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -19,26 +19,27 @@ goog.require('ol.proj'); * @param {olx.format.IGCOptions=} opt_options Options. * @api */ -ol.format.IGC = function(opt_options) { +var _ol_format_IGC_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.TextFeature.call(this); + _ol_format_TextFeature_.call(this); /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get('EPSG:4326'); + this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); /** * @private * @type {ol.format.IGCZ} */ this.altitudeMode_ = options.altitudeMode ? - options.altitudeMode : ol.format.IGCZ.NONE; + options.altitudeMode : _ol_format_IGCZ_.NONE; }; -ol.inherits(ol.format.IGC, ol.format.TextFeature); + +_ol_.inherits(_ol_format_IGC_, _ol_format_TextFeature_); /** @@ -46,7 +47,7 @@ ol.inherits(ol.format.IGC, ol.format.TextFeature); * @type {RegExp} * @private */ -ol.format.IGC.B_RECORD_RE_ = +_ol_format_IGC_.B_RECORD_RE_ = /^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/; @@ -55,7 +56,7 @@ ol.format.IGC.B_RECORD_RE_ = * @type {RegExp} * @private */ -ol.format.IGC.H_RECORD_RE_ = /^H.([A-Z]{3}).*?:(.*)/; +_ol_format_IGC_.H_RECORD_RE_ = /^H.([A-Z]{3}).*?:(.*)/; /** @@ -63,7 +64,7 @@ ol.format.IGC.H_RECORD_RE_ = /^H.([A-Z]{3}).*?:(.*)/; * @type {RegExp} * @private */ -ol.format.IGC.HFDTE_RECORD_RE_ = /^HFDTE(\d{2})(\d{2})(\d{2})/; +_ol_format_IGC_.HFDTE_RECORD_RE_ = /^HFDTE(\d{2})(\d{2})(\d{2})/; /** @@ -73,7 +74,7 @@ ol.format.IGC.HFDTE_RECORD_RE_ = /^HFDTE(\d{2})(\d{2})(\d{2})/; * @type {RegExp} * @private */ -ol.format.IGC.NEWLINE_RE_ = /\r\n|\r|\n/; +_ol_format_IGC_.NEWLINE_RE_ = /\r\n|\r|\n/; /** @@ -85,15 +86,15 @@ ol.format.IGC.NEWLINE_RE_ = /\r\n|\r|\n/; * @return {ol.Feature} Feature. * @api */ -ol.format.IGC.prototype.readFeature; +_ol_format_IGC_.prototype.readFeature; /** * @inheritDoc */ -ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { +_ol_format_IGC_.prototype.readFeatureFromText = function(text, opt_options) { var altitudeMode = this.altitudeMode_; - var lines = text.split(ol.format.IGC.NEWLINE_RE_); + var lines = text.split(_ol_format_IGC_.NEWLINE_RE_); /** @type {Object.} */ var properties = {}; var flatCoordinates = []; @@ -106,7 +107,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { var line = lines[i]; var m; if (line.charAt(0) == 'B') { - m = ol.format.IGC.B_RECORD_RE_.exec(line); + m = _ol_format_IGC_.B_RECORD_RE_.exec(line); if (m) { var hour = parseInt(m[1], 10); var minute = parseInt(m[2], 10); @@ -120,11 +121,11 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { x = -x; } flatCoordinates.push(x, y); - if (altitudeMode != ol.format.IGCZ.NONE) { + if (altitudeMode != _ol_format_IGCZ_.NONE) { var z; - if (altitudeMode == ol.format.IGCZ.GPS) { + if (altitudeMode == _ol_format_IGCZ_.GPS) { z = parseInt(m[11], 10); - } else if (altitudeMode == ol.format.IGCZ.BAROMETRIC) { + } else if (altitudeMode == _ol_format_IGCZ_.BAROMETRIC) { z = parseInt(m[12], 10); } else { z = 0; @@ -140,13 +141,13 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { lastDateTime = dateTime; } } else if (line.charAt(0) == 'H') { - m = ol.format.IGC.HFDTE_RECORD_RE_.exec(line); + m = _ol_format_IGC_.HFDTE_RECORD_RE_.exec(line); if (m) { day = parseInt(m[1], 10); month = parseInt(m[2], 10) - 1; year = 2000 + parseInt(m[3], 10); } else { - m = ol.format.IGC.H_RECORD_RE_.exec(line); + m = _ol_format_IGC_.H_RECORD_RE_.exec(line); if (m) { properties[m[1]] = m[2].trim(); } @@ -156,11 +157,11 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { if (flatCoordinates.length === 0) { return null; } - var lineString = new ol.geom.LineString(null); - var layout = altitudeMode == ol.format.IGCZ.NONE ? - ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM; + var lineString = new _ol_geom_LineString_(null); + var layout = altitudeMode == _ol_format_IGCZ_.NONE ? + _ol_geom_GeometryLayout_.XYM : _ol_geom_GeometryLayout_.XYZM; lineString.setFlatCoordinates(layout, flatCoordinates); - var feature = new ol.Feature(ol.format.Feature.transformWithOptions( + var feature = new _ol_Feature_(_ol_format_Feature_.transformWithOptions( lineString, false, opt_options)); feature.setProperties(properties); return feature; @@ -177,13 +178,13 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) { * @return {Array.} Features. * @api */ -ol.format.IGC.prototype.readFeatures; +_ol_format_IGC_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) { +_ol_format_IGC_.prototype.readFeaturesFromText = function(text, opt_options) { var feature = this.readFeatureFromText(text, opt_options); if (feature) { return [feature]; @@ -201,32 +202,33 @@ ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) { * @return {ol.proj.Projection} Projection. * @api */ -ol.format.IGC.prototype.readProjection; +_ol_format_IGC_.prototype.readProjection; /** * Not implemented. * @inheritDoc */ -ol.format.IGC.prototype.writeFeatureText = function(feature, opt_options) {}; +_ol_format_IGC_.prototype.writeFeatureText = function(feature, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.IGC.prototype.writeFeaturesText = function(features, opt_options) {}; +_ol_format_IGC_.prototype.writeFeaturesText = function(features, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.IGC.prototype.writeGeometryText = function(geometry, opt_options) {}; +_ol_format_IGC_.prototype.writeGeometryText = function(geometry, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.IGC.prototype.readGeometryFromText = function(text, opt_options) {}; +_ol_format_IGC_.prototype.readGeometryFromText = function(text, opt_options) {}; +export default _ol_format_IGC_; diff --git a/src/ol/format/IGCZ.js b/src/ol/format/IGCZ.js index 3394a69945..587cdef0fd 100644 --- a/src/ol/format/IGCZ.js +++ b/src/ol/format/IGCZ.js @@ -1,11 +1,14 @@ -goog.provide('ol.format.IGCZ'); - +/** + * @module ol/format/IGCZ + */ /** * IGC altitude/z. One of 'barometric', 'gps', 'none'. * @enum {string} */ -ol.format.IGCZ = { +var _ol_format_IGCZ_ = { BAROMETRIC: 'barometric', GPS: 'gps', NONE: 'none' }; + +export default _ol_format_IGCZ_; diff --git a/src/ol/format/JSONFeature.js b/src/ol/format/JSONFeature.js index 95ec963001..9aaeb4a3b5 100644 --- a/src/ol/format/JSONFeature.js +++ b/src/ol/format/JSONFeature.js @@ -1,9 +1,9 @@ -goog.provide('ol.format.JSONFeature'); - -goog.require('ol'); -goog.require('ol.format.Feature'); -goog.require('ol.format.FormatType'); - +/** + * @module ol/format/JSONFeature + */ +import _ol_ from '../index.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_FormatType_ from '../format/FormatType.js'; /** * @classdesc @@ -15,10 +15,11 @@ goog.require('ol.format.FormatType'); * @abstract * @extends {ol.format.Feature} */ -ol.format.JSONFeature = function() { - ol.format.Feature.call(this); +var _ol_format_JSONFeature_ = function() { + _ol_format_Feature_.call(this); }; -ol.inherits(ol.format.JSONFeature, ol.format.Feature); + +_ol_.inherits(_ol_format_JSONFeature_, _ol_format_Feature_); /** @@ -26,7 +27,7 @@ ol.inherits(ol.format.JSONFeature, ol.format.Feature); * @private * @return {Object} Object. */ -ol.format.JSONFeature.prototype.getObject_ = function(source) { +_ol_format_JSONFeature_.prototype.getObject_ = function(source) { if (typeof source === 'string') { var object = JSON.parse(source); return object ? /** @type {Object} */ (object) : null; @@ -41,15 +42,15 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) { /** * @inheritDoc */ -ol.format.JSONFeature.prototype.getType = function() { - return ol.format.FormatType.JSON; +_ol_format_JSONFeature_.prototype.getType = function() { + return _ol_format_FormatType_.JSON; }; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.readFeature = function(source, opt_options) { +_ol_format_JSONFeature_.prototype.readFeature = function(source, opt_options) { return this.readFeatureFromObject( this.getObject_(source), this.getReadOptions(source, opt_options)); }; @@ -58,7 +59,7 @@ ol.format.JSONFeature.prototype.readFeature = function(source, opt_options) { /** * @inheritDoc */ -ol.format.JSONFeature.prototype.readFeatures = function(source, opt_options) { +_ol_format_JSONFeature_.prototype.readFeatures = function(source, opt_options) { return this.readFeaturesFromObject( this.getObject_(source), this.getReadOptions(source, opt_options)); }; @@ -71,7 +72,7 @@ ol.format.JSONFeature.prototype.readFeatures = function(source, opt_options) { * @protected * @return {ol.Feature} Feature. */ -ol.format.JSONFeature.prototype.readFeatureFromObject = function(object, opt_options) {}; +_ol_format_JSONFeature_.prototype.readFeatureFromObject = function(object, opt_options) {}; /** @@ -81,13 +82,13 @@ ol.format.JSONFeature.prototype.readFeatureFromObject = function(object, opt_opt * @protected * @return {Array.} Features. */ -ol.format.JSONFeature.prototype.readFeaturesFromObject = function(object, opt_options) {}; +_ol_format_JSONFeature_.prototype.readFeaturesFromObject = function(object, opt_options) {}; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.readGeometry = function(source, opt_options) { +_ol_format_JSONFeature_.prototype.readGeometry = function(source, opt_options) { return this.readGeometryFromObject( this.getObject_(source), this.getReadOptions(source, opt_options)); }; @@ -100,13 +101,13 @@ ol.format.JSONFeature.prototype.readGeometry = function(source, opt_options) { * @protected * @return {ol.geom.Geometry} Geometry. */ -ol.format.JSONFeature.prototype.readGeometryFromObject = function(object, opt_options) {}; +_ol_format_JSONFeature_.prototype.readGeometryFromObject = function(object, opt_options) {}; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.readProjection = function(source) { +_ol_format_JSONFeature_.prototype.readProjection = function(source) { return this.readProjectionFromObject(this.getObject_(source)); }; @@ -117,13 +118,13 @@ ol.format.JSONFeature.prototype.readProjection = function(source) { * @protected * @return {ol.proj.Projection} Projection. */ -ol.format.JSONFeature.prototype.readProjectionFromObject = function(object) {}; +_ol_format_JSONFeature_.prototype.readProjectionFromObject = function(object) {}; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.writeFeature = function(feature, opt_options) { +_ol_format_JSONFeature_.prototype.writeFeature = function(feature, opt_options) { return JSON.stringify(this.writeFeatureObject(feature, opt_options)); }; @@ -134,13 +135,13 @@ ol.format.JSONFeature.prototype.writeFeature = function(feature, opt_options) { * @param {olx.format.WriteOptions=} opt_options Write options. * @return {Object} Object. */ -ol.format.JSONFeature.prototype.writeFeatureObject = function(feature, opt_options) {}; +_ol_format_JSONFeature_.prototype.writeFeatureObject = function(feature, opt_options) {}; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.writeFeatures = function(features, opt_options) { +_ol_format_JSONFeature_.prototype.writeFeatures = function(features, opt_options) { return JSON.stringify(this.writeFeaturesObject(features, opt_options)); }; @@ -151,13 +152,13 @@ ol.format.JSONFeature.prototype.writeFeatures = function(features, opt_options) * @param {olx.format.WriteOptions=} opt_options Write options. * @return {Object} Object. */ -ol.format.JSONFeature.prototype.writeFeaturesObject = function(features, opt_options) {}; +_ol_format_JSONFeature_.prototype.writeFeaturesObject = function(features, opt_options) {}; /** * @inheritDoc */ -ol.format.JSONFeature.prototype.writeGeometry = function(geometry, opt_options) { +_ol_format_JSONFeature_.prototype.writeGeometry = function(geometry, opt_options) { return JSON.stringify(this.writeGeometryObject(geometry, opt_options)); }; @@ -168,4 +169,5 @@ ol.format.JSONFeature.prototype.writeGeometry = function(geometry, opt_options) * @param {olx.format.WriteOptions=} opt_options Write options. * @return {Object} Object. */ -ol.format.JSONFeature.prototype.writeGeometryObject = function(geometry, opt_options) {}; +_ol_format_JSONFeature_.prototype.writeGeometryObject = function(geometry, opt_options) {}; +export default _ol_format_JSONFeature_; diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index 9460995be7..6d86898aea 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -1,38 +1,38 @@ +/** + * @module ol/format/KML + */ // FIXME http://earth.google.com/kml/1.0 namespace? // FIXME why does node.getAttribute return an unknown type? // FIXME serialize arbitrary feature properties // FIXME don't parse style if extractStyles is false -goog.provide('ol.format.KML'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.array'); -goog.require('ol.asserts'); -goog.require('ol.color'); -goog.require('ol.format.Feature'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.format.XSD'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.math'); -goog.require('ol.proj'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.IconAnchorUnits'); -goog.require('ol.style.IconOrigin'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); -goog.require('ol.xml'); - +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_array_ from '../array.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_color_ from '../color.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_geom_GeometryCollection_ from '../geom/GeometryCollection.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_math_ from '../math.js'; +import _ol_proj_ from '../proj.js'; +import _ol_style_Fill_ from '../style/Fill.js'; +import _ol_style_Icon_ from '../style/Icon.js'; +import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; +import _ol_style_IconOrigin_ from '../style/IconOrigin.js'; +import _ol_style_Stroke_ from '../style/Stroke.js'; +import _ol_style_Style_ from '../style/Style.js'; +import _ol_style_Text_ from '../style/Text.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -46,27 +46,27 @@ goog.require('ol.xml'); * @param {olx.format.KMLOptions=} opt_options Options. * @api */ -ol.format.KML = function(opt_options) { +var _ol_format_KML_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.XMLFeature.call(this); + _ol_format_XMLFeature_.call(this); - if (!ol.format.KML.DEFAULT_STYLE_ARRAY_) { - ol.format.KML.createStyleDefaults_(); + if (!_ol_format_KML_.DEFAULT_STYLE_ARRAY_) { + _ol_format_KML_.createStyleDefaults_(); } /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get('EPSG:4326'); + this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); /** * @private * @type {Array.} */ this.defaultStyle_ = options.defaultStyle ? - options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_; + options.defaultStyle : _ol_format_KML_.DEFAULT_STYLE_ARRAY_; /** * @private @@ -96,7 +96,8 @@ ol.format.KML = function(opt_options) { options.showPointNames : true; }; -ol.inherits(ol.format.KML, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_KML_, _ol_format_XMLFeature_); /** @@ -104,7 +105,7 @@ ol.inherits(ol.format.KML, ol.format.XMLFeature); * @type {Array.} * @private */ -ol.format.KML.GX_NAMESPACE_URIS_ = [ +_ol_format_KML_.GX_NAMESPACE_URIS_ = [ 'http://www.google.com/kml/ext/2.2' ]; @@ -114,7 +115,7 @@ ol.format.KML.GX_NAMESPACE_URIS_ = [ * @type {Array.} * @private */ -ol.format.KML.NAMESPACE_URIS_ = [ +_ol_format_KML_.NAMESPACE_URIS_ = [ null, 'http://earth.google.com/kml/2.0', 'http://earth.google.com/kml/2.1', @@ -128,7 +129,7 @@ ol.format.KML.NAMESPACE_URIS_ = [ * @type {string} * @private */ -ol.format.KML.SCHEMA_LOCATION_ = 'http://www.opengis.net/kml/2.2 ' + +_ol_format_KML_.SCHEMA_LOCATION_ = 'http://www.opengis.net/kml/2.2 ' + 'https://developers.google.com/kml/schema/kml22gx.xsd'; @@ -136,21 +137,21 @@ ol.format.KML.SCHEMA_LOCATION_ = 'http://www.opengis.net/kml/2.2 ' + * @return {Array.} Default style. * @private */ -ol.format.KML.createStyleDefaults_ = function() { +_ol_format_KML_.createStyleDefaults_ = function() { /** * @const * @type {ol.Color} * @private */ - ol.format.KML.DEFAULT_COLOR_ = [255, 255, 255, 1]; + _ol_format_KML_.DEFAULT_COLOR_ = [255, 255, 255, 1]; /** * @const * @type {ol.style.Fill} * @private */ - ol.format.KML.DEFAULT_FILL_STYLE_ = new ol.style.Fill({ - color: ol.format.KML.DEFAULT_COLOR_ + _ol_format_KML_.DEFAULT_FILL_STYLE_ = new _ol_style_Fill_({ + color: _ol_format_KML_.DEFAULT_COLOR_ }); /** @@ -158,37 +159,37 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {ol.Size} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ? + _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ? /** * @const * @type {ol.style.IconAnchorUnits} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = - ol.style.IconAnchorUnits.PIXELS; + _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = + _ol_style_IconAnchorUnits_.PIXELS; /** * @const * @type {ol.style.IconAnchorUnits} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = - ol.style.IconAnchorUnits.PIXELS; + _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = + _ol_style_IconAnchorUnits_.PIXELS; /** * @const * @type {ol.Size} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64]; + _ol_format_KML_.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64]; /** * @const * @type {string} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ = + _ol_format_KML_.DEFAULT_IMAGE_STYLE_SRC_ = 'https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png'; /** @@ -196,23 +197,23 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {number} * @private */ - ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_ = 0.5; + _ol_format_KML_.DEFAULT_IMAGE_SCALE_MULTIPLIER_ = 0.5; /** * @const * @type {ol.style.Image} * @private */ - ol.format.KML.DEFAULT_IMAGE_STYLE_ = new ol.style.Icon({ - anchor: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_, - anchorOrigin: ol.style.IconOrigin.BOTTOM_LEFT, - anchorXUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_, - anchorYUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_, + _ol_format_KML_.DEFAULT_IMAGE_STYLE_ = new _ol_style_Icon_({ + anchor: _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_, + anchorOrigin: _ol_style_IconOrigin_.BOTTOM_LEFT, + anchorXUnits: _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_, + anchorYUnits: _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_, crossOrigin: 'anonymous', rotation: 0, - scale: ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_, - size: ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_, - src: ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ + scale: _ol_format_KML_.DEFAULT_IMAGE_SCALE_MULTIPLIER_, + size: _ol_format_KML_.DEFAULT_IMAGE_STYLE_SIZE_, + src: _ol_format_KML_.DEFAULT_IMAGE_STYLE_SRC_ }); /** @@ -220,15 +221,15 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {string} * @private */ - ol.format.KML.DEFAULT_NO_IMAGE_STYLE_ = 'NO_IMAGE'; + _ol_format_KML_.DEFAULT_NO_IMAGE_STYLE_ = 'NO_IMAGE'; /** * @const * @type {ol.style.Stroke} * @private */ - ol.format.KML.DEFAULT_STROKE_STYLE_ = new ol.style.Stroke({ - color: ol.format.KML.DEFAULT_COLOR_, + _ol_format_KML_.DEFAULT_STROKE_STYLE_ = new _ol_style_Stroke_({ + color: _ol_format_KML_.DEFAULT_COLOR_, width: 1 }); @@ -237,7 +238,7 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {ol.style.Stroke} * @private */ - ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_ = new ol.style.Stroke({ + _ol_format_KML_.DEFAULT_TEXT_STROKE_STYLE_ = new _ol_style_Stroke_({ color: [51, 51, 51, 1], width: 2 }); @@ -247,10 +248,10 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {ol.style.Text} * @private */ - ol.format.KML.DEFAULT_TEXT_STYLE_ = new ol.style.Text({ + _ol_format_KML_.DEFAULT_TEXT_STYLE_ = new _ol_style_Text_({ font: 'bold 16px Helvetica', - fill: ol.format.KML.DEFAULT_FILL_STYLE_, - stroke: ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_, + fill: _ol_format_KML_.DEFAULT_FILL_STYLE_, + stroke: _ol_format_KML_.DEFAULT_TEXT_STROKE_STYLE_, scale: 0.8 }); @@ -259,11 +260,11 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {ol.style.Style} * @private */ - ol.format.KML.DEFAULT_STYLE_ = new ol.style.Style({ - fill: ol.format.KML.DEFAULT_FILL_STYLE_, - image: ol.format.KML.DEFAULT_IMAGE_STYLE_, - text: ol.format.KML.DEFAULT_TEXT_STYLE_, - stroke: ol.format.KML.DEFAULT_STROKE_STYLE_, + _ol_format_KML_.DEFAULT_STYLE_ = new _ol_style_Style_({ + fill: _ol_format_KML_.DEFAULT_FILL_STYLE_, + image: _ol_format_KML_.DEFAULT_IMAGE_STYLE_, + text: _ol_format_KML_.DEFAULT_TEXT_STYLE_, + stroke: _ol_format_KML_.DEFAULT_STROKE_STYLE_, zIndex: 0 }); @@ -272,9 +273,9 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {Array.} * @private */ - ol.format.KML.DEFAULT_STYLE_ARRAY_ = [ol.format.KML.DEFAULT_STYLE_]; + _ol_format_KML_.DEFAULT_STYLE_ARRAY_ = [_ol_format_KML_.DEFAULT_STYLE_]; - return ol.format.KML.DEFAULT_STYLE_ARRAY_; + return _ol_format_KML_.DEFAULT_STYLE_ARRAY_; }; @@ -283,10 +284,10 @@ ol.format.KML.createStyleDefaults_ = function() { * @type {Object.} * @private */ -ol.format.KML.ICON_ANCHOR_UNITS_MAP_ = { - 'fraction': ol.style.IconAnchorUnits.FRACTION, - 'pixels': ol.style.IconAnchorUnits.PIXELS, - 'insetPixels': ol.style.IconAnchorUnits.PIXELS +_ol_format_KML_.ICON_ANCHOR_UNITS_MAP_ = { + 'fraction': _ol_style_IconAnchorUnits_.FRACTION, + 'pixels': _ol_style_IconAnchorUnits_.PIXELS, + 'insetPixels': _ol_style_IconAnchorUnits_.PIXELS }; @@ -296,14 +297,14 @@ ol.format.KML.ICON_ANCHOR_UNITS_MAP_ = { * @return {ol.style.Style} style Style. * @private */ -ol.format.KML.createNameStyleFunction_ = function(foundStyle, name) { +_ol_format_KML_.createNameStyleFunction_ = function(foundStyle, name) { var textStyle = null; var textOffset = [0, 0]; var textAlign = 'start'; if (foundStyle.getImage()) { var imageSize = foundStyle.getImage().getImageSize(); if (imageSize === null) { - imageSize = ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_; + imageSize = _ol_format_KML_.DEFAULT_IMAGE_STYLE_SIZE_; } if (imageSize.length == 2) { var imageScale = foundStyle.getImage().getScale(); @@ -319,19 +320,19 @@ ol.format.KML.createNameStyleFunction_ = function(foundStyle, name) { // Note that kml does not support many text options that OpenLayers does (rotation, textBaseline). var foundText = foundStyle.getText(); textStyle = foundText.clone(); - textStyle.setFont(foundText.getFont() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFont()); - textStyle.setScale(foundText.getScale() || ol.format.KML.DEFAULT_TEXT_STYLE_.getScale()); - textStyle.setFill(foundText.getFill() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFill()); - textStyle.setStroke(foundText.getStroke() || ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_); + textStyle.setFont(foundText.getFont() || _ol_format_KML_.DEFAULT_TEXT_STYLE_.getFont()); + textStyle.setScale(foundText.getScale() || _ol_format_KML_.DEFAULT_TEXT_STYLE_.getScale()); + textStyle.setFill(foundText.getFill() || _ol_format_KML_.DEFAULT_TEXT_STYLE_.getFill()); + textStyle.setStroke(foundText.getStroke() || _ol_format_KML_.DEFAULT_TEXT_STROKE_STYLE_); } else { - textStyle = ol.format.KML.DEFAULT_TEXT_STYLE_.clone(); + textStyle = _ol_format_KML_.DEFAULT_TEXT_STYLE_.clone(); } textStyle.setText(name); textStyle.setOffsetX(textOffset[0]); textStyle.setOffsetY(textOffset[1]); textStyle.setTextAlign(textAlign); - var nameStyle = new ol.style.Style({ + var nameStyle = new _ol_style_Style_({ text: textStyle }); return nameStyle; @@ -349,15 +350,15 @@ ol.format.KML.createNameStyleFunction_ = function(foundStyle, name) { * @return {ol.FeatureStyleFunction} Feature style function. * @private */ -ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl, +_ol_format_KML_.createFeatureStyleFunction_ = function(style, styleUrl, defaultStyle, sharedStyles, showPointNames) { return ( - /** - * @param {number} resolution Resolution. - * @return {Array.} Style. - * @this {ol.Feature} - */ + /** + * @param {number} resolution Resolution. + * @return {Array.} Style. + * @this {ol.Feature} + */ function(resolution) { var drawName = showPointNames; /** @type {ol.style.Style|undefined} */ @@ -366,7 +367,7 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl, if (drawName) { if (this.getGeometry()) { drawName = (this.getGeometry().getType() === - ol.geom.GeometryType.POINT); + _ol_geom_GeometryType_.POINT); } } @@ -377,29 +378,30 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl, if (style) { if (drawName) { - nameStyle = ol.format.KML.createNameStyleFunction_(style[0], + nameStyle = _ol_format_KML_.createNameStyleFunction_(style[0], name); return style.concat(nameStyle); } return style; } if (styleUrl) { - var foundStyle = ol.format.KML.findStyle_(styleUrl, defaultStyle, + var foundStyle = _ol_format_KML_.findStyle_(styleUrl, defaultStyle, sharedStyles); if (drawName) { - nameStyle = ol.format.KML.createNameStyleFunction_(foundStyle[0], + nameStyle = _ol_format_KML_.createNameStyleFunction_(foundStyle[0], name); return foundStyle.concat(nameStyle); } return foundStyle; } if (drawName) { - nameStyle = ol.format.KML.createNameStyleFunction_(defaultStyle[0], + nameStyle = _ol_format_KML_.createNameStyleFunction_(defaultStyle[0], name); return defaultStyle.concat(nameStyle); } return defaultStyle; - }); + } + ); }; @@ -411,7 +413,7 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl, * @return {Array.} Style. * @private */ -ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) { +_ol_format_KML_.findStyle_ = function(styleValue, defaultStyle, sharedStyles) { if (Array.isArray(styleValue)) { return styleValue; } else if (typeof styleValue === 'string') { @@ -421,7 +423,7 @@ ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) { if (!(styleValue in sharedStyles) && ('#' + styleValue in sharedStyles)) { styleValue = '#' + styleValue; } - return ol.format.KML.findStyle_( + return _ol_format_KML_.findStyle_( sharedStyles[styleValue], defaultStyle, sharedStyles); } else { return defaultStyle; @@ -434,8 +436,8 @@ ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) { * @private * @return {ol.Color|undefined} Color. */ -ol.format.KML.readColor_ = function(node) { - var s = ol.xml.getAllTextContent(node, false); +_ol_format_KML_.readColor_ = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); // The KML specification states that colors should not include a leading `#` // but we tolerate them. var m = /^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(s); @@ -459,8 +461,8 @@ ol.format.KML.readColor_ = function(node) { * @private * @return {Array.|undefined} Flat coordinates. */ -ol.format.KML.readFlatCoordinates_ = function(node) { - var s = ol.xml.getAllTextContent(node, false); +_ol_format_KML_.readFlatCoordinates_ = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); var flatCoordinates = []; // The KML specification states that coordinate tuples should not include // spaces, but we tolerate them. @@ -486,8 +488,8 @@ ol.format.KML.readFlatCoordinates_ = function(node) { * @private * @return {string} URI. */ -ol.format.KML.readURI_ = function(node) { - var s = ol.xml.getAllTextContent(node, false).trim(); +_ol_format_KML_.readURI_ = function(node) { + var s = _ol_xml_.getAllTextContent(node, false).trim(); var baseURI = node.baseURI; if (!baseURI || baseURI == 'about:blank') { baseURI = window.location.href; @@ -506,28 +508,28 @@ ol.format.KML.readURI_ = function(node) { * @private * @return {ol.KMLVec2_} Vec2. */ -ol.format.KML.readVec2_ = function(node) { +_ol_format_KML_.readVec2_ = function(node) { var xunits = node.getAttribute('xunits'); var yunits = node.getAttribute('yunits'); var origin; if (xunits !== 'insetPixels') { if (yunits !== 'insetPixels') { - origin = ol.style.IconOrigin.BOTTOM_LEFT; + origin = _ol_style_IconOrigin_.BOTTOM_LEFT; } else { - origin = ol.style.IconOrigin.TOP_LEFT; + origin = _ol_style_IconOrigin_.TOP_LEFT; } } else { if (yunits !== 'insetPixels') { - origin = ol.style.IconOrigin.BOTTOM_RIGHT; + origin = _ol_style_IconOrigin_.BOTTOM_RIGHT; } else { - origin = ol.style.IconOrigin.TOP_RIGHT; + origin = _ol_style_IconOrigin_.TOP_RIGHT; } } return { x: parseFloat(node.getAttribute('x')), - xunits: ol.format.KML.ICON_ANCHOR_UNITS_MAP_[xunits], + xunits: _ol_format_KML_.ICON_ANCHOR_UNITS_MAP_[xunits], y: parseFloat(node.getAttribute('y')), - yunits: ol.format.KML.ICON_ANCHOR_UNITS_MAP_[yunits], + yunits: _ol_format_KML_.ICON_ANCHOR_UNITS_MAP_[yunits], origin: origin }; }; @@ -538,8 +540,8 @@ ol.format.KML.readVec2_ = function(node) { * @private * @return {number|undefined} Scale. */ -ol.format.KML.readScale_ = function(node) { - return ol.format.XSD.readDecimal(node); +_ol_format_KML_.readScale_ = function(node) { + return _ol_format_XSD_.readDecimal(node); }; @@ -549,24 +551,24 @@ ol.format.KML.readScale_ = function(node) { * @private * @return {Array.|string|undefined} StyleMap. */ -ol.format.KML.readStyleMapValue_ = function(node, objectStack) { - return ol.xml.pushParseAndPop(undefined, - ol.format.KML.STYLE_MAP_PARSERS_, node, objectStack); +_ol_format_KML_.readStyleMapValue_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop(undefined, + _ol_format_KML_.STYLE_MAP_PARSERS_, node, objectStack); }; /** * @param {Node} node Node. * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.IconStyleParser_ = function(node, objectStack) { +_ol_format_KML_.IconStyleParser_ = function(node, objectStack) { // FIXME refreshMode // FIXME refreshInterval // FIXME viewRefreshTime // FIXME viewBoundScale // FIXME viewFormat // FIXME httpQuery - var object = ol.xml.pushParseAndPop( - {}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack); + var object = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.ICON_STYLE_PARSERS_, node, objectStack); if (!object) { return; } @@ -579,10 +581,10 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { if (href) { src = href; } else if (drawIcon) { - src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_; + src = _ol_format_KML_.DEFAULT_IMAGE_STYLE_SRC_; } var anchor, anchorXUnits, anchorYUnits; - var anchorOrigin = ol.style.IconOrigin.BOTTOM_LEFT; + var anchorOrigin = _ol_style_IconOrigin_.BOTTOM_LEFT; var hotSpot = /** @type {ol.KMLVec2_|undefined} */ (object['hotSpot']); if (hotSpot) { @@ -590,14 +592,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { anchorXUnits = hotSpot.xunits; anchorYUnits = hotSpot.yunits; anchorOrigin = hotSpot.origin; - } else if (src === ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) { - anchor = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_; - anchorXUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_; - anchorYUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_; + } else if (src === _ol_format_KML_.DEFAULT_IMAGE_STYLE_SRC_) { + anchor = _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_; + anchorXUnits = _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_; + anchorYUnits = _ol_format_KML_.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_; } else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) { anchor = [0.5, 0]; - anchorXUnits = ol.style.IconAnchorUnits.FRACTION; - anchorYUnits = ol.style.IconAnchorUnits.FRACTION; + anchorXUnits = _ol_style_IconAnchorUnits_.FRACTION; + anchorYUnits = _ol_style_IconAnchorUnits_.FRACTION; } var offset; @@ -622,28 +624,28 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var heading = /** @type {number} */ (object['heading']); if (heading !== undefined) { - rotation = ol.math.toRadians(heading); + rotation = _ol_math_.toRadians(heading); } var scale = /** @type {number|undefined} */ (object['scale']); if (drawIcon) { - if (src == ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) { - size = ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_; + if (src == _ol_format_KML_.DEFAULT_IMAGE_STYLE_SRC_) { + size = _ol_format_KML_.DEFAULT_IMAGE_STYLE_SIZE_; if (scale === undefined) { - scale = ol.format.KML.DEFAULT_IMAGE_SCALE_MULTIPLIER_; + scale = _ol_format_KML_.DEFAULT_IMAGE_SCALE_MULTIPLIER_; } } - var imageStyle = new ol.style.Icon({ + var imageStyle = new _ol_style_Icon_({ anchor: anchor, anchorOrigin: anchorOrigin, anchorXUnits: anchorXUnits, anchorYUnits: anchorYUnits, crossOrigin: 'anonymous', // FIXME should this be configurable? offset: offset, - offsetOrigin: ol.style.IconOrigin.BOTTOM_LEFT, + offsetOrigin: _ol_style_IconOrigin_.BOTTOM_LEFT, rotation: rotation, scale: scale, size: size, @@ -652,7 +654,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { styleObject['imageStyle'] = imageStyle; } else { // handle the case when we explicitly want to draw no icon. - styleObject['imageStyle'] = ol.format.KML.DEFAULT_NO_IMAGE_STYLE_; + styleObject['imageStyle'] = _ol_format_KML_.DEFAULT_NO_IMAGE_STYLE_; } }; @@ -662,18 +664,18 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.LabelStyleParser_ = function(node, objectStack) { +_ol_format_KML_.LabelStyleParser_ = function(node, objectStack) { // FIXME colorMode - var object = ol.xml.pushParseAndPop( - {}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack); + var object = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.LABEL_STYLE_PARSERS_, node, objectStack); if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; - var textStyle = new ol.style.Text({ - fill: new ol.style.Fill({ + var textStyle = new _ol_style_Text_({ + fill: new _ol_style_Fill_({ color: /** @type {ol.Color} */ - ('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_) + ('color' in object ? object['color'] : _ol_format_KML_.DEFAULT_COLOR_) }), scale: /** @type {number|undefined} */ (object['scale']) @@ -687,21 +689,21 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.LineStyleParser_ = function(node, objectStack) { +_ol_format_KML_.LineStyleParser_ = function(node, objectStack) { // FIXME colorMode // FIXME gx:outerColor // FIXME gx:outerWidth // FIXME gx:physicalWidth // FIXME gx:labelVisibility - var object = ol.xml.pushParseAndPop( - {}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack); + var object = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.LINE_STYLE_PARSERS_, node, objectStack); if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; - var strokeStyle = new ol.style.Stroke({ + var strokeStyle = new _ol_style_Stroke_({ color: /** @type {ol.Color} */ - ('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_), + ('color' in object ? object['color'] : _ol_format_KML_.DEFAULT_COLOR_), width: /** @type {number} */ ('width' in object ? object['width'] : 1) }); styleObject['strokeStyle'] = strokeStyle; @@ -713,17 +715,17 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.PolyStyleParser_ = function(node, objectStack) { +_ol_format_KML_.PolyStyleParser_ = function(node, objectStack) { // FIXME colorMode - var object = ol.xml.pushParseAndPop( - {}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack); + var object = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.POLY_STYLE_PARSERS_, node, objectStack); if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; - var fillStyle = new ol.style.Fill({ + var fillStyle = new _ol_style_Fill_({ color: /** @type {ol.Color} */ - ('color' in object ? object['color'] : ol.format.KML.DEFAULT_COLOR_) + ('color' in object ? object['color'] : _ol_format_KML_.DEFAULT_COLOR_) }); styleObject['fillStyle'] = fillStyle; var fill = /** @type {boolean|undefined} */ (object['fill']); @@ -744,9 +746,9 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { * @private * @return {Array.} LinearRing flat coordinates. */ -ol.format.KML.readFlatLinearRing_ = function(node, objectStack) { - return ol.xml.pushParseAndPop(null, - ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack); +_ol_format_KML_.readFlatLinearRing_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop(null, + _ol_format_KML_.FLAT_LINEAR_RING_PARSERS_, node, objectStack); }; @@ -755,11 +757,11 @@ ol.format.KML.readFlatLinearRing_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.gxCoordParser_ = function(node, objectStack) { +_ol_format_KML_.gxCoordParser_ = function(node, objectStack) { var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */ (objectStack[objectStack.length - 1]); var flatCoordinates = gxTrackObject.flatCoordinates; - var s = ol.xml.getAllTextContent(node, false); + var s = _ol_xml_.getAllTextContent(node, false); var re = /^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i; var m = re.exec(s); @@ -780,13 +782,13 @@ ol.format.KML.gxCoordParser_ = function(node, objectStack) { * @private * @return {ol.geom.MultiLineString|undefined} MultiLineString. */ -ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { - var lineStrings = ol.xml.pushParseAndPop([], - ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); +_ol_format_KML_.readGxMultiTrack_ = function(node, objectStack) { + var lineStrings = _ol_xml_.pushParseAndPop([], + _ol_format_KML_.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); if (!lineStrings) { return undefined; } - var multiLineString = new ol.geom.MultiLineString(null); + var multiLineString = new _ol_geom_MultiLineString_(null); multiLineString.setLineStrings(lineStrings); return multiLineString; }; @@ -798,12 +800,12 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { * @private * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.KML.readGxTrack_ = function(node, objectStack) { - var gxTrackObject = ol.xml.pushParseAndPop( +_ol_format_KML_.readGxTrack_ = function(node, objectStack) { + var gxTrackObject = _ol_xml_.pushParseAndPop( /** @type {ol.KMLGxTrackObject_} */ ({ flatCoordinates: [], whens: [] - }), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack); + }), _ol_format_KML_.GX_TRACK_PARSERS_, node, objectStack); if (!gxTrackObject) { return undefined; } @@ -814,8 +816,8 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) { ++i) { flatCoordinates[4 * i + 3] = whens[i]; } - var lineString = new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZM, flatCoordinates); + var lineString = new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZM, flatCoordinates); return lineString; }; @@ -826,9 +828,9 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) { * @private * @return {Object} Icon object. */ -ol.format.KML.readIcon_ = function(node, objectStack) { - var iconObject = ol.xml.pushParseAndPop( - {}, ol.format.KML.ICON_PARSERS_, node, objectStack); +_ol_format_KML_.readIcon_ = function(node, objectStack) { + var iconObject = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.ICON_PARSERS_, node, objectStack); if (iconObject) { return iconObject; } else { @@ -843,9 +845,9 @@ ol.format.KML.readIcon_ = function(node, objectStack) { * @private * @return {Array.} Flat coordinates. */ -ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) { - return ol.xml.pushParseAndPop(null, - ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack); +_ol_format_KML_.readFlatCoordinatesFromNode_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop(null, + _ol_format_KML_.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack); }; @@ -855,15 +857,15 @@ ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) { * @private * @return {ol.geom.LineString|undefined} LineString. */ -ol.format.KML.readLineString_ = function(node, objectStack) { - var properties = ol.xml.pushParseAndPop({}, - ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, +_ol_format_KML_.readLineString_ = function(node, objectStack) { + var properties = _ol_xml_.pushParseAndPop({}, + _ol_format_KML_.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, objectStack); var flatCoordinates = - ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); + _ol_format_KML_.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var lineString = new ol.geom.LineString(null); - lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var lineString = new _ol_geom_LineString_(null); + lineString.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); lineString.setProperties(properties); return lineString; } else { @@ -878,15 +880,15 @@ ol.format.KML.readLineString_ = function(node, objectStack) { * @private * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.KML.readLinearRing_ = function(node, objectStack) { - var properties = ol.xml.pushParseAndPop({}, - ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, +_ol_format_KML_.readLinearRing_ = function(node, objectStack) { + var properties = _ol_xml_.pushParseAndPop({}, + _ol_format_KML_.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, objectStack); var flatCoordinates = - ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); + _ol_format_KML_.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var polygon = new ol.geom.Polygon(null); - polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates, + var polygon = new _ol_geom_Polygon_(null); + polygon.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates, [flatCoordinates.length]); polygon.setProperties(properties); return polygon; @@ -902,14 +904,14 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) { * @private * @return {ol.geom.Geometry} Geometry. */ -ol.format.KML.readMultiGeometry_ = function(node, objectStack) { - var geometries = ol.xml.pushParseAndPop([], - ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack); +_ol_format_KML_.readMultiGeometry_ = function(node, objectStack) { + var geometries = _ol_xml_.pushParseAndPop([], + _ol_format_KML_.MULTI_GEOMETRY_PARSERS_, node, objectStack); if (!geometries) { return null; } if (geometries.length === 0) { - return new ol.geom.GeometryCollection(geometries); + return new _ol_geom_GeometryCollection_(geometries); } /** @type {ol.geom.Geometry} */ var multiGeometry; @@ -926,32 +928,32 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) { if (homogeneous) { var layout; var flatCoordinates; - if (type == ol.geom.GeometryType.POINT) { + if (type == _ol_geom_GeometryType_.POINT) { var point = geometries[0]; layout = point.getLayout(); flatCoordinates = point.getFlatCoordinates(); for (i = 1, ii = geometries.length; i < ii; ++i) { geometry = geometries[i]; - ol.array.extend(flatCoordinates, geometry.getFlatCoordinates()); + _ol_array_.extend(flatCoordinates, geometry.getFlatCoordinates()); } - multiGeometry = new ol.geom.MultiPoint(null); + multiGeometry = new _ol_geom_MultiPoint_(null); multiGeometry.setFlatCoordinates(layout, flatCoordinates); - ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries); - } else if (type == ol.geom.GeometryType.LINE_STRING) { - multiGeometry = new ol.geom.MultiLineString(null); + _ol_format_KML_.setCommonGeometryProperties_(multiGeometry, geometries); + } else if (type == _ol_geom_GeometryType_.LINE_STRING) { + multiGeometry = new _ol_geom_MultiLineString_(null); multiGeometry.setLineStrings(geometries); - ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries); - } else if (type == ol.geom.GeometryType.POLYGON) { - multiGeometry = new ol.geom.MultiPolygon(null); + _ol_format_KML_.setCommonGeometryProperties_(multiGeometry, geometries); + } else if (type == _ol_geom_GeometryType_.POLYGON) { + multiGeometry = new _ol_geom_MultiPolygon_(null); multiGeometry.setPolygons(geometries); - ol.format.KML.setCommonGeometryProperties_(multiGeometry, geometries); - } else if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) { - multiGeometry = new ol.geom.GeometryCollection(geometries); + _ol_format_KML_.setCommonGeometryProperties_(multiGeometry, geometries); + } else if (type == _ol_geom_GeometryType_.GEOMETRY_COLLECTION) { + multiGeometry = new _ol_geom_GeometryCollection_(geometries); } else { - ol.asserts.assert(false, 37); // Unknown geometry type found + _ol_asserts_.assert(false, 37); // Unknown geometry type found } } else { - multiGeometry = new ol.geom.GeometryCollection(geometries); + multiGeometry = new _ol_geom_GeometryCollection_(geometries); } return /** @type {ol.geom.Geometry} */ (multiGeometry); }; @@ -963,15 +965,15 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) { * @private * @return {ol.geom.Point|undefined} Point. */ -ol.format.KML.readPoint_ = function(node, objectStack) { - var properties = ol.xml.pushParseAndPop({}, - ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, +_ol_format_KML_.readPoint_ = function(node, objectStack) { + var properties = _ol_xml_.pushParseAndPop({}, + _ol_format_KML_.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, objectStack); var flatCoordinates = - ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); + _ol_format_KML_.readFlatCoordinatesFromNode_(node, objectStack); if (flatCoordinates) { - var point = new ol.geom.Point(null); - point.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); + var point = new _ol_geom_Point_(null); + point.setFlatCoordinates(_ol_geom_GeometryLayout_.XYZ, flatCoordinates); point.setProperties(properties); return point; } else { @@ -986,23 +988,23 @@ ol.format.KML.readPoint_ = function(node, objectStack) { * @private * @return {ol.geom.Polygon|undefined} Polygon. */ -ol.format.KML.readPolygon_ = function(node, objectStack) { - var properties = ol.xml.pushParseAndPop(/** @type {Object} */ ({}), - ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, +_ol_format_KML_.readPolygon_ = function(node, objectStack) { + var properties = _ol_xml_.pushParseAndPop(/** @type {Object} */ ({}), + _ol_format_KML_.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_, node, objectStack); - var flatLinearRings = ol.xml.pushParseAndPop([null], - ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack); + var flatLinearRings = _ol_xml_.pushParseAndPop([null], + _ol_format_KML_.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack); if (flatLinearRings && flatLinearRings[0]) { - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); var flatCoordinates = flatLinearRings[0]; var ends = [flatCoordinates.length]; var i, ii; for (i = 1, ii = flatLinearRings.length; i < ii; ++i) { - ol.array.extend(flatCoordinates, flatLinearRings[i]); + _ol_array_.extend(flatCoordinates, flatLinearRings[i]); ends.push(flatCoordinates.length); } polygon.setFlatCoordinates( - ol.geom.GeometryLayout.XYZ, flatCoordinates, ends); + _ol_geom_GeometryLayout_.XYZ, flatCoordinates, ends); polygon.setProperties(properties); return polygon; } else { @@ -1017,37 +1019,37 @@ ol.format.KML.readPolygon_ = function(node, objectStack) { * @private * @return {Array.} Style. */ -ol.format.KML.readStyle_ = function(node, objectStack) { - var styleObject = ol.xml.pushParseAndPop( - {}, ol.format.KML.STYLE_PARSERS_, node, objectStack); +_ol_format_KML_.readStyle_ = function(node, objectStack) { + var styleObject = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.STYLE_PARSERS_, node, objectStack); if (!styleObject) { return null; } var fillStyle = /** @type {ol.style.Fill} */ ('fillStyle' in styleObject ? - styleObject['fillStyle'] : ol.format.KML.DEFAULT_FILL_STYLE_); + styleObject['fillStyle'] : _ol_format_KML_.DEFAULT_FILL_STYLE_); var fill = /** @type {boolean|undefined} */ (styleObject['fill']); if (fill !== undefined && !fill) { fillStyle = null; } var imageStyle = /** @type {ol.style.Image} */ ('imageStyle' in styleObject ? - styleObject['imageStyle'] : ol.format.KML.DEFAULT_IMAGE_STYLE_); - if (imageStyle == ol.format.KML.DEFAULT_NO_IMAGE_STYLE_) { + styleObject['imageStyle'] : _ol_format_KML_.DEFAULT_IMAGE_STYLE_); + if (imageStyle == _ol_format_KML_.DEFAULT_NO_IMAGE_STYLE_) { imageStyle = undefined; } var textStyle = /** @type {ol.style.Text} */ ('textStyle' in styleObject ? - styleObject['textStyle'] : ol.format.KML.DEFAULT_TEXT_STYLE_); + styleObject['textStyle'] : _ol_format_KML_.DEFAULT_TEXT_STYLE_); var strokeStyle = /** @type {ol.style.Stroke} */ ('strokeStyle' in styleObject ? - styleObject['strokeStyle'] : ol.format.KML.DEFAULT_STROKE_STYLE_); + styleObject['strokeStyle'] : _ol_format_KML_.DEFAULT_STROKE_STYLE_); var outline = /** @type {boolean|undefined} */ (styleObject['outline']); if (outline !== undefined && !outline) { strokeStyle = null; } - return [new ol.style.Style({ + return [new _ol_style_Style_({ fill: fillStyle, image: imageStyle, stroke: strokeStyle, @@ -1065,7 +1067,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) { * @param {Array.} geometries List of geometries. * @private */ -ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry, +_ol_format_KML_.setCommonGeometryProperties_ = function(multiGeometry, geometries) { var ii = geometries.length; var extrudes = new Array(geometries.length); @@ -1099,9 +1101,9 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry, * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.DataParser_ = function(node, objectStack) { +_ol_format_KML_.DataParser_ = function(node, objectStack) { var name = node.getAttribute('name'); - ol.xml.parseNode(ol.format.KML.DATA_PARSERS_, node, objectStack); + _ol_xml_.parseNode(_ol_format_KML_.DATA_PARSERS_, node, objectStack); var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); if (name !== null) { featureObject[name] = featureObject.value; @@ -1117,8 +1119,8 @@ ol.format.KML.DataParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.ExtendedDataParser_ = function(node, objectStack) { - ol.xml.parseNode(ol.format.KML.EXTENDED_DATA_PARSERS_, node, objectStack); +_ol_format_KML_.ExtendedDataParser_ = function(node, objectStack) { + _ol_xml_.parseNode(_ol_format_KML_.EXTENDED_DATA_PARSERS_, node, objectStack); }; /** @@ -1126,8 +1128,8 @@ ol.format.KML.ExtendedDataParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.RegionParser_ = function(node, objectStack) { - ol.xml.parseNode(ol.format.KML.REGION_PARSERS_, node, objectStack); +_ol_format_KML_.RegionParser_ = function(node, objectStack) { + _ol_xml_.parseNode(_ol_format_KML_.REGION_PARSERS_, node, objectStack); }; /** @@ -1135,9 +1137,9 @@ ol.format.KML.RegionParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.PairDataParser_ = function(node, objectStack) { - var pairObject = ol.xml.pushParseAndPop( - {}, ol.format.KML.PAIR_PARSERS_, node, objectStack); +_ol_format_KML_.PairDataParser_ = function(node, objectStack) { + var pairObject = _ol_xml_.pushParseAndPop( + {}, _ol_format_KML_.PAIR_PARSERS_, node, objectStack); if (!pairObject) { return; } @@ -1163,8 +1165,8 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) { - var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); +_ol_format_KML_.PlacemarkStyleMapParser_ = function(node, objectStack) { + var styleMapValue = _ol_format_KML_.readStyleMapValue_(node, objectStack); if (!styleMapValue) { return; } @@ -1174,7 +1176,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) { } else if (typeof styleMapValue === 'string') { placemarkObject['styleUrl'] = styleMapValue; } else { - ol.asserts.assert(false, 38); // `styleMapValue` has an unknown type + _ol_asserts_.assert(false, 38); // `styleMapValue` has an unknown type } }; @@ -1184,8 +1186,8 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.SchemaDataParser_ = function(node, objectStack) { - ol.xml.parseNode(ol.format.KML.SCHEMA_DATA_PARSERS_, node, objectStack); +_ol_format_KML_.SchemaDataParser_ = function(node, objectStack) { + _ol_xml_.parseNode(_ol_format_KML_.SCHEMA_DATA_PARSERS_, node, objectStack); }; @@ -1194,10 +1196,10 @@ ol.format.KML.SchemaDataParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.SimpleDataParser_ = function(node, objectStack) { +_ol_format_KML_.SimpleDataParser_ = function(node, objectStack) { var name = node.getAttribute('name'); if (name !== null) { - var data = ol.format.XSD.readString(node); + var data = _ol_format_XSD_.readString(node); var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); featureObject[name] = data; @@ -1210,8 +1212,8 @@ ol.format.KML.SimpleDataParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.LatLonAltBoxParser_ = function(node, objectStack) { - var object = ol.xml.pushParseAndPop({}, ol.format.KML.LAT_LON_ALT_BOX_PARSERS_, node, objectStack); +_ol_format_KML_.LatLonAltBoxParser_ = function(node, objectStack) { + var object = _ol_xml_.pushParseAndPop({}, _ol_format_KML_.LAT_LON_ALT_BOX_PARSERS_, node, objectStack); if (!object) { return; } @@ -1234,8 +1236,8 @@ ol.format.KML.LatLonAltBoxParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.LodParser_ = function(node, objectStack) { - var object = ol.xml.pushParseAndPop({}, ol.format.KML.LOD_PARSERS_, node, objectStack); +_ol_format_KML_.LodParser_ = function(node, objectStack) { + var object = _ol_xml_.pushParseAndPop({}, _ol_format_KML_.LOD_PARSERS_, node, objectStack); if (!object) { return; } @@ -1252,10 +1254,10 @@ ol.format.KML.LodParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) { +_ol_format_KML_.innerBoundaryIsParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, - ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, + _ol_format_KML_.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -1269,10 +1271,10 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) { +_ol_format_KML_.outerBoundaryIsParser_ = function(node, objectStack) { /** @type {Array.|undefined} */ - var flatLinearRing = ol.xml.pushParseAndPop(undefined, - ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); + var flatLinearRing = _ol_xml_.pushParseAndPop(undefined, + _ol_format_KML_.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); @@ -1286,8 +1288,8 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.LinkParser_ = function(node, objectStack) { - ol.xml.parseNode(ol.format.KML.LINK_PARSERS_, node, objectStack); +_ol_format_KML_.LinkParser_ = function(node, objectStack) { + _ol_xml_.parseNode(_ol_format_KML_.LINK_PARSERS_, node, objectStack); }; @@ -1296,11 +1298,11 @@ ol.format.KML.LinkParser_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.whenParser_ = function(node, objectStack) { +_ol_format_KML_.whenParser_ = function(node, objectStack) { var gxTrackObject = /** @type {ol.KMLGxTrackObject_} */ (objectStack[objectStack.length - 1]); var whens = gxTrackObject.whens; - var s = ol.xml.getAllTextContent(node, false); + var s = _ol_xml_.getAllTextContent(node, false); var when = Date.parse(s); whens.push(isNaN(when) ? 0 : when); }; @@ -1311,10 +1313,10 @@ ol.format.KML.whenParser_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.KML.DATA_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'displayName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'value': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString) +_ol_format_KML_.DATA_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'displayName': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'value': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString) }); @@ -1323,10 +1325,10 @@ ol.format.KML.DATA_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.EXTENDED_DATA_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Data': ol.format.KML.DataParser_, - 'SchemaData': ol.format.KML.SchemaDataParser_ +_ol_format_KML_.EXTENDED_DATA_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Data': _ol_format_KML_.DataParser_, + 'SchemaData': _ol_format_KML_.SchemaDataParser_ }); @@ -1335,10 +1337,10 @@ ol.format.KML.EXTENDED_DATA_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.REGION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LatLonAltBox': ol.format.KML.LatLonAltBoxParser_, - 'Lod': ol.format.KML.LodParser_ +_ol_format_KML_.REGION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LatLonAltBox': _ol_format_KML_.LatLonAltBoxParser_, + 'Lod': _ol_format_KML_.LodParser_ }); @@ -1347,15 +1349,15 @@ ol.format.KML.REGION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LAT_LON_ALT_BOX_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'altitudeMode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'minAltitude': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'maxAltitude': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'north': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'south': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'east': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'west': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal) +_ol_format_KML_.LAT_LON_ALT_BOX_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'altitudeMode': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'minAltitude': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'maxAltitude': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'north': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'south': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'east': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'west': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal) }); @@ -1364,12 +1366,12 @@ ol.format.KML.LAT_LON_ALT_BOX_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LOD_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'minLodPixels': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'maxLodPixels': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'minFadeExtent': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'maxFadeExtent': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal) +_ol_format_KML_.LOD_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'minLodPixels': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'maxLodPixels': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'minFadeExtent': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'maxFadeExtent': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal) }); @@ -1378,11 +1380,11 @@ ol.format.KML.LOD_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'extrude': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean), - 'tessellate': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean), - 'altitudeMode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString) +_ol_format_KML_.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'extrude': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean), + 'tessellate': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean), + 'altitudeMode': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString) }); @@ -1391,9 +1393,9 @@ ol.format.KML.EXTRUDE_AND_ALTITUDE_MODE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.FLAT_LINEAR_RING_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'coordinates': ol.xml.makeReplacer(ol.format.KML.readFlatCoordinates_) +_ol_format_KML_.FLAT_LINEAR_RING_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'coordinates': _ol_xml_.makeReplacer(_ol_format_KML_.readFlatCoordinates_) }); @@ -1402,10 +1404,10 @@ ol.format.KML.FLAT_LINEAR_RING_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'innerBoundaryIs': ol.format.KML.innerBoundaryIsParser_, - 'outerBoundaryIs': ol.format.KML.outerBoundaryIsParser_ +_ol_format_KML_.FLAT_LINEAR_RINGS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'innerBoundaryIs': _ol_format_KML_.innerBoundaryIsParser_, + 'outerBoundaryIs': _ol_format_KML_.outerBoundaryIsParser_ }); @@ -1414,12 +1416,12 @@ ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.GX_TRACK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'when': ol.format.KML.whenParser_ - }, ol.xml.makeStructureNS( - ol.format.KML.GX_NAMESPACE_URIS_, { - 'coord': ol.format.KML.gxCoordParser_ +_ol_format_KML_.GX_TRACK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'when': _ol_format_KML_.whenParser_ + }, _ol_xml_.makeStructureNS( + _ol_format_KML_.GX_NAMESPACE_URIS_, { + 'coord': _ol_format_KML_.gxCoordParser_ })); @@ -1428,9 +1430,9 @@ ol.format.KML.GX_TRACK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'coordinates': ol.xml.makeReplacer(ol.format.KML.readFlatCoordinates_) +_ol_format_KML_.GEOMETRY_FLAT_COORDINATES_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'coordinates': _ol_xml_.makeReplacer(_ol_format_KML_.readFlatCoordinates_) }); @@ -1439,15 +1441,15 @@ ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.ICON_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'href': ol.xml.makeObjectPropertySetter(ol.format.KML.readURI_) - }, ol.xml.makeStructureNS( - ol.format.KML.GX_NAMESPACE_URIS_, { - 'x': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'y': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'w': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'h': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal) +_ol_format_KML_.ICON_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'href': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readURI_) + }, _ol_xml_.makeStructureNS( + _ol_format_KML_.GX_NAMESPACE_URIS_, { + 'x': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'y': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'w': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'h': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal) })); @@ -1456,12 +1458,12 @@ ol.format.KML.ICON_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.ICON_STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Icon': ol.xml.makeObjectPropertySetter(ol.format.KML.readIcon_), - 'heading': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), - 'hotSpot': ol.xml.makeObjectPropertySetter(ol.format.KML.readVec2_), - 'scale': ol.xml.makeObjectPropertySetter(ol.format.KML.readScale_) +_ol_format_KML_.ICON_STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Icon': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readIcon_), + 'heading': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal), + 'hotSpot': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readVec2_), + 'scale': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readScale_) }); @@ -1470,9 +1472,9 @@ ol.format.KML.ICON_STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.INNER_BOUNDARY_IS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LinearRing': ol.xml.makeReplacer(ol.format.KML.readFlatLinearRing_) +_ol_format_KML_.INNER_BOUNDARY_IS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LinearRing': _ol_xml_.makeReplacer(_ol_format_KML_.readFlatLinearRing_) }); @@ -1481,10 +1483,10 @@ ol.format.KML.INNER_BOUNDARY_IS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LABEL_STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeObjectPropertySetter(ol.format.KML.readColor_), - 'scale': ol.xml.makeObjectPropertySetter(ol.format.KML.readScale_) +_ol_format_KML_.LABEL_STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readColor_), + 'scale': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readScale_) }); @@ -1493,10 +1495,10 @@ ol.format.KML.LABEL_STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LINE_STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeObjectPropertySetter(ol.format.KML.readColor_), - 'width': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal) +_ol_format_KML_.LINE_STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readColor_), + 'width': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readDecimal) }); @@ -1505,13 +1507,13 @@ ol.format.KML.LINE_STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.MULTI_GEOMETRY_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LineString': ol.xml.makeArrayPusher(ol.format.KML.readLineString_), - 'LinearRing': ol.xml.makeArrayPusher(ol.format.KML.readLinearRing_), - 'MultiGeometry': ol.xml.makeArrayPusher(ol.format.KML.readMultiGeometry_), - 'Point': ol.xml.makeArrayPusher(ol.format.KML.readPoint_), - 'Polygon': ol.xml.makeArrayPusher(ol.format.KML.readPolygon_) +_ol_format_KML_.MULTI_GEOMETRY_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LineString': _ol_xml_.makeArrayPusher(_ol_format_KML_.readLineString_), + 'LinearRing': _ol_xml_.makeArrayPusher(_ol_format_KML_.readLinearRing_), + 'MultiGeometry': _ol_xml_.makeArrayPusher(_ol_format_KML_.readMultiGeometry_), + 'Point': _ol_xml_.makeArrayPusher(_ol_format_KML_.readPoint_), + 'Polygon': _ol_xml_.makeArrayPusher(_ol_format_KML_.readPolygon_) }); @@ -1520,9 +1522,9 @@ ol.format.KML.MULTI_GEOMETRY_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.GX_NAMESPACE_URIS_, { - 'Track': ol.xml.makeArrayPusher(ol.format.KML.readGxTrack_) +_ol_format_KML_.GX_MULTITRACK_GEOMETRY_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.GX_NAMESPACE_URIS_, { + 'Track': _ol_xml_.makeArrayPusher(_ol_format_KML_.readGxTrack_) }); @@ -1531,17 +1533,17 @@ ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.NETWORK_LINK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'ExtendedData': ol.format.KML.ExtendedDataParser_, - 'Region': ol.format.KML.RegionParser_, - 'Link': ol.format.KML.LinkParser_, - 'address': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'description': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'open': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean), - 'phoneNumber': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'visibility': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean) +_ol_format_KML_.NETWORK_LINK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'ExtendedData': _ol_format_KML_.ExtendedDataParser_, + 'Region': _ol_format_KML_.RegionParser_, + 'Link': _ol_format_KML_.LinkParser_, + 'address': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'description': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'open': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean), + 'phoneNumber': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'visibility': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean) }); @@ -1550,9 +1552,9 @@ ol.format.KML.NETWORK_LINK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LINK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'href': ol.xml.makeObjectPropertySetter(ol.format.KML.readURI_) +_ol_format_KML_.LINK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'href': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readURI_) }); @@ -1561,9 +1563,9 @@ ol.format.KML.LINK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LinearRing': ol.xml.makeReplacer(ol.format.KML.readFlatLinearRing_) +_ol_format_KML_.OUTER_BOUNDARY_IS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LinearRing': _ol_xml_.makeReplacer(_ol_format_KML_.readFlatLinearRing_) }); @@ -1572,11 +1574,11 @@ ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PAIR_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Style': ol.xml.makeObjectPropertySetter(ol.format.KML.readStyle_), - 'key': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'styleUrl': ol.xml.makeObjectPropertySetter(ol.format.KML.readURI_) +_ol_format_KML_.PAIR_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Style': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readStyle_), + 'key': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'styleUrl': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readURI_) }); @@ -1585,35 +1587,35 @@ ol.format.KML.PAIR_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PLACEMARK_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'ExtendedData': ol.format.KML.ExtendedDataParser_, - 'Region': ol.format.KML.RegionParser_, - 'MultiGeometry': ol.xml.makeObjectPropertySetter( - ol.format.KML.readMultiGeometry_, 'geometry'), - 'LineString': ol.xml.makeObjectPropertySetter( - ol.format.KML.readLineString_, 'geometry'), - 'LinearRing': ol.xml.makeObjectPropertySetter( - ol.format.KML.readLinearRing_, 'geometry'), - 'Point': ol.xml.makeObjectPropertySetter( - ol.format.KML.readPoint_, 'geometry'), - 'Polygon': ol.xml.makeObjectPropertySetter( - ol.format.KML.readPolygon_, 'geometry'), - 'Style': ol.xml.makeObjectPropertySetter(ol.format.KML.readStyle_), - 'StyleMap': ol.format.KML.PlacemarkStyleMapParser_, - 'address': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'description': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'open': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean), - 'phoneNumber': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'styleUrl': ol.xml.makeObjectPropertySetter(ol.format.KML.readURI_), - 'visibility': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean) - }, ol.xml.makeStructureNS( - ol.format.KML.GX_NAMESPACE_URIS_, { - 'MultiTrack': ol.xml.makeObjectPropertySetter( - ol.format.KML.readGxMultiTrack_, 'geometry'), - 'Track': ol.xml.makeObjectPropertySetter( - ol.format.KML.readGxTrack_, 'geometry') +_ol_format_KML_.PLACEMARK_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'ExtendedData': _ol_format_KML_.ExtendedDataParser_, + 'Region': _ol_format_KML_.RegionParser_, + 'MultiGeometry': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readMultiGeometry_, 'geometry'), + 'LineString': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readLineString_, 'geometry'), + 'LinearRing': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readLinearRing_, 'geometry'), + 'Point': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readPoint_, 'geometry'), + 'Polygon': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readPolygon_, 'geometry'), + 'Style': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readStyle_), + 'StyleMap': _ol_format_KML_.PlacemarkStyleMapParser_, + 'address': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'description': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'open': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean), + 'phoneNumber': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'styleUrl': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readURI_), + 'visibility': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean) + }, _ol_xml_.makeStructureNS( + _ol_format_KML_.GX_NAMESPACE_URIS_, { + 'MultiTrack': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readGxMultiTrack_, 'geometry'), + 'Track': _ol_xml_.makeObjectPropertySetter( + _ol_format_KML_.readGxTrack_, 'geometry') } )); @@ -1623,11 +1625,11 @@ ol.format.KML.PLACEMARK_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.POLY_STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeObjectPropertySetter(ol.format.KML.readColor_), - 'fill': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean), - 'outline': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean) +_ol_format_KML_.POLY_STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeObjectPropertySetter(_ol_format_KML_.readColor_), + 'fill': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean), + 'outline': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readBoolean) }); @@ -1636,9 +1638,9 @@ ol.format.KML.POLY_STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.SCHEMA_DATA_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'SimpleData': ol.format.KML.SimpleDataParser_ +_ol_format_KML_.SCHEMA_DATA_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'SimpleData': _ol_format_KML_.SimpleDataParser_ }); @@ -1647,12 +1649,12 @@ ol.format.KML.SCHEMA_DATA_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'IconStyle': ol.format.KML.IconStyleParser_, - 'LabelStyle': ol.format.KML.LabelStyleParser_, - 'LineStyle': ol.format.KML.LineStyleParser_, - 'PolyStyle': ol.format.KML.PolyStyleParser_ +_ol_format_KML_.STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'IconStyle': _ol_format_KML_.IconStyleParser_, + 'LabelStyle': _ol_format_KML_.LabelStyleParser_, + 'LineStyle': _ol_format_KML_.LineStyleParser_, + 'PolyStyle': _ol_format_KML_.PolyStyleParser_ }); @@ -1661,9 +1663,9 @@ ol.format.KML.STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.STYLE_MAP_PARSERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Pair': ol.format.KML.PairDataParser_ +_ol_format_KML_.STYLE_MAP_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Pair': _ol_format_KML_.PairDataParser_ }); @@ -1673,18 +1675,18 @@ ol.format.KML.STYLE_MAP_PARSERS_ = ol.xml.makeStructureNS( * @private * @return {Array.|undefined} Features. */ -ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) { +_ol_format_KML_.prototype.readDocumentOrFolder_ = function(node, objectStack) { // FIXME use scope somehow - var parsersNS = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Document': ol.xml.makeArrayExtender(this.readDocumentOrFolder_, this), - 'Folder': ol.xml.makeArrayExtender(this.readDocumentOrFolder_, this), - 'Placemark': ol.xml.makeArrayPusher(this.readPlacemark_, this), + var parsersNS = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Document': _ol_xml_.makeArrayExtender(this.readDocumentOrFolder_, this), + 'Folder': _ol_xml_.makeArrayExtender(this.readDocumentOrFolder_, this), + 'Placemark': _ol_xml_.makeArrayPusher(this.readPlacemark_, this), 'Style': this.readSharedStyle_.bind(this), 'StyleMap': this.readSharedStyleMap_.bind(this) }); /** @type {Array.} */ - var features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack, this); + var features = _ol_xml_.pushParseAndPop([], parsersNS, node, objectStack, this); if (features) { return features; } else { @@ -1699,13 +1701,13 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) { * @private * @return {ol.Feature|undefined} Feature. */ -ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { - var object = ol.xml.pushParseAndPop({'geometry': null}, - ol.format.KML.PLACEMARK_PARSERS_, node, objectStack); +_ol_format_KML_.prototype.readPlacemark_ = function(node, objectStack) { + var object = _ol_xml_.pushParseAndPop({'geometry': null}, + _ol_format_KML_.PLACEMARK_PARSERS_, node, objectStack); if (!object) { return undefined; } - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); var id = node.getAttribute('id'); if (id !== null) { feature.setId(id); @@ -1714,7 +1716,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { var geometry = object['geometry']; if (geometry) { - ol.format.Feature.transformWithOptions(geometry, false, options); + _ol_format_Feature_.transformWithOptions(geometry, false, options); } feature.setGeometry(geometry); delete object['geometry']; @@ -1722,7 +1724,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { if (this.extractStyles_) { var style = object['Style']; var styleUrl = object['styleUrl']; - var styleFunction = ol.format.KML.createFeatureStyleFunction_( + var styleFunction = _ol_format_KML_.createFeatureStyleFunction_( style, styleUrl, this.defaultStyle_, this.sharedStyles_, this.showPointNames_); feature.setStyle(styleFunction); @@ -1742,10 +1744,10 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) { +_ol_format_KML_.prototype.readSharedStyle_ = function(node, objectStack) { var id = node.getAttribute('id'); if (id !== null) { - var style = ol.format.KML.readStyle_(node, objectStack); + var style = _ol_format_KML_.readStyle_(node, objectStack); if (style) { var styleUri; var baseURI = node.baseURI; @@ -1769,12 +1771,12 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) { +_ol_format_KML_.prototype.readSharedStyleMap_ = function(node, objectStack) { var id = node.getAttribute('id'); if (id === null) { return; } - var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); + var styleMapValue = _ol_format_KML_.readStyleMapValue_(node, objectStack); if (!styleMapValue) { return; } @@ -1804,14 +1806,14 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) { * @return {ol.Feature} Feature. * @api */ -ol.format.KML.prototype.readFeature; +_ol_format_KML_.prototype.readFeature; /** * @inheritDoc */ -ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) { - if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { +_ol_format_KML_.prototype.readFeatureFromNode = function(node, opt_options) { + if (!_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, node.namespaceURI)) { return null; } var feature = this.readPlacemark_( @@ -1835,14 +1837,14 @@ ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) { * @return {Array.} Features. * @api */ -ol.format.KML.prototype.readFeatures; +_ol_format_KML_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { - if (!ol.array.includes(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) { +_ol_format_KML_.prototype.readFeaturesFromNode = function(node, opt_options) { + if (!_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, node.namespaceURI)) { return []; } var features; @@ -1869,7 +1871,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { for (n = node.firstElementChild; n; n = n.nextElementSibling) { var fs = this.readFeaturesFromNode(n, opt_options); if (fs) { - ol.array.extend(features, fs); + _ol_array_.extend(features, fs); } } return features; @@ -1886,13 +1888,13 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { * @return {string|undefined} Name. * @api */ -ol.format.KML.prototype.readName = function(source) { - if (ol.xml.isDocument(source)) { +_ol_format_KML_.prototype.readName = function(source) { + if (_ol_xml_.isDocument(source)) { return this.readNameFromDocument(/** @type {Document} */ (source)); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readNameFromNode(/** @type {Node} */ (source)); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readNameFromDocument(doc); } else { return undefined; @@ -1904,7 +1906,7 @@ ol.format.KML.prototype.readName = function(source) { * @param {Document} doc Document. * @return {string|undefined} Name. */ -ol.format.KML.prototype.readNameFromDocument = function(doc) { +_ol_format_KML_.prototype.readNameFromDocument = function(doc) { var n; for (n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { @@ -1922,17 +1924,17 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) { * @param {Node} node Node. * @return {string|undefined} Name. */ -ol.format.KML.prototype.readNameFromNode = function(node) { +_ol_format_KML_.prototype.readNameFromNode = function(node) { var n; for (n = node.firstElementChild; n; n = n.nextElementSibling) { - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && n.localName == 'name') { - return ol.format.XSD.readString(n); + return _ol_format_XSD_.readString(n); } } for (n = node.firstElementChild; n; n = n.nextElementSibling) { var localName = n.localName; - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && (localName == 'Document' || localName == 'Folder' || localName == 'Placemark' || @@ -1954,17 +1956,17 @@ ol.format.KML.prototype.readNameFromNode = function(node) { * @return {Array.} Network links. * @api */ -ol.format.KML.prototype.readNetworkLinks = function(source) { +_ol_format_KML_.prototype.readNetworkLinks = function(source) { var networkLinks = []; - if (ol.xml.isDocument(source)) { - ol.array.extend(networkLinks, this.readNetworkLinksFromDocument( + if (_ol_xml_.isDocument(source)) { + _ol_array_.extend(networkLinks, this.readNetworkLinksFromDocument( /** @type {Document} */ (source))); - } else if (ol.xml.isNode(source)) { - ol.array.extend(networkLinks, this.readNetworkLinksFromNode( + } else if (_ol_xml_.isNode(source)) { + _ol_array_.extend(networkLinks, this.readNetworkLinksFromNode( /** @type {Node} */ (source))); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); - ol.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc)); + var doc = _ol_xml_.parse(source); + _ol_array_.extend(networkLinks, this.readNetworkLinksFromDocument(doc)); } return networkLinks; }; @@ -1974,11 +1976,11 @@ ol.format.KML.prototype.readNetworkLinks = function(source) { * @param {Document} doc Document. * @return {Array.} Network links. */ -ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) { +_ol_format_KML_.prototype.readNetworkLinksFromDocument = function(doc) { var n, networkLinks = []; for (n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { - ol.array.extend(networkLinks, this.readNetworkLinksFromNode(n)); + _ol_array_.extend(networkLinks, this.readNetworkLinksFromNode(n)); } } return networkLinks; @@ -1989,23 +1991,23 @@ ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) { * @param {Node} node Node. * @return {Array.} Network links. */ -ol.format.KML.prototype.readNetworkLinksFromNode = function(node) { +_ol_format_KML_.prototype.readNetworkLinksFromNode = function(node) { var n, networkLinks = []; for (n = node.firstElementChild; n; n = n.nextElementSibling) { - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && n.localName == 'NetworkLink') { - var obj = ol.xml.pushParseAndPop({}, ol.format.KML.NETWORK_LINK_PARSERS_, + var obj = _ol_xml_.pushParseAndPop({}, _ol_format_KML_.NETWORK_LINK_PARSERS_, n, []); networkLinks.push(obj); } } for (n = node.firstElementChild; n; n = n.nextElementSibling) { var localName = n.localName; - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && (localName == 'Document' || localName == 'Folder' || localName == 'kml')) { - ol.array.extend(networkLinks, this.readNetworkLinksFromNode(n)); + _ol_array_.extend(networkLinks, this.readNetworkLinksFromNode(n)); } } return networkLinks; @@ -2019,17 +2021,17 @@ ol.format.KML.prototype.readNetworkLinksFromNode = function(node) { * @return {Array.} Regions. * @api */ -ol.format.KML.prototype.readRegion = function(source) { +_ol_format_KML_.prototype.readRegion = function(source) { var regions = []; - if (ol.xml.isDocument(source)) { - ol.array.extend(regions, this.readRegionFromDocument( + if (_ol_xml_.isDocument(source)) { + _ol_array_.extend(regions, this.readRegionFromDocument( /** @type {Document} */ (source))); - } else if (ol.xml.isNode(source)) { - ol.array.extend(regions, this.readRegionFromNode( + } else if (_ol_xml_.isNode(source)) { + _ol_array_.extend(regions, this.readRegionFromNode( /** @type {Node} */ (source))); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); - ol.array.extend(regions, this.readRegionFromDocument(doc)); + var doc = _ol_xml_.parse(source); + _ol_array_.extend(regions, this.readRegionFromDocument(doc)); } return regions; }; @@ -2039,11 +2041,11 @@ ol.format.KML.prototype.readRegion = function(source) { * @param {Document} doc Document. * @return {Array.} Region. */ -ol.format.KML.prototype.readRegionFromDocument = function(doc) { +_ol_format_KML_.prototype.readRegionFromDocument = function(doc) { var n, regions = []; for (n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { - ol.array.extend(regions, this.readRegionFromNode(n)); + _ol_array_.extend(regions, this.readRegionFromNode(n)); } } return regions; @@ -2055,23 +2057,23 @@ ol.format.KML.prototype.readRegionFromDocument = function(doc) { * @return {Array.} Region. * @api */ -ol.format.KML.prototype.readRegionFromNode = function(node) { +_ol_format_KML_.prototype.readRegionFromNode = function(node) { var n, regions = []; for (n = node.firstElementChild; n; n = n.nextElementSibling) { - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && n.localName == 'Region') { - var obj = ol.xml.pushParseAndPop({}, ol.format.KML.REGION_PARSERS_, + var obj = _ol_xml_.pushParseAndPop({}, _ol_format_KML_.REGION_PARSERS_, n, []); regions.push(obj); } } for (n = node.firstElementChild; n; n = n.nextElementSibling) { var localName = n.localName; - if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && + if (_ol_array_.includes(_ol_format_KML_.NAMESPACE_URIS_, n.namespaceURI) && (localName == 'Document' || localName == 'Folder' || localName == 'kml')) { - ol.array.extend(regions, this.readRegionFromNode(n)); + _ol_array_.extend(regions, this.readRegionFromNode(n)); } } return regions; @@ -2086,7 +2088,7 @@ ol.format.KML.prototype.readRegionFromNode = function(node) { * @return {ol.proj.Projection} Projection. * @api */ -ol.format.KML.prototype.readProjection; +_ol_format_KML_.prototype.readProjection; /** @@ -2094,8 +2096,8 @@ ol.format.KML.prototype.readProjection; * @param {ol.Color|string} color Color. * @private */ -ol.format.KML.writeColorTextNode_ = function(node, color) { - var rgba = ol.color.asArray(color); +_ol_format_KML_.writeColorTextNode_ = function(node, color) { + var rgba = _ol_color_.asArray(color); var opacity = (rgba.length == 4) ? rgba[3] : 1; var abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]]; var i; @@ -2103,7 +2105,7 @@ ol.format.KML.writeColorTextNode_ = function(node, color) { var hex = parseInt(abgr[i], 10).toString(16); abgr[i] = (hex.length == 1) ? '0' + hex : hex; } - ol.format.XSD.writeStringTextNode(node, abgr.join('')); + _ol_format_XSD_.writeStringTextNode(node, abgr.join('')); }; @@ -2113,21 +2115,21 @@ ol.format.KML.writeColorTextNode_ = function(node, color) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStack) { +_ol_format_KML_.writeCoordinatesTextNode_ = function(node, coordinates, objectStack) { var context = objectStack[objectStack.length - 1]; var layout = context['layout']; var stride = context['stride']; var dimension; - if (layout == ol.geom.GeometryLayout.XY || - layout == ol.geom.GeometryLayout.XYM) { + if (layout == _ol_geom_GeometryLayout_.XY || + layout == _ol_geom_GeometryLayout_.XYM) { dimension = 2; - } else if (layout == ol.geom.GeometryLayout.XYZ || - layout == ol.geom.GeometryLayout.XYZM) { + } else if (layout == _ol_geom_GeometryLayout_.XYZ || + layout == _ol_geom_GeometryLayout_.XYZM) { dimension = 3; } else { - ol.asserts.assert(false, 34); // Invalid geometry layout + _ol_asserts_.assert(false, 34); // Invalid geometry layout } var d, i; @@ -2145,7 +2147,7 @@ ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStac } } } - ol.format.XSD.writeStringTextNode(node, text); + _ol_format_XSD_.writeStringTextNode(node, text); }; @@ -2155,24 +2157,24 @@ ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStac * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeDataNode_ = function(node, pair, objectStack) { +_ol_format_KML_.writeDataNode_ = function(node, pair, objectStack) { node.setAttribute('name', pair.name); var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var value = pair.value; if (typeof value == 'object') { if (value !== null && value.displayName) { - ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.displayName], objectStack, ['displayName']); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.EXTENDEDDATA_NODE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, [value.displayName], objectStack, ['displayName']); } if (value !== null && value.value) { - ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value.value], objectStack, ['value']); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.EXTENDEDDATA_NODE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, [value.value], objectStack, ['value']); } } else { - ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, [value], objectStack, ['value']); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.EXTENDEDDATA_NODE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, [value], objectStack, ['value']); } }; @@ -2182,8 +2184,8 @@ ol.format.KML.writeDataNode_ = function(node, pair, objectStack) { * @param {string} name DisplayName. * @private */ -ol.format.KML.writeDataNodeName_ = function(node, name) { - ol.format.XSD.writeCDATASection(node, name); +_ol_format_KML_.writeDataNodeName_ = function(node, name) { + _ol_format_XSD_.writeCDATASection(node, name); }; @@ -2192,8 +2194,8 @@ ol.format.KML.writeDataNodeName_ = function(node, name) { * @param {string} value Value. * @private */ -ol.format.KML.writeDataNodeValue_ = function(node, value) { - ol.format.XSD.writeStringTextNode(node, value); +_ol_format_KML_.writeDataNodeValue_ = function(node, value) { + _ol_format_XSD_.writeStringTextNode(node, value); }; @@ -2204,10 +2206,10 @@ ol.format.KML.writeDataNodeValue_ = function(node, value) { * @this {ol.format.KML} * @private */ -ol.format.KML.writeDocument_ = function(node, features, objectStack) { +_ol_format_KML_.writeDocument_ = function(node, features, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; - ol.xml.pushSerializeAndPop(context, ol.format.KML.DOCUMENT_SERIALIZERS_, - ol.format.KML.DOCUMENT_NODE_FACTORY_, features, objectStack, undefined, + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.DOCUMENT_SERIALIZERS_, + _ol_format_KML_.DOCUMENT_NODE_FACTORY_, features, objectStack, undefined, this); }; @@ -2218,14 +2220,14 @@ ol.format.KML.writeDocument_ = function(node, features, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeExtendedData_ = function(node, namesAndValues, objectStack) { +_ol_format_KML_.writeExtendedData_ = function(node, namesAndValues, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var names = namesAndValues.names, values = namesAndValues.values; var length = names.length; for (var i = 0; i < length; i++) { - ol.xml.pushSerializeAndPop(context, ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_, - ol.format.KML.DATA_NODE_FACTORY_, [{name: names[i], value: values[i]}], objectStack); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.EXTENDEDDATA_NODE_SERIALIZERS_, + _ol_format_KML_.DATA_NODE_FACTORY_, [{name: names[i], value: values[i]}], objectStack); } }; @@ -2236,19 +2238,19 @@ ol.format.KML.writeExtendedData_ = function(node, namesAndValues, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeIcon_ = function(node, icon, objectStack) { +_ol_format_KML_.writeIcon_ = function(node, icon, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.ICON_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(icon, orderedKeys); - ol.xml.pushSerializeAndPop(context, - ol.format.KML.ICON_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, + var orderedKeys = _ol_format_KML_.ICON_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(icon, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, + _ol_format_KML_.ICON_SERIALIZERS_, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); orderedKeys = - ol.format.KML.ICON_SEQUENCE_[ol.format.KML.GX_NAMESPACE_URIS_[0]]; - values = ol.xml.makeSequence(icon, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.ICON_SERIALIZERS_, - ol.format.KML.GX_NODE_FACTORY_, values, objectStack, orderedKeys); + _ol_format_KML_.ICON_SEQUENCE_[_ol_format_KML_.GX_NAMESPACE_URIS_[0]]; + values = _ol_xml_.makeSequence(icon, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.ICON_SERIALIZERS_, + _ol_format_KML_.GX_NODE_FACTORY_, values, objectStack, orderedKeys); }; @@ -2258,7 +2260,7 @@ ol.format.KML.writeIcon_ = function(node, icon, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeIconStyle_ = function(node, style, objectStack) { +_ol_format_KML_.writeIconStyle_ = function(node, style, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var properties = {}; var src = style.getSrc(); @@ -2282,9 +2284,9 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) { if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) { var /** @type {ol.KMLVec2_} */ hotSpot = { x: anchor[0], - xunits: ol.style.IconAnchorUnits.PIXELS, + xunits: _ol_style_IconAnchorUnits_.PIXELS, y: size[1] - anchor[1], - yunits: ol.style.IconAnchorUnits.PIXELS + yunits: _ol_style_IconAnchorUnits_.PIXELS }; properties['hotSpot'] = hotSpot; } @@ -2303,10 +2305,10 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) { } var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.ICON_STYLE_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.ICON_STYLE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + var orderedKeys = _ol_format_KML_.ICON_STYLE_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.ICON_STYLE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -2316,7 +2318,7 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) { +_ol_format_KML_.writeLabelStyle_ = function(node, style, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var properties = {}; var fill = style.getFill(); @@ -2329,10 +2331,10 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) { } var parentNode = objectStack[objectStack.length - 1].node; var orderedKeys = - ol.format.KML.LABEL_STYLE_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.LABEL_STYLE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + _ol_format_KML_.LABEL_STYLE_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.LABEL_STYLE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -2342,17 +2344,17 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeLineStyle_ = function(node, style, objectStack) { +_ol_format_KML_.writeLineStyle_ = function(node, style, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var properties = { 'color': style.getColor(), 'width': style.getWidth() }; var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.LINE_STYLE_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.LINE_STYLE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + var orderedKeys = _ol_format_KML_.LINE_STYLE_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.LINE_STYLE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -2362,7 +2364,7 @@ ol.format.KML.writeLineStyle_ = function(node, style, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) { +_ol_format_KML_.writeMultiGeometry_ = function(node, geometry, objectStack) { /** @type {ol.XmlNodeStackItem} */ var context = {node: node}; var type = geometry.getType(); @@ -2370,25 +2372,25 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) { var geometries; /** @type {function(*, Array.<*>, string=): (Node|undefined)} */ var factory; - if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) { + if (type == _ol_geom_GeometryType_.GEOMETRY_COLLECTION) { geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries(); - factory = ol.format.KML.GEOMETRY_NODE_FACTORY_; - } else if (type == ol.geom.GeometryType.MULTI_POINT) { + factory = _ol_format_KML_.GEOMETRY_NODE_FACTORY_; + } else if (type == _ol_geom_GeometryType_.MULTI_POINT) { geometries = /** @type {ol.geom.MultiPoint} */ (geometry).getPoints(); - factory = ol.format.KML.POINT_NODE_FACTORY_; - } else if (type == ol.geom.GeometryType.MULTI_LINE_STRING) { + factory = _ol_format_KML_.POINT_NODE_FACTORY_; + } else if (type == _ol_geom_GeometryType_.MULTI_LINE_STRING) { geometries = (/** @type {ol.geom.MultiLineString} */ (geometry)).getLineStrings(); - factory = ol.format.KML.LINE_STRING_NODE_FACTORY_; - } else if (type == ol.geom.GeometryType.MULTI_POLYGON) { + factory = _ol_format_KML_.LINE_STRING_NODE_FACTORY_; + } else if (type == _ol_geom_GeometryType_.MULTI_POLYGON) { geometries = (/** @type {ol.geom.MultiPolygon} */ (geometry)).getPolygons(); - factory = ol.format.KML.POLYGON_NODE_FACTORY_; + factory = _ol_format_KML_.POLYGON_NODE_FACTORY_; } else { - ol.asserts.assert(false, 39); // Unknown geometry type + _ol_asserts_.assert(false, 39); // Unknown geometry type } - ol.xml.pushSerializeAndPop(context, - ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_, factory, + _ol_xml_.pushSerializeAndPop(context, + _ol_format_KML_.MULTI_GEOMETRY_SERIALIZERS_, factory, geometries, objectStack); }; @@ -2399,11 +2401,11 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeBoundaryIs_ = function(node, linearRing, objectStack) { +_ol_format_KML_.writeBoundaryIs_ = function(node, linearRing, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; - ol.xml.pushSerializeAndPop(context, - ol.format.KML.BOUNDARY_IS_SERIALIZERS_, - ol.format.KML.LINEAR_RING_NODE_FACTORY_, [linearRing], objectStack); + _ol_xml_.pushSerializeAndPop(context, + _ol_format_KML_.BOUNDARY_IS_SERIALIZERS_, + _ol_format_KML_.LINEAR_RING_NODE_FACTORY_, [linearRing], objectStack); }; @@ -2416,7 +2418,7 @@ ol.format.KML.writeBoundaryIs_ = function(node, linearRing, objectStack) { * @this {ol.format.KML} * @private */ -ol.format.KML.writePlacemark_ = function(node, feature, objectStack) { +_ol_format_KML_.writePlacemark_ = function(node, feature, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; // set id @@ -2436,10 +2438,10 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) { }); if (keys.length > 0) { - var sequence = ol.xml.makeSequence(properties, keys); + var sequence = _ol_xml_.makeSequence(properties, keys); var namesAndValues = {names: keys, values: sequence}; - ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_, - ol.format.KML.EXTENDEDDATA_NODE_FACTORY_, [namesAndValues], objectStack); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.PLACEMARK_SERIALIZERS_, + _ol_format_KML_.EXTENDEDDATA_NODE_FACTORY_, [namesAndValues], objectStack); } var styleFunction = feature.getStyleFunction(); @@ -2459,20 +2461,20 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) { } } var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.PLACEMARK_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + var orderedKeys = _ol_format_KML_.PLACEMARK_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.PLACEMARK_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); // serialize geometry var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]); var geometry = feature.getGeometry(); if (geometry) { geometry = - ol.format.Feature.transformWithOptions(geometry, true, options); + _ol_format_Feature_.transformWithOptions(geometry, true, options); } - ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_, - ol.format.KML.GEOMETRY_NODE_FACTORY_, [geometry], objectStack); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.PLACEMARK_SERIALIZERS_, + _ol_format_KML_.GEOMETRY_NODE_FACTORY_, [geometry], objectStack); }; @@ -2482,7 +2484,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) { +_ol_format_KML_.writePrimitiveGeometry_ = function(node, geometry, objectStack) { var flatCoordinates = geometry.getFlatCoordinates(); var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; context['layout'] = geometry.getLayout(); @@ -2493,10 +2495,10 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) { properties.coordinates = flatCoordinates; var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + var orderedKeys = _ol_format_KML_.PRIMITIVE_GEOMETRY_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.PRIMITIVE_GEOMETRY_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -2506,19 +2508,19 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writePolygon_ = function(node, polygon, objectStack) { +_ol_format_KML_.writePolygon_ = function(node, polygon, objectStack) { var linearRings = polygon.getLinearRings(); var outerRing = linearRings.shift(); var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; // inner rings - ol.xml.pushSerializeAndPop(context, - ol.format.KML.POLYGON_SERIALIZERS_, - ol.format.KML.INNER_BOUNDARY_NODE_FACTORY_, + _ol_xml_.pushSerializeAndPop(context, + _ol_format_KML_.POLYGON_SERIALIZERS_, + _ol_format_KML_.INNER_BOUNDARY_NODE_FACTORY_, linearRings, objectStack); // outer ring - ol.xml.pushSerializeAndPop(context, - ol.format.KML.POLYGON_SERIALIZERS_, - ol.format.KML.OUTER_BOUNDARY_NODE_FACTORY_, + _ol_xml_.pushSerializeAndPop(context, + _ol_format_KML_.POLYGON_SERIALIZERS_, + _ol_format_KML_.OUTER_BOUNDARY_NODE_FACTORY_, [outerRing], objectStack); }; @@ -2529,10 +2531,10 @@ ol.format.KML.writePolygon_ = function(node, polygon, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writePolyStyle_ = function(node, style, objectStack) { +_ol_format_KML_.writePolyStyle_ = function(node, style, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; - ol.xml.pushSerializeAndPop(context, ol.format.KML.POLY_STYLE_SERIALIZERS_, - ol.format.KML.COLOR_NODE_FACTORY_, [style.getColor()], objectStack); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.POLY_STYLE_SERIALIZERS_, + _ol_format_KML_.COLOR_NODE_FACTORY_, [style.getColor()], objectStack); }; @@ -2541,9 +2543,9 @@ ol.format.KML.writePolyStyle_ = function(node, style, objectStack) { * @param {number|undefined} scale Scale. * @private */ -ol.format.KML.writeScaleTextNode_ = function(node, scale) { +_ol_format_KML_.writeScaleTextNode_ = function(node, scale) { // the Math is to remove any excess decimals created by float arithmetic - ol.format.XSD.writeDecimalTextNode(node, + _ol_format_XSD_.writeDecimalTextNode(node, Math.round(scale * 1e6) / 1e6); }; @@ -2554,14 +2556,14 @@ ol.format.KML.writeScaleTextNode_ = function(node, scale) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.KML.writeStyle_ = function(node, style, objectStack) { +_ol_format_KML_.writeStyle_ = function(node, style, objectStack) { var /** @type {ol.XmlNodeStackItem} */ context = {node: node}; var properties = {}; var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); var imageStyle = style.getImage(); var textStyle = style.getText(); - if (imageStyle instanceof ol.style.Icon) { + if (imageStyle instanceof _ol_style_Icon_) { properties['IconStyle'] = imageStyle; } if (textStyle) { @@ -2574,10 +2576,10 @@ ol.format.KML.writeStyle_ = function(node, style, objectStack) { properties['PolyStyle'] = fillStyle; } var parentNode = objectStack[objectStack.length - 1].node; - var orderedKeys = ol.format.KML.STYLE_SEQUENCE_[parentNode.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.STYLE_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); + var orderedKeys = _ol_format_KML_.STYLE_SEQUENCE_[parentNode.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.STYLE_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); }; @@ -2586,7 +2588,7 @@ ol.format.KML.writeStyle_ = function(node, style, objectStack) { * @param {ol.KMLVec2_} vec2 Vec2. * @private */ -ol.format.KML.writeVec2_ = function(node, vec2) { +_ol_format_KML_.writeVec2_ = function(node, vec2) { node.setAttribute('x', vec2.x); node.setAttribute('y', vec2.y); node.setAttribute('xunits', vec2.xunits); @@ -2599,8 +2601,8 @@ ol.format.KML.writeVec2_ = function(node, vec2) { * @type {Object.>} * @private */ -ol.format.KML.KML_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.KML_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'Document', 'Placemark' ]); @@ -2610,10 +2612,10 @@ ol.format.KML.KML_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.KML_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Document': ol.xml.makeChildAppender(ol.format.KML.writeDocument_), - 'Placemark': ol.xml.makeChildAppender(ol.format.KML.writePlacemark_) +_ol_format_KML_.KML_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Document': _ol_xml_.makeChildAppender(_ol_format_KML_.writeDocument_), + 'Placemark': _ol_xml_.makeChildAppender(_ol_format_KML_.writePlacemark_) }); @@ -2622,9 +2624,9 @@ ol.format.KML.KML_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.DOCUMENT_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Placemark': ol.xml.makeChildAppender(ol.format.KML.writePlacemark_) +_ol_format_KML_.DOCUMENT_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Placemark': _ol_xml_.makeChildAppender(_ol_format_KML_.writePlacemark_) }); @@ -2633,11 +2635,11 @@ ol.format.KML.DOCUMENT_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Data': ol.xml.makeChildAppender(ol.format.KML.writeDataNode_), - 'value': ol.xml.makeChildAppender(ol.format.KML.writeDataNodeValue_), - 'displayName': ol.xml.makeChildAppender(ol.format.KML.writeDataNodeName_) +_ol_format_KML_.EXTENDEDDATA_NODE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Data': _ol_xml_.makeChildAppender(_ol_format_KML_.writeDataNode_), + 'value': _ol_xml_.makeChildAppender(_ol_format_KML_.writeDataNodeValue_), + 'displayName': _ol_xml_.makeChildAppender(_ol_format_KML_.writeDataNodeName_) }); @@ -2646,7 +2648,7 @@ ol.format.KML.EXTENDEDDATA_NODE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.} * @private */ -ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_ = { +_ol_format_KML_.GEOMETRY_TYPE_TO_NODENAME_ = { 'Point': 'Point', 'LineString': 'LineString', 'LinearRing': 'LinearRing', @@ -2662,11 +2664,11 @@ ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_ = { * @type {Object.>} * @private */ -ol.format.KML.ICON_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.ICON_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'href' ], - ol.xml.makeStructureNS(ol.format.KML.GX_NAMESPACE_URIS_, [ + _ol_xml_.makeStructureNS(_ol_format_KML_.GX_NAMESPACE_URIS_, [ 'x', 'y', 'w', 'h' ])); @@ -2676,15 +2678,15 @@ ol.format.KML.ICON_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.ICON_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'href': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) - }, ol.xml.makeStructureNS( - ol.format.KML.GX_NAMESPACE_URIS_, { - 'x': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'y': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'w': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'h': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode) +_ol_format_KML_.ICON_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'href': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode) + }, _ol_xml_.makeStructureNS( + _ol_format_KML_.GX_NAMESPACE_URIS_, { + 'x': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'y': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'w': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'h': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode) })); @@ -2693,8 +2695,8 @@ ol.format.KML.ICON_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.ICON_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.ICON_STYLE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'scale', 'heading', 'Icon', 'hotSpot' ]); @@ -2704,12 +2706,12 @@ ol.format.KML.ICON_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.ICON_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'Icon': ol.xml.makeChildAppender(ol.format.KML.writeIcon_), - 'heading': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode), - 'hotSpot': ol.xml.makeChildAppender(ol.format.KML.writeVec2_), - 'scale': ol.xml.makeChildAppender(ol.format.KML.writeScaleTextNode_) +_ol_format_KML_.ICON_STYLE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'Icon': _ol_xml_.makeChildAppender(_ol_format_KML_.writeIcon_), + 'heading': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode), + 'hotSpot': _ol_xml_.makeChildAppender(_ol_format_KML_.writeVec2_), + 'scale': _ol_xml_.makeChildAppender(_ol_format_KML_.writeScaleTextNode_) }); @@ -2718,8 +2720,8 @@ ol.format.KML.ICON_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LABEL_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.LABEL_STYLE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'color', 'scale' ]); @@ -2729,10 +2731,10 @@ ol.format.KML.LABEL_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LABEL_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeChildAppender(ol.format.KML.writeColorTextNode_), - 'scale': ol.xml.makeChildAppender(ol.format.KML.writeScaleTextNode_) +_ol_format_KML_.LABEL_STYLE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeChildAppender(_ol_format_KML_.writeColorTextNode_), + 'scale': _ol_xml_.makeChildAppender(_ol_format_KML_.writeScaleTextNode_) }); @@ -2741,8 +2743,8 @@ ol.format.KML.LABEL_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LINE_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.LINE_STYLE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'color', 'width' ]); @@ -2752,10 +2754,10 @@ ol.format.KML.LINE_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.LINE_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeChildAppender(ol.format.KML.writeColorTextNode_), - 'width': ol.xml.makeChildAppender(ol.format.XSD.writeDecimalTextNode) +_ol_format_KML_.LINE_STYLE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeChildAppender(_ol_format_KML_.writeColorTextNode_), + 'width': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeDecimalTextNode) }); @@ -2764,10 +2766,10 @@ ol.format.KML.LINE_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.BOUNDARY_IS_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LinearRing': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_) +_ol_format_KML_.BOUNDARY_IS_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LinearRing': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_) }); @@ -2776,15 +2778,15 @@ ol.format.KML.BOUNDARY_IS_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'LineString': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_), - 'Point': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_), - 'Polygon': ol.xml.makeChildAppender(ol.format.KML.writePolygon_), - 'GeometryCollection': ol.xml.makeChildAppender( - ol.format.KML.writeMultiGeometry_) +_ol_format_KML_.MULTI_GEOMETRY_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'LineString': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_), + 'Point': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_), + 'Polygon': _ol_xml_.makeChildAppender(_ol_format_KML_.writePolygon_), + 'GeometryCollection': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeMultiGeometry_) }); @@ -2793,8 +2795,8 @@ ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PLACEMARK_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.PLACEMARK_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'name', 'open', 'visibility', 'address', 'phoneNumber', 'description', 'styleUrl', 'Style' ]); @@ -2805,30 +2807,30 @@ ol.format.KML.PLACEMARK_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'ExtendedData': ol.xml.makeChildAppender( - ol.format.KML.writeExtendedData_), - 'MultiGeometry': ol.xml.makeChildAppender( - ol.format.KML.writeMultiGeometry_), - 'LineString': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_), - 'LinearRing': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_), - 'Point': ol.xml.makeChildAppender( - ol.format.KML.writePrimitiveGeometry_), - 'Polygon': ol.xml.makeChildAppender(ol.format.KML.writePolygon_), - 'Style': ol.xml.makeChildAppender(ol.format.KML.writeStyle_), - 'address': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'description': ol.xml.makeChildAppender( - ol.format.XSD.writeStringTextNode), - 'name': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'open': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode), - 'phoneNumber': ol.xml.makeChildAppender( - ol.format.XSD.writeStringTextNode), - 'styleUrl': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'visibility': ol.xml.makeChildAppender( - ol.format.XSD.writeBooleanTextNode) +_ol_format_KML_.PLACEMARK_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'ExtendedData': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeExtendedData_), + 'MultiGeometry': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeMultiGeometry_), + 'LineString': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_), + 'LinearRing': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_), + 'Point': _ol_xml_.makeChildAppender( + _ol_format_KML_.writePrimitiveGeometry_), + 'Polygon': _ol_xml_.makeChildAppender(_ol_format_KML_.writePolygon_), + 'Style': _ol_xml_.makeChildAppender(_ol_format_KML_.writeStyle_), + 'address': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'description': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeStringTextNode), + 'name': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'open': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeBooleanTextNode), + 'phoneNumber': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeStringTextNode), + 'styleUrl': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'visibility': _ol_xml_.makeChildAppender( + _ol_format_XSD_.writeBooleanTextNode) }); @@ -2837,8 +2839,8 @@ ol.format.KML.PLACEMARK_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.PRIMITIVE_GEOMETRY_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'extrude', 'tessellate', 'altitudeMode', 'coordinates' ]); @@ -2848,13 +2850,13 @@ ol.format.KML.PRIMITIVE_GEOMETRY_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'extrude': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode), - 'tessellate': ol.xml.makeChildAppender(ol.format.XSD.writeBooleanTextNode), - 'altitudeMode': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode), - 'coordinates': ol.xml.makeChildAppender( - ol.format.KML.writeCoordinatesTextNode_) +_ol_format_KML_.PRIMITIVE_GEOMETRY_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'extrude': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeBooleanTextNode), + 'tessellate': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeBooleanTextNode), + 'altitudeMode': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode), + 'coordinates': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeCoordinatesTextNode_) }); @@ -2863,12 +2865,12 @@ ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.POLYGON_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'outerBoundaryIs': ol.xml.makeChildAppender( - ol.format.KML.writeBoundaryIs_), - 'innerBoundaryIs': ol.xml.makeChildAppender( - ol.format.KML.writeBoundaryIs_) +_ol_format_KML_.POLYGON_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'outerBoundaryIs': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeBoundaryIs_), + 'innerBoundaryIs': _ol_xml_.makeChildAppender( + _ol_format_KML_.writeBoundaryIs_) }); @@ -2877,9 +2879,9 @@ ol.format.KML.POLYGON_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.POLY_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'color': ol.xml.makeChildAppender(ol.format.KML.writeColorTextNode_) +_ol_format_KML_.POLY_STYLE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'color': _ol_xml_.makeChildAppender(_ol_format_KML_.writeColorTextNode_) }); @@ -2888,8 +2890,8 @@ ol.format.KML.POLY_STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.STYLE_SEQUENCE_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, [ +_ol_format_KML_.STYLE_SEQUENCE_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, [ 'IconStyle', 'LabelStyle', 'LineStyle', 'PolyStyle' ]); @@ -2899,12 +2901,12 @@ ol.format.KML.STYLE_SEQUENCE_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.KML.STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( - ol.format.KML.NAMESPACE_URIS_, { - 'IconStyle': ol.xml.makeChildAppender(ol.format.KML.writeIconStyle_), - 'LabelStyle': ol.xml.makeChildAppender(ol.format.KML.writeLabelStyle_), - 'LineStyle': ol.xml.makeChildAppender(ol.format.KML.writeLineStyle_), - 'PolyStyle': ol.xml.makeChildAppender(ol.format.KML.writePolyStyle_) +_ol_format_KML_.STYLE_SERIALIZERS_ = _ol_xml_.makeStructureNS( + _ol_format_KML_.NAMESPACE_URIS_, { + 'IconStyle': _ol_xml_.makeChildAppender(_ol_format_KML_.writeIconStyle_), + 'LabelStyle': _ol_xml_.makeChildAppender(_ol_format_KML_.writeLabelStyle_), + 'LineStyle': _ol_xml_.makeChildAppender(_ol_format_KML_.writeLineStyle_), + 'PolyStyle': _ol_xml_.makeChildAppender(_ol_format_KML_.writePolyStyle_) }); @@ -2916,8 +2918,8 @@ ol.format.KML.STYLE_SERIALIZERS_ = ol.xml.makeStructureNS( * @return {Node|undefined} Node. * @private */ -ol.format.KML.GX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { - return ol.xml.createElementNS(ol.format.KML.GX_NAMESPACE_URIS_[0], +_ol_format_KML_.GX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { + return _ol_xml_.createElementNS(_ol_format_KML_.GX_NAMESPACE_URIS_[0], 'gx:' + opt_nodeName); }; @@ -2930,10 +2932,10 @@ ol.format.KML.GX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { * @return {Node|undefined} Node. * @private */ -ol.format.KML.DOCUMENT_NODE_FACTORY_ = function(value, objectStack, +_ol_format_KML_.DOCUMENT_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { var parentNode = objectStack[objectStack.length - 1].node; - return ol.xml.createElementNS(parentNode.namespaceURI, 'Placemark'); + return _ol_xml_.createElementNS(parentNode.namespaceURI, 'Placemark'); }; @@ -2945,12 +2947,12 @@ ol.format.KML.DOCUMENT_NODE_FACTORY_ = function(value, objectStack, * @return {Node|undefined} Node. * @private */ -ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, +_ol_format_KML_.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) { if (value) { var parentNode = objectStack[objectStack.length - 1].node; - return ol.xml.createElementNS(parentNode.namespaceURI, - ol.format.KML.GEOMETRY_TYPE_TO_NODENAME_[/** @type {ol.geom.Geometry} */ (value).getType()]); + return _ol_xml_.createElementNS(parentNode.namespaceURI, + _ol_format_KML_.GEOMETRY_TYPE_TO_NODENAME_[/** @type {ol.geom.Geometry} */ (value).getType()]); } }; @@ -2961,7 +2963,7 @@ ol.format.KML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.COLOR_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('color'); +_ol_format_KML_.COLOR_NODE_FACTORY_ = _ol_xml_.makeSimpleNodeFactory('color'); /** @@ -2970,8 +2972,8 @@ ol.format.KML.COLOR_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('color'); * @type {function(*, Array.<*>): (Node|undefined)} * @private */ -ol.format.KML.DATA_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('Data'); +_ol_format_KML_.DATA_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('Data'); /** @@ -2980,8 +2982,8 @@ ol.format.KML.DATA_NODE_FACTORY_ = * @type {function(*, Array.<*>): (Node|undefined)} * @private */ -ol.format.KML.EXTENDEDDATA_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('ExtendedData'); +_ol_format_KML_.EXTENDEDDATA_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('ExtendedData'); /** @@ -2990,8 +2992,8 @@ ol.format.KML.EXTENDEDDATA_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.INNER_BOUNDARY_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('innerBoundaryIs'); +_ol_format_KML_.INNER_BOUNDARY_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('innerBoundaryIs'); /** @@ -3000,8 +3002,8 @@ ol.format.KML.INNER_BOUNDARY_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.POINT_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('Point'); +_ol_format_KML_.POINT_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('Point'); /** @@ -3010,8 +3012,8 @@ ol.format.KML.POINT_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.LINE_STRING_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('LineString'); +_ol_format_KML_.LINE_STRING_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('LineString'); /** @@ -3020,8 +3022,8 @@ ol.format.KML.LINE_STRING_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.LINEAR_RING_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('LinearRing'); +_ol_format_KML_.LINEAR_RING_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('LinearRing'); /** @@ -3030,8 +3032,8 @@ ol.format.KML.LINEAR_RING_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.POLYGON_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('Polygon'); +_ol_format_KML_.POLYGON_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('Polygon'); /** @@ -3040,8 +3042,8 @@ ol.format.KML.POLYGON_NODE_FACTORY_ = * @type {function(*, Array.<*>, string=): (Node|undefined)} * @private */ -ol.format.KML.OUTER_BOUNDARY_NODE_FACTORY_ = - ol.xml.makeSimpleNodeFactory('outerBoundaryIs'); +_ol_format_KML_.OUTER_BOUNDARY_NODE_FACTORY_ = + _ol_xml_.makeSimpleNodeFactory('outerBoundaryIs'); /** @@ -3054,7 +3056,7 @@ ol.format.KML.OUTER_BOUNDARY_NODE_FACTORY_ = * @return {string} Result. * @api */ -ol.format.KML.prototype.writeFeatures; +_ol_format_KML_.prototype.writeFeatures; /** @@ -3067,16 +3069,16 @@ ol.format.KML.prototype.writeFeatures; * @override * @api */ -ol.format.KML.prototype.writeFeaturesNode = function(features, opt_options) { +_ol_format_KML_.prototype.writeFeaturesNode = function(features, opt_options) { opt_options = this.adaptOptions(opt_options); - var kml = ol.xml.createElementNS(ol.format.KML.NAMESPACE_URIS_[4], 'kml'); + var kml = _ol_xml_.createElementNS(_ol_format_KML_.NAMESPACE_URIS_[4], 'kml'); var xmlnsUri = 'http://www.w3.org/2000/xmlns/'; var xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance'; - ol.xml.setAttributeNS(kml, xmlnsUri, 'xmlns:gx', - ol.format.KML.GX_NAMESPACE_URIS_[0]); - ol.xml.setAttributeNS(kml, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri); - ol.xml.setAttributeNS(kml, xmlSchemaInstanceUri, 'xsi:schemaLocation', - ol.format.KML.SCHEMA_LOCATION_); + _ol_xml_.setAttributeNS(kml, xmlnsUri, 'xmlns:gx', + _ol_format_KML_.GX_NAMESPACE_URIS_[0]); + _ol_xml_.setAttributeNS(kml, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri); + _ol_xml_.setAttributeNS(kml, xmlSchemaInstanceUri, 'xsi:schemaLocation', + _ol_format_KML_.SCHEMA_LOCATION_); var /** @type {ol.XmlNodeStackItem} */ context = {node: kml}; var properties = {}; @@ -3085,10 +3087,11 @@ ol.format.KML.prototype.writeFeaturesNode = function(features, opt_options) { } else if (features.length == 1) { properties['Placemark'] = features[0]; } - var orderedKeys = ol.format.KML.KML_SEQUENCE_[kml.namespaceURI]; - var values = ol.xml.makeSequence(properties, orderedKeys); - ol.xml.pushSerializeAndPop(context, ol.format.KML.KML_SERIALIZERS_, - ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, [opt_options], orderedKeys, + var orderedKeys = _ol_format_KML_.KML_SEQUENCE_[kml.namespaceURI]; + var values = _ol_xml_.makeSequence(properties, orderedKeys); + _ol_xml_.pushSerializeAndPop(context, _ol_format_KML_.KML_SERIALIZERS_, + _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY, values, [opt_options], orderedKeys, this); return kml; }; +export default _ol_format_KML_; diff --git a/src/ol/format/MVT.js b/src/ol/format/MVT.js index 7477e73ba8..65e2e4bfb1 100644 --- a/src/ol/format/MVT.js +++ b/src/ol/format/MVT.js @@ -1,25 +1,25 @@ +/** + * @module ol/format/MVT + */ //FIXME Implement projection handling -goog.provide('ol.format.MVT'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.ext.PBF'); -goog.require('ol.format.Feature'); -goog.require('ol.format.FormatType'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.proj.Projection'); -goog.require('ol.proj.Units'); -goog.require('ol.render.Feature'); - +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_ext_PBF_ from 'pbf'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_FormatType_ from '../format/FormatType.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; +import _ol_proj_Projection_ from '../proj/Projection.js'; +import _ol_proj_Units_ from '../proj/Units.js'; +import _ol_render_Feature_ from '../render/Feature.js'; /** * @classdesc @@ -30,18 +30,18 @@ goog.require('ol.render.Feature'); * @param {olx.format.MVTOptions=} opt_options Options. * @api */ -ol.format.MVT = function(opt_options) { +var _ol_format_MVT_ = function(opt_options) { - ol.format.Feature.call(this); + _ol_format_Feature_.call(this); var options = opt_options ? opt_options : {}; /** * @type {ol.proj.Projection} */ - this.defaultDataProjection = new ol.proj.Projection({ + this.defaultDataProjection = new _ol_proj_Projection_({ code: '', - units: ol.proj.Units.TILE_PIXELS + units: _ol_proj_Units_.TILE_PIXELS }); /** @@ -51,7 +51,7 @@ ol.format.MVT = function(opt_options) { * (Array.|Array.>),Object.,number)} */ this.featureClass_ = options.featureClass ? - options.featureClass : ol.render.Feature; + options.featureClass : _ol_render_Feature_; /** * @private @@ -78,14 +78,15 @@ ol.format.MVT = function(opt_options) { this.extent_ = null; }; -ol.inherits(ol.format.MVT, ol.format.Feature); + +_ol_.inherits(_ol_format_MVT_, _ol_format_Feature_); /** * Reader callbacks for parsing the PBF. * @type {Object.} */ -ol.format.MVT.pbfReaders_ = { +_ol_format_MVT_.pbfReaders_ = { layers: function(tag, layers, pbf) { if (tag === 3) { var layer = { @@ -94,7 +95,7 @@ ol.format.MVT.pbfReaders_ = { features: [] }; var end = pbf.readVarint() + pbf.pos; - pbf.readFields(ol.format.MVT.pbfReaders_.layer, layer, end); + pbf.readFields(_ol_format_MVT_.pbfReaders_.layer, layer, end); layer.length = layer.features.length; if (layer.length) { layers[layer.name] = layer; @@ -156,7 +157,7 @@ ol.format.MVT.pbfReaders_ = { * @param {number} i Index of the feature in the raw layer's `features` array. * @return {Object} Raw feature. */ -ol.format.MVT.readRawFeature_ = function(pbf, layer, i) { +_ol_format_MVT_.readRawFeature_ = function(pbf, layer, i) { pbf.pos = layer.features[i]; var end = pbf.readVarint() + pbf.pos; @@ -165,7 +166,7 @@ ol.format.MVT.readRawFeature_ = function(pbf, layer, i) { type: 0, properties: {} }; - pbf.readFields(ol.format.MVT.pbfReaders_.feature, feature, end); + pbf.readFields(_ol_format_MVT_.pbfReaders_.feature, feature, end); return feature; }; @@ -180,7 +181,7 @@ ol.format.MVT.readRawFeature_ = function(pbf, layer, i) { * @param {Array.} flatCoordinates Array to store flat coordinates in. * @param {Array.} ends Array to store ends in. */ -ol.format.MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) { +_ol_format_MVT_.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) { pbf.pos = feature.geometry; var end = pbf.readVarint() + pbf.pos; @@ -224,7 +225,7 @@ ol.format.MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) { } } else { - ol.asserts.assert(false, 59); // Invalid command found in the PBF + _ol_asserts_.assert(false, 59); // Invalid command found in the PBF } } @@ -244,18 +245,18 @@ ol.format.MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) { * geometry. * @return {ol.geom.GeometryType} The geometry type. */ -ol.format.MVT.getGeometryType_ = function(type, numEnds) { +_ol_format_MVT_.getGeometryType_ = function(type, numEnds) { /** @type {ol.geom.GeometryType} */ var geometryType; if (type === 1) { geometryType = numEnds === 1 ? - ol.geom.GeometryType.POINT : ol.geom.GeometryType.MULTI_POINT; + _ol_geom_GeometryType_.POINT : _ol_geom_GeometryType_.MULTI_POINT; } else if (type === 2) { geometryType = numEnds === 1 ? - ol.geom.GeometryType.LINE_STRING : - ol.geom.GeometryType.MULTI_LINE_STRING; + _ol_geom_GeometryType_.LINE_STRING : + _ol_geom_GeometryType_.MULTI_LINE_STRING; } else if (type === 3) { - geometryType = ol.geom.GeometryType.POLYGON; + geometryType = _ol_geom_GeometryType_.POLYGON; // MultiPolygon not relevant for rendering - winding order determines // outer rings of polygons. } @@ -269,7 +270,7 @@ ol.format.MVT.getGeometryType_ = function(type, numEnds) { * @param {olx.format.ReadOptions=} opt_options Read options. * @return {ol.Feature|ol.render.Feature} Feature. */ -ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) { +_ol_format_MVT_.prototype.createFeature_ = function(pbf, rawFeature, opt_options) { var type = rawFeature.type; if (type === 0) { return null; @@ -282,21 +283,21 @@ ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) var flatCoordinates = []; var ends = []; - ol.format.MVT.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends); + _ol_format_MVT_.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends); - var geometryType = ol.format.MVT.getGeometryType_(type, ends.length); + var geometryType = _ol_format_MVT_.getGeometryType_(type, ends.length); - if (this.featureClass_ === ol.render.Feature) { + if (this.featureClass_ === _ol_render_Feature_) { feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id); } else { var geom; - if (geometryType == ol.geom.GeometryType.POLYGON) { + if (geometryType == _ol_geom_GeometryType_.POLYGON) { var endss = []; var offset = 0; var prevEndIndex = 0; for (var i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - if (!ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, offset, end, 2)) { + if (!_ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, offset, end, 2)) { endss.push(ends.slice(prevEndIndex, i)); prevEndIndex = i; } @@ -304,24 +305,24 @@ ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) } if (endss.length > 1) { ends = endss; - geom = new ol.geom.MultiPolygon(null); + geom = new _ol_geom_MultiPolygon_(null); } else { - geom = new ol.geom.Polygon(null); + geom = new _ol_geom_Polygon_(null); } } else { - geom = geometryType === ol.geom.GeometryType.POINT ? new ol.geom.Point(null) : - geometryType === ol.geom.GeometryType.LINE_STRING ? new ol.geom.LineString(null) : - geometryType === ol.geom.GeometryType.POLYGON ? new ol.geom.Polygon(null) : - geometryType === ol.geom.GeometryType.MULTI_POINT ? new ol.geom.MultiPoint (null) : - geometryType === ol.geom.GeometryType.MULTI_LINE_STRING ? new ol.geom.MultiLineString(null) : + geom = geometryType === _ol_geom_GeometryType_.POINT ? new _ol_geom_Point_(null) : + geometryType === _ol_geom_GeometryType_.LINE_STRING ? new _ol_geom_LineString_(null) : + geometryType === _ol_geom_GeometryType_.POLYGON ? new _ol_geom_Polygon_(null) : + geometryType === _ol_geom_GeometryType_.MULTI_POINT ? new _ol_geom_MultiPoint_ (null) : + geometryType === _ol_geom_GeometryType_.MULTI_LINE_STRING ? new _ol_geom_MultiLineString_(null) : null; } - geom.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates, ends); + geom.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, flatCoordinates, ends); feature = new this.featureClass_(); if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } - var geometry = ol.format.Feature.transformWithOptions(geom, false, this.adaptOptions(opt_options)); + var geometry = _ol_format_Feature_.transformWithOptions(geom, false, this.adaptOptions(opt_options)); feature.setGeometry(geometry); feature.setId(id); feature.setProperties(values); @@ -335,7 +336,7 @@ ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) * @inheritDoc * @api */ -ol.format.MVT.prototype.getLastExtent = function() { +_ol_format_MVT_.prototype.getLastExtent = function() { return this.extent_; }; @@ -343,8 +344,8 @@ ol.format.MVT.prototype.getLastExtent = function() { /** * @inheritDoc */ -ol.format.MVT.prototype.getType = function() { - return ol.format.FormatType.ARRAY_BUFFER; +_ol_format_MVT_.prototype.getType = function() { + return _ol_format_FormatType_.ARRAY_BUFFER; }; @@ -352,11 +353,11 @@ ol.format.MVT.prototype.getType = function() { * @inheritDoc * @api */ -ol.format.MVT.prototype.readFeatures = function(source, opt_options) { +_ol_format_MVT_.prototype.readFeatures = function(source, opt_options) { var layers = this.layers_; - var pbf = new ol.ext.PBF(/** @type {ArrayBuffer} */ (source)); - var pbfLayers = pbf.readFields(ol.format.MVT.pbfReaders_.layers, {}); + var pbf = new _ol_ext_PBF_(/** @type {ArrayBuffer} */ (source)); + var pbfLayers = pbf.readFields(_ol_format_MVT_.pbfReaders_.layers, {}); /** @type {Array.} */ var features = []; var pbfLayer; @@ -368,7 +369,7 @@ ol.format.MVT.prototype.readFeatures = function(source, opt_options) { var rawFeature; for (var i = 0, ii = pbfLayer.length; i < ii; ++i) { - rawFeature = ol.format.MVT.readRawFeature_(pbf, pbfLayer, i); + rawFeature = _ol_format_MVT_.readRawFeature_(pbf, pbfLayer, i); features.push(this.createFeature_(pbf, rawFeature)); } this.extent_ = pbfLayer ? [0, 0, pbfLayer.extent, pbfLayer.extent] : null; @@ -382,7 +383,7 @@ ol.format.MVT.prototype.readFeatures = function(source, opt_options) { * @inheritDoc * @api */ -ol.format.MVT.prototype.readProjection = function(source) { +_ol_format_MVT_.prototype.readProjection = function(source) { return this.defaultDataProjection; }; @@ -392,7 +393,7 @@ ol.format.MVT.prototype.readProjection = function(source) { * @param {Array.} layers Layers. * @api */ -ol.format.MVT.prototype.setLayers = function(layers) { +_ol_format_MVT_.prototype.setLayers = function(layers) { this.layers_ = layers; }; @@ -401,32 +402,33 @@ ol.format.MVT.prototype.setLayers = function(layers) { * Not implemented. * @override */ -ol.format.MVT.prototype.readFeature = function() {}; +_ol_format_MVT_.prototype.readFeature = function() {}; /** * Not implemented. * @override */ -ol.format.MVT.prototype.readGeometry = function() {}; +_ol_format_MVT_.prototype.readGeometry = function() {}; /** * Not implemented. * @override */ -ol.format.MVT.prototype.writeFeature = function() {}; +_ol_format_MVT_.prototype.writeFeature = function() {}; /** * Not implemented. * @override */ -ol.format.MVT.prototype.writeGeometry = function() {}; +_ol_format_MVT_.prototype.writeGeometry = function() {}; /** * Not implemented. * @override */ -ol.format.MVT.prototype.writeFeatures = function() {}; +_ol_format_MVT_.prototype.writeFeatures = function() {}; +export default _ol_format_MVT_; diff --git a/src/ol/format/OSMXML.js b/src/ol/format/OSMXML.js index f5a133f286..71f93982e1 100644 --- a/src/ol/format/OSMXML.js +++ b/src/ol/format/OSMXML.js @@ -1,19 +1,19 @@ +/** + * @module ol/format/OSMXML + */ // FIXME add typedef for stack state objects -goog.provide('ol.format.OSMXML'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -24,15 +24,16 @@ goog.require('ol.xml'); * @extends {ol.format.XMLFeature} * @api */ -ol.format.OSMXML = function() { - ol.format.XMLFeature.call(this); +var _ol_format_OSMXML_ = function() { + _ol_format_XMLFeature_.call(this); /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get('EPSG:4326'); + this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); }; -ol.inherits(ol.format.OSMXML, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_); /** @@ -40,7 +41,7 @@ ol.inherits(ol.format.OSMXML, ol.format.XMLFeature); * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.OSMXML.readNode_ = function(node, objectStack) { +_ol_format_OSMXML_.readNode_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); var state = /** @type {Object} */ (objectStack[objectStack.length - 1]); var id = node.getAttribute('id'); @@ -51,13 +52,13 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) { ]; state.nodes[id] = coordinates; - var values = ol.xml.pushParseAndPop({ + var values = _ol_xml_.pushParseAndPop({ tags: {} - }, ol.format.OSMXML.NODE_PARSERS_, node, objectStack); - if (!ol.obj.isEmpty(values.tags)) { - var geometry = new ol.geom.Point(coordinates); - ol.format.Feature.transformWithOptions(geometry, false, options); - var feature = new ol.Feature(geometry); + }, _ol_format_OSMXML_.NODE_PARSERS_, node, objectStack); + if (!_ol_obj_.isEmpty(values.tags)) { + var geometry = new _ol_geom_Point_(coordinates); + _ol_format_Feature_.transformWithOptions(geometry, false, options); + var feature = new _ol_Feature_(geometry); feature.setId(id); feature.setProperties(values.tags); state.features.push(feature); @@ -70,13 +71,13 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.OSMXML.readWay_ = function(node, objectStack) { +_ol_format_OSMXML_.readWay_ = function(node, objectStack) { var id = node.getAttribute('id'); - var values = ol.xml.pushParseAndPop({ + var values = _ol_xml_.pushParseAndPop({ id: id, ndrefs: [], tags: {} - }, ol.format.OSMXML.WAY_PARSERS_, node, objectStack); + }, _ol_format_OSMXML_.WAY_PARSERS_, node, objectStack); var state = /** @type {Object} */ (objectStack[objectStack.length - 1]); state.ways.push(values); }; @@ -87,7 +88,7 @@ ol.format.OSMXML.readWay_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.OSMXML.readNd_ = function(node, objectStack) { +_ol_format_OSMXML_.readNd_ = function(node, objectStack) { var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); values.ndrefs.push(node.getAttribute('ref')); }; @@ -98,7 +99,7 @@ ol.format.OSMXML.readNd_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.OSMXML.readTag_ = function(node, objectStack) { +_ol_format_OSMXML_.readTag_ = function(node, objectStack) { var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); values.tags[node.getAttribute('k')] = node.getAttribute('v'); }; @@ -109,7 +110,7 @@ ol.format.OSMXML.readTag_ = function(node, objectStack) { * @private * @type {Array.} */ -ol.format.OSMXML.NAMESPACE_URIS_ = [ +_ol_format_OSMXML_.NAMESPACE_URIS_ = [ null ]; @@ -119,10 +120,10 @@ ol.format.OSMXML.NAMESPACE_URIS_ = [ * @type {Object.>} * @private */ -ol.format.OSMXML.WAY_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OSMXML.NAMESPACE_URIS_, { - 'nd': ol.format.OSMXML.readNd_, - 'tag': ol.format.OSMXML.readTag_ +_ol_format_OSMXML_.WAY_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OSMXML_.NAMESPACE_URIS_, { + 'nd': _ol_format_OSMXML_.readNd_, + 'tag': _ol_format_OSMXML_.readTag_ }); @@ -131,10 +132,10 @@ ol.format.OSMXML.WAY_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OSMXML.PARSERS_ = ol.xml.makeStructureNS( - ol.format.OSMXML.NAMESPACE_URIS_, { - 'node': ol.format.OSMXML.readNode_, - 'way': ol.format.OSMXML.readWay_ +_ol_format_OSMXML_.PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OSMXML_.NAMESPACE_URIS_, { + 'node': _ol_format_OSMXML_.readNode_, + 'way': _ol_format_OSMXML_.readWay_ }); @@ -143,9 +144,9 @@ ol.format.OSMXML.PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OSMXML.NODE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OSMXML.NAMESPACE_URIS_, { - 'tag': ol.format.OSMXML.readTag_ +_ol_format_OSMXML_.NODE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OSMXML_.NAMESPACE_URIS_, { + 'tag': _ol_format_OSMXML_.readTag_ }); @@ -158,20 +159,20 @@ ol.format.OSMXML.NODE_PARSERS_ = ol.xml.makeStructureNS( * @return {Array.} Features. * @api */ -ol.format.OSMXML.prototype.readFeatures; +_ol_format_OSMXML_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { +_ol_format_OSMXML_.prototype.readFeaturesFromNode = function(node, opt_options) { var options = this.getReadOptions(node, opt_options); if (node.localName == 'osm') { - var state = ol.xml.pushParseAndPop({ + var state = _ol_xml_.pushParseAndPop({ nodes: {}, ways: [], features: [] - }, ol.format.OSMXML.PARSERS_, node, [options]); + }, _ol_format_OSMXML_.PARSERS_, node, [options]); // parse nodes in ways for (var j = 0; j < state.ways.length; j++) { var values = /** @type {Object} */ (state.ways[j]); @@ -179,20 +180,20 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { var flatCoordinates = []; for (var i = 0, ii = values.ndrefs.length; i < ii; i++) { var point = state.nodes[values.ndrefs[i]]; - ol.array.extend(flatCoordinates, point); + _ol_array_.extend(flatCoordinates, point); } var geometry; if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) { // closed way - geometry = new ol.geom.Polygon(null); - geometry.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates, + geometry = new _ol_geom_Polygon_(null); + geometry.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, flatCoordinates, [flatCoordinates.length]); } else { - geometry = new ol.geom.LineString(null); - geometry.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); + geometry = new _ol_geom_LineString_(null); + geometry.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, flatCoordinates); } - ol.format.Feature.transformWithOptions(geometry, false, options); - var feature = new ol.Feature(geometry); + _ol_format_Feature_.transformWithOptions(geometry, false, options); + var feature = new _ol_Feature_(geometry); feature.setId(values.id); feature.setProperties(values.tags); state.features.push(feature); @@ -213,25 +214,26 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { * @return {ol.proj.Projection} Projection. * @api */ -ol.format.OSMXML.prototype.readProjection; +_ol_format_OSMXML_.prototype.readProjection; /** * Not implemented. * @inheritDoc */ -ol.format.OSMXML.prototype.writeFeatureNode = function(feature, opt_options) {}; +_ol_format_OSMXML_.prototype.writeFeatureNode = function(feature, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.OSMXML.prototype.writeFeaturesNode = function(features, opt_options) {}; +_ol_format_OSMXML_.prototype.writeFeaturesNode = function(features, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.OSMXML.prototype.writeGeometryNode = function(geometry, opt_options) {}; +_ol_format_OSMXML_.prototype.writeGeometryNode = function(geometry, opt_options) {}; +export default _ol_format_OSMXML_; diff --git a/src/ol/format/OWS.js b/src/ol/format/OWS.js index dc4615a398..3699982d38 100644 --- a/src/ol/format/OWS.js +++ b/src/ol/format/OWS.js @@ -1,26 +1,27 @@ -goog.provide('ol.format.OWS'); - -goog.require('ol'); -goog.require('ol.format.XLink'); -goog.require('ol.format.XML'); -goog.require('ol.format.XSD'); -goog.require('ol.xml'); - +/** + * @module ol/format/OWS + */ +import _ol_ from '../index.js'; +import _ol_format_XLink_ from '../format/XLink.js'; +import _ol_format_XML_ from '../format/XML.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_xml_ from '../xml.js'; /** * @constructor * @extends {ol.format.XML} */ -ol.format.OWS = function() { - ol.format.XML.call(this); +var _ol_format_OWS_ = function() { + _ol_format_XML_.call(this); }; -ol.inherits(ol.format.OWS, ol.format.XML); + +_ol_.inherits(_ol_format_OWS_, _ol_format_XML_); /** * @inheritDoc */ -ol.format.OWS.prototype.readFromDocument = function(doc) { +_ol_format_OWS_.prototype.readFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readFromNode(n); @@ -33,9 +34,9 @@ ol.format.OWS.prototype.readFromDocument = function(doc) { /** * @inheritDoc */ -ol.format.OWS.prototype.readFromNode = function(node) { - var owsObject = ol.xml.pushParseAndPop({}, - ol.format.OWS.PARSERS_, node, []); +_ol_format_OWS_.prototype.readFromNode = function(node) { + var owsObject = _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.PARSERS_, node, []); return owsObject ? owsObject : null; }; @@ -46,9 +47,9 @@ ol.format.OWS.prototype.readFromNode = function(node) { * @private * @return {Object|undefined} The address. */ -ol.format.OWS.readAddress_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.ADDRESS_PARSERS_, node, objectStack); +_ol_format_OWS_.readAddress_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.ADDRESS_PARSERS_, node, objectStack); }; @@ -58,9 +59,9 @@ ol.format.OWS.readAddress_ = function(node, objectStack) { * @private * @return {Object|undefined} The values. */ -ol.format.OWS.readAllowedValues_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack); +_ol_format_OWS_.readAllowedValues_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.ALLOWED_VALUES_PARSERS_, node, objectStack); }; @@ -70,13 +71,13 @@ ol.format.OWS.readAllowedValues_ = function(node, objectStack) { * @private * @return {Object|undefined} The constraint. */ -ol.format.OWS.readConstraint_ = function(node, objectStack) { +_ol_format_OWS_.readConstraint_ = function(node, objectStack) { var name = node.getAttribute('name'); if (!name) { return undefined; } - return ol.xml.pushParseAndPop({'name': name}, - ol.format.OWS.CONSTRAINT_PARSERS_, node, + return _ol_xml_.pushParseAndPop({'name': name}, + _ol_format_OWS_.CONSTRAINT_PARSERS_, node, objectStack); }; @@ -87,9 +88,9 @@ ol.format.OWS.readConstraint_ = function(node, objectStack) { * @private * @return {Object|undefined} The contact info. */ -ol.format.OWS.readContactInfo_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack); +_ol_format_OWS_.readContactInfo_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.CONTACT_INFO_PARSERS_, node, objectStack); }; @@ -99,9 +100,9 @@ ol.format.OWS.readContactInfo_ = function(node, objectStack) { * @private * @return {Object|undefined} The DCP. */ -ol.format.OWS.readDcp_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.DCP_PARSERS_, node, objectStack); +_ol_format_OWS_.readDcp_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.DCP_PARSERS_, node, objectStack); }; @@ -111,13 +112,13 @@ ol.format.OWS.readDcp_ = function(node, objectStack) { * @private * @return {Object|undefined} The GET object. */ -ol.format.OWS.readGet_ = function(node, objectStack) { - var href = ol.format.XLink.readHref(node); +_ol_format_OWS_.readGet_ = function(node, objectStack) { + var href = _ol_format_XLink_.readHref(node); if (!href) { return undefined; } - return ol.xml.pushParseAndPop({'href': href}, - ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack); + return _ol_xml_.pushParseAndPop({'href': href}, + _ol_format_OWS_.REQUEST_METHOD_PARSERS_, node, objectStack); }; @@ -127,8 +128,8 @@ ol.format.OWS.readGet_ = function(node, objectStack) { * @private * @return {Object|undefined} The HTTP object. */ -ol.format.OWS.readHttp_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, ol.format.OWS.HTTP_PARSERS_, +_ol_format_OWS_.readHttp_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, _ol_format_OWS_.HTTP_PARSERS_, node, objectStack); }; @@ -139,10 +140,10 @@ ol.format.OWS.readHttp_ = function(node, objectStack) { * @private * @return {Object|undefined} The operation. */ -ol.format.OWS.readOperation_ = function(node, objectStack) { +_ol_format_OWS_.readOperation_ = function(node, objectStack) { var name = node.getAttribute('name'); - var value = ol.xml.pushParseAndPop({}, - ol.format.OWS.OPERATION_PARSERS_, node, objectStack); + var value = _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.OPERATION_PARSERS_, node, objectStack); if (!value) { return undefined; } @@ -158,10 +159,10 @@ ol.format.OWS.readOperation_ = function(node, objectStack) { * @private * @return {Object|undefined} The operations metadata. */ -ol.format.OWS.readOperationsMetadata_ = function(node, +_ol_format_OWS_.readOperationsMetadata_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node, + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.OPERATIONS_METADATA_PARSERS_, node, objectStack); }; @@ -172,9 +173,9 @@ ol.format.OWS.readOperationsMetadata_ = function(node, * @private * @return {Object|undefined} The phone. */ -ol.format.OWS.readPhone_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.OWS.PHONE_PARSERS_, node, objectStack); +_ol_format_OWS_.readPhone_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_OWS_.PHONE_PARSERS_, node, objectStack); }; @@ -184,10 +185,10 @@ ol.format.OWS.readPhone_ = function(node, objectStack) { * @private * @return {Object|undefined} The service identification. */ -ol.format.OWS.readServiceIdentification_ = function(node, +_ol_format_OWS_.readServiceIdentification_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node, + return _ol_xml_.pushParseAndPop( + {}, _ol_format_OWS_.SERVICE_IDENTIFICATION_PARSERS_, node, objectStack); }; @@ -198,9 +199,9 @@ ol.format.OWS.readServiceIdentification_ = function(node, * @private * @return {Object|undefined} The service contact. */ -ol.format.OWS.readServiceContact_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node, +_ol_format_OWS_.readServiceContact_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_OWS_.SERVICE_CONTACT_PARSERS_, node, objectStack); }; @@ -211,9 +212,9 @@ ol.format.OWS.readServiceContact_ = function(node, objectStack) { * @private * @return {Object|undefined} The service provider. */ -ol.format.OWS.readServiceProvider_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node, +_ol_format_OWS_.readServiceProvider_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_OWS_.SERVICE_PROVIDER_PARSERS_, node, objectStack); }; @@ -224,8 +225,8 @@ ol.format.OWS.readServiceProvider_ = function(node, objectStack) { * @private * @return {string|undefined} The value. */ -ol.format.OWS.readValue_ = function(node, objectStack) { - return ol.format.XSD.readString(node); +_ol_format_OWS_.readValue_ = function(node, objectStack) { + return _ol_format_XSD_.readString(node); }; @@ -234,7 +235,7 @@ ol.format.OWS.readValue_ = function(node, objectStack) { * @type {Array.} * @private */ -ol.format.OWS.NAMESPACE_URIS_ = [ +_ol_format_OWS_.NAMESPACE_URIS_ = [ null, 'http://www.opengis.net/ows/1.1' ]; @@ -245,14 +246,14 @@ ol.format.OWS.NAMESPACE_URIS_ = [ * @type {Object.>} * @private */ -ol.format.OWS.PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'ServiceIdentification': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readServiceIdentification_), - 'ServiceProvider': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readServiceProvider_), - 'OperationsMetadata': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readOperationsMetadata_) +_ol_format_OWS_.PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'ServiceIdentification': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readServiceIdentification_), + 'ServiceProvider': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readServiceProvider_), + 'OperationsMetadata': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readOperationsMetadata_) }); @@ -261,17 +262,17 @@ ol.format.OWS.PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'DeliveryPoint': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'AdministrativeArea': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Country': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'ElectronicMailAddress': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_OWS_.ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'DeliveryPoint': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'City': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'AdministrativeArea': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'PostalCode': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Country': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'ElectronicMailAddress': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) }); @@ -280,9 +281,9 @@ ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Value': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readValue_) +_ol_format_OWS_.ALLOWED_VALUES_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Value': _ol_xml_.makeObjectPropertyPusher(_ol_format_OWS_.readValue_) }); @@ -291,10 +292,10 @@ ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'AllowedValues': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readAllowedValues_) +_ol_format_OWS_.CONSTRAINT_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'AllowedValues': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readAllowedValues_) }); @@ -303,10 +304,10 @@ ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Phone': ol.xml.makeObjectPropertySetter(ol.format.OWS.readPhone_), - 'Address': ol.xml.makeObjectPropertySetter(ol.format.OWS.readAddress_) +_ol_format_OWS_.CONTACT_INFO_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Phone': _ol_xml_.makeObjectPropertySetter(_ol_format_OWS_.readPhone_), + 'Address': _ol_xml_.makeObjectPropertySetter(_ol_format_OWS_.readAddress_) }); @@ -315,9 +316,9 @@ ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.DCP_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'HTTP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readHttp_) +_ol_format_OWS_.DCP_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'HTTP': _ol_xml_.makeObjectPropertySetter(_ol_format_OWS_.readHttp_) }); @@ -326,9 +327,9 @@ ol.format.OWS.DCP_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Get': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readGet_), +_ol_format_OWS_.HTTP_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Get': _ol_xml_.makeObjectPropertyPusher(_ol_format_OWS_.readGet_), 'Post': undefined // TODO }); @@ -338,9 +339,9 @@ ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'DCP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readDcp_) +_ol_format_OWS_.OPERATION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'DCP': _ol_xml_.makeObjectPropertySetter(_ol_format_OWS_.readDcp_) }); @@ -349,9 +350,9 @@ ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Operation': ol.format.OWS.readOperation_ +_ol_format_OWS_.OPERATIONS_METADATA_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Operation': _ol_format_OWS_.readOperation_ }); @@ -360,10 +361,10 @@ ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString) +_ol_format_OWS_.PHONE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Voice': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Facsimile': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString) }); @@ -372,10 +373,10 @@ ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Constraint': ol.xml.makeObjectPropertyPusher( - ol.format.OWS.readConstraint_) +_ol_format_OWS_.REQUEST_METHOD_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Constraint': _ol_xml_.makeObjectPropertyPusher( + _ol_format_OWS_.readConstraint_) }); @@ -384,14 +385,14 @@ ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.OWS.SERVICE_CONTACT_PARSERS_ = - ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'IndividualName': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'ContactInfo': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readContactInfo_) +_ol_format_OWS_.SERVICE_CONTACT_PARSERS_ = + _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'IndividualName': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'PositionName': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'ContactInfo': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readContactInfo_) }); @@ -400,16 +401,16 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ = * @type {Object.>} * @private */ -ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ = - ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'AccessConstraints': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Fees': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'ServiceTypeVersion': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'ServiceType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString) +_ol_format_OWS_.SERVICE_IDENTIFICATION_PARSERS_ = + _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'Abstract': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'AccessConstraints': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Fees': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Title': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'ServiceTypeVersion': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'ServiceType': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString) }); @@ -418,11 +419,12 @@ ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ = * @type {Object.>} * @private */ -ol.format.OWS.SERVICE_PROVIDER_PARSERS_ = - ol.xml.makeStructureNS( - ol.format.OWS.NAMESPACE_URIS_, { - 'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref), - 'ServiceContact': ol.xml.makeObjectPropertySetter( - ol.format.OWS.readServiceContact_) +_ol_format_OWS_.SERVICE_PROVIDER_PARSERS_ = + _ol_xml_.makeStructureNS( + _ol_format_OWS_.NAMESPACE_URIS_, { + 'ProviderName': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'ProviderSite': _ol_xml_.makeObjectPropertySetter(_ol_format_XLink_.readHref), + 'ServiceContact': _ol_xml_.makeObjectPropertySetter( + _ol_format_OWS_.readServiceContact_) }); +export default _ol_format_OWS_; diff --git a/src/ol/format/Polyline.js b/src/ol/format/Polyline.js index e7390ee75b..86986147eb 100644 --- a/src/ol/format/Polyline.js +++ b/src/ol/format/Polyline.js @@ -1,17 +1,17 @@ -goog.provide('ol.format.Polyline'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.TextFeature'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.flip'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.proj'); - +/** + * @module ol/format/Polyline + */ +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_TextFeature_ from '../format/TextFeature.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_flip_ from '../geom/flat/flip.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -24,16 +24,16 @@ goog.require('ol.proj'); * Optional configuration object. * @api */ -ol.format.Polyline = function(opt_options) { +var _ol_format_Polyline_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.TextFeature.call(this); + _ol_format_TextFeature_.call(this); /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get('EPSG:4326'); + this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); /** * @private @@ -46,9 +46,10 @@ ol.format.Polyline = function(opt_options) { * @type {ol.geom.GeometryLayout} */ this.geometryLayout_ = options.geometryLayout ? - options.geometryLayout : ol.geom.GeometryLayout.XY; + options.geometryLayout : _ol_geom_GeometryLayout_.XY; }; -ol.inherits(ol.format.Polyline, ol.format.TextFeature); + +_ol_.inherits(_ol_format_Polyline_, _ol_format_TextFeature_); /** @@ -64,7 +65,7 @@ ol.inherits(ol.format.Polyline, ol.format.TextFeature); * @return {string} The encoded string. * @api */ -ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { +_ol_format_Polyline_.encodeDeltas = function(numbers, stride, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var d; @@ -84,7 +85,7 @@ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { } } - return ol.format.Polyline.encodeFloats(numbers, factor); + return _ol_format_Polyline_.encodeFloats(numbers, factor); }; @@ -99,7 +100,7 @@ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { * @return {Array.} A list of n-dimensional points. * @api */ -ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { +_ol_format_Polyline_.decodeDeltas = function(encoded, stride, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var d; @@ -109,7 +110,7 @@ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { lastNumbers[d] = 0; } - var numbers = ol.format.Polyline.decodeFloats(encoded, factor); + var numbers = _ol_format_Polyline_.decodeFloats(encoded, factor); var i, ii; for (i = 0, ii = numbers.length; i < ii;) { @@ -136,14 +137,14 @@ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { * @return {string} The encoded string. * @api */ -ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { +_ol_format_Polyline_.encodeFloats = function(numbers, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] = Math.round(numbers[i] * factor); } - return ol.format.Polyline.encodeSignedIntegers(numbers); + return _ol_format_Polyline_.encodeSignedIntegers(numbers); }; @@ -156,9 +157,9 @@ ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { * @return {Array.} A list of floating point numbers. * @api */ -ol.format.Polyline.decodeFloats = function(encoded, opt_factor) { +_ol_format_Polyline_.decodeFloats = function(encoded, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; - var numbers = ol.format.Polyline.decodeSignedIntegers(encoded); + var numbers = _ol_format_Polyline_.decodeSignedIntegers(encoded); var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] /= factor; @@ -175,13 +176,13 @@ ol.format.Polyline.decodeFloats = function(encoded, opt_factor) { * @param {Array.} numbers A list of signed integers. * @return {string} The encoded string. */ -ol.format.Polyline.encodeSignedIntegers = function(numbers) { +_ol_format_Polyline_.encodeSignedIntegers = function(numbers) { var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { var num = numbers[i]; numbers[i] = (num < 0) ? ~(num << 1) : (num << 1); } - return ol.format.Polyline.encodeUnsignedIntegers(numbers); + return _ol_format_Polyline_.encodeUnsignedIntegers(numbers); }; @@ -191,8 +192,8 @@ ol.format.Polyline.encodeSignedIntegers = function(numbers) { * @param {string} encoded An encoded string. * @return {Array.} A list of signed integers. */ -ol.format.Polyline.decodeSignedIntegers = function(encoded) { - var numbers = ol.format.Polyline.decodeUnsignedIntegers(encoded); +_ol_format_Polyline_.decodeSignedIntegers = function(encoded) { + var numbers = _ol_format_Polyline_.decodeUnsignedIntegers(encoded); var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { var num = numbers[i]; @@ -208,11 +209,11 @@ ol.format.Polyline.decodeSignedIntegers = function(encoded) { * @param {Array.} numbers A list of unsigned integers. * @return {string} The encoded string. */ -ol.format.Polyline.encodeUnsignedIntegers = function(numbers) { +_ol_format_Polyline_.encodeUnsignedIntegers = function(numbers) { var encoded = ''; var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { - encoded += ol.format.Polyline.encodeUnsignedInteger(numbers[i]); + encoded += _ol_format_Polyline_.encodeUnsignedInteger(numbers[i]); } return encoded; }; @@ -224,7 +225,7 @@ ol.format.Polyline.encodeUnsignedIntegers = function(numbers) { * @param {string} encoded An encoded string. * @return {Array.} A list of unsigned integers. */ -ol.format.Polyline.decodeUnsignedIntegers = function(encoded) { +_ol_format_Polyline_.decodeUnsignedIntegers = function(encoded) { var numbers = []; var current = 0; var shift = 0; @@ -250,7 +251,7 @@ ol.format.Polyline.decodeUnsignedIntegers = function(encoded) { * @param {number} num Unsigned integer that should be encoded. * @return {string} The encoded string. */ -ol.format.Polyline.encodeUnsignedInteger = function(num) { +_ol_format_Polyline_.encodeUnsignedInteger = function(num) { var value, encoded = ''; while (num >= 0x20) { value = (0x20 | (num & 0x1f)) + 63; @@ -273,15 +274,15 @@ ol.format.Polyline.encodeUnsignedInteger = function(num) { * @return {ol.Feature} Feature. * @api */ -ol.format.Polyline.prototype.readFeature; +_ol_format_Polyline_.prototype.readFeature; /** * @inheritDoc */ -ol.format.Polyline.prototype.readFeatureFromText = function(text, opt_options) { +_ol_format_Polyline_.prototype.readFeatureFromText = function(text, opt_options) { var geometry = this.readGeometryFromText(text, opt_options); - return new ol.Feature(geometry); + return new _ol_Feature_(geometry); }; @@ -295,13 +296,13 @@ ol.format.Polyline.prototype.readFeatureFromText = function(text, opt_options) { * @return {Array.} Features. * @api */ -ol.format.Polyline.prototype.readFeatures; +_ol_format_Polyline_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.Polyline.prototype.readFeaturesFromText = function(text, opt_options) { +_ol_format_Polyline_.prototype.readFeaturesFromText = function(text, opt_options) { var feature = this.readFeatureFromText(text, opt_options); return [feature]; }; @@ -316,25 +317,26 @@ ol.format.Polyline.prototype.readFeaturesFromText = function(text, opt_options) * @return {ol.geom.Geometry} Geometry. * @api */ -ol.format.Polyline.prototype.readGeometry; +_ol_format_Polyline_.prototype.readGeometry; /** * @inheritDoc */ -ol.format.Polyline.prototype.readGeometryFromText = function(text, opt_options) { - var stride = ol.geom.SimpleGeometry.getStrideForLayout(this.geometryLayout_); - var flatCoordinates = ol.format.Polyline.decodeDeltas( +_ol_format_Polyline_.prototype.readGeometryFromText = function(text, opt_options) { + var stride = _ol_geom_SimpleGeometry_.getStrideForLayout(this.geometryLayout_); + var flatCoordinates = _ol_format_Polyline_.decodeDeltas( text, stride, this.factor_); - ol.geom.flat.flip.flipXY( + _ol_geom_flat_flip_.flipXY( flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates); - var coordinates = ol.geom.flat.inflate.coordinates( + var coordinates = _ol_geom_flat_inflate_.coordinates( flatCoordinates, 0, flatCoordinates.length, stride); - return /** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions( - new ol.geom.LineString(coordinates, this.geometryLayout_), false, - this.adaptOptions(opt_options))); + return ( + /** @type {ol.geom.Geometry} */ _ol_format_Feature_.transformWithOptions( + new _ol_geom_LineString_(coordinates, this.geometryLayout_), false, + this.adaptOptions(opt_options)) + ); }; @@ -346,18 +348,18 @@ ol.format.Polyline.prototype.readGeometryFromText = function(text, opt_options) * @return {ol.proj.Projection} Projection. * @api */ -ol.format.Polyline.prototype.readProjection; +_ol_format_Polyline_.prototype.readProjection; /** * @inheritDoc */ -ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) { +_ol_format_Polyline_.prototype.writeFeatureText = function(feature, opt_options) { var geometry = feature.getGeometry(); if (geometry) { return this.writeGeometryText(geometry, opt_options); } else { - ol.asserts.assert(false, 40); // Expected `feature` to have a geometry + _ol_asserts_.assert(false, 40); // Expected `feature` to have a geometry return ''; } }; @@ -366,7 +368,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) { /** * @inheritDoc */ -ol.format.Polyline.prototype.writeFeaturesText = function(features, opt_options) { +_ol_format_Polyline_.prototype.writeFeaturesText = function(features, opt_options) { return this.writeFeatureText(features[0], opt_options); }; @@ -380,19 +382,20 @@ ol.format.Polyline.prototype.writeFeaturesText = function(features, opt_options) * @return {string} Geometry. * @api */ -ol.format.Polyline.prototype.writeGeometry; +_ol_format_Polyline_.prototype.writeGeometry; /** * @inheritDoc */ -ol.format.Polyline.prototype.writeGeometryText = function(geometry, opt_options) { +_ol_format_Polyline_.prototype.writeGeometryText = function(geometry, opt_options) { geometry = /** @type {ol.geom.LineString} */ - (ol.format.Feature.transformWithOptions( + (_ol_format_Feature_.transformWithOptions( geometry, true, this.adaptOptions(opt_options))); var flatCoordinates = geometry.getFlatCoordinates(); var stride = geometry.getStride(); - ol.geom.flat.flip.flipXY( + _ol_geom_flat_flip_.flipXY( flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates); - return ol.format.Polyline.encodeDeltas(flatCoordinates, stride, this.factor_); + return _ol_format_Polyline_.encodeDeltas(flatCoordinates, stride, this.factor_); }; +export default _ol_format_Polyline_; diff --git a/src/ol/format/TextFeature.js b/src/ol/format/TextFeature.js index 3651d25b26..0570b92877 100644 --- a/src/ol/format/TextFeature.js +++ b/src/ol/format/TextFeature.js @@ -1,9 +1,9 @@ -goog.provide('ol.format.TextFeature'); - -goog.require('ol'); -goog.require('ol.format.Feature'); -goog.require('ol.format.FormatType'); - +/** + * @module ol/format/TextFeature + */ +import _ol_ from '../index.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_FormatType_ from '../format/FormatType.js'; /** * @classdesc @@ -15,10 +15,11 @@ goog.require('ol.format.FormatType'); * @abstract * @extends {ol.format.Feature} */ -ol.format.TextFeature = function() { - ol.format.Feature.call(this); +var _ol_format_TextFeature_ = function() { + _ol_format_Feature_.call(this); }; -ol.inherits(ol.format.TextFeature, ol.format.Feature); + +_ol_.inherits(_ol_format_TextFeature_, _ol_format_Feature_); /** @@ -26,7 +27,7 @@ ol.inherits(ol.format.TextFeature, ol.format.Feature); * @private * @return {string} Text. */ -ol.format.TextFeature.prototype.getText_ = function(source) { +_ol_format_TextFeature_.prototype.getText_ = function(source) { if (typeof source === 'string') { return source; } else { @@ -38,15 +39,15 @@ ol.format.TextFeature.prototype.getText_ = function(source) { /** * @inheritDoc */ -ol.format.TextFeature.prototype.getType = function() { - return ol.format.FormatType.TEXT; +_ol_format_TextFeature_.prototype.getType = function() { + return _ol_format_FormatType_.TEXT; }; /** * @inheritDoc */ -ol.format.TextFeature.prototype.readFeature = function(source, opt_options) { +_ol_format_TextFeature_.prototype.readFeature = function(source, opt_options) { return this.readFeatureFromText( this.getText_(source), this.adaptOptions(opt_options)); }; @@ -59,13 +60,13 @@ ol.format.TextFeature.prototype.readFeature = function(source, opt_options) { * @protected * @return {ol.Feature} Feature. */ -ol.format.TextFeature.prototype.readFeatureFromText = function(text, opt_options) {}; +_ol_format_TextFeature_.prototype.readFeatureFromText = function(text, opt_options) {}; /** * @inheritDoc */ -ol.format.TextFeature.prototype.readFeatures = function(source, opt_options) { +_ol_format_TextFeature_.prototype.readFeatures = function(source, opt_options) { return this.readFeaturesFromText( this.getText_(source), this.adaptOptions(opt_options)); }; @@ -78,13 +79,13 @@ ol.format.TextFeature.prototype.readFeatures = function(source, opt_options) { * @protected * @return {Array.} Features. */ -ol.format.TextFeature.prototype.readFeaturesFromText = function(text, opt_options) {}; +_ol_format_TextFeature_.prototype.readFeaturesFromText = function(text, opt_options) {}; /** * @inheritDoc */ -ol.format.TextFeature.prototype.readGeometry = function(source, opt_options) { +_ol_format_TextFeature_.prototype.readGeometry = function(source, opt_options) { return this.readGeometryFromText( this.getText_(source), this.adaptOptions(opt_options)); }; @@ -97,13 +98,13 @@ ol.format.TextFeature.prototype.readGeometry = function(source, opt_options) { * @protected * @return {ol.geom.Geometry} Geometry. */ -ol.format.TextFeature.prototype.readGeometryFromText = function(text, opt_options) {}; +_ol_format_TextFeature_.prototype.readGeometryFromText = function(text, opt_options) {}; /** * @inheritDoc */ -ol.format.TextFeature.prototype.readProjection = function(source) { +_ol_format_TextFeature_.prototype.readProjection = function(source) { return this.readProjectionFromText(this.getText_(source)); }; @@ -113,7 +114,7 @@ ol.format.TextFeature.prototype.readProjection = function(source) { * @protected * @return {ol.proj.Projection} Projection. */ -ol.format.TextFeature.prototype.readProjectionFromText = function(text) { +_ol_format_TextFeature_.prototype.readProjectionFromText = function(text) { return this.defaultDataProjection; }; @@ -121,7 +122,7 @@ ol.format.TextFeature.prototype.readProjectionFromText = function(text) { /** * @inheritDoc */ -ol.format.TextFeature.prototype.writeFeature = function(feature, opt_options) { +_ol_format_TextFeature_.prototype.writeFeature = function(feature, opt_options) { return this.writeFeatureText(feature, this.adaptOptions(opt_options)); }; @@ -133,13 +134,13 @@ ol.format.TextFeature.prototype.writeFeature = function(feature, opt_options) { * @protected * @return {string} Text. */ -ol.format.TextFeature.prototype.writeFeatureText = function(feature, opt_options) {}; +_ol_format_TextFeature_.prototype.writeFeatureText = function(feature, opt_options) {}; /** * @inheritDoc */ -ol.format.TextFeature.prototype.writeFeatures = function( +_ol_format_TextFeature_.prototype.writeFeatures = function( features, opt_options) { return this.writeFeaturesText(features, this.adaptOptions(opt_options)); }; @@ -152,13 +153,13 @@ ol.format.TextFeature.prototype.writeFeatures = function( * @protected * @return {string} Text. */ -ol.format.TextFeature.prototype.writeFeaturesText = function(features, opt_options) {}; +_ol_format_TextFeature_.prototype.writeFeaturesText = function(features, opt_options) {}; /** * @inheritDoc */ -ol.format.TextFeature.prototype.writeGeometry = function( +_ol_format_TextFeature_.prototype.writeGeometry = function( geometry, opt_options) { return this.writeGeometryText(geometry, this.adaptOptions(opt_options)); }; @@ -171,4 +172,5 @@ ol.format.TextFeature.prototype.writeGeometry = function( * @protected * @return {string} Text. */ -ol.format.TextFeature.prototype.writeGeometryText = function(geometry, opt_options) {}; +_ol_format_TextFeature_.prototype.writeGeometryText = function(geometry, opt_options) {}; +export default _ol_format_TextFeature_; diff --git a/src/ol/format/TopoJSON.js b/src/ol/format/TopoJSON.js index a498a48b02..e79b9dbf8f 100644 --- a/src/ol/format/TopoJSON.js +++ b/src/ol/format/TopoJSON.js @@ -1,17 +1,17 @@ -goog.provide('ol.format.TopoJSON'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.JSONFeature'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); - +/** + * @module ol/format/TopoJSON + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_JSONFeature_ from '../format/JSONFeature.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -22,11 +22,11 @@ goog.require('ol.proj'); * @param {olx.format.TopoJSONOptions=} opt_options Options. * @api */ -ol.format.TopoJSON = function(opt_options) { +var _ol_format_TopoJSON_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.JSONFeature.call(this); + _ol_format_JSONFeature_.call(this); /** * @private @@ -43,12 +43,13 @@ ol.format.TopoJSON = function(opt_options) { /** * @inheritDoc */ - this.defaultDataProjection = ol.proj.get( + this.defaultDataProjection = _ol_proj_.get( options.defaultDataProjection ? options.defaultDataProjection : 'EPSG:4326'); }; -ol.inherits(ol.format.TopoJSON, ol.format.JSONFeature); + +_ol_.inherits(_ol_format_TopoJSON_, _ol_format_JSONFeature_); /** @@ -60,7 +61,7 @@ ol.inherits(ol.format.TopoJSON, ol.format.JSONFeature); * @return {Array.} Coordinates array. * @private */ -ol.format.TopoJSON.concatenateArcs_ = function(indices, arcs) { +_ol_format_TopoJSON_.concatenateArcs_ = function(indices, arcs) { /** @type {Array.} */ var coordinates = []; var index, arc; @@ -98,12 +99,12 @@ ol.format.TopoJSON.concatenateArcs_ = function(indices, arcs) { * @return {ol.geom.Point} Geometry. * @private */ -ol.format.TopoJSON.readPointGeometry_ = function(object, scale, translate) { +_ol_format_TopoJSON_.readPointGeometry_ = function(object, scale, translate) { var coordinates = object.coordinates; if (scale && translate) { - ol.format.TopoJSON.transformVertex_(coordinates, scale, translate); + _ol_format_TopoJSON_.transformVertex_(coordinates, scale, translate); } - return new ol.geom.Point(coordinates); + return new _ol_geom_Point_(coordinates); }; @@ -116,16 +117,16 @@ ol.format.TopoJSON.readPointGeometry_ = function(object, scale, translate) { * @return {ol.geom.MultiPoint} Geometry. * @private */ -ol.format.TopoJSON.readMultiPointGeometry_ = function(object, scale, +_ol_format_TopoJSON_.readMultiPointGeometry_ = function(object, scale, translate) { var coordinates = object.coordinates; var i, ii; if (scale && translate) { for (i = 0, ii = coordinates.length; i < ii; ++i) { - ol.format.TopoJSON.transformVertex_(coordinates[i], scale, translate); + _ol_format_TopoJSON_.transformVertex_(coordinates[i], scale, translate); } } - return new ol.geom.MultiPoint(coordinates); + return new _ol_geom_MultiPoint_(coordinates); }; @@ -137,9 +138,9 @@ ol.format.TopoJSON.readMultiPointGeometry_ = function(object, scale, * @return {ol.geom.LineString} Geometry. * @private */ -ol.format.TopoJSON.readLineStringGeometry_ = function(object, arcs) { - var coordinates = ol.format.TopoJSON.concatenateArcs_(object.arcs, arcs); - return new ol.geom.LineString(coordinates); +_ol_format_TopoJSON_.readLineStringGeometry_ = function(object, arcs) { + var coordinates = _ol_format_TopoJSON_.concatenateArcs_(object.arcs, arcs); + return new _ol_geom_LineString_(coordinates); }; @@ -151,13 +152,13 @@ ol.format.TopoJSON.readLineStringGeometry_ = function(object, arcs) { * @return {ol.geom.MultiLineString} Geometry. * @private */ -ol.format.TopoJSON.readMultiLineStringGeometry_ = function(object, arcs) { +_ol_format_TopoJSON_.readMultiLineStringGeometry_ = function(object, arcs) { var coordinates = []; var i, ii; for (i = 0, ii = object.arcs.length; i < ii; ++i) { - coordinates[i] = ol.format.TopoJSON.concatenateArcs_(object.arcs[i], arcs); + coordinates[i] = _ol_format_TopoJSON_.concatenateArcs_(object.arcs[i], arcs); } - return new ol.geom.MultiLineString(coordinates); + return new _ol_geom_MultiLineString_(coordinates); }; @@ -169,13 +170,13 @@ ol.format.TopoJSON.readMultiLineStringGeometry_ = function(object, arcs) { * @return {ol.geom.Polygon} Geometry. * @private */ -ol.format.TopoJSON.readPolygonGeometry_ = function(object, arcs) { +_ol_format_TopoJSON_.readPolygonGeometry_ = function(object, arcs) { var coordinates = []; var i, ii; for (i = 0, ii = object.arcs.length; i < ii; ++i) { - coordinates[i] = ol.format.TopoJSON.concatenateArcs_(object.arcs[i], arcs); + coordinates[i] = _ol_format_TopoJSON_.concatenateArcs_(object.arcs[i], arcs); } - return new ol.geom.Polygon(coordinates); + return new _ol_geom_Polygon_(coordinates); }; @@ -187,7 +188,7 @@ ol.format.TopoJSON.readPolygonGeometry_ = function(object, arcs) { * @return {ol.geom.MultiPolygon} Geometry. * @private */ -ol.format.TopoJSON.readMultiPolygonGeometry_ = function(object, arcs) { +_ol_format_TopoJSON_.readMultiPolygonGeometry_ = function(object, arcs) { var coordinates = []; var polyArray, ringCoords, j, jj; var i, ii; @@ -197,11 +198,11 @@ ol.format.TopoJSON.readMultiPolygonGeometry_ = function(object, arcs) { ringCoords = []; for (j = 0, jj = polyArray.length; j < jj; ++j) { // for each ring - ringCoords[j] = ol.format.TopoJSON.concatenateArcs_(polyArray[j], arcs); + ringCoords[j] = _ol_format_TopoJSON_.concatenateArcs_(polyArray[j], arcs); } coordinates[i] = ringCoords; } - return new ol.geom.MultiPolygon(coordinates); + return new _ol_geom_MultiPolygon_(coordinates); }; @@ -220,13 +221,13 @@ ol.format.TopoJSON.readMultiPolygonGeometry_ = function(object, arcs) { * @return {Array.} Array of features. * @private */ -ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function( +_ol_format_TopoJSON_.readFeaturesFromGeometryCollection_ = function( collection, arcs, scale, translate, property, name, opt_options) { var geometries = collection.geometries; var features = []; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { - features[i] = ol.format.TopoJSON.readFeatureFromGeometry_( + features[i] = _ol_format_TopoJSON_.readFeatureFromGeometry_( geometries[i], arcs, scale, translate, property, name, opt_options); } return features; @@ -247,19 +248,19 @@ ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function( * @return {ol.Feature} Feature. * @private */ -ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, +_ol_format_TopoJSON_.readFeatureFromGeometry_ = function(object, arcs, scale, translate, property, name, opt_options) { var geometry; var type = object.type; - var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type]; + var geometryReader = _ol_format_TopoJSON_.GEOMETRY_READERS_[type]; if ((type === 'Point') || (type === 'MultiPoint')) { geometry = geometryReader(object, scale, translate); } else { geometry = geometryReader(object, arcs); } - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(/** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions(geometry, false, opt_options))); + _ol_format_Feature_.transformWithOptions(geometry, false, opt_options))); if (object.id !== undefined) { feature.setId(object.id); } @@ -285,13 +286,13 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, * @return {Array.} Features. * @api */ -ol.format.TopoJSON.prototype.readFeatures; +_ol_format_TopoJSON_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.TopoJSON.prototype.readFeaturesFromObject = function( +_ol_format_TopoJSON_.prototype.readFeaturesFromObject = function( object, opt_options) { if (object.type == 'Topology') { var topoJSONTopology = /** @type {TopoJSONTopology} */ (object); @@ -303,7 +304,7 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function( } var arcs = topoJSONTopology.arcs; if (transform) { - ol.format.TopoJSON.transformArcs_(arcs, scale, translate); + _ol_format_TopoJSON_.transformArcs_(arcs, scale, translate); } /** @type {Array.} */ var features = []; @@ -318,12 +319,12 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function( feature = /** @type {TopoJSONGeometryCollection} */ (topoJSONFeatures[objectName]); features.push.apply(features, - ol.format.TopoJSON.readFeaturesFromGeometryCollection_( + _ol_format_TopoJSON_.readFeaturesFromGeometryCollection_( feature, arcs, scale, translate, property, objectName, opt_options)); } else { feature = /** @type {TopoJSONGeometry} */ (topoJSONFeatures[objectName]); - features.push(ol.format.TopoJSON.readFeatureFromGeometry_( + features.push(_ol_format_TopoJSON_.readFeatureFromGeometry_( feature, arcs, scale, translate, property, objectName, opt_options)); } } @@ -343,10 +344,10 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function( * @param {Array.} translate Translation for each dimension. * @private */ -ol.format.TopoJSON.transformArcs_ = function(arcs, scale, translate) { +_ol_format_TopoJSON_.transformArcs_ = function(arcs, scale, translate) { var i, ii; for (i = 0, ii = arcs.length; i < ii; ++i) { - ol.format.TopoJSON.transformArc_(arcs[i], scale, translate); + _ol_format_TopoJSON_.transformArc_(arcs[i], scale, translate); } }; @@ -359,7 +360,7 @@ ol.format.TopoJSON.transformArcs_ = function(arcs, scale, translate) { * @param {Array.} translate Translation for each dimension. * @private */ -ol.format.TopoJSON.transformArc_ = function(arc, scale, translate) { +_ol_format_TopoJSON_.transformArc_ = function(arc, scale, translate) { var x = 0; var y = 0; var vertex; @@ -370,7 +371,7 @@ ol.format.TopoJSON.transformArc_ = function(arc, scale, translate) { y += vertex[1]; vertex[0] = x; vertex[1] = y; - ol.format.TopoJSON.transformVertex_(vertex, scale, translate); + _ol_format_TopoJSON_.transformVertex_(vertex, scale, translate); } }; @@ -384,7 +385,7 @@ ol.format.TopoJSON.transformArc_ = function(arc, scale, translate) { * @param {Array.} translate Translation for each dimension. * @private */ -ol.format.TopoJSON.transformVertex_ = function(vertex, scale, translate) { +_ol_format_TopoJSON_.transformVertex_ = function(vertex, scale, translate) { vertex[0] = vertex[0] * scale[0] + translate[0]; vertex[1] = vertex[1] * scale[1] + translate[1]; }; @@ -398,13 +399,13 @@ ol.format.TopoJSON.transformVertex_ = function(vertex, scale, translate) { * @override * @api */ -ol.format.TopoJSON.prototype.readProjection; +_ol_format_TopoJSON_.prototype.readProjection; /** * @inheritDoc */ -ol.format.TopoJSON.prototype.readProjectionFromObject = function(object) { +_ol_format_TopoJSON_.prototype.readProjectionFromObject = function(object) { return this.defaultDataProjection; }; @@ -414,13 +415,13 @@ ol.format.TopoJSON.prototype.readProjectionFromObject = function(object) { * @private * @type {Object.} */ -ol.format.TopoJSON.GEOMETRY_READERS_ = { - 'Point': ol.format.TopoJSON.readPointGeometry_, - 'LineString': ol.format.TopoJSON.readLineStringGeometry_, - 'Polygon': ol.format.TopoJSON.readPolygonGeometry_, - 'MultiPoint': ol.format.TopoJSON.readMultiPointGeometry_, - 'MultiLineString': ol.format.TopoJSON.readMultiLineStringGeometry_, - 'MultiPolygon': ol.format.TopoJSON.readMultiPolygonGeometry_ +_ol_format_TopoJSON_.GEOMETRY_READERS_ = { + 'Point': _ol_format_TopoJSON_.readPointGeometry_, + 'LineString': _ol_format_TopoJSON_.readLineStringGeometry_, + 'Polygon': _ol_format_TopoJSON_.readPolygonGeometry_, + 'MultiPoint': _ol_format_TopoJSON_.readMultiPointGeometry_, + 'MultiLineString': _ol_format_TopoJSON_.readMultiLineStringGeometry_, + 'MultiPolygon': _ol_format_TopoJSON_.readMultiPolygonGeometry_ }; @@ -428,32 +429,33 @@ ol.format.TopoJSON.GEOMETRY_READERS_ = { * Not implemented. * @inheritDoc */ -ol.format.TopoJSON.prototype.writeFeatureObject = function(feature, opt_options) {}; +_ol_format_TopoJSON_.prototype.writeFeatureObject = function(feature, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.TopoJSON.prototype.writeFeaturesObject = function(features, opt_options) {}; +_ol_format_TopoJSON_.prototype.writeFeaturesObject = function(features, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.TopoJSON.prototype.writeGeometryObject = function(geometry, opt_options) {}; +_ol_format_TopoJSON_.prototype.writeGeometryObject = function(geometry, opt_options) {}; /** * Not implemented. * @override */ -ol.format.TopoJSON.prototype.readGeometryFromObject = function() {}; +_ol_format_TopoJSON_.prototype.readGeometryFromObject = function() {}; /** * Not implemented. * @override */ -ol.format.TopoJSON.prototype.readFeatureFromObject = function() {}; +_ol_format_TopoJSON_.prototype.readFeatureFromObject = function() {}; +export default _ol_format_TopoJSON_; diff --git a/src/ol/format/WFS.js b/src/ol/format/WFS.js index 40a98cb333..0fe8e66785 100644 --- a/src/ol/format/WFS.js +++ b/src/ol/format/WFS.js @@ -1,18 +1,18 @@ -goog.provide('ol.format.WFS'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.format.GML2'); -goog.require('ol.format.GML3'); -goog.require('ol.format.GMLBase'); -goog.require('ol.format.filter'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.format.XSD'); -goog.require('ol.geom.Geometry'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.xml'); - +/** + * @module ol/format/WFS + */ +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_format_GML2_ from '../format/GML2.js'; +import _ol_format_GML3_ from '../format/GML3.js'; +import _ol_format_GMLBase_ from '../format/GMLBase.js'; +import _ol_format_filter_ from '../format/filter.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -27,7 +27,7 @@ goog.require('ol.xml'); * @extends {ol.format.XMLFeature} * @api */ -ol.format.WFS = function(opt_options) { +var _ol_format_WFS_ = function(opt_options) { var options = opt_options ? opt_options : {}; /** @@ -47,7 +47,7 @@ ol.format.WFS = function(opt_options) { * @type {ol.format.GMLBase} */ this.gmlFormat_ = options.gmlFormat ? - options.gmlFormat : new ol.format.GML3(); + options.gmlFormat : new _ol_format_GML3_(); /** * @private @@ -55,53 +55,54 @@ ol.format.WFS = function(opt_options) { */ this.schemaLocation_ = options.schemaLocation ? options.schemaLocation : - ol.format.WFS.SCHEMA_LOCATIONS[ol.format.WFS.DEFAULT_VERSION]; + _ol_format_WFS_.SCHEMA_LOCATIONS[_ol_format_WFS_.DEFAULT_VERSION]; - ol.format.XMLFeature.call(this); + _ol_format_XMLFeature_.call(this); }; -ol.inherits(ol.format.WFS, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_WFS_, _ol_format_XMLFeature_); /** * @const * @type {string} */ -ol.format.WFS.FEATURE_PREFIX = 'feature'; +_ol_format_WFS_.FEATURE_PREFIX = 'feature'; /** * @const * @type {string} */ -ol.format.WFS.XMLNS = 'http://www.w3.org/2000/xmlns/'; +_ol_format_WFS_.XMLNS = 'http://www.w3.org/2000/xmlns/'; /** * @const * @type {string} */ -ol.format.WFS.OGCNS = 'http://www.opengis.net/ogc'; +_ol_format_WFS_.OGCNS = 'http://www.opengis.net/ogc'; /** * @const * @type {string} */ -ol.format.WFS.WFSNS = 'http://www.opengis.net/wfs'; +_ol_format_WFS_.WFSNS = 'http://www.opengis.net/wfs'; /** * @const * @type {string} */ -ol.format.WFS.FESNS = 'http://www.opengis.net/fes'; +_ol_format_WFS_.FESNS = 'http://www.opengis.net/fes'; /** * @const * @type {Object.} */ -ol.format.WFS.SCHEMA_LOCATIONS = { +_ol_format_WFS_.SCHEMA_LOCATIONS = { '1.1.0': 'http://www.opengis.net/wfs ' + 'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd', '1.0.0': 'http://www.opengis.net/wfs ' + @@ -113,13 +114,13 @@ ol.format.WFS.SCHEMA_LOCATIONS = { * @const * @type {string} */ -ol.format.WFS.DEFAULT_VERSION = '1.1.0'; +_ol_format_WFS_.DEFAULT_VERSION = '1.1.0'; /** * @return {Array.|string|undefined} featureType */ -ol.format.WFS.prototype.getFeatureType = function() { +_ol_format_WFS_.prototype.getFeatureType = function() { return this.featureType_; }; @@ -127,7 +128,7 @@ ol.format.WFS.prototype.getFeatureType = function() { /** * @param {Array.|string|undefined} featureType Feature type(s) to parse. */ -ol.format.WFS.prototype.setFeatureType = function(featureType) { +_ol_format_WFS_.prototype.setFeatureType = function(featureType) { this.featureType_ = featureType; }; @@ -141,24 +142,24 @@ ol.format.WFS.prototype.setFeatureType = function(featureType) { * @return {Array.} Features. * @api */ -ol.format.WFS.prototype.readFeatures; +_ol_format_WFS_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { +_ol_format_WFS_.prototype.readFeaturesFromNode = function(node, opt_options) { var context = /** @type {ol.XmlNodeStackItem} */ ({ 'featureType': this.featureType_, 'featureNS': this.featureNS_ }); - ol.obj.assign(context, this.getReadOptions(node, + _ol_obj_.assign(context, this.getReadOptions(node, opt_options ? opt_options : {})); var objectStack = [context]; - this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ + this.gmlFormat_.FEATURE_COLLECTION_PARSERS[_ol_format_GMLBase_.GMLNS][ 'featureMember'] = - ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readFeaturesInternal); - var features = ol.xml.pushParseAndPop([], + _ol_xml_.makeArrayPusher(_ol_format_GMLBase_.prototype.readFeaturesInternal); + var features = _ol_xml_.pushParseAndPop([], this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, objectStack, this.gmlFormat_); if (!features) { @@ -175,14 +176,14 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { * @return {ol.WFSTransactionResponse|undefined} Transaction response. * @api */ -ol.format.WFS.prototype.readTransactionResponse = function(source) { - if (ol.xml.isDocument(source)) { +_ol_format_WFS_.prototype.readTransactionResponse = function(source) { + if (_ol_xml_.isDocument(source)) { return this.readTransactionResponseFromDocument( /** @type {Document} */ (source)); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readTransactionResponseFromNode(/** @type {Node} */ (source)); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readTransactionResponseFromDocument(doc); } else { return undefined; @@ -198,15 +199,15 @@ ol.format.WFS.prototype.readTransactionResponse = function(source) { * FeatureCollection metadata. * @api */ -ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) { - if (ol.xml.isDocument(source)) { +_ol_format_WFS_.prototype.readFeatureCollectionMetadata = function(source) { + if (_ol_xml_.isDocument(source)) { return this.readFeatureCollectionMetadataFromDocument( /** @type {Document} */ (source)); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readFeatureCollectionMetadataFromNode( /** @type {Node} */ (source)); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readFeatureCollectionMetadataFromDocument(doc); } else { return undefined; @@ -219,7 +220,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) { * @return {ol.WFSFeatureCollectionMetadata|undefined} * FeatureCollection metadata. */ -ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc) { +_ol_format_WFS_.prototype.readFeatureCollectionMetadataFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readFeatureCollectionMetadataFromNode(n); @@ -234,10 +235,10 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc * @type {Object.>} * @private */ -ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = { +_ol_format_WFS_.FEATURE_COLLECTION_PARSERS_ = { 'http://www.opengis.net/gml': { - 'boundedBy': ol.xml.makeObjectPropertySetter( - ol.format.GMLBase.prototype.readGeometryElement, 'bounds') + 'boundedBy': _ol_xml_.makeObjectPropertySetter( + _ol_format_GMLBase_.prototype.readGeometryElement, 'bounds') } }; @@ -247,14 +248,14 @@ ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = { * @return {ol.WFSFeatureCollectionMetadata|undefined} * FeatureCollection metadata. */ -ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) { +_ol_format_WFS_.prototype.readFeatureCollectionMetadataFromNode = function(node) { var result = {}; - var value = ol.format.XSD.readNonNegativeIntegerString( + var value = _ol_format_XSD_.readNonNegativeIntegerString( node.getAttribute('numberOfFeatures')); result['numberOfFeatures'] = value; - return ol.xml.pushParseAndPop( + return _ol_xml_.pushParseAndPop( /** @type {ol.WFSFeatureCollectionMetadata} */ (result), - ol.format.WFS.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_); + _ol_format_WFS_.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_); }; @@ -263,14 +264,14 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) { * @type {Object.>} * @private */ -ol.format.WFS.TRANSACTION_SUMMARY_PARSERS_ = { +_ol_format_WFS_.TRANSACTION_SUMMARY_PARSERS_ = { 'http://www.opengis.net/wfs': { - 'totalInserted': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'totalUpdated': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'totalDeleted': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger) + 'totalInserted': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'totalUpdated': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'totalDeleted': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger) } }; @@ -281,9 +282,9 @@ ol.format.WFS.TRANSACTION_SUMMARY_PARSERS_ = { * @return {Object|undefined} Transaction Summary. * @private */ -ol.format.WFS.readTransactionSummary_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WFS.TRANSACTION_SUMMARY_PARSERS_, node, objectStack); +_ol_format_WFS_.readTransactionSummary_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WFS_.TRANSACTION_SUMMARY_PARSERS_, node, objectStack); }; @@ -292,9 +293,9 @@ ol.format.WFS.readTransactionSummary_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.WFS.OGC_FID_PARSERS_ = { +_ol_format_WFS_.OGC_FID_PARSERS_ = { 'http://www.opengis.net/ogc': { - 'FeatureId': ol.xml.makeArrayPusher(function(node, objectStack) { + 'FeatureId': _ol_xml_.makeArrayPusher(function(node, objectStack) { return node.getAttribute('fid'); }) } @@ -306,8 +307,8 @@ ol.format.WFS.OGC_FID_PARSERS_ = { * @param {Array.<*>} objectStack Object stack. * @private */ -ol.format.WFS.fidParser_ = function(node, objectStack) { - ol.xml.parseNode(ol.format.WFS.OGC_FID_PARSERS_, node, objectStack); +_ol_format_WFS_.fidParser_ = function(node, objectStack) { + _ol_xml_.parseNode(_ol_format_WFS_.OGC_FID_PARSERS_, node, objectStack); }; @@ -316,9 +317,9 @@ ol.format.WFS.fidParser_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.WFS.INSERT_RESULTS_PARSERS_ = { +_ol_format_WFS_.INSERT_RESULTS_PARSERS_ = { 'http://www.opengis.net/wfs': { - 'Feature': ol.format.WFS.fidParser_ + 'Feature': _ol_format_WFS_.fidParser_ } }; @@ -329,9 +330,9 @@ ol.format.WFS.INSERT_RESULTS_PARSERS_ = { * @return {Array.|undefined} Insert results. * @private */ -ol.format.WFS.readInsertResults_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - [], ol.format.WFS.INSERT_RESULTS_PARSERS_, node, objectStack); +_ol_format_WFS_.readInsertResults_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + [], _ol_format_WFS_.INSERT_RESULTS_PARSERS_, node, objectStack); }; @@ -340,12 +341,12 @@ ol.format.WFS.readInsertResults_ = function(node, objectStack) { * @type {Object.>} * @private */ -ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = { +_ol_format_WFS_.TRANSACTION_RESPONSE_PARSERS_ = { 'http://www.opengis.net/wfs': { - 'TransactionSummary': ol.xml.makeObjectPropertySetter( - ol.format.WFS.readTransactionSummary_, 'transactionSummary'), - 'InsertResults': ol.xml.makeObjectPropertySetter( - ol.format.WFS.readInsertResults_, 'insertIds') + 'TransactionSummary': _ol_xml_.makeObjectPropertySetter( + _ol_format_WFS_.readTransactionSummary_, 'transactionSummary'), + 'InsertResults': _ol_xml_.makeObjectPropertySetter( + _ol_format_WFS_.readInsertResults_, 'insertIds') } }; @@ -354,7 +355,7 @@ ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = { * @param {Document} doc Document. * @return {ol.WFSTransactionResponse|undefined} Transaction response. */ -ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) { +_ol_format_WFS_.prototype.readTransactionResponseFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readTransactionResponseFromNode(n); @@ -368,10 +369,10 @@ ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) { * @param {Node} node Node. * @return {ol.WFSTransactionResponse|undefined} Transaction response. */ -ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) { - return ol.xml.pushParseAndPop( +_ol_format_WFS_.prototype.readTransactionResponseFromNode = function(node) { + return _ol_xml_.pushParseAndPop( /** @type {ol.WFSTransactionResponse} */({}), - ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_, node, []); + _ol_format_WFS_.TRANSACTION_RESPONSE_PARSERS_, node, []); }; @@ -379,9 +380,9 @@ ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) { * @type {Object.>} * @private */ -ol.format.WFS.QUERY_SERIALIZERS_ = { +_ol_format_WFS_.QUERY_SERIALIZERS_ = { 'http://www.opengis.net/wfs': { - 'PropertyName': ol.xml.makeChildAppender(ol.format.XSD.writeStringTextNode) + 'PropertyName': _ol_xml_.makeChildAppender(_ol_format_XSD_.writeStringTextNode) } }; @@ -392,17 +393,17 @@ ol.format.WFS.QUERY_SERIALIZERS_ = { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeFeature_ = function(node, feature, objectStack) { +_ol_format_WFS_.writeFeature_ = function(node, feature, objectStack) { var context = objectStack[objectStack.length - 1]; var featureType = context['featureType']; var featureNS = context['featureNS']; var gmlVersion = context['gmlVersion']; - var child = ol.xml.createElementNS(featureNS, featureType); + var child = _ol_xml_.createElementNS(featureNS, featureType); node.appendChild(child); if (gmlVersion === 2) { - ol.format.GML2.prototype.writeFeatureElement(child, feature, objectStack); + _ol_format_GML2_.prototype.writeFeatureElement(child, feature, objectStack); } else { - ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack); + _ol_format_GML3_.prototype.writeFeatureElement(child, feature, objectStack); } }; @@ -413,9 +414,9 @@ ol.format.WFS.writeFeature_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) { - var filter = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter'); - var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'FeatureId'); +_ol_format_WFS_.writeOgcFidFilter_ = function(node, fid, objectStack) { + var filter = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'Filter'); + var child = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'FeatureId'); filter.appendChild(child); child.setAttribute('fid', fid); node.appendChild(filter); @@ -428,9 +429,9 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) { * @returns {string} The value of the typeName property. * @private */ -ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) { +_ol_format_WFS_.getTypeName_ = function(featurePrefix, featureType) { featurePrefix = featurePrefix ? featurePrefix : - ol.format.WFS.FEATURE_PREFIX; + _ol_format_WFS_.FEATURE_PREFIX; var prefix = featurePrefix + ':'; // The featureType already contains the prefix. if (featureType.indexOf(prefix) === 0) { @@ -447,19 +448,19 @@ ol.format.WFS.getTypeName_ = function(featurePrefix, featureType) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeDelete_ = function(node, feature, objectStack) { +_ol_format_WFS_.writeDelete_ = function(node, feature, objectStack) { var context = objectStack[objectStack.length - 1]; - ol.asserts.assert(feature.getId() !== undefined, 26); // Features must have an id set + _ol_asserts_.assert(feature.getId() !== undefined, 26); // Features must have an id set var featureType = context['featureType']; var featurePrefix = context['featurePrefix']; var featureNS = context['featureNS']; - var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType); + var typeName = _ol_format_WFS_.getTypeName_(featurePrefix, featureType); node.setAttribute('typeName', typeName); - ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, + _ol_xml_.setAttributeNS(node, _ol_format_WFS_.XMLNS, 'xmlns:' + featurePrefix, featureNS); var fid = feature.getId(); if (fid !== undefined) { - ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack); + _ol_format_WFS_.writeOgcFidFilter_(node, fid, objectStack); } }; @@ -470,16 +471,16 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { +_ol_format_WFS_.writeUpdate_ = function(node, feature, objectStack) { var context = objectStack[objectStack.length - 1]; - ol.asserts.assert(feature.getId() !== undefined, 27); // Features must have an id set + _ol_asserts_.assert(feature.getId() !== undefined, 27); // Features must have an id set var featureType = context['featureType']; var featurePrefix = context['featurePrefix']; var featureNS = context['featureNS']; - var typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType); + var typeName = _ol_format_WFS_.getTypeName_(featurePrefix, featureType); var geometryName = feature.getGeometryName(); node.setAttribute('typeName', typeName); - ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, + _ol_xml_.setAttributeNS(node, _ol_format_WFS_.XMLNS, 'xmlns:' + featurePrefix, featureNS); var fid = feature.getId(); if (fid !== undefined) { @@ -489,19 +490,19 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { var value = feature.get(keys[i]); if (value !== undefined) { var name = keys[i]; - if (value instanceof ol.geom.Geometry) { + if (value instanceof _ol_geom_Geometry_) { name = geometryName; } values.push({name: name, value: value}); } } - ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ( + _ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ( {'gmlVersion': context['gmlVersion'], node: node, 'hasZ': context['hasZ'], 'srsName': context['srsName']}), - ol.format.WFS.TRANSACTION_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Property'), values, + _ol_format_WFS_.TRANSACTION_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Property'), values, objectStack); - ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack); + _ol_format_WFS_.writeOgcFidFilter_(node, fid, objectStack); } }; @@ -512,25 +513,25 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeProperty_ = function(node, pair, objectStack) { - var name = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Name'); +_ol_format_WFS_.writeProperty_ = function(node, pair, objectStack) { + var name = _ol_xml_.createElementNS(_ol_format_WFS_.WFSNS, 'Name'); var context = objectStack[objectStack.length - 1]; var gmlVersion = context['gmlVersion']; node.appendChild(name); - ol.format.XSD.writeStringTextNode(name, pair.name); + _ol_format_XSD_.writeStringTextNode(name, pair.name); if (pair.value !== undefined && pair.value !== null) { - var value = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Value'); + var value = _ol_xml_.createElementNS(_ol_format_WFS_.WFSNS, 'Value'); node.appendChild(value); - if (pair.value instanceof ol.geom.Geometry) { + if (pair.value instanceof _ol_geom_Geometry_) { if (gmlVersion === 2) { - ol.format.GML2.prototype.writeGeometryElement(value, + _ol_format_GML2_.prototype.writeGeometryElement(value, pair.value, objectStack); } else { - ol.format.GML3.prototype.writeGeometryElement(value, + _ol_format_GML3_.prototype.writeGeometryElement(value, pair.value, objectStack); } } else { - ol.format.XSD.writeStringTextNode(value, pair.value); + _ol_format_XSD_.writeStringTextNode(value, pair.value); } } }; @@ -543,7 +544,7 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { +_ol_format_WFS_.writeNative_ = function(node, nativeElement, objectStack) { if (nativeElement.vendorId) { node.setAttribute('vendorId', nativeElement.vendorId); } @@ -551,7 +552,7 @@ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); } if (nativeElement.value !== undefined) { - ol.format.XSD.writeStringTextNode(node, nativeElement.value); + _ol_format_XSD_.writeStringTextNode(node, nativeElement.value); } }; @@ -560,13 +561,13 @@ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { * @type {Object.>} * @private */ -ol.format.WFS.TRANSACTION_SERIALIZERS_ = { +_ol_format_WFS_.TRANSACTION_SERIALIZERS_ = { 'http://www.opengis.net/wfs': { - 'Insert': ol.xml.makeChildAppender(ol.format.WFS.writeFeature_), - 'Update': ol.xml.makeChildAppender(ol.format.WFS.writeUpdate_), - 'Delete': ol.xml.makeChildAppender(ol.format.WFS.writeDelete_), - 'Property': ol.xml.makeChildAppender(ol.format.WFS.writeProperty_), - 'Native': ol.xml.makeChildAppender(ol.format.WFS.writeNative_) + 'Insert': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeFeature_), + 'Update': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeUpdate_), + 'Delete': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeDelete_), + 'Property': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeProperty_), + 'Native': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeNative_) } }; @@ -577,7 +578,7 @@ ol.format.WFS.TRANSACTION_SERIALIZERS_ = { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { +_ol_format_WFS_.writeQuery_ = function(node, featureType, objectStack) { var context = /** @type {Object} */ (objectStack[objectStack.length - 1]); var featurePrefix = context['featurePrefix']; var featureNS = context['featureNS']; @@ -586,7 +587,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { var typeName; // If feature prefix is not defined, we must not use the default prefix. if (featurePrefix) { - typeName = ol.format.WFS.getTypeName_(featurePrefix, featureType); + typeName = _ol_format_WFS_.getTypeName_(featurePrefix, featureType); } else { typeName = featureType; } @@ -595,20 +596,20 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { node.setAttribute('srsName', srsName); } if (featureNS) { - ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, + _ol_xml_.setAttributeNS(node, _ol_format_WFS_.XMLNS, 'xmlns:' + featurePrefix, featureNS); } - var item = /** @type {ol.XmlNodeStackItem} */ (ol.obj.assign({}, context)); + var item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context)); item.node = node; - ol.xml.pushSerializeAndPop(item, - ol.format.WFS.QUERY_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames, + _ol_xml_.pushSerializeAndPop(item, + _ol_format_WFS_.QUERY_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('PropertyName'), propertyNames, objectStack); var filter = context['filter']; if (filter) { - var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter'); + var child = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'Filter'); node.appendChild(child); - ol.format.WFS.writeFilterCondition_(child, filter, objectStack); + _ol_format_WFS_.writeFilterCondition_(child, filter, objectStack); } }; @@ -619,12 +620,12 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeFilterCondition_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeFilterCondition_ = function(node, filter, objectStack) { /** @type {ol.XmlNodeStackItem} */ var item = {node: node}; - ol.xml.pushSerializeAndPop(item, - ol.format.WFS.GETFEATURE_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory(filter.getTagName()), + _ol_xml_.pushSerializeAndPop(item, + _ol_format_WFS_.GETFEATURE_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory(filter.getTagName()), [filter], objectStack); }; @@ -635,12 +636,12 @@ ol.format.WFS.writeFilterCondition_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeBboxFilter_ = function(node, filter, objectStack) { var context = objectStack[objectStack.length - 1]; context['srsName'] = filter.srsName; - ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName); - ol.format.GML3.prototype.writeGeometryElement(node, filter.extent, objectStack); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.geometryName); + _ol_format_GML3_.prototype.writeGeometryElement(node, filter.extent, objectStack); }; @@ -650,12 +651,12 @@ ol.format.WFS.writeBboxFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeContainsFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeContainsFilter_ = function(node, filter, objectStack) { var context = objectStack[objectStack.length - 1]; context['srsName'] = filter.srsName; - ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName); - ol.format.GML3.prototype.writeGeometryElement(node, filter.geometry, objectStack); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.geometryName); + _ol_format_GML3_.prototype.writeGeometryElement(node, filter.geometry, objectStack); }; @@ -665,12 +666,12 @@ ol.format.WFS.writeContainsFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeIntersectsFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeIntersectsFilter_ = function(node, filter, objectStack) { var context = objectStack[objectStack.length - 1]; context['srsName'] = filter.srsName; - ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName); - ol.format.GML3.prototype.writeGeometryElement(node, filter.geometry, objectStack); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.geometryName); + _ol_format_GML3_.prototype.writeGeometryElement(node, filter.geometry, objectStack); }; @@ -680,12 +681,12 @@ ol.format.WFS.writeIntersectsFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeWithinFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeWithinFilter_ = function(node, filter, objectStack) { var context = objectStack[objectStack.length - 1]; context['srsName'] = filter.srsName; - ol.format.WFS.writeOgcPropertyName_(node, filter.geometryName); - ol.format.GML3.prototype.writeGeometryElement(node, filter.geometry, objectStack); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.geometryName); + _ol_format_GML3_.prototype.writeGeometryElement(node, filter.geometry, objectStack); }; @@ -695,23 +696,23 @@ ol.format.WFS.writeWithinFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeDuringFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeDuringFilter_ = function(node, filter, objectStack) { - var valueReference = ol.xml.createElementNS(ol.format.WFS.FESNS, 'ValueReference'); - ol.format.XSD.writeStringTextNode(valueReference, filter.propertyName); + var valueReference = _ol_xml_.createElementNS(_ol_format_WFS_.FESNS, 'ValueReference'); + _ol_format_XSD_.writeStringTextNode(valueReference, filter.propertyName); node.appendChild(valueReference); - var timePeriod = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'TimePeriod'); + var timePeriod = _ol_xml_.createElementNS(_ol_format_GMLBase_.GMLNS, 'TimePeriod'); node.appendChild(timePeriod); - var begin = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'begin'); + var begin = _ol_xml_.createElementNS(_ol_format_GMLBase_.GMLNS, 'begin'); timePeriod.appendChild(begin); - ol.format.WFS.writeTimeInstant_(begin, filter.begin); + _ol_format_WFS_.writeTimeInstant_(begin, filter.begin); - var end = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'end'); + var end = _ol_xml_.createElementNS(_ol_format_GMLBase_.GMLNS, 'end'); timePeriod.appendChild(end); - ol.format.WFS.writeTimeInstant_(end, filter.end); + _ol_format_WFS_.writeTimeInstant_(end, filter.end); }; @@ -721,15 +722,15 @@ ol.format.WFS.writeDuringFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeLogicalFilter_ = function(node, filter, objectStack) { /** @type {ol.XmlNodeStackItem} */ var item = {node: node}; var conditions = filter.conditions; for (var i = 0, ii = conditions.length; i < ii; ++i) { var condition = conditions[i]; - ol.xml.pushSerializeAndPop(item, - ol.format.WFS.GETFEATURE_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory(condition.getTagName()), + _ol_xml_.pushSerializeAndPop(item, + _ol_format_WFS_.GETFEATURE_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory(condition.getTagName()), [condition], objectStack); } }; @@ -741,13 +742,13 @@ ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeNotFilter_ = function(node, filter, objectStack) { /** @type {ol.XmlNodeStackItem} */ var item = {node: node}; var condition = filter.condition; - ol.xml.pushSerializeAndPop(item, - ol.format.WFS.GETFEATURE_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory(condition.getTagName()), + _ol_xml_.pushSerializeAndPop(item, + _ol_format_WFS_.GETFEATURE_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory(condition.getTagName()), [condition], objectStack); }; @@ -758,12 +759,12 @@ ol.format.WFS.writeNotFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeComparisonFilter_ = function(node, filter, objectStack) { if (filter.matchCase !== undefined) { node.setAttribute('matchCase', filter.matchCase.toString()); } - ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName); - ol.format.WFS.writeOgcLiteral_(node, '' + filter.expression); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.propertyName); + _ol_format_WFS_.writeOgcLiteral_(node, '' + filter.expression); }; @@ -773,8 +774,8 @@ ol.format.WFS.writeComparisonFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeIsNullFilter_ = function(node, filter, objectStack) { - ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName); +_ol_format_WFS_.writeIsNullFilter_ = function(node, filter, objectStack) { + _ol_format_WFS_.writeOgcPropertyName_(node, filter.propertyName); }; @@ -784,16 +785,16 @@ ol.format.WFS.writeIsNullFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) { - ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName); +_ol_format_WFS_.writeIsBetweenFilter_ = function(node, filter, objectStack) { + _ol_format_WFS_.writeOgcPropertyName_(node, filter.propertyName); - var lowerBoundary = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'LowerBoundary'); + var lowerBoundary = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'LowerBoundary'); node.appendChild(lowerBoundary); - ol.format.WFS.writeOgcLiteral_(lowerBoundary, '' + filter.lowerBoundary); + _ol_format_WFS_.writeOgcLiteral_(lowerBoundary, '' + filter.lowerBoundary); - var upperBoundary = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'UpperBoundary'); + var upperBoundary = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'UpperBoundary'); node.appendChild(upperBoundary); - ol.format.WFS.writeOgcLiteral_(upperBoundary, '' + filter.upperBoundary); + _ol_format_WFS_.writeOgcLiteral_(upperBoundary, '' + filter.upperBoundary); }; @@ -803,15 +804,15 @@ ol.format.WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeIsLikeFilter_ = function(node, filter, objectStack) { +_ol_format_WFS_.writeIsLikeFilter_ = function(node, filter, objectStack) { node.setAttribute('wildCard', filter.wildCard); node.setAttribute('singleChar', filter.singleChar); node.setAttribute('escapeChar', filter.escapeChar); if (filter.matchCase !== undefined) { node.setAttribute('matchCase', filter.matchCase.toString()); } - ol.format.WFS.writeOgcPropertyName_(node, filter.propertyName); - ol.format.WFS.writeOgcLiteral_(node, '' + filter.pattern); + _ol_format_WFS_.writeOgcPropertyName_(node, filter.propertyName); + _ol_format_WFS_.writeOgcLiteral_(node, '' + filter.pattern); }; @@ -821,9 +822,9 @@ ol.format.WFS.writeIsLikeFilter_ = function(node, filter, objectStack) { * @param {string} value Value. * @private */ -ol.format.WFS.writeOgcExpression_ = function(tagName, node, value) { - var property = ol.xml.createElementNS(ol.format.WFS.OGCNS, tagName); - ol.format.XSD.writeStringTextNode(property, value); +_ol_format_WFS_.writeOgcExpression_ = function(tagName, node, value) { + var property = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, tagName); + _ol_format_XSD_.writeStringTextNode(property, value); node.appendChild(property); }; @@ -833,8 +834,8 @@ ol.format.WFS.writeOgcExpression_ = function(tagName, node, value) { * @param {string} value PropertyName value. * @private */ -ol.format.WFS.writeOgcPropertyName_ = function(node, value) { - ol.format.WFS.writeOgcExpression_('PropertyName', node, value); +_ol_format_WFS_.writeOgcPropertyName_ = function(node, value) { + _ol_format_WFS_.writeOgcExpression_('PropertyName', node, value); }; @@ -843,8 +844,8 @@ ol.format.WFS.writeOgcPropertyName_ = function(node, value) { * @param {string} value PropertyName value. * @private */ -ol.format.WFS.writeOgcLiteral_ = function(node, value) { - ol.format.WFS.writeOgcExpression_('Literal', node, value); +_ol_format_WFS_.writeOgcLiteral_ = function(node, value) { + _ol_format_WFS_.writeOgcExpression_('Literal', node, value); }; @@ -853,13 +854,13 @@ ol.format.WFS.writeOgcLiteral_ = function(node, value) { * @param {string} time PropertyName value. * @private */ -ol.format.WFS.writeTimeInstant_ = function(node, time) { - var timeInstant = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'TimeInstant'); +_ol_format_WFS_.writeTimeInstant_ = function(node, time) { + var timeInstant = _ol_xml_.createElementNS(_ol_format_GMLBase_.GMLNS, 'TimeInstant'); node.appendChild(timeInstant); - var timePosition = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'timePosition'); + var timePosition = _ol_xml_.createElementNS(_ol_format_GMLBase_.GMLNS, 'timePosition'); timeInstant.appendChild(timePosition); - ol.format.XSD.writeStringTextNode(timePosition, time); + _ol_format_XSD_.writeStringTextNode(timePosition, time); }; @@ -867,28 +868,28 @@ ol.format.WFS.writeTimeInstant_ = function(node, time) { * @type {Object.>} * @private */ -ol.format.WFS.GETFEATURE_SERIALIZERS_ = { +_ol_format_WFS_.GETFEATURE_SERIALIZERS_ = { 'http://www.opengis.net/wfs': { - 'Query': ol.xml.makeChildAppender(ol.format.WFS.writeQuery_) + 'Query': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeQuery_) }, 'http://www.opengis.net/ogc': { - 'During': ol.xml.makeChildAppender(ol.format.WFS.writeDuringFilter_), - 'And': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_), - 'Or': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_), - 'Not': ol.xml.makeChildAppender(ol.format.WFS.writeNotFilter_), - 'BBOX': ol.xml.makeChildAppender(ol.format.WFS.writeBboxFilter_), - 'Contains': ol.xml.makeChildAppender(ol.format.WFS.writeContainsFilter_), - 'Intersects': ol.xml.makeChildAppender(ol.format.WFS.writeIntersectsFilter_), - 'Within': ol.xml.makeChildAppender(ol.format.WFS.writeWithinFilter_), - 'PropertyIsEqualTo': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsNotEqualTo': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsLessThan': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsLessThanOrEqualTo': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsGreaterThan': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsGreaterThanOrEqualTo': ol.xml.makeChildAppender(ol.format.WFS.writeComparisonFilter_), - 'PropertyIsNull': ol.xml.makeChildAppender(ol.format.WFS.writeIsNullFilter_), - 'PropertyIsBetween': ol.xml.makeChildAppender(ol.format.WFS.writeIsBetweenFilter_), - 'PropertyIsLike': ol.xml.makeChildAppender(ol.format.WFS.writeIsLikeFilter_) + 'During': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeDuringFilter_), + 'And': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeLogicalFilter_), + 'Or': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeLogicalFilter_), + 'Not': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeNotFilter_), + 'BBOX': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeBboxFilter_), + 'Contains': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeContainsFilter_), + 'Intersects': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeIntersectsFilter_), + 'Within': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeWithinFilter_), + 'PropertyIsEqualTo': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsNotEqualTo': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsLessThan': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsLessThanOrEqualTo': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsGreaterThan': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsGreaterThanOrEqualTo': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeComparisonFilter_), + 'PropertyIsNull': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeIsNullFilter_), + 'PropertyIsBetween': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeIsBetweenFilter_), + 'PropertyIsLike': _ol_xml_.makeChildAppender(_ol_format_WFS_.writeIsLikeFilter_) } }; @@ -900,9 +901,9 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = { * @return {Node} Result. * @api */ -ol.format.WFS.writeFilter = function(filter) { - var child = ol.xml.createElementNS(ol.format.WFS.OGCNS, 'Filter'); - ol.format.WFS.writeFilterCondition_(child, filter, []); +_ol_format_WFS_.writeFilter = function(filter) { + var child = _ol_xml_.createElementNS(_ol_format_WFS_.OGCNS, 'Filter'); + _ol_format_WFS_.writeFilterCondition_(child, filter, []); return child; }; @@ -913,13 +914,13 @@ ol.format.WFS.writeFilter = function(filter) { * @param {Array.<*>} objectStack Node stack. * @private */ -ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) { +_ol_format_WFS_.writeGetFeature_ = function(node, featureTypes, objectStack) { var context = /** @type {Object} */ (objectStack[objectStack.length - 1]); - var item = /** @type {ol.XmlNodeStackItem} */ (ol.obj.assign({}, context)); + var item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context)); item.node = node; - ol.xml.pushSerializeAndPop(item, - ol.format.WFS.GETFEATURE_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Query'), featureTypes, + _ol_xml_.pushSerializeAndPop(item, + _ol_format_WFS_.GETFEATURE_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Query'), featureTypes, objectStack); }; @@ -931,8 +932,8 @@ ol.format.WFS.writeGetFeature_ = function(node, featureTypes, objectStack) { * @return {Node} Result. * @api */ -ol.format.WFS.prototype.writeGetFeature = function(options) { - var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'GetFeature'); +_ol_format_WFS_.prototype.writeGetFeature = function(options) { + var node = _ol_xml_.createElementNS(_ol_format_WFS_.WFSNS, 'GetFeature'); node.setAttribute('service', 'WFS'); node.setAttribute('version', '1.1.0'); var filter; @@ -957,19 +958,19 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { } filter = options.filter; if (options.bbox) { - ol.asserts.assert(options.geometryName, + _ol_asserts_.assert(options.geometryName, 12); // `options.geometryName` must also be provided when `options.bbox` is set - var bbox = ol.format.filter.bbox( + var bbox = _ol_format_filter_.bbox( /** @type {string} */ (options.geometryName), options.bbox, options.srsName); if (filter) { // if bbox and filter are both set, combine the two into a single filter - filter = ol.format.filter.and(filter, bbox); + filter = _ol_format_filter_.and(filter, bbox); } else { filter = bbox; } } } - ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', + _ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', this.schemaLocation_); /** @type {ol.XmlNodeStackItem} */ var context = { @@ -981,9 +982,9 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { 'filter': filter, 'propertyNames': options.propertyNames ? options.propertyNames : [] }; - ol.asserts.assert(Array.isArray(options.featureTypes), + _ol_asserts_.assert(Array.isArray(options.featureTypes), 11); // `options.featureTypes` should be an Array - ol.format.WFS.writeGetFeature_(node, /** @type {!Array.} */ (options.featureTypes), [context]); + _ol_format_WFS_.writeGetFeature_(node, /** @type {!Array.} */ (options.featureTypes), [context]); return node; }; @@ -998,12 +999,12 @@ ol.format.WFS.prototype.writeGetFeature = function(options) { * @return {Node} Result. * @api */ -ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, +_ol_format_WFS_.prototype.writeTransaction = function(inserts, updates, deletes, options) { var objectStack = []; - var node = ol.xml.createElementNS(ol.format.WFS.WFSNS, 'Transaction'); + var node = _ol_xml_.createElementNS(_ol_format_WFS_.WFSNS, 'Transaction'); var version = options.version ? - options.version : ol.format.WFS.DEFAULT_VERSION; + options.version : _ol_format_WFS_.DEFAULT_VERSION; var gmlVersion = version === '1.0.0' ? 2 : 3; node.setAttribute('service', 'WFS'); node.setAttribute('version', version); @@ -1016,44 +1017,44 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, node.setAttribute('handle', options.handle); } } - var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version]; - ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', + var schemaLocation = _ol_format_WFS_.SCHEMA_LOCATIONS[version]; + _ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', schemaLocation); - var featurePrefix = options.featurePrefix ? options.featurePrefix : ol.format.WFS.FEATURE_PREFIX; + var featurePrefix = options.featurePrefix ? options.featurePrefix : _ol_format_WFS_.FEATURE_PREFIX; if (inserts) { obj = {node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': featurePrefix, 'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName}; - ol.obj.assign(obj, baseObj); - ol.xml.pushSerializeAndPop(obj, - ol.format.WFS.TRANSACTION_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Insert'), inserts, + _ol_obj_.assign(obj, baseObj); + _ol_xml_.pushSerializeAndPop(obj, + _ol_format_WFS_.TRANSACTION_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Insert'), inserts, objectStack); } if (updates) { obj = {node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': featurePrefix, 'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName}; - ol.obj.assign(obj, baseObj); - ol.xml.pushSerializeAndPop(obj, - ol.format.WFS.TRANSACTION_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Update'), updates, + _ol_obj_.assign(obj, baseObj); + _ol_xml_.pushSerializeAndPop(obj, + _ol_format_WFS_.TRANSACTION_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Update'), updates, objectStack); } if (deletes) { - ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS, + _ol_xml_.pushSerializeAndPop({node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': featurePrefix, 'gmlVersion': gmlVersion, 'srsName': options.srsName}, - ol.format.WFS.TRANSACTION_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Delete'), deletes, + _ol_format_WFS_.TRANSACTION_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Delete'), deletes, objectStack); } if (options.nativeElements) { - ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS, + _ol_xml_.pushSerializeAndPop({node: node, 'featureNS': options.featureNS, 'featureType': options.featureType, 'featurePrefix': featurePrefix, 'gmlVersion': gmlVersion, 'srsName': options.srsName}, - ol.format.WFS.TRANSACTION_SERIALIZERS_, - ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements, + _ol_format_WFS_.TRANSACTION_SERIALIZERS_, + _ol_xml_.makeSimpleNodeFactory('Native'), options.nativeElements, objectStack); } return node; @@ -1068,13 +1069,13 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, * @return {?ol.proj.Projection} Projection. * @api */ -ol.format.WFS.prototype.readProjection; +_ol_format_WFS_.prototype.readProjection; /** * @inheritDoc */ -ol.format.WFS.prototype.readProjectionFromDocument = function(doc) { +_ol_format_WFS_.prototype.readProjectionFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readProjectionFromNode(n); @@ -1087,7 +1088,7 @@ ol.format.WFS.prototype.readProjectionFromDocument = function(doc) { /** * @inheritDoc */ -ol.format.WFS.prototype.readProjectionFromNode = function(node) { +_ol_format_WFS_.prototype.readProjectionFromNode = function(node) { if (node.firstElementChild && node.firstElementChild.firstElementChild) { node = node.firstElementChild.firstElementChild; @@ -1097,10 +1098,11 @@ ol.format.WFS.prototype.readProjectionFromNode = function(node) { n.firstChild.nodeType === 3))) { var objectStack = [{}]; this.gmlFormat_.readGeometryElement(n, objectStack); - return ol.proj.get(objectStack.pop().srsName); + return _ol_proj_.get(objectStack.pop().srsName); } } } return null; }; +export default _ol_format_WFS_; diff --git a/src/ol/format/WKT.js b/src/ol/format/WKT.js index dd625c15dd..e21ab6477c 100644 --- a/src/ol/format/WKT.js +++ b/src/ol/format/WKT.js @@ -1,20 +1,20 @@ -goog.provide('ol.format.WKT'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.format.Feature'); -goog.require('ol.format.TextFeature'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.SimpleGeometry'); - +/** + * @module ol/format/WKT + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_TextFeature_ from '../format/TextFeature.js'; +import _ol_geom_GeometryCollection_ from '../geom/GeometryCollection.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; /** * @classdesc @@ -26,11 +26,11 @@ goog.require('ol.geom.SimpleGeometry'); * @param {olx.format.WKTOptions=} opt_options Options. * @api */ -ol.format.WKT = function(opt_options) { +var _ol_format_WKT_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.format.TextFeature.call(this); + _ol_format_TextFeature_.call(this); /** * Split GeometryCollection into multiple features. @@ -41,35 +41,36 @@ ol.format.WKT = function(opt_options) { options.splitCollection : false; }; -ol.inherits(ol.format.WKT, ol.format.TextFeature); + +_ol_.inherits(_ol_format_WKT_, _ol_format_TextFeature_); /** * @const * @type {string} */ -ol.format.WKT.EMPTY = 'EMPTY'; +_ol_format_WKT_.EMPTY = 'EMPTY'; /** * @const * @type {string} */ -ol.format.WKT.Z = 'Z'; +_ol_format_WKT_.Z = 'Z'; /** * @const * @type {string} */ -ol.format.WKT.M = 'M'; +_ol_format_WKT_.M = 'M'; /** * @const * @type {string} */ -ol.format.WKT.ZM = 'ZM'; +_ol_format_WKT_.ZM = 'ZM'; /** @@ -77,7 +78,7 @@ ol.format.WKT.ZM = 'ZM'; * @return {string} Coordinates part of Point as WKT. * @private */ -ol.format.WKT.encodePointGeometry_ = function(geom) { +_ol_format_WKT_.encodePointGeometry_ = function(geom) { var coordinates = geom.getCoordinates(); if (coordinates.length === 0) { return ''; @@ -91,11 +92,11 @@ ol.format.WKT.encodePointGeometry_ = function(geom) { * @return {string} Coordinates part of MultiPoint as WKT. * @private */ -ol.format.WKT.encodeMultiPointGeometry_ = function(geom) { +_ol_format_WKT_.encodeMultiPointGeometry_ = function(geom) { var array = []; var components = geom.getPoints(); for (var i = 0, ii = components.length; i < ii; ++i) { - array.push('(' + ol.format.WKT.encodePointGeometry_(components[i]) + ')'); + array.push('(' + _ol_format_WKT_.encodePointGeometry_(components[i]) + ')'); } return array.join(','); }; @@ -106,11 +107,11 @@ ol.format.WKT.encodeMultiPointGeometry_ = function(geom) { * @return {string} Coordinates part of GeometryCollection as WKT. * @private */ -ol.format.WKT.encodeGeometryCollectionGeometry_ = function(geom) { +_ol_format_WKT_.encodeGeometryCollectionGeometry_ = function(geom) { var array = []; var geoms = geom.getGeometries(); for (var i = 0, ii = geoms.length; i < ii; ++i) { - array.push(ol.format.WKT.encode_(geoms[i])); + array.push(_ol_format_WKT_.encode_(geoms[i])); } return array.join(','); }; @@ -121,7 +122,7 @@ ol.format.WKT.encodeGeometryCollectionGeometry_ = function(geom) { * @return {string} Coordinates part of LineString as WKT. * @private */ -ol.format.WKT.encodeLineStringGeometry_ = function(geom) { +_ol_format_WKT_.encodeLineStringGeometry_ = function(geom) { var coordinates = geom.getCoordinates(); var array = []; for (var i = 0, ii = coordinates.length; i < ii; ++i) { @@ -136,11 +137,11 @@ ol.format.WKT.encodeLineStringGeometry_ = function(geom) { * @return {string} Coordinates part of MultiLineString as WKT. * @private */ -ol.format.WKT.encodeMultiLineStringGeometry_ = function(geom) { +_ol_format_WKT_.encodeMultiLineStringGeometry_ = function(geom) { var array = []; var components = geom.getLineStrings(); for (var i = 0, ii = components.length; i < ii; ++i) { - array.push('(' + ol.format.WKT.encodeLineStringGeometry_( + array.push('(' + _ol_format_WKT_.encodeLineStringGeometry_( components[i]) + ')'); } return array.join(','); @@ -152,11 +153,11 @@ ol.format.WKT.encodeMultiLineStringGeometry_ = function(geom) { * @return {string} Coordinates part of Polygon as WKT. * @private */ -ol.format.WKT.encodePolygonGeometry_ = function(geom) { +_ol_format_WKT_.encodePolygonGeometry_ = function(geom) { var array = []; var rings = geom.getLinearRings(); for (var i = 0, ii = rings.length; i < ii; ++i) { - array.push('(' + ol.format.WKT.encodeLineStringGeometry_( + array.push('(' + _ol_format_WKT_.encodeLineStringGeometry_( rings[i]) + ')'); } return array.join(','); @@ -168,11 +169,11 @@ ol.format.WKT.encodePolygonGeometry_ = function(geom) { * @return {string} Coordinates part of MultiPolygon as WKT. * @private */ -ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) { +_ol_format_WKT_.encodeMultiPolygonGeometry_ = function(geom) { var array = []; var components = geom.getPolygons(); for (var i = 0, ii = components.length; i < ii; ++i) { - array.push('(' + ol.format.WKT.encodePolygonGeometry_( + array.push('(' + _ol_format_WKT_.encodePolygonGeometry_( components[i]) + ')'); } return array.join(','); @@ -183,14 +184,14 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) { * @return {string} Potential dimensional information for WKT type. * @private */ -ol.format.WKT.encodeGeometryLayout_ = function(geom) { +_ol_format_WKT_.encodeGeometryLayout_ = function(geom) { var layout = geom.getLayout(); var dimInfo = ''; - if (layout === ol.geom.GeometryLayout.XYZ || layout === ol.geom.GeometryLayout.XYZM) { - dimInfo += ol.format.WKT.Z; + if (layout === _ol_geom_GeometryLayout_.XYZ || layout === _ol_geom_GeometryLayout_.XYZM) { + dimInfo += _ol_format_WKT_.Z; } - if (layout === ol.geom.GeometryLayout.XYM || layout === ol.geom.GeometryLayout.XYZM) { - dimInfo += ol.format.WKT.M; + if (layout === _ol_geom_GeometryLayout_.XYM || layout === _ol_geom_GeometryLayout_.XYZM) { + dimInfo += _ol_format_WKT_.M; } return dimInfo; }; @@ -202,19 +203,19 @@ ol.format.WKT.encodeGeometryLayout_ = function(geom) { * @return {string} WKT string for the geometry. * @private */ -ol.format.WKT.encode_ = function(geom) { +_ol_format_WKT_.encode_ = function(geom) { var type = geom.getType(); - var geometryEncoder = ol.format.WKT.GeometryEncoder_[type]; + var geometryEncoder = _ol_format_WKT_.GeometryEncoder_[type]; var enc = geometryEncoder(geom); type = type.toUpperCase(); - if (geom instanceof ol.geom.SimpleGeometry) { - var dimInfo = ol.format.WKT.encodeGeometryLayout_(geom); + if (geom instanceof _ol_geom_SimpleGeometry_) { + var dimInfo = _ol_format_WKT_.encodeGeometryLayout_(geom); if (dimInfo.length > 0) { type += ' ' + dimInfo; } } if (enc.length === 0) { - return type + ' ' + ol.format.WKT.EMPTY; + return type + ' ' + _ol_format_WKT_.EMPTY; } return type + '(' + enc + ')'; }; @@ -225,14 +226,14 @@ ol.format.WKT.encode_ = function(geom) { * @type {Object.} * @private */ -ol.format.WKT.GeometryEncoder_ = { - 'Point': ol.format.WKT.encodePointGeometry_, - 'LineString': ol.format.WKT.encodeLineStringGeometry_, - 'Polygon': ol.format.WKT.encodePolygonGeometry_, - 'MultiPoint': ol.format.WKT.encodeMultiPointGeometry_, - 'MultiLineString': ol.format.WKT.encodeMultiLineStringGeometry_, - 'MultiPolygon': ol.format.WKT.encodeMultiPolygonGeometry_, - 'GeometryCollection': ol.format.WKT.encodeGeometryCollectionGeometry_ +_ol_format_WKT_.GeometryEncoder_ = { + 'Point': _ol_format_WKT_.encodePointGeometry_, + 'LineString': _ol_format_WKT_.encodeLineStringGeometry_, + 'Polygon': _ol_format_WKT_.encodePolygonGeometry_, + 'MultiPoint': _ol_format_WKT_.encodeMultiPointGeometry_, + 'MultiLineString': _ol_format_WKT_.encodeMultiLineStringGeometry_, + 'MultiPolygon': _ol_format_WKT_.encodeMultiPolygonGeometry_, + 'GeometryCollection': _ol_format_WKT_.encodeGeometryCollectionGeometry_ }; @@ -243,9 +244,9 @@ ol.format.WKT.GeometryEncoder_ = { * The geometry created. * @private */ -ol.format.WKT.prototype.parse_ = function(wkt) { - var lexer = new ol.format.WKT.Lexer(wkt); - var parser = new ol.format.WKT.Parser(lexer); +_ol_format_WKT_.prototype.parse_ = function(wkt) { + var lexer = new _ol_format_WKT_.Lexer(wkt); + var parser = new _ol_format_WKT_.Parser(lexer); return parser.parse(); }; @@ -259,16 +260,16 @@ ol.format.WKT.prototype.parse_ = function(wkt) { * @return {ol.Feature} Feature. * @api */ -ol.format.WKT.prototype.readFeature; +_ol_format_WKT_.prototype.readFeature; /** * @inheritDoc */ -ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) { +_ol_format_WKT_.prototype.readFeatureFromText = function(text, opt_options) { var geom = this.readGeometryFromText(text, opt_options); if (geom) { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(geom); return feature; } @@ -285,17 +286,17 @@ ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) { * @return {Array.} Features. * @api */ -ol.format.WKT.prototype.readFeatures; +_ol_format_WKT_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.WKT.prototype.readFeaturesFromText = function(text, opt_options) { +_ol_format_WKT_.prototype.readFeaturesFromText = function(text, opt_options) { var geometries = []; var geometry = this.readGeometryFromText(text, opt_options); if (this.splitCollection_ && - geometry.getType() == ol.geom.GeometryType.GEOMETRY_COLLECTION) { + geometry.getType() == _ol_geom_GeometryType_.GEOMETRY_COLLECTION) { geometries = (/** @type {ol.geom.GeometryCollection} */ (geometry)) .getGeometriesArray(); } else { @@ -303,7 +304,7 @@ ol.format.WKT.prototype.readFeaturesFromText = function(text, opt_options) { } var feature, features = []; for (var i = 0, ii = geometries.length; i < ii; ++i) { - feature = new ol.Feature(); + feature = new _ol_Feature_(); feature.setGeometry(geometries[i]); features.push(feature); } @@ -320,17 +321,18 @@ ol.format.WKT.prototype.readFeaturesFromText = function(text, opt_options) { * @return {ol.geom.Geometry} Geometry. * @api */ -ol.format.WKT.prototype.readGeometry; +_ol_format_WKT_.prototype.readGeometry; /** * @inheritDoc */ -ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) { +_ol_format_WKT_.prototype.readGeometryFromText = function(text, opt_options) { var geometry = this.parse_(text); if (geometry) { - return /** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions(geometry, false, opt_options)); + return ( + /** @type {ol.geom.Geometry} */ _ol_format_Feature_.transformWithOptions(geometry, false, opt_options) + ); } else { return null; } @@ -346,13 +348,13 @@ ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) { * @return {string} WKT string. * @api */ -ol.format.WKT.prototype.writeFeature; +_ol_format_WKT_.prototype.writeFeature; /** * @inheritDoc */ -ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) { +_ol_format_WKT_.prototype.writeFeatureText = function(feature, opt_options) { var geometry = feature.getGeometry(); if (geometry) { return this.writeGeometryText(geometry, opt_options); @@ -370,13 +372,13 @@ ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) { * @return {string} WKT string. * @api */ -ol.format.WKT.prototype.writeFeatures; +_ol_format_WKT_.prototype.writeFeatures; /** * @inheritDoc */ -ol.format.WKT.prototype.writeFeaturesText = function(features, opt_options) { +_ol_format_WKT_.prototype.writeFeaturesText = function(features, opt_options) { if (features.length == 1) { return this.writeFeatureText(features[0], opt_options); } @@ -384,7 +386,7 @@ ol.format.WKT.prototype.writeFeaturesText = function(features, opt_options) { for (var i = 0, ii = features.length; i < ii; ++i) { geometries.push(features[i].getGeometry()); } - var collection = new ol.geom.GeometryCollection(geometries); + var collection = new _ol_geom_GeometryCollection_(geometries); return this.writeGeometryText(collection, opt_options); }; @@ -398,15 +400,15 @@ ol.format.WKT.prototype.writeFeaturesText = function(features, opt_options) { * @return {string} WKT string. * @api */ -ol.format.WKT.prototype.writeGeometry; +_ol_format_WKT_.prototype.writeGeometry; /** * @inheritDoc */ -ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) { - return ol.format.WKT.encode_(/** @type {ol.geom.Geometry} */ ( - ol.format.Feature.transformWithOptions(geometry, true, opt_options))); +_ol_format_WKT_.prototype.writeGeometryText = function(geometry, opt_options) { + return _ol_format_WKT_.encode_(/** @type {ol.geom.Geometry} */ ( + _ol_format_Feature_.transformWithOptions(geometry, true, opt_options))); }; @@ -415,7 +417,7 @@ ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) { * @enum {number} * @private */ -ol.format.WKT.TokenType_ = { +_ol_format_WKT_.TokenType_ = { TEXT: 1, LEFT_PAREN: 2, RIGHT_PAREN: 3, @@ -431,7 +433,7 @@ ol.format.WKT.TokenType_ = { * @constructor * @protected */ -ol.format.WKT.Lexer = function(wkt) { +_ol_format_WKT_.Lexer = function(wkt) { /** * @type {string} @@ -451,7 +453,7 @@ ol.format.WKT.Lexer = function(wkt) { * @return {boolean} Whether the character is alphabetic. * @private */ -ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) { +_ol_format_WKT_.Lexer.prototype.isAlpha_ = function(c) { return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'; }; @@ -463,7 +465,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) { * @return {boolean} Whether the character is numeric. * @private */ -ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { +_ol_format_WKT_.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { var decimal = opt_decimal !== undefined ? opt_decimal : false; return c >= '0' && c <= '9' || c == '.' && !decimal; }; @@ -474,7 +476,7 @@ ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { * @return {boolean} Whether the character is whitespace. * @private */ -ol.format.WKT.Lexer.prototype.isWhiteSpace_ = function(c) { +_ol_format_WKT_.Lexer.prototype.isWhiteSpace_ = function(c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; }; @@ -483,7 +485,7 @@ ol.format.WKT.Lexer.prototype.isWhiteSpace_ = function(c) { * @return {string} Next string character. * @private */ -ol.format.WKT.Lexer.prototype.nextChar_ = function() { +_ol_format_WKT_.Lexer.prototype.nextChar_ = function() { return this.wkt.charAt(++this.index_); }; @@ -492,26 +494,26 @@ ol.format.WKT.Lexer.prototype.nextChar_ = function() { * Fetch and return the next token. * @return {!ol.WKTToken} Next string token. */ -ol.format.WKT.Lexer.prototype.nextToken = function() { +_ol_format_WKT_.Lexer.prototype.nextToken = function() { var c = this.nextChar_(); var token = {position: this.index_, value: c}; if (c == '(') { - token.type = ol.format.WKT.TokenType_.LEFT_PAREN; + token.type = _ol_format_WKT_.TokenType_.LEFT_PAREN; } else if (c == ',') { - token.type = ol.format.WKT.TokenType_.COMMA; + token.type = _ol_format_WKT_.TokenType_.COMMA; } else if (c == ')') { - token.type = ol.format.WKT.TokenType_.RIGHT_PAREN; + token.type = _ol_format_WKT_.TokenType_.RIGHT_PAREN; } else if (this.isNumeric_(c) || c == '-') { - token.type = ol.format.WKT.TokenType_.NUMBER; + token.type = _ol_format_WKT_.TokenType_.NUMBER; token.value = this.readNumber_(); } else if (this.isAlpha_(c)) { - token.type = ol.format.WKT.TokenType_.TEXT; + token.type = _ol_format_WKT_.TokenType_.TEXT; token.value = this.readText_(); } else if (this.isWhiteSpace_(c)) { return this.nextToken(); } else if (c === '') { - token.type = ol.format.WKT.TokenType_.EOF; + token.type = _ol_format_WKT_.TokenType_.EOF; } else { throw new Error('Unexpected character: ' + c); } @@ -524,7 +526,7 @@ ol.format.WKT.Lexer.prototype.nextToken = function() { * @return {number} Numeric token value. * @private */ -ol.format.WKT.Lexer.prototype.readNumber_ = function() { +_ol_format_WKT_.Lexer.prototype.readNumber_ = function() { var c, index = this.index_; var decimal = false; var scientificNotation = false; @@ -552,7 +554,7 @@ ol.format.WKT.Lexer.prototype.readNumber_ = function() { * @return {string} String token value. * @private */ -ol.format.WKT.Lexer.prototype.readText_ = function() { +_ol_format_WKT_.Lexer.prototype.readText_ = function() { var c, index = this.index_; do { c = this.nextChar_(); @@ -567,7 +569,7 @@ ol.format.WKT.Lexer.prototype.readText_ = function() { * @constructor * @protected */ -ol.format.WKT.Parser = function(lexer) { +_ol_format_WKT_.Parser = function(lexer) { /** * @type {ol.format.WKT.Lexer} @@ -585,7 +587,7 @@ ol.format.WKT.Parser = function(lexer) { * @type {ol.geom.GeometryLayout} * @private */ - this.layout_ = ol.geom.GeometryLayout.XY; + this.layout_ = _ol_geom_GeometryLayout_.XY; }; @@ -593,7 +595,7 @@ ol.format.WKT.Parser = function(lexer) { * Fetch the next token form the lexer and replace the active token. * @private */ -ol.format.WKT.Parser.prototype.consume_ = function() { +_ol_format_WKT_.Parser.prototype.consume_ = function() { this.token_ = this.lexer_.nextToken(); }; @@ -602,7 +604,7 @@ ol.format.WKT.Parser.prototype.consume_ = function() { * @param {ol.format.WKT.TokenType_} type Token type. * @return {boolean} Whether the token matches the given type. */ -ol.format.WKT.Parser.prototype.isTokenType = function(type) { +_ol_format_WKT_.Parser.prototype.isTokenType = function(type) { var isMatch = this.token_.type == type; return isMatch; }; @@ -613,7 +615,7 @@ ol.format.WKT.Parser.prototype.isTokenType = function(type) { * @param {ol.format.WKT.TokenType_} type Token type. * @return {boolean} Whether the token matches the given type. */ -ol.format.WKT.Parser.prototype.match = function(type) { +_ol_format_WKT_.Parser.prototype.match = function(type) { var isMatch = this.isTokenType(type); if (isMatch) { this.consume_(); @@ -626,7 +628,7 @@ ol.format.WKT.Parser.prototype.match = function(type) { * Try to parse the tokens provided by the lexer. * @return {ol.geom.Geometry} The geometry. */ -ol.format.WKT.Parser.prototype.parse = function() { +_ol_format_WKT_.Parser.prototype.parse = function() { this.consume_(); var geometry = this.parseGeometry_(); return geometry; @@ -638,19 +640,19 @@ ol.format.WKT.Parser.prototype.parse = function() { * @return {ol.geom.GeometryLayout} The layout. * @private */ -ol.format.WKT.Parser.prototype.parseGeometryLayout_ = function() { - var layout = ol.geom.GeometryLayout.XY; +_ol_format_WKT_.Parser.prototype.parseGeometryLayout_ = function() { + var layout = _ol_geom_GeometryLayout_.XY; var dimToken = this.token_; - if (this.isTokenType(ol.format.WKT.TokenType_.TEXT)) { + if (this.isTokenType(_ol_format_WKT_.TokenType_.TEXT)) { var dimInfo = dimToken.value; - if (dimInfo === ol.format.WKT.Z) { - layout = ol.geom.GeometryLayout.XYZ; - } else if (dimInfo === ol.format.WKT.M) { - layout = ol.geom.GeometryLayout.XYM; - } else if (dimInfo === ol.format.WKT.ZM) { - layout = ol.geom.GeometryLayout.XYZM; + if (dimInfo === _ol_format_WKT_.Z) { + layout = _ol_geom_GeometryLayout_.XYZ; + } else if (dimInfo === _ol_format_WKT_.M) { + layout = _ol_geom_GeometryLayout_.XYM; + } else if (dimInfo === _ol_format_WKT_.ZM) { + layout = _ol_geom_GeometryLayout_.XYZM; } - if (layout !== ol.geom.GeometryLayout.XY) { + if (layout !== _ol_geom_GeometryLayout_.XY) { this.consume_(); } } @@ -662,17 +664,17 @@ ol.format.WKT.Parser.prototype.parseGeometryLayout_ = function() { * @return {!ol.geom.Geometry} The geometry. * @private */ -ol.format.WKT.Parser.prototype.parseGeometry_ = function() { +_ol_format_WKT_.Parser.prototype.parseGeometry_ = function() { var token = this.token_; - if (this.match(ol.format.WKT.TokenType_.TEXT)) { + if (this.match(_ol_format_WKT_.TokenType_.TEXT)) { var geomType = token.value; this.layout_ = this.parseGeometryLayout_(); - if (geomType == ol.geom.GeometryType.GEOMETRY_COLLECTION.toUpperCase()) { + if (geomType == _ol_geom_GeometryType_.GEOMETRY_COLLECTION.toUpperCase()) { var geometries = this.parseGeometryCollectionText_(); - return new ol.geom.GeometryCollection(geometries); + return new _ol_geom_GeometryCollection_(geometries); } else { - var parser = ol.format.WKT.Parser.GeometryParser_[geomType]; - var ctor = ol.format.WKT.Parser.GeometryConstructor_[geomType]; + var parser = _ol_format_WKT_.Parser.GeometryParser_[geomType]; + var ctor = _ol_format_WKT_.Parser.GeometryConstructor_[geomType]; if (!parser || !ctor) { throw new Error('Invalid geometry type: ' + geomType); } @@ -688,13 +690,13 @@ ol.format.WKT.Parser.prototype.parseGeometry_ = function() { * @return {!Array.} A collection of geometries. * @private */ -ol.format.WKT.Parser.prototype.parseGeometryCollectionText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parseGeometryCollectionText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var geometries = []; do { geometries.push(this.parseGeometry_()); - } while (this.match(ol.format.WKT.TokenType_.COMMA)); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + } while (this.match(_ol_format_WKT_.TokenType_.COMMA)); + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return geometries; } } else if (this.isEmptyGeometry_()) { @@ -708,10 +710,10 @@ ol.format.WKT.Parser.prototype.parseGeometryCollectionText_ = function() { * @return {Array.} All values in a point. * @private */ -ol.format.WKT.Parser.prototype.parsePointText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parsePointText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates = this.parsePoint_(); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -725,10 +727,10 @@ ol.format.WKT.Parser.prototype.parsePointText_ = function() { * @return {!Array.>} All points in a linestring. * @private */ -ol.format.WKT.Parser.prototype.parseLineStringText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parseLineStringText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates = this.parsePointList_(); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -742,10 +744,10 @@ ol.format.WKT.Parser.prototype.parseLineStringText_ = function() { * @return {!Array.>} All points in a polygon. * @private */ -ol.format.WKT.Parser.prototype.parsePolygonText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parsePolygonText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates = this.parseLineStringTextList_(); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -759,15 +761,15 @@ ol.format.WKT.Parser.prototype.parsePolygonText_ = function() { * @return {!Array.>} All points in a multipoint. * @private */ -ol.format.WKT.Parser.prototype.parseMultiPointText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parseMultiPointText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates; - if (this.token_.type == ol.format.WKT.TokenType_.LEFT_PAREN) { + if (this.token_.type == _ol_format_WKT_.TokenType_.LEFT_PAREN) { coordinates = this.parsePointTextList_(); } else { coordinates = this.parsePointList_(); } - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -782,10 +784,10 @@ ol.format.WKT.Parser.prototype.parseMultiPointText_ = function() { * in a multilinestring. * @private */ -ol.format.WKT.Parser.prototype.parseMultiLineStringText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parseMultiLineStringText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates = this.parseLineStringTextList_(); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -799,10 +801,10 @@ ol.format.WKT.Parser.prototype.parseMultiLineStringText_ = function() { * @return {!Array.>} All polygon points in a multipolygon. * @private */ -ol.format.WKT.Parser.prototype.parseMultiPolygonText_ = function() { - if (this.match(ol.format.WKT.TokenType_.LEFT_PAREN)) { +_ol_format_WKT_.Parser.prototype.parseMultiPolygonText_ = function() { + if (this.match(_ol_format_WKT_.TokenType_.LEFT_PAREN)) { var coordinates = this.parsePolygonTextList_(); - if (this.match(ol.format.WKT.TokenType_.RIGHT_PAREN)) { + if (this.match(_ol_format_WKT_.TokenType_.RIGHT_PAREN)) { return coordinates; } } else if (this.isEmptyGeometry_()) { @@ -816,12 +818,12 @@ ol.format.WKT.Parser.prototype.parseMultiPolygonText_ = function() { * @return {!Array.} A point. * @private */ -ol.format.WKT.Parser.prototype.parsePoint_ = function() { +_ol_format_WKT_.Parser.prototype.parsePoint_ = function() { var coordinates = []; var dimensions = this.layout_.length; for (var i = 0; i < dimensions; ++i) { var token = this.token_; - if (this.match(ol.format.WKT.TokenType_.NUMBER)) { + if (this.match(_ol_format_WKT_.TokenType_.NUMBER)) { coordinates.push(token.value); } else { break; @@ -838,9 +840,9 @@ ol.format.WKT.Parser.prototype.parsePoint_ = function() { * @return {!Array.>} An array of points. * @private */ -ol.format.WKT.Parser.prototype.parsePointList_ = function() { +_ol_format_WKT_.Parser.prototype.parsePointList_ = function() { var coordinates = [this.parsePoint_()]; - while (this.match(ol.format.WKT.TokenType_.COMMA)) { + while (this.match(_ol_format_WKT_.TokenType_.COMMA)) { coordinates.push(this.parsePoint_()); } return coordinates; @@ -851,9 +853,9 @@ ol.format.WKT.Parser.prototype.parsePointList_ = function() { * @return {!Array.>} An array of points. * @private */ -ol.format.WKT.Parser.prototype.parsePointTextList_ = function() { +_ol_format_WKT_.Parser.prototype.parsePointTextList_ = function() { var coordinates = [this.parsePointText_()]; - while (this.match(ol.format.WKT.TokenType_.COMMA)) { + while (this.match(_ol_format_WKT_.TokenType_.COMMA)) { coordinates.push(this.parsePointText_()); } return coordinates; @@ -864,9 +866,9 @@ ol.format.WKT.Parser.prototype.parsePointTextList_ = function() { * @return {!Array.>} An array of points. * @private */ -ol.format.WKT.Parser.prototype.parseLineStringTextList_ = function() { +_ol_format_WKT_.Parser.prototype.parseLineStringTextList_ = function() { var coordinates = [this.parseLineStringText_()]; - while (this.match(ol.format.WKT.TokenType_.COMMA)) { + while (this.match(_ol_format_WKT_.TokenType_.COMMA)) { coordinates.push(this.parseLineStringText_()); } return coordinates; @@ -877,9 +879,9 @@ ol.format.WKT.Parser.prototype.parseLineStringTextList_ = function() { * @return {!Array.>} An array of points. * @private */ -ol.format.WKT.Parser.prototype.parsePolygonTextList_ = function() { +_ol_format_WKT_.Parser.prototype.parsePolygonTextList_ = function() { var coordinates = [this.parsePolygonText_()]; - while (this.match(ol.format.WKT.TokenType_.COMMA)) { + while (this.match(_ol_format_WKT_.TokenType_.COMMA)) { coordinates.push(this.parsePolygonText_()); } return coordinates; @@ -890,9 +892,9 @@ ol.format.WKT.Parser.prototype.parsePolygonTextList_ = function() { * @return {boolean} Whether the token implies an empty geometry. * @private */ -ol.format.WKT.Parser.prototype.isEmptyGeometry_ = function() { - var isEmpty = this.isTokenType(ol.format.WKT.TokenType_.TEXT) && - this.token_.value == ol.format.WKT.EMPTY; +_ol_format_WKT_.Parser.prototype.isEmptyGeometry_ = function() { + var isEmpty = this.isTokenType(_ol_format_WKT_.TokenType_.TEXT) && + this.token_.value == _ol_format_WKT_.EMPTY; if (isEmpty) { this.consume_(); } @@ -905,7 +907,7 @@ ol.format.WKT.Parser.prototype.isEmptyGeometry_ = function() { * @return {string} Error message. * @private */ -ol.format.WKT.Parser.prototype.formatErrorMessage_ = function() { +_ol_format_WKT_.Parser.prototype.formatErrorMessage_ = function() { return 'Unexpected `' + this.token_.value + '` at position ' + this.token_.position + ' in `' + this.lexer_.wkt + '`'; }; @@ -915,13 +917,13 @@ ol.format.WKT.Parser.prototype.formatErrorMessage_ = function() { * @enum {function (new:ol.geom.Geometry, Array, ol.geom.GeometryLayout)} * @private */ -ol.format.WKT.Parser.GeometryConstructor_ = { - 'POINT': ol.geom.Point, - 'LINESTRING': ol.geom.LineString, - 'POLYGON': ol.geom.Polygon, - 'MULTIPOINT': ol.geom.MultiPoint, - 'MULTILINESTRING': ol.geom.MultiLineString, - 'MULTIPOLYGON': ol.geom.MultiPolygon +_ol_format_WKT_.Parser.GeometryConstructor_ = { + 'POINT': _ol_geom_Point_, + 'LINESTRING': _ol_geom_LineString_, + 'POLYGON': _ol_geom_Polygon_, + 'MULTIPOINT': _ol_geom_MultiPoint_, + 'MULTILINESTRING': _ol_geom_MultiLineString_, + 'MULTIPOLYGON': _ol_geom_MultiPolygon_ }; @@ -929,11 +931,12 @@ ol.format.WKT.Parser.GeometryConstructor_ = { * @enum {(function(): Array)} * @private */ -ol.format.WKT.Parser.GeometryParser_ = { - 'POINT': ol.format.WKT.Parser.prototype.parsePointText_, - 'LINESTRING': ol.format.WKT.Parser.prototype.parseLineStringText_, - 'POLYGON': ol.format.WKT.Parser.prototype.parsePolygonText_, - 'MULTIPOINT': ol.format.WKT.Parser.prototype.parseMultiPointText_, - 'MULTILINESTRING': ol.format.WKT.Parser.prototype.parseMultiLineStringText_, - 'MULTIPOLYGON': ol.format.WKT.Parser.prototype.parseMultiPolygonText_ +_ol_format_WKT_.Parser.GeometryParser_ = { + 'POINT': _ol_format_WKT_.Parser.prototype.parsePointText_, + 'LINESTRING': _ol_format_WKT_.Parser.prototype.parseLineStringText_, + 'POLYGON': _ol_format_WKT_.Parser.prototype.parsePolygonText_, + 'MULTIPOINT': _ol_format_WKT_.Parser.prototype.parseMultiPointText_, + 'MULTILINESTRING': _ol_format_WKT_.Parser.prototype.parseMultiLineStringText_, + 'MULTIPOLYGON': _ol_format_WKT_.Parser.prototype.parseMultiPolygonText_ }; +export default _ol_format_WKT_; diff --git a/src/ol/format/WMSCapabilities.js b/src/ol/format/WMSCapabilities.js index 97be7fa915..2b3dd80cce 100644 --- a/src/ol/format/WMSCapabilities.js +++ b/src/ol/format/WMSCapabilities.js @@ -1,11 +1,11 @@ -goog.provide('ol.format.WMSCapabilities'); - -goog.require('ol'); -goog.require('ol.format.XLink'); -goog.require('ol.format.XML'); -goog.require('ol.format.XSD'); -goog.require('ol.xml'); - +/** + * @module ol/format/WMSCapabilities + */ +import _ol_ from '../index.js'; +import _ol_format_XLink_ from '../format/XLink.js'; +import _ol_format_XML_ from '../format/XML.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -15,16 +15,17 @@ goog.require('ol.xml'); * @extends {ol.format.XML} * @api */ -ol.format.WMSCapabilities = function() { +var _ol_format_WMSCapabilities_ = function() { - ol.format.XML.call(this); + _ol_format_XML_.call(this); /** * @type {string|undefined} */ this.version = undefined; }; -ol.inherits(ol.format.WMSCapabilities, ol.format.XML); + +_ol_.inherits(_ol_format_WMSCapabilities_, _ol_format_XML_); /** @@ -35,13 +36,13 @@ ol.inherits(ol.format.WMSCapabilities, ol.format.XML); * @return {Object} An object representing the WMS capabilities. * @api */ -ol.format.WMSCapabilities.prototype.read; +_ol_format_WMSCapabilities_.prototype.read; /** * @inheritDoc */ -ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) { +_ol_format_WMSCapabilities_.prototype.readFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readFromNode(n); @@ -54,11 +55,11 @@ ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) { /** * @inheritDoc */ -ol.format.WMSCapabilities.prototype.readFromNode = function(node) { +_ol_format_WMSCapabilities_.prototype.readFromNode = function(node) { this.version = node.getAttribute('version').trim(); - var wmsCapabilityObject = ol.xml.pushParseAndPop({ + var wmsCapabilityObject = _ol_xml_.pushParseAndPop({ 'version': this.version - }, ol.format.WMSCapabilities.PARSERS_, node, []); + }, _ol_format_WMSCapabilities_.PARSERS_, node, []); return wmsCapabilityObject ? wmsCapabilityObject : null; }; @@ -69,9 +70,9 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Attribution object. */ -ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readAttribution_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.ATTRIBUTION_PARSERS_, node, objectStack); }; @@ -81,17 +82,17 @@ ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object} Bounding box object. */ -ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readBoundingBox_ = function(node, objectStack) { var extent = [ - ol.format.XSD.readDecimalString(node.getAttribute('minx')), - ol.format.XSD.readDecimalString(node.getAttribute('miny')), - ol.format.XSD.readDecimalString(node.getAttribute('maxx')), - ol.format.XSD.readDecimalString(node.getAttribute('maxy')) + _ol_format_XSD_.readDecimalString(node.getAttribute('minx')), + _ol_format_XSD_.readDecimalString(node.getAttribute('miny')), + _ol_format_XSD_.readDecimalString(node.getAttribute('maxx')), + _ol_format_XSD_.readDecimalString(node.getAttribute('maxy')) ]; var resolutions = [ - ol.format.XSD.readDecimalString(node.getAttribute('resx')), - ol.format.XSD.readDecimalString(node.getAttribute('resy')) + _ol_format_XSD_.readDecimalString(node.getAttribute('resx')), + _ol_format_XSD_.readDecimalString(node.getAttribute('resy')) ]; return { @@ -108,10 +109,10 @@ ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {ol.Extent|undefined} Bounding box object. */ -ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) { - var geographicBoundingBox = ol.xml.pushParseAndPop( +_ol_format_WMSCapabilities_.readEXGeographicBoundingBox_ = function(node, objectStack) { + var geographicBoundingBox = _ol_xml_.pushParseAndPop( {}, - ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_, + _ol_format_WMSCapabilities_.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_, node, objectStack); if (!geographicBoundingBox) { return undefined; @@ -141,9 +142,9 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectSt * @private * @return {Object|undefined} Capability object. */ -ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readCapability_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.CAPABILITY_PARSERS_, node, objectStack); }; @@ -153,9 +154,9 @@ ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) { * @private * @return {Object|undefined} Service object. */ -ol.format.WMSCapabilities.readService_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readService_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.SERVICE_PARSERS_, node, objectStack); }; @@ -165,9 +166,9 @@ ol.format.WMSCapabilities.readService_ = function(node, objectStack) { * @private * @return {Object|undefined} Contact information object. */ -ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_, +_ol_format_WMSCapabilities_.readContactInformation_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.CONTACT_INFORMATION_PARSERS_, node, objectStack); }; @@ -178,9 +179,9 @@ ol.format.WMSCapabilities.readContactInformation_ = function(node, objectStack) * @private * @return {Object|undefined} Contact person object. */ -ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_, +_ol_format_WMSCapabilities_.readContactPersonPrimary_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.CONTACT_PERSON_PARSERS_, node, objectStack); }; @@ -191,9 +192,9 @@ ol.format.WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack * @private * @return {Object|undefined} Contact address object. */ -ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_, +_ol_format_WMSCapabilities_.readContactAddress_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.CONTACT_ADDRESS_PARSERS_, node, objectStack); }; @@ -204,9 +205,9 @@ ol.format.WMSCapabilities.readContactAddress_ = function(node, objectStack) { * @private * @return {Array.|undefined} Format array. */ -ol.format.WMSCapabilities.readException_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - [], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readException_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + [], _ol_format_WMSCapabilities_.EXCEPTION_PARSERS_, node, objectStack); }; @@ -216,9 +217,9 @@ ol.format.WMSCapabilities.readException_ = function(node, objectStack) { * @private * @return {Object|undefined} Layer object. */ -ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readCapabilityLayer_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.LAYER_PARSERS_, node, objectStack); }; @@ -228,52 +229,52 @@ ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Layer object. */ -ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readLayer_ = function(node, objectStack) { var parentLayerObject = /** @type {Object.} */ (objectStack[objectStack.length - 1]); - var layerObject = ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack); + var layerObject = _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.LAYER_PARSERS_, node, objectStack); if (!layerObject) { return undefined; } var queryable = - ol.format.XSD.readBooleanString(node.getAttribute('queryable')); + _ol_format_XSD_.readBooleanString(node.getAttribute('queryable')); if (queryable === undefined) { queryable = parentLayerObject['queryable']; } layerObject['queryable'] = queryable !== undefined ? queryable : false; - var cascaded = ol.format.XSD.readNonNegativeIntegerString( + var cascaded = _ol_format_XSD_.readNonNegativeIntegerString( node.getAttribute('cascaded')); if (cascaded === undefined) { cascaded = parentLayerObject['cascaded']; } layerObject['cascaded'] = cascaded; - var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); + var opaque = _ol_format_XSD_.readBooleanString(node.getAttribute('opaque')); if (opaque === undefined) { opaque = parentLayerObject['opaque']; } layerObject['opaque'] = opaque !== undefined ? opaque : false; var noSubsets = - ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); + _ol_format_XSD_.readBooleanString(node.getAttribute('noSubsets')); if (noSubsets === undefined) { noSubsets = parentLayerObject['noSubsets']; } layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false; var fixedWidth = - ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); + _ol_format_XSD_.readDecimalString(node.getAttribute('fixedWidth')); if (!fixedWidth) { fixedWidth = parentLayerObject['fixedWidth']; } layerObject['fixedWidth'] = fixedWidth; var fixedHeight = - ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight')); + _ol_format_XSD_.readDecimalString(node.getAttribute('fixedHeight')); if (!fixedHeight) { fixedHeight = parentLayerObject['fixedHeight']; } @@ -307,18 +308,18 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object} Dimension object. */ -ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readDimension_ = function(node, objectStack) { var dimensionObject = { 'name': node.getAttribute('name'), 'units': node.getAttribute('units'), 'unitSymbol': node.getAttribute('unitSymbol'), 'default': node.getAttribute('default'), - 'multipleValues': ol.format.XSD.readBooleanString( + 'multipleValues': _ol_format_XSD_.readBooleanString( node.getAttribute('multipleValues')), - 'nearestValue': ol.format.XSD.readBooleanString( + 'nearestValue': _ol_format_XSD_.readBooleanString( node.getAttribute('nearestValue')), - 'current': ol.format.XSD.readBooleanString(node.getAttribute('current')), - 'values': ol.format.XSD.readString(node) + 'current': _ol_format_XSD_.readBooleanString(node.getAttribute('current')), + 'values': _ol_format_XSD_.readString(node) }; return dimensionObject; }; @@ -330,9 +331,9 @@ ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Online resource object. */ -ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_, +_ol_format_WMSCapabilities_.readFormatOnlineresource_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.FORMAT_ONLINERESOURCE_PARSERS_, node, objectStack); }; @@ -343,9 +344,9 @@ ol.format.WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Request object. */ -ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readRequest_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.REQUEST_PARSERS_, node, objectStack); }; @@ -355,9 +356,9 @@ ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} DCP type object. */ -ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readDCPType_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.DCPTYPE_PARSERS_, node, objectStack); }; @@ -367,9 +368,9 @@ ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} HTTP object. */ -ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.HTTP_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readHTTP_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.HTTP_PARSERS_, node, objectStack); }; @@ -379,9 +380,9 @@ ol.format.WMSCapabilities.readHTTP_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Operation type object. */ -ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readOperationType_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.OPERATIONTYPE_PARSERS_, node, objectStack); }; @@ -391,13 +392,13 @@ ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Online resource object. */ -ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readSizedFormatOnlineresource_ = function(node, objectStack) { var formatOnlineresource = - ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); + _ol_format_WMSCapabilities_.readFormatOnlineresource_(node, objectStack); if (formatOnlineresource) { var size = [ - ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')), - ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height')) + _ol_format_XSD_.readNonNegativeIntegerString(node.getAttribute('width')), + _ol_format_XSD_.readNonNegativeIntegerString(node.getAttribute('height')) ]; formatOnlineresource['size'] = size; return formatOnlineresource; @@ -412,9 +413,9 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ = function(node, object * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Authority URL object. */ -ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readAuthorityURL_ = function(node, objectStack) { var authorityObject = - ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); + _ol_format_WMSCapabilities_.readFormatOnlineresource_(node, objectStack); if (authorityObject) { authorityObject['name'] = node.getAttribute('name'); return authorityObject; @@ -429,9 +430,9 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Metadata URL object. */ -ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) { +_ol_format_WMSCapabilities_.readMetadataURL_ = function(node, objectStack) { var metadataObject = - ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); + _ol_format_WMSCapabilities_.readFormatOnlineresource_(node, objectStack); if (metadataObject) { metadataObject['type'] = node.getAttribute('type'); return metadataObject; @@ -446,9 +447,9 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Style object. */ -ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - {}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readStyle_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + {}, _ol_format_WMSCapabilities_.STYLE_PARSERS_, node, objectStack); }; @@ -458,9 +459,9 @@ ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Array.|undefined} Keyword list. */ -ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) { - return ol.xml.pushParseAndPop( - [], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack); +_ol_format_WMSCapabilities_.readKeywordList_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop( + [], _ol_format_WMSCapabilities_.KEYWORDLIST_PARSERS_, node, objectStack); }; @@ -469,7 +470,7 @@ ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) { * @private * @type {Array.} */ -ol.format.WMSCapabilities.NAMESPACE_URIS_ = [ +_ol_format_WMSCapabilities_.NAMESPACE_URIS_ = [ null, 'http://www.opengis.net/wms' ]; @@ -480,12 +481,12 @@ ol.format.WMSCapabilities.NAMESPACE_URIS_ = [ * @type {Object.>} * @private */ -ol.format.WMSCapabilities.PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Service': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readService_), - 'Capability': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readCapability_) +_ol_format_WMSCapabilities_.PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Service': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readService_), + 'Capability': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readCapability_) }); @@ -494,14 +495,14 @@ ol.format.WMSCapabilities.PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.CAPABILITY_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Request': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readRequest_), - 'Exception': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readException_), - 'Layer': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readCapabilityLayer_) +_ol_format_WMSCapabilities_.CAPABILITY_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Request': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readRequest_), + 'Exception': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readException_), + 'Layer': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readCapabilityLayer_) }); @@ -510,26 +511,26 @@ ol.format.WMSCapabilities.CAPABILITY_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.SERVICE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'KeywordList': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readKeywordList_), - 'OnlineResource': ol.xml.makeObjectPropertySetter( - ol.format.XLink.readHref), - 'ContactInformation': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readContactInformation_), - 'Fees': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'AccessConstraints': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'LayerLimit': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MaxWidth': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MaxHeight': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger) +_ol_format_WMSCapabilities_.SERVICE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Title': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Abstract': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'KeywordList': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readKeywordList_), + 'OnlineResource': _ol_xml_.makeObjectPropertySetter( + _ol_format_XLink_.readHref), + 'ContactInformation': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readContactInformation_), + 'Fees': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'AccessConstraints': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'LayerLimit': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MaxWidth': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MaxHeight': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger) }); @@ -538,20 +539,20 @@ ol.format.WMSCapabilities.SERVICE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'ContactPersonPrimary': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readContactPersonPrimary_), - 'ContactPosition': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'ContactAddress': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readContactAddress_), - 'ContactVoiceTelephone': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'ContactFacsimileTelephone': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'ContactElectronicMailAddress': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMSCapabilities_.CONTACT_INFORMATION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'ContactPersonPrimary': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readContactPersonPrimary_), + 'ContactPosition': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'ContactAddress': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readContactAddress_), + 'ContactVoiceTelephone': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'ContactFacsimileTelephone': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'ContactElectronicMailAddress': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) }); @@ -560,12 +561,12 @@ ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'ContactPerson': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'ContactOrganization': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMSCapabilities_.CONTACT_PERSON_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'ContactPerson': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'ContactOrganization': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) }); @@ -574,15 +575,15 @@ ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'AddressType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Address': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'StateOrProvince': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'PostCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Country': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString) +_ol_format_WMSCapabilities_.CONTACT_ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'AddressType': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Address': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'City': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'StateOrProvince': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'PostCode': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Country': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString) }); @@ -591,9 +592,9 @@ ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.EXCEPTION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Format': ol.xml.makeArrayPusher(ol.format.XSD.readString) +_ol_format_WMSCapabilities_.EXCEPTION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Format': _ol_xml_.makeArrayPusher(_ol_format_XSD_.readString) }); @@ -602,39 +603,39 @@ ol.format.WMSCapabilities.EXCEPTION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.LAYER_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'KeywordList': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readKeywordList_), - 'CRS': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString), - 'EX_GeographicBoundingBox': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readEXGeographicBoundingBox_), - 'BoundingBox': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readBoundingBox_), - 'Dimension': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readDimension_), - 'Attribution': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readAttribution_), - 'AuthorityURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readAuthorityURL_), - 'Identifier': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString), - 'MetadataURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readMetadataURL_), - 'DataURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readFormatOnlineresource_), - 'FeatureListURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readFormatOnlineresource_), - 'Style': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readStyle_), - 'MinScaleDenominator': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'MaxScaleDenominator': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'Layer': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readLayer_) +_ol_format_WMSCapabilities_.LAYER_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Title': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Abstract': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'KeywordList': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readKeywordList_), + 'CRS': _ol_xml_.makeObjectPropertyPusher(_ol_format_XSD_.readString), + 'EX_GeographicBoundingBox': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readEXGeographicBoundingBox_), + 'BoundingBox': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readBoundingBox_), + 'Dimension': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readDimension_), + 'Attribution': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readAttribution_), + 'AuthorityURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readAuthorityURL_), + 'Identifier': _ol_xml_.makeObjectPropertyPusher(_ol_format_XSD_.readString), + 'MetadataURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readMetadataURL_), + 'DataURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readFormatOnlineresource_), + 'FeatureListURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readFormatOnlineresource_), + 'Style': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readStyle_), + 'MinScaleDenominator': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'MaxScaleDenominator': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'Layer': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readLayer_) }); @@ -643,13 +644,13 @@ ol.format.WMSCapabilities.LAYER_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'OnlineResource': ol.xml.makeObjectPropertySetter( - ol.format.XLink.readHref), - 'LogoURL': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readSizedFormatOnlineresource_) +_ol_format_WMSCapabilities_.ATTRIBUTION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Title': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'OnlineResource': _ol_xml_.makeObjectPropertySetter( + _ol_format_XLink_.readHref), + 'LogoURL': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readSizedFormatOnlineresource_) }); @@ -658,16 +659,16 @@ ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ = - ol.xml.makeStructureNS(ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'westBoundLongitude': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'eastBoundLongitude': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'southBoundLatitude': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'northBoundLatitude': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal) +_ol_format_WMSCapabilities_.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ = + _ol_xml_.makeStructureNS(_ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'westBoundLongitude': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'eastBoundLongitude': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'southBoundLatitude': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'northBoundLatitude': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal) }); @@ -676,14 +677,14 @@ ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ = * @type {Object.>} * @private */ -ol.format.WMSCapabilities.REQUEST_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'GetCapabilities': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readOperationType_), - 'GetMap': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readOperationType_), - 'GetFeatureInfo': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readOperationType_) +_ol_format_WMSCapabilities_.REQUEST_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'GetCapabilities': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readOperationType_), + 'GetMap': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readOperationType_), + 'GetFeatureInfo': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readOperationType_) }); @@ -692,11 +693,11 @@ ol.format.WMSCapabilities.REQUEST_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Format': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString), - 'DCPType': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readDCPType_) +_ol_format_WMSCapabilities_.OPERATIONTYPE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Format': _ol_xml_.makeObjectPropertyPusher(_ol_format_XSD_.readString), + 'DCPType': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readDCPType_) }); @@ -705,10 +706,10 @@ ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.DCPTYPE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'HTTP': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readHTTP_) +_ol_format_WMSCapabilities_.DCPTYPE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'HTTP': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readHTTP_) }); @@ -717,12 +718,12 @@ ol.format.WMSCapabilities.DCPTYPE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.HTTP_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Get': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readFormatOnlineresource_), - 'Post': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readFormatOnlineresource_) +_ol_format_WMSCapabilities_.HTTP_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Get': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readFormatOnlineresource_), + 'Post': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readFormatOnlineresource_) }); @@ -731,17 +732,17 @@ ol.format.WMSCapabilities.HTTP_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'LegendURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMSCapabilities.readSizedFormatOnlineresource_), - 'StyleSheetURL': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readFormatOnlineresource_), - 'StyleURL': ol.xml.makeObjectPropertySetter( - ol.format.WMSCapabilities.readFormatOnlineresource_) +_ol_format_WMSCapabilities_.STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Name': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Title': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'Abstract': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'LegendURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMSCapabilities_.readSizedFormatOnlineresource_), + 'StyleSheetURL': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readFormatOnlineresource_), + 'StyleURL': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMSCapabilities_.readFormatOnlineresource_) }); @@ -750,11 +751,11 @@ ol.format.WMSCapabilities.STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_ = - ol.xml.makeStructureNS(ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Format': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), - 'OnlineResource': ol.xml.makeObjectPropertySetter( - ol.format.XLink.readHref) +_ol_format_WMSCapabilities_.FORMAT_ONLINERESOURCE_PARSERS_ = + _ol_xml_.makeStructureNS(_ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Format': _ol_xml_.makeObjectPropertySetter(_ol_format_XSD_.readString), + 'OnlineResource': _ol_xml_.makeObjectPropertySetter( + _ol_format_XLink_.readHref) }); @@ -763,7 +764,8 @@ ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_ = * @type {Object.>} * @private */ -ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMSCapabilities.NAMESPACE_URIS_, { - 'Keyword': ol.xml.makeArrayPusher(ol.format.XSD.readString) +_ol_format_WMSCapabilities_.KEYWORDLIST_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMSCapabilities_.NAMESPACE_URIS_, { + 'Keyword': _ol_xml_.makeArrayPusher(_ol_format_XSD_.readString) }); +export default _ol_format_WMSCapabilities_; diff --git a/src/ol/format/WMSGetFeatureInfo.js b/src/ol/format/WMSGetFeatureInfo.js index d53ab8587c..4122920866 100644 --- a/src/ol/format/WMSGetFeatureInfo.js +++ b/src/ol/format/WMSGetFeatureInfo.js @@ -1,12 +1,12 @@ -goog.provide('ol.format.WMSGetFeatureInfo'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.format.GML2'); -goog.require('ol.format.XMLFeature'); -goog.require('ol.obj'); -goog.require('ol.xml'); - +/** + * @module ol/format/WMSGetFeatureInfo + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_format_GML2_ from '../format/GML2.js'; +import _ol_format_XMLFeature_ from '../format/XMLFeature.js'; +import _ol_obj_ from '../obj.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -18,7 +18,7 @@ goog.require('ol.xml'); * @param {olx.format.WMSGetFeatureInfoOptions=} opt_options Options. * @api */ -ol.format.WMSGetFeatureInfo = function(opt_options) { +var _ol_format_WMSGetFeatureInfo_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -33,7 +33,7 @@ ol.format.WMSGetFeatureInfo = function(opt_options) { * @private * @type {ol.format.GML2} */ - this.gmlFormat_ = new ol.format.GML2(); + this.gmlFormat_ = new _ol_format_GML2_(); /** @@ -42,9 +42,10 @@ ol.format.WMSGetFeatureInfo = function(opt_options) { */ this.layers_ = options.layers ? options.layers : null; - ol.format.XMLFeature.call(this); + _ol_format_XMLFeature_.call(this); }; -ol.inherits(ol.format.WMSGetFeatureInfo, ol.format.XMLFeature); + +_ol_.inherits(_ol_format_WMSGetFeatureInfo_, _ol_format_XMLFeature_); /** @@ -52,7 +53,7 @@ ol.inherits(ol.format.WMSGetFeatureInfo, ol.format.XMLFeature); * @type {string} * @private */ -ol.format.WMSGetFeatureInfo.featureIdentifier_ = '_feature'; +_ol_format_WMSGetFeatureInfo_.featureIdentifier_ = '_feature'; /** @@ -60,13 +61,13 @@ ol.format.WMSGetFeatureInfo.featureIdentifier_ = '_feature'; * @type {string} * @private */ -ol.format.WMSGetFeatureInfo.layerIdentifier_ = '_layer'; +_ol_format_WMSGetFeatureInfo_.layerIdentifier_ = '_layer'; /** * @return {Array.} layers */ -ol.format.WMSGetFeatureInfo.prototype.getLayers = function() { +_ol_format_WMSGetFeatureInfo_.prototype.getLayers = function() { return this.layers_; }; @@ -74,7 +75,7 @@ ol.format.WMSGetFeatureInfo.prototype.getLayers = function() { /** * @param {Array.} layers Layers to parse. */ -ol.format.WMSGetFeatureInfo.prototype.setLayers = function(layers) { +_ol_format_WMSGetFeatureInfo_.prototype.setLayers = function(layers) { this.layers_ = layers; }; @@ -85,7 +86,7 @@ ol.format.WMSGetFeatureInfo.prototype.setLayers = function(layers) { * @return {Array.} Features. * @private */ -ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) { +_ol_format_WMSGetFeatureInfo_.prototype.readFeatures_ = function(node, objectStack) { node.setAttribute('namespaceURI', this.featureNS_); var localName = node.localName; /** @type {Array.} */ @@ -101,34 +102,34 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack } var context = objectStack[0]; - var toRemove = ol.format.WMSGetFeatureInfo.layerIdentifier_; + var toRemove = _ol_format_WMSGetFeatureInfo_.layerIdentifier_; var layerName = layer.localName.replace(toRemove, ''); - if (this.layers_ && !ol.array.includes(this.layers_, layerName)) { + if (this.layers_ && !_ol_array_.includes(this.layers_, layerName)) { continue; } var featureType = layerName + - ol.format.WMSGetFeatureInfo.featureIdentifier_; + _ol_format_WMSGetFeatureInfo_.featureIdentifier_; context['featureType'] = featureType; context['featureNS'] = this.featureNS_; var parsers = {}; - parsers[featureType] = ol.xml.makeArrayPusher( + parsers[featureType] = _ol_xml_.makeArrayPusher( this.gmlFormat_.readFeatureElement, this.gmlFormat_); - var parsersNS = ol.xml.makeStructureNS( + var parsersNS = _ol_xml_.makeStructureNS( [context['featureNS'], null], parsers); layer.setAttribute('namespaceURI', this.featureNS_); - var layerFeatures = ol.xml.pushParseAndPop( + var layerFeatures = _ol_xml_.pushParseAndPop( [], parsersNS, layer, objectStack, this.gmlFormat_); if (layerFeatures) { - ol.array.extend(features, layerFeatures); + _ol_array_.extend(features, layerFeatures); } } } if (localName == 'FeatureCollection') { - var gmlFeatures = ol.xml.pushParseAndPop([], + var gmlFeatures = _ol_xml_.pushParseAndPop([], this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, [{}], this.gmlFormat_); if (gmlFeatures) { @@ -148,16 +149,16 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack * @return {Array.} Features. * @api */ -ol.format.WMSGetFeatureInfo.prototype.readFeatures; +_ol_format_WMSGetFeatureInfo_.prototype.readFeatures; /** * @inheritDoc */ -ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode = function(node, opt_options) { +_ol_format_WMSGetFeatureInfo_.prototype.readFeaturesFromNode = function(node, opt_options) { var options = {}; if (opt_options) { - ol.obj.assign(options, this.getReadOptions(node, opt_options)); + _ol_obj_.assign(options, this.getReadOptions(node, opt_options)); } return this.readFeatures_(node, [options]); }; @@ -167,18 +168,19 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode = function(node, opt_ * Not implemented. * @inheritDoc */ -ol.format.WMSGetFeatureInfo.prototype.writeFeatureNode = function(feature, opt_options) {}; +_ol_format_WMSGetFeatureInfo_.prototype.writeFeatureNode = function(feature, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.WMSGetFeatureInfo.prototype.writeFeaturesNode = function(features, opt_options) {}; +_ol_format_WMSGetFeatureInfo_.prototype.writeFeaturesNode = function(features, opt_options) {}; /** * Not implemented. * @inheritDoc */ -ol.format.WMSGetFeatureInfo.prototype.writeGeometryNode = function(geometry, opt_options) {}; +_ol_format_WMSGetFeatureInfo_.prototype.writeGeometryNode = function(geometry, opt_options) {}; +export default _ol_format_WMSGetFeatureInfo_; diff --git a/src/ol/format/WMTSCapabilities.js b/src/ol/format/WMTSCapabilities.js index 7022911ec1..976a8afd83 100644 --- a/src/ol/format/WMTSCapabilities.js +++ b/src/ol/format/WMTSCapabilities.js @@ -1,13 +1,13 @@ -goog.provide('ol.format.WMTSCapabilities'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.format.OWS'); -goog.require('ol.format.XLink'); -goog.require('ol.format.XML'); -goog.require('ol.format.XSD'); -goog.require('ol.xml'); - +/** + * @module ol/format/WMTSCapabilities + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_format_OWS_ from '../format/OWS.js'; +import _ol_format_XLink_ from '../format/XLink.js'; +import _ol_format_XML_ from '../format/XML.js'; +import _ol_format_XSD_ from '../format/XSD.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -17,16 +17,17 @@ goog.require('ol.xml'); * @extends {ol.format.XML} * @api */ -ol.format.WMTSCapabilities = function() { - ol.format.XML.call(this); +var _ol_format_WMTSCapabilities_ = function() { + _ol_format_XML_.call(this); /** * @type {ol.format.OWS} * @private */ - this.owsParser_ = new ol.format.OWS(); + this.owsParser_ = new _ol_format_OWS_(); }; -ol.inherits(ol.format.WMTSCapabilities, ol.format.XML); + +_ol_.inherits(_ol_format_WMTSCapabilities_, _ol_format_XML_); /** @@ -37,13 +38,13 @@ ol.inherits(ol.format.WMTSCapabilities, ol.format.XML); * @return {Object} An object representing the WMTS capabilities. * @api */ -ol.format.WMTSCapabilities.prototype.read; +_ol_format_WMTSCapabilities_.prototype.read; /** * @inheritDoc */ -ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) { +_ol_format_WMTSCapabilities_.prototype.readFromDocument = function(doc) { for (var n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { return this.readFromNode(n); @@ -56,15 +57,15 @@ ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) { /** * @inheritDoc */ -ol.format.WMTSCapabilities.prototype.readFromNode = function(node) { +_ol_format_WMTSCapabilities_.prototype.readFromNode = function(node) { var version = node.getAttribute('version').trim(); var WMTSCapabilityObject = this.owsParser_.readFromNode(node); if (!WMTSCapabilityObject) { return null; } WMTSCapabilityObject['version'] = version; - WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject, - ol.format.WMTSCapabilities.PARSERS_, node, []); + WMTSCapabilityObject = _ol_xml_.pushParseAndPop(WMTSCapabilityObject, + _ol_format_WMTSCapabilities_.PARSERS_, node, []); return WMTSCapabilityObject ? WMTSCapabilityObject : null; }; @@ -75,9 +76,9 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Attribution object. */ -ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.CONTENTS_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readContents_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.CONTENTS_PARSERS_, node, objectStack); }; @@ -87,9 +88,9 @@ ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Layers object. */ -ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readLayer_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.LAYER_PARSERS_, node, objectStack); }; @@ -99,9 +100,9 @@ ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Tile Matrix Set object. */ -ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.TMS_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readTileMatrixSet_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.TMS_PARSERS_, node, objectStack); }; @@ -111,9 +112,9 @@ ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Style object. */ -ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) { - var style = ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readStyle_ = function(node, objectStack) { + var style = _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.STYLE_PARSERS_, node, objectStack); if (!style) { return undefined; } @@ -130,10 +131,10 @@ ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Tile Matrix Set Link object. */ -ol.format.WMTSCapabilities.readTileMatrixSetLink_ = function(node, +_ol_format_WMTSCapabilities_.readTileMatrixSetLink_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_, node, objectStack); + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_, node, objectStack); }; @@ -143,9 +144,9 @@ ol.format.WMTSCapabilities.readTileMatrixSetLink_ = function(node, * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Dimension object. */ -ol.format.WMTSCapabilities.readDimensions_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.DIMENSION_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readDimensions_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.DIMENSION_PARSERS_, node, objectStack); }; @@ -155,7 +156,7 @@ ol.format.WMTSCapabilities.readDimensions_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Resource URL object. */ -ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) { +_ol_format_WMTSCapabilities_.readResourceUrl_ = function(node, objectStack) { var format = node.getAttribute('format'); var template = node.getAttribute('template'); var resourceType = node.getAttribute('resourceType'); @@ -179,13 +180,13 @@ ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} WGS84 BBox object. */ -ol.format.WMTSCapabilities.readWgs84BoundingBox_ = function(node, objectStack) { - var coordinates = ol.xml.pushParseAndPop([], - ol.format.WMTSCapabilities.WGS84_BBOX_READERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readWgs84BoundingBox_ = function(node, objectStack) { + var coordinates = _ol_xml_.pushParseAndPop([], + _ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_, node, objectStack); if (coordinates.length != 2) { return undefined; } - return ol.extent.boundingExtent(coordinates); + return _ol_extent_.boundingExtent(coordinates); }; @@ -195,10 +196,10 @@ ol.format.WMTSCapabilities.readWgs84BoundingBox_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Legend object. */ -ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) { +_ol_format_WMTSCapabilities_.readLegendUrl_ = function(node, objectStack) { var legend = {}; legend['format'] = node.getAttribute('format'); - legend['href'] = ol.format.XLink.readHref(node); + legend['href'] = _ol_format_XLink_.readHref(node); return legend; }; @@ -209,8 +210,8 @@ ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} Coordinates object. */ -ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) { - var coordinates = ol.format.XSD.readString(node).split(' '); +_ol_format_WMTSCapabilities_.readCoordinates_ = function(node, objectStack) { + var coordinates = _ol_format_XSD_.readString(node).split(' '); if (!coordinates || coordinates.length != 2) { return undefined; } @@ -229,9 +230,9 @@ ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} TileMatrix object. */ -ol.format.WMTSCapabilities.readTileMatrix_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.TM_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readTileMatrix_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.TM_PARSERS_, node, objectStack); }; @@ -241,10 +242,10 @@ ol.format.WMTSCapabilities.readTileMatrix_ = function(node, objectStack) { * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} TileMatrixSetLimits Object. */ -ol.format.WMTSCapabilities.readTileMatrixLimitsList_ = function(node, +_ol_format_WMTSCapabilities_.readTileMatrixLimitsList_ = function(node, objectStack) { - return ol.xml.pushParseAndPop([], - ol.format.WMTSCapabilities.TMS_LIMITS_LIST_PARSERS_, node, + return _ol_xml_.pushParseAndPop([], + _ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_, node, objectStack); }; @@ -255,9 +256,9 @@ ol.format.WMTSCapabilities.readTileMatrixLimitsList_ = function(node, * @param {Array.<*>} objectStack Object stack. * @return {Object|undefined} TileMatrixLimits Array. */ -ol.format.WMTSCapabilities.readTileMatrixLimits_ = function(node, objectStack) { - return ol.xml.pushParseAndPop({}, - ol.format.WMTSCapabilities.TMS_LIMITS_PARSERS_, node, objectStack); +_ol_format_WMTSCapabilities_.readTileMatrixLimits_ = function(node, objectStack) { + return _ol_xml_.pushParseAndPop({}, + _ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_, node, objectStack); }; @@ -266,7 +267,7 @@ ol.format.WMTSCapabilities.readTileMatrixLimits_ = function(node, objectStack) { * @private * @type {Array.} */ -ol.format.WMTSCapabilities.NAMESPACE_URIS_ = [ +_ol_format_WMTSCapabilities_.NAMESPACE_URIS_ = [ null, 'http://www.opengis.net/wmts/1.0' ]; @@ -277,7 +278,7 @@ ol.format.WMTSCapabilities.NAMESPACE_URIS_ = [ * @private * @type {Array.} */ -ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_ = [ +_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_ = [ null, 'http://www.opengis.net/ows/1.1' ]; @@ -288,10 +289,10 @@ ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_ = [ * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'Contents': ol.xml.makeObjectPropertySetter( - ol.format.WMTSCapabilities.readContents_) +_ol_format_WMTSCapabilities_.PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'Contents': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMTSCapabilities_.readContents_) }); @@ -300,12 +301,12 @@ ol.format.WMTSCapabilities.PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.CONTENTS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'Layer': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readLayer_), - 'TileMatrixSet': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readTileMatrixSet_) +_ol_format_WMTSCapabilities_.CONTENTS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'Layer': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readLayer_), + 'TileMatrixSet': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readTileMatrixSet_) }); @@ -314,27 +315,27 @@ ol.format.WMTSCapabilities.CONTENTS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.LAYER_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'Style': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readStyle_), - 'Format': ol.xml.makeObjectPropertyPusher( - ol.format.XSD.readString), - 'TileMatrixSetLink': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readTileMatrixSetLink_), - 'Dimension': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readDimensions_), - 'ResourceURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readResourceUrl_) - }, ol.xml.makeStructureNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'Title': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'Abstract': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'WGS84BoundingBox': ol.xml.makeObjectPropertySetter( - ol.format.WMTSCapabilities.readWgs84BoundingBox_), - 'Identifier': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMTSCapabilities_.LAYER_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'Style': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readStyle_), + 'Format': _ol_xml_.makeObjectPropertyPusher( + _ol_format_XSD_.readString), + 'TileMatrixSetLink': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readTileMatrixSetLink_), + 'Dimension': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readDimensions_), + 'ResourceURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readResourceUrl_) + }, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'Title': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'Abstract': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'WGS84BoundingBox': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMTSCapabilities_.readWgs84BoundingBox_), + 'Identifier': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) })); @@ -343,15 +344,15 @@ ol.format.WMTSCapabilities.LAYER_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.STYLE_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'LegendURL': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readLegendUrl_) - }, ol.xml.makeStructureNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'Title': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'Identifier': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMTSCapabilities_.STYLE_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'LegendURL': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readLegendUrl_) + }, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'Title': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'Identifier': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) })); @@ -360,12 +361,12 @@ ol.format.WMTSCapabilities.STYLE_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'TileMatrixSet': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'TileMatrixSetLimits': ol.xml.makeObjectPropertySetter( - ol.format.WMTSCapabilities.readTileMatrixLimitsList_) +_ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'TileMatrixSet': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'TileMatrixSetLimits': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMTSCapabilities_.readTileMatrixLimitsList_) }); /** @@ -373,10 +374,10 @@ ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.TMS_LIMITS_LIST_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'TileMatrixLimits': ol.xml.makeArrayPusher( - ol.format.WMTSCapabilities.readTileMatrixLimits_) +_ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'TileMatrixLimits': _ol_xml_.makeArrayPusher( + _ol_format_WMTSCapabilities_.readTileMatrixLimits_) }); @@ -385,18 +386,18 @@ ol.format.WMTSCapabilities.TMS_LIMITS_LIST_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.TMS_LIMITS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'TileMatrix': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'MinTileRow': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MaxTileRow': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MinTileCol': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MaxTileCol': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger) +_ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'TileMatrix': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'MinTileRow': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MaxTileRow': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MinTileCol': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MaxTileCol': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger) }); @@ -405,15 +406,15 @@ ol.format.WMTSCapabilities.TMS_LIMITS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.DIMENSION_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'Default': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'Value': ol.xml.makeObjectPropertyPusher( - ol.format.XSD.readString) - }, ol.xml.makeStructureNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'Identifier': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMTSCapabilities_.DIMENSION_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'Default': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'Value': _ol_xml_.makeObjectPropertyPusher( + _ol_format_XSD_.readString) + }, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'Identifier': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) })); @@ -422,12 +423,12 @@ ol.format.WMTSCapabilities.DIMENSION_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.WGS84_BBOX_READERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'LowerCorner': ol.xml.makeArrayPusher( - ol.format.WMTSCapabilities.readCoordinates_), - 'UpperCorner': ol.xml.makeArrayPusher( - ol.format.WMTSCapabilities.readCoordinates_) +_ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'LowerCorner': _ol_xml_.makeArrayPusher( + _ol_format_WMTSCapabilities_.readCoordinates_), + 'UpperCorner': _ol_xml_.makeArrayPusher( + _ol_format_WMTSCapabilities_.readCoordinates_) }); @@ -436,17 +437,17 @@ ol.format.WMTSCapabilities.WGS84_BBOX_READERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.TMS_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'WellKnownScaleSet': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'TileMatrix': ol.xml.makeObjectPropertyPusher( - ol.format.WMTSCapabilities.readTileMatrix_) - }, ol.xml.makeStructureNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'SupportedCRS': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString), - 'Identifier': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMTSCapabilities_.TMS_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'WellKnownScaleSet': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'TileMatrix': _ol_xml_.makeObjectPropertyPusher( + _ol_format_WMTSCapabilities_.readTileMatrix_) + }, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'SupportedCRS': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString), + 'Identifier': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) })); @@ -455,21 +456,22 @@ ol.format.WMTSCapabilities.TMS_PARSERS_ = ol.xml.makeStructureNS( * @type {Object.>} * @private */ -ol.format.WMTSCapabilities.TM_PARSERS_ = ol.xml.makeStructureNS( - ol.format.WMTSCapabilities.NAMESPACE_URIS_, { - 'TopLeftCorner': ol.xml.makeObjectPropertySetter( - ol.format.WMTSCapabilities.readCoordinates_), - 'ScaleDenominator': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readDecimal), - 'TileWidth': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'TileHeight': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MatrixWidth': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger), - 'MatrixHeight': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readNonNegativeInteger) - }, ol.xml.makeStructureNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, { - 'Identifier': ol.xml.makeObjectPropertySetter( - ol.format.XSD.readString) +_ol_format_WMTSCapabilities_.TM_PARSERS_ = _ol_xml_.makeStructureNS( + _ol_format_WMTSCapabilities_.NAMESPACE_URIS_, { + 'TopLeftCorner': _ol_xml_.makeObjectPropertySetter( + _ol_format_WMTSCapabilities_.readCoordinates_), + 'ScaleDenominator': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readDecimal), + 'TileWidth': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'TileHeight': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MatrixWidth': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger), + 'MatrixHeight': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readNonNegativeInteger) + }, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, { + 'Identifier': _ol_xml_.makeObjectPropertySetter( + _ol_format_XSD_.readString) })); +export default _ol_format_WMTSCapabilities_; diff --git a/src/ol/format/XLink.js b/src/ol/format/XLink.js index a01b61ec7e..4b60661f50 100644 --- a/src/ol/format/XLink.js +++ b/src/ol/format/XLink.js @@ -1,17 +1,21 @@ -goog.provide('ol.format.XLink'); +/** + * @module ol/format/XLink + */ +var _ol_format_XLink_ = {}; /** * @const * @type {string} */ -ol.format.XLink.NAMESPACE_URI = 'http://www.w3.org/1999/xlink'; +_ol_format_XLink_.NAMESPACE_URI = 'http://www.w3.org/1999/xlink'; /** * @param {Node} node Node. * @return {boolean|undefined} Boolean. */ -ol.format.XLink.readHref = function(node) { - return node.getAttributeNS(ol.format.XLink.NAMESPACE_URI, 'href'); +_ol_format_XLink_.readHref = function(node) { + return node.getAttributeNS(_ol_format_XLink_.NAMESPACE_URI, 'href'); }; +export default _ol_format_XLink_; diff --git a/src/ol/format/XML.js b/src/ol/format/XML.js index 9fa5eef5e8..17ab8d234a 100644 --- a/src/ol/format/XML.js +++ b/src/ol/format/XML.js @@ -1,7 +1,7 @@ -goog.provide('ol.format.XML'); - -goog.require('ol.xml'); - +/** + * @module ol/format/XML + */ +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -11,7 +11,7 @@ goog.require('ol.xml'); * @abstract * @struct */ -ol.format.XML = function() { +var _ol_format_XML_ = function() { }; @@ -19,13 +19,13 @@ ol.format.XML = function() { * @param {Document|Node|string} source Source. * @return {Object} The parsed result. */ -ol.format.XML.prototype.read = function(source) { - if (ol.xml.isDocument(source)) { +_ol_format_XML_.prototype.read = function(source) { + if (_ol_xml_.isDocument(source)) { return this.readFromDocument(/** @type {Document} */ (source)); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readFromNode(/** @type {Node} */ (source)); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readFromDocument(doc); } else { return null; @@ -38,7 +38,7 @@ ol.format.XML.prototype.read = function(source) { * @param {Document} doc Document. * @return {Object} Object */ -ol.format.XML.prototype.readFromDocument = function(doc) {}; +_ol_format_XML_.prototype.readFromDocument = function(doc) {}; /** @@ -46,4 +46,5 @@ ol.format.XML.prototype.readFromDocument = function(doc) {}; * @param {Node} node Node. * @return {Object} Object */ -ol.format.XML.prototype.readFromNode = function(node) {}; +_ol_format_XML_.prototype.readFromNode = function(node) {}; +export default _ol_format_XML_; diff --git a/src/ol/format/XMLFeature.js b/src/ol/format/XMLFeature.js index 5a67c551bc..880ee2aabb 100644 --- a/src/ol/format/XMLFeature.js +++ b/src/ol/format/XMLFeature.js @@ -1,11 +1,11 @@ -goog.provide('ol.format.XMLFeature'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.format.Feature'); -goog.require('ol.format.FormatType'); -goog.require('ol.xml'); - +/** + * @module ol/format/XMLFeature + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_format_Feature_ from '../format/Feature.js'; +import _ol_format_FormatType_ from '../format/FormatType.js'; +import _ol_xml_ from '../xml.js'; /** * @classdesc @@ -17,7 +17,7 @@ goog.require('ol.xml'); * @abstract * @extends {ol.format.Feature} */ -ol.format.XMLFeature = function() { +var _ol_format_XMLFeature_ = function() { /** * @type {XMLSerializer} @@ -25,30 +25,31 @@ ol.format.XMLFeature = function() { */ this.xmlSerializer_ = new XMLSerializer(); - ol.format.Feature.call(this); + _ol_format_Feature_.call(this); }; -ol.inherits(ol.format.XMLFeature, ol.format.Feature); + +_ol_.inherits(_ol_format_XMLFeature_, _ol_format_Feature_); /** * @inheritDoc */ -ol.format.XMLFeature.prototype.getType = function() { - return ol.format.FormatType.XML; +_ol_format_XMLFeature_.prototype.getType = function() { + return _ol_format_FormatType_.XML; }; /** * @inheritDoc */ -ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) { - if (ol.xml.isDocument(source)) { +_ol_format_XMLFeature_.prototype.readFeature = function(source, opt_options) { + if (_ol_xml_.isDocument(source)) { return this.readFeatureFromDocument( /** @type {Document} */ (source), opt_options); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readFeatureFromDocument(doc, opt_options); } else { return null; @@ -61,7 +62,7 @@ ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) { * @param {olx.format.ReadOptions=} opt_options Options. * @return {ol.Feature} Feature. */ -ol.format.XMLFeature.prototype.readFeatureFromDocument = function( +_ol_format_XMLFeature_.prototype.readFeatureFromDocument = function( doc, opt_options) { var features = this.readFeaturesFromDocument(doc, opt_options); if (features.length > 0) { @@ -77,7 +78,7 @@ ol.format.XMLFeature.prototype.readFeatureFromDocument = function( * @param {olx.format.ReadOptions=} opt_options Options. * @return {ol.Feature} Feature. */ -ol.format.XMLFeature.prototype.readFeatureFromNode = function(node, opt_options) { +_ol_format_XMLFeature_.prototype.readFeatureFromNode = function(node, opt_options) { return null; // not implemented }; @@ -85,14 +86,14 @@ ol.format.XMLFeature.prototype.readFeatureFromNode = function(node, opt_options) /** * @inheritDoc */ -ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) { - if (ol.xml.isDocument(source)) { +_ol_format_XMLFeature_.prototype.readFeatures = function(source, opt_options) { + if (_ol_xml_.isDocument(source)) { return this.readFeaturesFromDocument( /** @type {Document} */ (source), opt_options); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readFeaturesFromDocument(doc, opt_options); } else { return []; @@ -106,14 +107,14 @@ ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) { * @protected * @return {Array.} Features. */ -ol.format.XMLFeature.prototype.readFeaturesFromDocument = function( +_ol_format_XMLFeature_.prototype.readFeaturesFromDocument = function( doc, opt_options) { /** @type {Array.} */ var features = []; var n; for (n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { - ol.array.extend(features, this.readFeaturesFromNode(n, opt_options)); + _ol_array_.extend(features, this.readFeaturesFromNode(n, opt_options)); } } return features; @@ -127,20 +128,20 @@ ol.format.XMLFeature.prototype.readFeaturesFromDocument = function( * @protected * @return {Array.} Features. */ -ol.format.XMLFeature.prototype.readFeaturesFromNode = function(node, opt_options) {}; +_ol_format_XMLFeature_.prototype.readFeaturesFromNode = function(node, opt_options) {}; /** * @inheritDoc */ -ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) { - if (ol.xml.isDocument(source)) { +_ol_format_XMLFeature_.prototype.readGeometry = function(source, opt_options) { + if (_ol_xml_.isDocument(source)) { return this.readGeometryFromDocument( /** @type {Document} */ (source), opt_options); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readGeometryFromDocument(doc, opt_options); } else { return null; @@ -154,7 +155,7 @@ ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) { * @protected * @return {ol.geom.Geometry} Geometry. */ -ol.format.XMLFeature.prototype.readGeometryFromDocument = function(doc, opt_options) { +_ol_format_XMLFeature_.prototype.readGeometryFromDocument = function(doc, opt_options) { return null; // not implemented }; @@ -165,7 +166,7 @@ ol.format.XMLFeature.prototype.readGeometryFromDocument = function(doc, opt_opti * @protected * @return {ol.geom.Geometry} Geometry. */ -ol.format.XMLFeature.prototype.readGeometryFromNode = function(node, opt_options) { +_ol_format_XMLFeature_.prototype.readGeometryFromNode = function(node, opt_options) { return null; // not implemented }; @@ -173,13 +174,13 @@ ol.format.XMLFeature.prototype.readGeometryFromNode = function(node, opt_options /** * @inheritDoc */ -ol.format.XMLFeature.prototype.readProjection = function(source) { - if (ol.xml.isDocument(source)) { +_ol_format_XMLFeature_.prototype.readProjection = function(source) { + if (_ol_xml_.isDocument(source)) { return this.readProjectionFromDocument(/** @type {Document} */ (source)); - } else if (ol.xml.isNode(source)) { + } else if (_ol_xml_.isNode(source)) { return this.readProjectionFromNode(/** @type {Node} */ (source)); } else if (typeof source === 'string') { - var doc = ol.xml.parse(source); + var doc = _ol_xml_.parse(source); return this.readProjectionFromDocument(doc); } else { return null; @@ -192,7 +193,7 @@ ol.format.XMLFeature.prototype.readProjection = function(source) { * @protected * @return {ol.proj.Projection} Projection. */ -ol.format.XMLFeature.prototype.readProjectionFromDocument = function(doc) { +_ol_format_XMLFeature_.prototype.readProjectionFromDocument = function(doc) { return this.defaultDataProjection; }; @@ -202,7 +203,7 @@ ol.format.XMLFeature.prototype.readProjectionFromDocument = function(doc) { * @protected * @return {ol.proj.Projection} Projection. */ -ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) { +_ol_format_XMLFeature_.prototype.readProjectionFromNode = function(node) { return this.defaultDataProjection; }; @@ -210,7 +211,7 @@ ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) { /** * @inheritDoc */ -ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) { +_ol_format_XMLFeature_.prototype.writeFeature = function(feature, opt_options) { var node = this.writeFeatureNode(feature, opt_options); return this.xmlSerializer_.serializeToString(node); }; @@ -222,7 +223,7 @@ ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) { * @protected * @return {Node} Node. */ -ol.format.XMLFeature.prototype.writeFeatureNode = function(feature, opt_options) { +_ol_format_XMLFeature_.prototype.writeFeatureNode = function(feature, opt_options) { return null; // not implemented }; @@ -230,7 +231,7 @@ ol.format.XMLFeature.prototype.writeFeatureNode = function(feature, opt_options) /** * @inheritDoc */ -ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) { +_ol_format_XMLFeature_.prototype.writeFeatures = function(features, opt_options) { var node = this.writeFeaturesNode(features, opt_options); return this.xmlSerializer_.serializeToString(node); }; @@ -241,7 +242,7 @@ ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) { * @param {olx.format.WriteOptions=} opt_options Options. * @return {Node} Node. */ -ol.format.XMLFeature.prototype.writeFeaturesNode = function(features, opt_options) { +_ol_format_XMLFeature_.prototype.writeFeaturesNode = function(features, opt_options) { return null; // not implemented }; @@ -249,7 +250,7 @@ ol.format.XMLFeature.prototype.writeFeaturesNode = function(features, opt_option /** * @inheritDoc */ -ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) { +_ol_format_XMLFeature_.prototype.writeGeometry = function(geometry, opt_options) { var node = this.writeGeometryNode(geometry, opt_options); return this.xmlSerializer_.serializeToString(node); }; @@ -260,6 +261,7 @@ ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) { * @param {olx.format.WriteOptions=} opt_options Options. * @return {Node} Node. */ -ol.format.XMLFeature.prototype.writeGeometryNode = function(geometry, opt_options) { +_ol_format_XMLFeature_.prototype.writeGeometryNode = function(geometry, opt_options) { return null; // not implemented }; +export default _ol_format_XMLFeature_; diff --git a/src/ol/format/XSD.js b/src/ol/format/XSD.js index a3abdb64f7..e93c1ae933 100644 --- a/src/ol/format/XSD.js +++ b/src/ol/format/XSD.js @@ -1,23 +1,25 @@ -goog.provide('ol.format.XSD'); - -goog.require('ol.xml'); -goog.require('ol.string'); +/** + * @module ol/format/XSD + */ +import _ol_xml_ from '../xml.js'; +import _ol_string_ from '../string.js'; +var _ol_format_XSD_ = {}; /** * @const * @type {string} */ -ol.format.XSD.NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema'; +_ol_format_XSD_.NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema'; /** * @param {Node} node Node. * @return {boolean|undefined} Boolean. */ -ol.format.XSD.readBoolean = function(node) { - var s = ol.xml.getAllTextContent(node, false); - return ol.format.XSD.readBooleanString(s); +_ol_format_XSD_.readBoolean = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); + return _ol_format_XSD_.readBooleanString(s); }; @@ -25,7 +27,7 @@ ol.format.XSD.readBoolean = function(node) { * @param {string} string String. * @return {boolean|undefined} Boolean. */ -ol.format.XSD.readBooleanString = function(string) { +_ol_format_XSD_.readBooleanString = function(string) { var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); if (m) { return m[1] !== undefined || false; @@ -39,8 +41,8 @@ ol.format.XSD.readBooleanString = function(string) { * @param {Node} node Node. * @return {number|undefined} DateTime in seconds. */ -ol.format.XSD.readDateTime = function(node) { - var s = ol.xml.getAllTextContent(node, false); +_ol_format_XSD_.readDateTime = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); var dateTime = Date.parse(s); return isNaN(dateTime) ? undefined : dateTime / 1000; }; @@ -50,9 +52,9 @@ ol.format.XSD.readDateTime = function(node) { * @param {Node} node Node. * @return {number|undefined} Decimal. */ -ol.format.XSD.readDecimal = function(node) { - var s = ol.xml.getAllTextContent(node, false); - return ol.format.XSD.readDecimalString(s); +_ol_format_XSD_.readDecimal = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); + return _ol_format_XSD_.readDecimalString(s); }; @@ -60,7 +62,7 @@ ol.format.XSD.readDecimal = function(node) { * @param {string} string String. * @return {number|undefined} Decimal. */ -ol.format.XSD.readDecimalString = function(string) { +_ol_format_XSD_.readDecimalString = function(string) { // FIXME check spec var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string); if (m) { @@ -75,9 +77,9 @@ ol.format.XSD.readDecimalString = function(string) { * @param {Node} node Node. * @return {number|undefined} Non negative integer. */ -ol.format.XSD.readNonNegativeInteger = function(node) { - var s = ol.xml.getAllTextContent(node, false); - return ol.format.XSD.readNonNegativeIntegerString(s); +_ol_format_XSD_.readNonNegativeInteger = function(node) { + var s = _ol_xml_.getAllTextContent(node, false); + return _ol_format_XSD_.readNonNegativeIntegerString(s); }; @@ -85,7 +87,7 @@ ol.format.XSD.readNonNegativeInteger = function(node) { * @param {string} string String. * @return {number|undefined} Non negative integer. */ -ol.format.XSD.readNonNegativeIntegerString = function(string) { +_ol_format_XSD_.readNonNegativeIntegerString = function(string) { var m = /^\s*(\d+)\s*$/.exec(string); if (m) { return parseInt(m[1], 10); @@ -99,8 +101,8 @@ ol.format.XSD.readNonNegativeIntegerString = function(string) { * @param {Node} node Node. * @return {string|undefined} String. */ -ol.format.XSD.readString = function(node) { - return ol.xml.getAllTextContent(node, false).trim(); +_ol_format_XSD_.readString = function(node) { + return _ol_xml_.getAllTextContent(node, false).trim(); }; @@ -108,8 +110,8 @@ ol.format.XSD.readString = function(node) { * @param {Node} node Node to append a TextNode with the boolean to. * @param {boolean} bool Boolean. */ -ol.format.XSD.writeBooleanTextNode = function(node, bool) { - ol.format.XSD.writeStringTextNode(node, (bool) ? '1' : '0'); +_ol_format_XSD_.writeBooleanTextNode = function(node, bool) { + _ol_format_XSD_.writeStringTextNode(node, (bool) ? '1' : '0'); }; @@ -117,8 +119,8 @@ ol.format.XSD.writeBooleanTextNode = function(node, bool) { * @param {Node} node Node to append a CDATA Section with the string to. * @param {string} string String. */ -ol.format.XSD.writeCDATASection = function(node, string) { - node.appendChild(ol.xml.DOCUMENT.createCDATASection(string)); +_ol_format_XSD_.writeCDATASection = function(node, string) { + node.appendChild(_ol_xml_.DOCUMENT.createCDATASection(string)); }; @@ -126,15 +128,15 @@ ol.format.XSD.writeCDATASection = function(node, string) { * @param {Node} node Node to append a TextNode with the dateTime to. * @param {number} dateTime DateTime in seconds. */ -ol.format.XSD.writeDateTimeTextNode = function(node, dateTime) { +_ol_format_XSD_.writeDateTimeTextNode = function(node, dateTime) { var date = new Date(dateTime * 1000); var string = date.getUTCFullYear() + '-' + - ol.string.padNumber(date.getUTCMonth() + 1, 2) + '-' + - ol.string.padNumber(date.getUTCDate(), 2) + 'T' + - ol.string.padNumber(date.getUTCHours(), 2) + ':' + - ol.string.padNumber(date.getUTCMinutes(), 2) + ':' + - ol.string.padNumber(date.getUTCSeconds(), 2) + 'Z'; - node.appendChild(ol.xml.DOCUMENT.createTextNode(string)); + _ol_string_.padNumber(date.getUTCMonth() + 1, 2) + '-' + + _ol_string_.padNumber(date.getUTCDate(), 2) + 'T' + + _ol_string_.padNumber(date.getUTCHours(), 2) + ':' + + _ol_string_.padNumber(date.getUTCMinutes(), 2) + ':' + + _ol_string_.padNumber(date.getUTCSeconds(), 2) + 'Z'; + node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string)); }; @@ -142,9 +144,9 @@ ol.format.XSD.writeDateTimeTextNode = function(node, dateTime) { * @param {Node} node Node to append a TextNode with the decimal to. * @param {number} decimal Decimal. */ -ol.format.XSD.writeDecimalTextNode = function(node, decimal) { +_ol_format_XSD_.writeDecimalTextNode = function(node, decimal) { var string = decimal.toPrecision(); - node.appendChild(ol.xml.DOCUMENT.createTextNode(string)); + node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string)); }; @@ -152,9 +154,9 @@ ol.format.XSD.writeDecimalTextNode = function(node, decimal) { * @param {Node} node Node to append a TextNode with the decimal to. * @param {number} nonNegativeInteger Non negative integer. */ -ol.format.XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) { +_ol_format_XSD_.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) { var string = nonNegativeInteger.toString(); - node.appendChild(ol.xml.DOCUMENT.createTextNode(string)); + node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string)); }; @@ -162,6 +164,7 @@ ol.format.XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeIntege * @param {Node} node Node to append a TextNode with the string to. * @param {string} string String. */ -ol.format.XSD.writeStringTextNode = function(node, string) { - node.appendChild(ol.xml.DOCUMENT.createTextNode(string)); +_ol_format_XSD_.writeStringTextNode = function(node, string) { + node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string)); }; +export default _ol_format_XSD_; diff --git a/src/ol/format/filter.js b/src/ol/format/filter.js index de855e9ef8..f67492f7bd 100644 --- a/src/ol/format/filter.js +++ b/src/ol/format/filter.js @@ -1,22 +1,24 @@ -goog.provide('ol.format.filter'); - -goog.require('ol.format.filter.And'); -goog.require('ol.format.filter.Bbox'); -goog.require('ol.format.filter.Contains'); -goog.require('ol.format.filter.During'); -goog.require('ol.format.filter.EqualTo'); -goog.require('ol.format.filter.GreaterThan'); -goog.require('ol.format.filter.GreaterThanOrEqualTo'); -goog.require('ol.format.filter.Intersects'); -goog.require('ol.format.filter.IsBetween'); -goog.require('ol.format.filter.IsLike'); -goog.require('ol.format.filter.IsNull'); -goog.require('ol.format.filter.LessThan'); -goog.require('ol.format.filter.LessThanOrEqualTo'); -goog.require('ol.format.filter.Not'); -goog.require('ol.format.filter.NotEqualTo'); -goog.require('ol.format.filter.Or'); -goog.require('ol.format.filter.Within'); +/** + * @module ol/format/filter + */ +import _ol_format_filter_And_ from '../format/filter/And.js'; +import _ol_format_filter_Bbox_ from '../format/filter/Bbox.js'; +import _ol_format_filter_Contains_ from '../format/filter/Contains.js'; +import _ol_format_filter_During_ from '../format/filter/During.js'; +import _ol_format_filter_EqualTo_ from '../format/filter/EqualTo.js'; +import _ol_format_filter_GreaterThan_ from '../format/filter/GreaterThan.js'; +import _ol_format_filter_GreaterThanOrEqualTo_ from '../format/filter/GreaterThanOrEqualTo.js'; +import _ol_format_filter_Intersects_ from '../format/filter/Intersects.js'; +import _ol_format_filter_IsBetween_ from '../format/filter/IsBetween.js'; +import _ol_format_filter_IsLike_ from '../format/filter/IsLike.js'; +import _ol_format_filter_IsNull_ from '../format/filter/IsNull.js'; +import _ol_format_filter_LessThan_ from '../format/filter/LessThan.js'; +import _ol_format_filter_LessThanOrEqualTo_ from '../format/filter/LessThanOrEqualTo.js'; +import _ol_format_filter_Not_ from '../format/filter/Not.js'; +import _ol_format_filter_NotEqualTo_ from '../format/filter/NotEqualTo.js'; +import _ol_format_filter_Or_ from '../format/filter/Or.js'; +import _ol_format_filter_Within_ from '../format/filter/Within.js'; +var _ol_format_filter_ = {}; /** @@ -26,9 +28,9 @@ goog.require('ol.format.filter.Within'); * @returns {!ol.format.filter.And} `` operator. * @api */ -ol.format.filter.and = function(conditions) { +_ol_format_filter_.and = function(conditions) { var params = [null].concat(Array.prototype.slice.call(arguments)); - return new (Function.prototype.bind.apply(ol.format.filter.And, params)); + return new (Function.prototype.bind.apply(_ol_format_filter_And_, params)); }; @@ -39,9 +41,9 @@ ol.format.filter.and = function(conditions) { * @returns {!ol.format.filter.Or} `` operator. * @api */ -ol.format.filter.or = function(conditions) { +_ol_format_filter_.or = function(conditions) { var params = [null].concat(Array.prototype.slice.call(arguments)); - return new (Function.prototype.bind.apply(ol.format.filter.Or, params)); + return new (Function.prototype.bind.apply(_ol_format_filter_Or_, params)); }; @@ -52,8 +54,8 @@ ol.format.filter.or = function(conditions) { * @returns {!ol.format.filter.Not} `` operator. * @api */ -ol.format.filter.not = function(condition) { - return new ol.format.filter.Not(condition); +_ol_format_filter_.not = function(condition) { + return new _ol_format_filter_Not_(condition); }; @@ -68,8 +70,8 @@ ol.format.filter.not = function(condition) { * @returns {!ol.format.filter.Bbox} `` operator. * @api */ -ol.format.filter.bbox = function(geometryName, extent, opt_srsName) { - return new ol.format.filter.Bbox(geometryName, extent, opt_srsName); +_ol_format_filter_.bbox = function(geometryName, extent, opt_srsName) { + return new _ol_format_filter_Bbox_(geometryName, extent, opt_srsName); }; /** @@ -83,8 +85,8 @@ ol.format.filter.bbox = function(geometryName, extent, opt_srsName) { * @returns {!ol.format.filter.Contains} `` operator. * @api */ -ol.format.filter.contains = function(geometryName, geometry, opt_srsName) { - return new ol.format.filter.Contains(geometryName, geometry, opt_srsName); +_ol_format_filter_.contains = function(geometryName, geometry, opt_srsName) { + return new _ol_format_filter_Contains_(geometryName, geometry, opt_srsName); }; /** @@ -98,8 +100,8 @@ ol.format.filter.contains = function(geometryName, geometry, opt_srsName) { * @returns {!ol.format.filter.Intersects} `` operator. * @api */ -ol.format.filter.intersects = function(geometryName, geometry, opt_srsName) { - return new ol.format.filter.Intersects(geometryName, geometry, opt_srsName); +_ol_format_filter_.intersects = function(geometryName, geometry, opt_srsName) { + return new _ol_format_filter_Intersects_(geometryName, geometry, opt_srsName); }; /** @@ -113,8 +115,8 @@ ol.format.filter.intersects = function(geometryName, geometry, opt_srsName) { * @returns {!ol.format.filter.Within} `` operator. * @api */ -ol.format.filter.within = function(geometryName, geometry, opt_srsName) { - return new ol.format.filter.Within(geometryName, geometry, opt_srsName); +_ol_format_filter_.within = function(geometryName, geometry, opt_srsName) { + return new _ol_format_filter_Within_(geometryName, geometry, opt_srsName); }; @@ -127,8 +129,8 @@ ol.format.filter.within = function(geometryName, geometry, opt_srsName) { * @returns {!ol.format.filter.EqualTo} `` operator. * @api */ -ol.format.filter.equalTo = function(propertyName, expression, opt_matchCase) { - return new ol.format.filter.EqualTo(propertyName, expression, opt_matchCase); +_ol_format_filter_.equalTo = function(propertyName, expression, opt_matchCase) { + return new _ol_format_filter_EqualTo_(propertyName, expression, opt_matchCase); }; @@ -141,8 +143,8 @@ ol.format.filter.equalTo = function(propertyName, expression, opt_matchCase) { * @returns {!ol.format.filter.NotEqualTo} `` operator. * @api */ -ol.format.filter.notEqualTo = function(propertyName, expression, opt_matchCase) { - return new ol.format.filter.NotEqualTo(propertyName, expression, opt_matchCase); +_ol_format_filter_.notEqualTo = function(propertyName, expression, opt_matchCase) { + return new _ol_format_filter_NotEqualTo_(propertyName, expression, opt_matchCase); }; @@ -154,8 +156,8 @@ ol.format.filter.notEqualTo = function(propertyName, expression, opt_matchCase) * @returns {!ol.format.filter.LessThan} `` operator. * @api */ -ol.format.filter.lessThan = function(propertyName, expression) { - return new ol.format.filter.LessThan(propertyName, expression); +_ol_format_filter_.lessThan = function(propertyName, expression) { + return new _ol_format_filter_LessThan_(propertyName, expression); }; @@ -167,8 +169,8 @@ ol.format.filter.lessThan = function(propertyName, expression) { * @returns {!ol.format.filter.LessThanOrEqualTo} `` operator. * @api */ -ol.format.filter.lessThanOrEqualTo = function(propertyName, expression) { - return new ol.format.filter.LessThanOrEqualTo(propertyName, expression); +_ol_format_filter_.lessThanOrEqualTo = function(propertyName, expression) { + return new _ol_format_filter_LessThanOrEqualTo_(propertyName, expression); }; @@ -180,8 +182,8 @@ ol.format.filter.lessThanOrEqualTo = function(propertyName, expression) { * @returns {!ol.format.filter.GreaterThan} `` operator. * @api */ -ol.format.filter.greaterThan = function(propertyName, expression) { - return new ol.format.filter.GreaterThan(propertyName, expression); +_ol_format_filter_.greaterThan = function(propertyName, expression) { + return new _ol_format_filter_GreaterThan_(propertyName, expression); }; @@ -193,8 +195,8 @@ ol.format.filter.greaterThan = function(propertyName, expression) { * @returns {!ol.format.filter.GreaterThanOrEqualTo} `` operator. * @api */ -ol.format.filter.greaterThanOrEqualTo = function(propertyName, expression) { - return new ol.format.filter.GreaterThanOrEqualTo(propertyName, expression); +_ol_format_filter_.greaterThanOrEqualTo = function(propertyName, expression) { + return new _ol_format_filter_GreaterThanOrEqualTo_(propertyName, expression); }; @@ -206,8 +208,8 @@ ol.format.filter.greaterThanOrEqualTo = function(propertyName, expression) { * @returns {!ol.format.filter.IsNull} `` operator. * @api */ -ol.format.filter.isNull = function(propertyName) { - return new ol.format.filter.IsNull(propertyName); +_ol_format_filter_.isNull = function(propertyName) { + return new _ol_format_filter_IsNull_(propertyName); }; @@ -221,8 +223,8 @@ ol.format.filter.isNull = function(propertyName) { * @returns {!ol.format.filter.IsBetween} `` operator. * @api */ -ol.format.filter.between = function(propertyName, lowerBoundary, upperBoundary) { - return new ol.format.filter.IsBetween(propertyName, lowerBoundary, upperBoundary); +_ol_format_filter_.between = function(propertyName, lowerBoundary, upperBoundary) { + return new _ol_format_filter_IsBetween_(propertyName, lowerBoundary, upperBoundary); }; @@ -242,9 +244,9 @@ ol.format.filter.between = function(propertyName, lowerBoundary, upperBoundary) * @returns {!ol.format.filter.IsLike} `` operator. * @api */ -ol.format.filter.like = function(propertyName, pattern, +_ol_format_filter_.like = function(propertyName, pattern, opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) { - return new ol.format.filter.IsLike(propertyName, pattern, + return new _ol_format_filter_IsLike_(propertyName, pattern, opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase); }; @@ -258,6 +260,7 @@ ol.format.filter.like = function(propertyName, pattern, * @returns {!ol.format.filter.During} `` operator. * @api */ -ol.format.filter.during = function(propertyName, begin, end) { - return new ol.format.filter.During(propertyName, begin, end); +_ol_format_filter_.during = function(propertyName, begin, end) { + return new _ol_format_filter_During_(propertyName, begin, end); }; +export default _ol_format_filter_; diff --git a/src/ol/format/filter/And.js b/src/ol/format/filter/And.js index 0a23faca86..f73ddba39f 100644 --- a/src/ol/format/filter/And.js +++ b/src/ol/format/filter/And.js @@ -1,7 +1,8 @@ -goog.provide('ol.format.filter.And'); - -goog.require('ol'); -goog.require('ol.format.filter.LogicalNary'); +/** + * @module ol/format/filter/And + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_LogicalNary_ from '../filter/LogicalNary.js'; /** * @classdesc @@ -15,8 +16,10 @@ goog.require('ol.format.filter.LogicalNary'); * @extends {ol.format.filter.LogicalNary} * @api */ -ol.format.filter.And = function(conditions) { +var _ol_format_filter_And_ = function(conditions) { var params = ['And'].concat(Array.prototype.slice.call(arguments)); - ol.format.filter.LogicalNary.apply(this, params); + _ol_format_filter_LogicalNary_.apply(this, params); }; -ol.inherits(ol.format.filter.And, ol.format.filter.LogicalNary); + +_ol_.inherits(_ol_format_filter_And_, _ol_format_filter_LogicalNary_); +export default _ol_format_filter_And_; diff --git a/src/ol/format/filter/Bbox.js b/src/ol/format/filter/Bbox.js index adde43c1b4..2c2c2428d6 100644 --- a/src/ol/format/filter/Bbox.js +++ b/src/ol/format/filter/Bbox.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Bbox'); - -goog.require('ol'); -goog.require('ol.format.filter.Filter'); - +/** + * @module ol/format/filter/Bbox + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Filter_ from '../filter/Filter.js'; /** * @classdesc @@ -17,9 +17,9 @@ goog.require('ol.format.filter.Filter'); * @extends {ol.format.filter.Filter} * @api */ -ol.format.filter.Bbox = function(geometryName, extent, opt_srsName) { +var _ol_format_filter_Bbox_ = function(geometryName, extent, opt_srsName) { - ol.format.filter.Filter.call(this, 'BBOX'); + _ol_format_filter_Filter_.call(this, 'BBOX'); /** * @public @@ -39,4 +39,6 @@ ol.format.filter.Bbox = function(geometryName, extent, opt_srsName) { */ this.srsName = opt_srsName; }; -ol.inherits(ol.format.filter.Bbox, ol.format.filter.Filter); + +_ol_.inherits(_ol_format_filter_Bbox_, _ol_format_filter_Filter_); +export default _ol_format_filter_Bbox_; diff --git a/src/ol/format/filter/Comparison.js b/src/ol/format/filter/Comparison.js index e3724036c8..073eac22f4 100644 --- a/src/ol/format/filter/Comparison.js +++ b/src/ol/format/filter/Comparison.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Comparison'); - -goog.require('ol'); -goog.require('ol.format.filter.Filter'); - +/** + * @module ol/format/filter/Comparison + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Filter_ from '../filter/Filter.js'; /** * @classdesc @@ -18,9 +18,9 @@ goog.require('ol.format.filter.Filter'); * @extends {ol.format.filter.Filter} * @api */ -ol.format.filter.Comparison = function(tagName, propertyName) { +var _ol_format_filter_Comparison_ = function(tagName, propertyName) { - ol.format.filter.Filter.call(this, tagName); + _ol_format_filter_Filter_.call(this, tagName); /** * @public @@ -28,4 +28,6 @@ ol.format.filter.Comparison = function(tagName, propertyName) { */ this.propertyName = propertyName; }; -ol.inherits(ol.format.filter.Comparison, ol.format.filter.Filter); + +_ol_.inherits(_ol_format_filter_Comparison_, _ol_format_filter_Filter_); +export default _ol_format_filter_Comparison_; diff --git a/src/ol/format/filter/ComparisonBinary.js b/src/ol/format/filter/ComparisonBinary.js index 3ab5c67992..415c145988 100644 --- a/src/ol/format/filter/ComparisonBinary.js +++ b/src/ol/format/filter/ComparisonBinary.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.ComparisonBinary'); - -goog.require('ol'); -goog.require('ol.format.filter.Comparison'); - +/** + * @module ol/format/filter/ComparisonBinary + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; /** * @classdesc @@ -20,10 +20,10 @@ goog.require('ol.format.filter.Comparison'); * @extends {ol.format.filter.Comparison} * @api */ -ol.format.filter.ComparisonBinary = function( +var _ol_format_filter_ComparisonBinary_ = function( tagName, propertyName, expression, opt_matchCase) { - ol.format.filter.Comparison.call(this, tagName, propertyName); + _ol_format_filter_Comparison_.call(this, tagName, propertyName); /** * @public @@ -37,4 +37,6 @@ ol.format.filter.ComparisonBinary = function( */ this.matchCase = opt_matchCase; }; -ol.inherits(ol.format.filter.ComparisonBinary, ol.format.filter.Comparison); + +_ol_.inherits(_ol_format_filter_ComparisonBinary_, _ol_format_filter_Comparison_); +export default _ol_format_filter_ComparisonBinary_; diff --git a/src/ol/format/filter/Contains.js b/src/ol/format/filter/Contains.js index dcfdaf4910..4ac3acafbd 100644 --- a/src/ol/format/filter/Contains.js +++ b/src/ol/format/filter/Contains.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Contains'); - -goog.require('ol'); -goog.require('ol.format.filter.Spatial'); - +/** + * @module ol/format/filter/Contains + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Spatial_ from '../filter/Spatial.js'; /** * @classdesc @@ -17,9 +17,11 @@ goog.require('ol.format.filter.Spatial'); * @extends {ol.format.filter.Spatial} * @api */ -ol.format.filter.Contains = function(geometryName, geometry, opt_srsName) { +var _ol_format_filter_Contains_ = function(geometryName, geometry, opt_srsName) { - ol.format.filter.Spatial.call(this, 'Contains', geometryName, geometry, opt_srsName); + _ol_format_filter_Spatial_.call(this, 'Contains', geometryName, geometry, opt_srsName); }; -ol.inherits(ol.format.filter.Contains, ol.format.filter.Spatial); + +_ol_.inherits(_ol_format_filter_Contains_, _ol_format_filter_Spatial_); +export default _ol_format_filter_Contains_; diff --git a/src/ol/format/filter/During.js b/src/ol/format/filter/During.js index 81c70c889f..4536ec25f2 100644 --- a/src/ol/format/filter/During.js +++ b/src/ol/format/filter/During.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.During'); - -goog.require('ol'); -goog.require('ol.format.filter.Comparison'); - +/** + * @module ol/format/filter/During + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; /** * @classdesc @@ -15,8 +15,8 @@ goog.require('ol.format.filter.Comparison'); * @extends {ol.format.filter.Comparison} * @api */ -ol.format.filter.During = function(propertyName, begin, end) { - ol.format.filter.Comparison.call(this, 'During', propertyName); +var _ol_format_filter_During_ = function(propertyName, begin, end) { + _ol_format_filter_Comparison_.call(this, 'During', propertyName); /** * @public @@ -30,4 +30,6 @@ ol.format.filter.During = function(propertyName, begin, end) { */ this.end = end; }; -ol.inherits(ol.format.filter.During, ol.format.filter.Comparison); + +_ol_.inherits(_ol_format_filter_During_, _ol_format_filter_Comparison_); +export default _ol_format_filter_During_; diff --git a/src/ol/format/filter/EqualTo.js b/src/ol/format/filter/EqualTo.js index 5e1bc3dc02..f26fff30e1 100644 --- a/src/ol/format/filter/EqualTo.js +++ b/src/ol/format/filter/EqualTo.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.EqualTo'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/EqualTo + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -15,7 +15,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.EqualTo = function(propertyName, expression, opt_matchCase) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsEqualTo', propertyName, expression, opt_matchCase); +var _ol_format_filter_EqualTo_ = function(propertyName, expression, opt_matchCase) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsEqualTo', propertyName, expression, opt_matchCase); }; -ol.inherits(ol.format.filter.EqualTo, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_EqualTo_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_EqualTo_; diff --git a/src/ol/format/filter/Filter.js b/src/ol/format/filter/Filter.js index 7f21c3f0d4..717fdc92be 100644 --- a/src/ol/format/filter/Filter.js +++ b/src/ol/format/filter/Filter.js @@ -1,6 +1,6 @@ -goog.provide('ol.format.filter.Filter'); - - +/** + * @module ol/format/filter/Filter + */ /** * @classdesc * Abstract class; normally only used for creating subclasses and not instantiated in apps. @@ -14,7 +14,7 @@ goog.provide('ol.format.filter.Filter'); * @struct * @api */ -ol.format.filter.Filter = function(tagName) { +var _ol_format_filter_Filter_ = function(tagName) { /** * @private @@ -27,6 +27,7 @@ ol.format.filter.Filter = function(tagName) { * The XML tag name for a filter. * @returns {!string} Name. */ -ol.format.filter.Filter.prototype.getTagName = function() { +_ol_format_filter_Filter_.prototype.getTagName = function() { return this.tagName_; }; +export default _ol_format_filter_Filter_; diff --git a/src/ol/format/filter/GreaterThan.js b/src/ol/format/filter/GreaterThan.js index c7306f5e4f..3cd1c92845 100644 --- a/src/ol/format/filter/GreaterThan.js +++ b/src/ol/format/filter/GreaterThan.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.GreaterThan'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/GreaterThan + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -14,7 +14,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.GreaterThan = function(propertyName, expression) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThan', propertyName, expression); +var _ol_format_filter_GreaterThan_ = function(propertyName, expression) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsGreaterThan', propertyName, expression); }; -ol.inherits(ol.format.filter.GreaterThan, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_GreaterThan_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_GreaterThan_; diff --git a/src/ol/format/filter/GreaterThanOrEqualTo.js b/src/ol/format/filter/GreaterThanOrEqualTo.js index 2105415ec2..e62881fa8d 100644 --- a/src/ol/format/filter/GreaterThanOrEqualTo.js +++ b/src/ol/format/filter/GreaterThanOrEqualTo.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.GreaterThanOrEqualTo'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/GreaterThanOrEqualTo + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -14,7 +14,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.GreaterThanOrEqualTo = function(propertyName, expression) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThanOrEqualTo', propertyName, expression); +var _ol_format_filter_GreaterThanOrEqualTo_ = function(propertyName, expression) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsGreaterThanOrEqualTo', propertyName, expression); }; -ol.inherits(ol.format.filter.GreaterThanOrEqualTo, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_GreaterThanOrEqualTo_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_GreaterThanOrEqualTo_; diff --git a/src/ol/format/filter/Intersects.js b/src/ol/format/filter/Intersects.js index 774868b1b2..697c893182 100644 --- a/src/ol/format/filter/Intersects.js +++ b/src/ol/format/filter/Intersects.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Intersects'); - -goog.require('ol'); -goog.require('ol.format.filter.Spatial'); - +/** + * @module ol/format/filter/Intersects + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Spatial_ from '../filter/Spatial.js'; /** * @classdesc @@ -17,9 +17,11 @@ goog.require('ol.format.filter.Spatial'); * @extends {ol.format.filter.Spatial} * @api */ -ol.format.filter.Intersects = function(geometryName, geometry, opt_srsName) { +var _ol_format_filter_Intersects_ = function(geometryName, geometry, opt_srsName) { - ol.format.filter.Spatial.call(this, 'Intersects', geometryName, geometry, opt_srsName); + _ol_format_filter_Spatial_.call(this, 'Intersects', geometryName, geometry, opt_srsName); }; -ol.inherits(ol.format.filter.Intersects, ol.format.filter.Spatial); + +_ol_.inherits(_ol_format_filter_Intersects_, _ol_format_filter_Spatial_); +export default _ol_format_filter_Intersects_; diff --git a/src/ol/format/filter/IsBetween.js b/src/ol/format/filter/IsBetween.js index 2421a1d003..5457fea6aa 100644 --- a/src/ol/format/filter/IsBetween.js +++ b/src/ol/format/filter/IsBetween.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.IsBetween'); - -goog.require('ol'); -goog.require('ol.format.filter.Comparison'); - +/** + * @module ol/format/filter/IsBetween + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; /** * @classdesc @@ -15,8 +15,8 @@ goog.require('ol.format.filter.Comparison'); * @extends {ol.format.filter.Comparison} * @api */ -ol.format.filter.IsBetween = function(propertyName, lowerBoundary, upperBoundary) { - ol.format.filter.Comparison.call(this, 'PropertyIsBetween', propertyName); +var _ol_format_filter_IsBetween_ = function(propertyName, lowerBoundary, upperBoundary) { + _ol_format_filter_Comparison_.call(this, 'PropertyIsBetween', propertyName); /** * @public @@ -30,4 +30,6 @@ ol.format.filter.IsBetween = function(propertyName, lowerBoundary, upperBoundary */ this.upperBoundary = upperBoundary; }; -ol.inherits(ol.format.filter.IsBetween, ol.format.filter.Comparison); + +_ol_.inherits(_ol_format_filter_IsBetween_, _ol_format_filter_Comparison_); +export default _ol_format_filter_IsBetween_; diff --git a/src/ol/format/filter/IsLike.js b/src/ol/format/filter/IsLike.js index 7b64050520..b27dc4dde3 100644 --- a/src/ol/format/filter/IsLike.js +++ b/src/ol/format/filter/IsLike.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.IsLike'); - -goog.require('ol'); -goog.require('ol.format.filter.Comparison'); - +/** + * @module ol/format/filter/IsLike + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; /** * @classdesc @@ -21,9 +21,9 @@ goog.require('ol.format.filter.Comparison'); * @extends {ol.format.filter.Comparison} * @api */ -ol.format.filter.IsLike = function(propertyName, pattern, +var _ol_format_filter_IsLike_ = function(propertyName, pattern, opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) { - ol.format.filter.Comparison.call(this, 'PropertyIsLike', propertyName); + _ol_format_filter_Comparison_.call(this, 'PropertyIsLike', propertyName); /** * @public @@ -55,4 +55,6 @@ ol.format.filter.IsLike = function(propertyName, pattern, */ this.matchCase = opt_matchCase; }; -ol.inherits(ol.format.filter.IsLike, ol.format.filter.Comparison); + +_ol_.inherits(_ol_format_filter_IsLike_, _ol_format_filter_Comparison_); +export default _ol_format_filter_IsLike_; diff --git a/src/ol/format/filter/IsNull.js b/src/ol/format/filter/IsNull.js index 42ac132d86..af025ac72c 100644 --- a/src/ol/format/filter/IsNull.js +++ b/src/ol/format/filter/IsNull.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.IsNull'); - -goog.require('ol'); -goog.require('ol.format.filter.Comparison'); - +/** + * @module ol/format/filter/IsNull + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Comparison_ from '../filter/Comparison.js'; /** * @classdesc @@ -13,7 +13,9 @@ goog.require('ol.format.filter.Comparison'); * @extends {ol.format.filter.Comparison} * @api */ -ol.format.filter.IsNull = function(propertyName) { - ol.format.filter.Comparison.call(this, 'PropertyIsNull', propertyName); +var _ol_format_filter_IsNull_ = function(propertyName) { + _ol_format_filter_Comparison_.call(this, 'PropertyIsNull', propertyName); }; -ol.inherits(ol.format.filter.IsNull, ol.format.filter.Comparison); + +_ol_.inherits(_ol_format_filter_IsNull_, _ol_format_filter_Comparison_); +export default _ol_format_filter_IsNull_; diff --git a/src/ol/format/filter/LessThan.js b/src/ol/format/filter/LessThan.js index 8d02359674..d13005be8f 100644 --- a/src/ol/format/filter/LessThan.js +++ b/src/ol/format/filter/LessThan.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.LessThan'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/LessThan + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -14,7 +14,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.LessThan = function(propertyName, expression) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsLessThan', propertyName, expression); +var _ol_format_filter_LessThan_ = function(propertyName, expression) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsLessThan', propertyName, expression); }; -ol.inherits(ol.format.filter.LessThan, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_LessThan_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_LessThan_; diff --git a/src/ol/format/filter/LessThanOrEqualTo.js b/src/ol/format/filter/LessThanOrEqualTo.js index 24fce9c499..c7b9c52861 100644 --- a/src/ol/format/filter/LessThanOrEqualTo.js +++ b/src/ol/format/filter/LessThanOrEqualTo.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.LessThanOrEqualTo'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/LessThanOrEqualTo + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -14,7 +14,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.LessThanOrEqualTo = function(propertyName, expression) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsLessThanOrEqualTo', propertyName, expression); +var _ol_format_filter_LessThanOrEqualTo_ = function(propertyName, expression) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsLessThanOrEqualTo', propertyName, expression); }; -ol.inherits(ol.format.filter.LessThanOrEqualTo, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_LessThanOrEqualTo_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_LessThanOrEqualTo_; diff --git a/src/ol/format/filter/LogicalNary.js b/src/ol/format/filter/LogicalNary.js index 748bb8f6af..b6d4322597 100644 --- a/src/ol/format/filter/LogicalNary.js +++ b/src/ol/format/filter/LogicalNary.js @@ -1,9 +1,9 @@ -goog.provide('ol.format.filter.LogicalNary'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.format.filter.Filter'); - +/** + * @module ol/format/filter/LogicalNary + */ +import _ol_ from '../../index.js'; +import _ol_asserts_ from '../../asserts.js'; +import _ol_format_filter_Filter_ from '../filter/Filter.js'; /** * @classdesc @@ -16,15 +16,17 @@ goog.require('ol.format.filter.Filter'); * @param {...ol.format.filter.Filter} conditions Conditions. * @extends {ol.format.filter.Filter} */ -ol.format.filter.LogicalNary = function(tagName, conditions) { +var _ol_format_filter_LogicalNary_ = function(tagName, conditions) { - ol.format.filter.Filter.call(this, tagName); + _ol_format_filter_Filter_.call(this, tagName); /** * @public * @type {Array.} */ this.conditions = Array.prototype.slice.call(arguments, 1); - ol.asserts.assert(this.conditions.length >= 2, 57); // At least 2 conditions are required. + _ol_asserts_.assert(this.conditions.length >= 2, 57); // At least 2 conditions are required. }; -ol.inherits(ol.format.filter.LogicalNary, ol.format.filter.Filter); + +_ol_.inherits(_ol_format_filter_LogicalNary_, _ol_format_filter_Filter_); +export default _ol_format_filter_LogicalNary_; diff --git a/src/ol/format/filter/Not.js b/src/ol/format/filter/Not.js index e07f9f00e6..d9e5eb406a 100644 --- a/src/ol/format/filter/Not.js +++ b/src/ol/format/filter/Not.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Not'); - -goog.require('ol'); -goog.require('ol.format.filter.Filter'); - +/** + * @module ol/format/filter/Not + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Filter_ from '../filter/Filter.js'; /** * @classdesc @@ -13,9 +13,9 @@ goog.require('ol.format.filter.Filter'); * @extends {ol.format.filter.Filter} * @api */ -ol.format.filter.Not = function(condition) { +var _ol_format_filter_Not_ = function(condition) { - ol.format.filter.Filter.call(this, 'Not'); + _ol_format_filter_Filter_.call(this, 'Not'); /** * @public @@ -23,4 +23,6 @@ ol.format.filter.Not = function(condition) { */ this.condition = condition; }; -ol.inherits(ol.format.filter.Not, ol.format.filter.Filter); + +_ol_.inherits(_ol_format_filter_Not_, _ol_format_filter_Filter_); +export default _ol_format_filter_Not_; diff --git a/src/ol/format/filter/NotEqualTo.js b/src/ol/format/filter/NotEqualTo.js index a281326257..971dbb5213 100644 --- a/src/ol/format/filter/NotEqualTo.js +++ b/src/ol/format/filter/NotEqualTo.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.NotEqualTo'); - -goog.require('ol'); -goog.require('ol.format.filter.ComparisonBinary'); - +/** + * @module ol/format/filter/NotEqualTo + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_ComparisonBinary_ from '../filter/ComparisonBinary.js'; /** * @classdesc @@ -15,7 +15,9 @@ goog.require('ol.format.filter.ComparisonBinary'); * @extends {ol.format.filter.ComparisonBinary} * @api */ -ol.format.filter.NotEqualTo = function(propertyName, expression, opt_matchCase) { - ol.format.filter.ComparisonBinary.call(this, 'PropertyIsNotEqualTo', propertyName, expression, opt_matchCase); +var _ol_format_filter_NotEqualTo_ = function(propertyName, expression, opt_matchCase) { + _ol_format_filter_ComparisonBinary_.call(this, 'PropertyIsNotEqualTo', propertyName, expression, opt_matchCase); }; -ol.inherits(ol.format.filter.NotEqualTo, ol.format.filter.ComparisonBinary); + +_ol_.inherits(_ol_format_filter_NotEqualTo_, _ol_format_filter_ComparisonBinary_); +export default _ol_format_filter_NotEqualTo_; diff --git a/src/ol/format/filter/Or.js b/src/ol/format/filter/Or.js index 01f04600c1..71f3edacef 100644 --- a/src/ol/format/filter/Or.js +++ b/src/ol/format/filter/Or.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Or'); - -goog.require('ol'); -goog.require('ol.format.filter.LogicalNary'); - +/** + * @module ol/format/filter/Or + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_LogicalNary_ from '../filter/LogicalNary.js'; /** * @classdesc @@ -13,8 +13,10 @@ goog.require('ol.format.filter.LogicalNary'); * @extends {ol.format.filter.LogicalNary} * @api */ -ol.format.filter.Or = function(conditions) { +var _ol_format_filter_Or_ = function(conditions) { var params = ['Or'].concat(Array.prototype.slice.call(arguments)); - ol.format.filter.LogicalNary.apply(this, params); + _ol_format_filter_LogicalNary_.apply(this, params); }; -ol.inherits(ol.format.filter.Or, ol.format.filter.LogicalNary); + +_ol_.inherits(_ol_format_filter_Or_, _ol_format_filter_LogicalNary_); +export default _ol_format_filter_Or_; diff --git a/src/ol/format/filter/Spatial.js b/src/ol/format/filter/Spatial.js index b86ebc0e47..043da0dde7 100644 --- a/src/ol/format/filter/Spatial.js +++ b/src/ol/format/filter/Spatial.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Spatial'); - -goog.require('ol'); -goog.require('ol.format.filter.Filter'); - +/** + * @module ol/format/filter/Spatial + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Filter_ from '../filter/Filter.js'; /** * @classdesc @@ -22,9 +22,9 @@ goog.require('ol.format.filter.Filter'); * @extends {ol.format.filter.Filter} * @api */ -ol.format.filter.Spatial = function(tagName, geometryName, geometry, opt_srsName) { +var _ol_format_filter_Spatial_ = function(tagName, geometryName, geometry, opt_srsName) { - ol.format.filter.Filter.call(this, tagName); + _ol_format_filter_Filter_.call(this, tagName); /** * @public @@ -44,4 +44,6 @@ ol.format.filter.Spatial = function(tagName, geometryName, geometry, opt_srsName */ this.srsName = opt_srsName; }; -ol.inherits(ol.format.filter.Spatial, ol.format.filter.Filter); + +_ol_.inherits(_ol_format_filter_Spatial_, _ol_format_filter_Filter_); +export default _ol_format_filter_Spatial_; diff --git a/src/ol/format/filter/Within.js b/src/ol/format/filter/Within.js index aa698ec5ff..d84bff09cd 100644 --- a/src/ol/format/filter/Within.js +++ b/src/ol/format/filter/Within.js @@ -1,8 +1,8 @@ -goog.provide('ol.format.filter.Within'); - -goog.require('ol'); -goog.require('ol.format.filter.Spatial'); - +/** + * @module ol/format/filter/Within + */ +import _ol_ from '../../index.js'; +import _ol_format_filter_Spatial_ from '../filter/Spatial.js'; /** * @classdesc @@ -17,9 +17,11 @@ goog.require('ol.format.filter.Spatial'); * @extends {ol.format.filter.Spatial} * @api */ -ol.format.filter.Within = function(geometryName, geometry, opt_srsName) { +var _ol_format_filter_Within_ = function(geometryName, geometry, opt_srsName) { - ol.format.filter.Spatial.call(this, 'Within', geometryName, geometry, opt_srsName); + _ol_format_filter_Spatial_.call(this, 'Within', geometryName, geometry, opt_srsName); }; -ol.inherits(ol.format.filter.Within, ol.format.filter.Spatial); + +_ol_.inherits(_ol_format_filter_Within_, _ol_format_filter_Spatial_); +export default _ol_format_filter_Within_; diff --git a/src/ol/functions.js b/src/ol/functions.js index 4541a4f555..2f58ffc6a5 100644 --- a/src/ol/functions.js +++ b/src/ol/functions.js @@ -1,10 +1,13 @@ -goog.provide('ol.functions'); +/** + * @module ol/functions + */ +var _ol_functions_ = {}; /** * Always returns true. * @returns {boolean} true. */ -ol.functions.TRUE = function() { +_ol_functions_.TRUE = function() { return true; }; @@ -12,6 +15,7 @@ ol.functions.TRUE = function() { * Always returns false. * @returns {boolean} false. */ -ol.functions.FALSE = function() { +_ol_functions_.FALSE = function() { return false; }; +export default _ol_functions_; diff --git a/src/ol/geom/Circle.js b/src/ol/geom/Circle.js index fe174164eb..4df84da725 100644 --- a/src/ol/geom/Circle.js +++ b/src/ol/geom/Circle.js @@ -1,12 +1,12 @@ -goog.provide('ol.geom.Circle'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.deflate'); - +/** + * @module ol/geom/Circle + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; /** * @classdesc @@ -19,12 +19,13 @@ goog.require('ol.geom.flat.deflate'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.Circle = function(center, opt_radius, opt_layout) { - ol.geom.SimpleGeometry.call(this); +var _ol_geom_Circle_ = function(center, opt_radius, opt_layout) { + _ol_geom_SimpleGeometry_.call(this); var radius = opt_radius ? opt_radius : 0; this.setCenterAndRadius(center, radius, opt_layout); }; -ol.inherits(ol.geom.Circle, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_Circle_, _ol_geom_SimpleGeometry_); /** @@ -33,8 +34,8 @@ ol.inherits(ol.geom.Circle, ol.geom.SimpleGeometry); * @override * @api */ -ol.geom.Circle.prototype.clone = function() { - var circle = new ol.geom.Circle(null); +_ol_geom_Circle_.prototype.clone = function() { + var circle = new _ol_geom_Circle_(null); circle.setFlatCoordinates(this.layout, this.flatCoordinates.slice()); return circle; }; @@ -43,7 +44,7 @@ ol.geom.Circle.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.Circle.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_Circle_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { var flatCoordinates = this.flatCoordinates; var dx = x - flatCoordinates[0]; var dy = y - flatCoordinates[1]; @@ -73,7 +74,7 @@ ol.geom.Circle.prototype.closestPointXY = function(x, y, closestPoint, minSquare /** * @inheritDoc */ -ol.geom.Circle.prototype.containsXY = function(x, y) { +_ol_geom_Circle_.prototype.containsXY = function(x, y) { var flatCoordinates = this.flatCoordinates; var dx = x - flatCoordinates[0]; var dy = y - flatCoordinates[1]; @@ -86,7 +87,7 @@ ol.geom.Circle.prototype.containsXY = function(x, y) { * @return {ol.Coordinate} Center. * @api */ -ol.geom.Circle.prototype.getCenter = function() { +_ol_geom_Circle_.prototype.getCenter = function() { return this.flatCoordinates.slice(0, this.stride); }; @@ -94,10 +95,10 @@ ol.geom.Circle.prototype.getCenter = function() { /** * @inheritDoc */ -ol.geom.Circle.prototype.computeExtent = function(extent) { +_ol_geom_Circle_.prototype.computeExtent = function(extent) { var flatCoordinates = this.flatCoordinates; var radius = flatCoordinates[this.stride] - flatCoordinates[0]; - return ol.extent.createOrUpdate( + return _ol_extent_.createOrUpdate( flatCoordinates[0] - radius, flatCoordinates[1] - radius, flatCoordinates[0] + radius, flatCoordinates[1] + radius, extent); @@ -109,7 +110,7 @@ ol.geom.Circle.prototype.computeExtent = function(extent) { * @return {number} Radius. * @api */ -ol.geom.Circle.prototype.getRadius = function() { +_ol_geom_Circle_.prototype.getRadius = function() { return Math.sqrt(this.getRadiusSquared_()); }; @@ -118,7 +119,7 @@ ol.geom.Circle.prototype.getRadius = function() { * @private * @return {number} Radius squared. */ -ol.geom.Circle.prototype.getRadiusSquared_ = function() { +_ol_geom_Circle_.prototype.getRadiusSquared_ = function() { var dx = this.flatCoordinates[this.stride] - this.flatCoordinates[0]; var dy = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1]; return dx * dx + dy * dy; @@ -129,8 +130,8 @@ ol.geom.Circle.prototype.getRadiusSquared_ = function() { * @inheritDoc * @api */ -ol.geom.Circle.prototype.getType = function() { - return ol.geom.GeometryType.CIRCLE; +_ol_geom_Circle_.prototype.getType = function() { + return _ol_geom_GeometryType_.CIRCLE; }; @@ -138,9 +139,9 @@ ol.geom.Circle.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.Circle.prototype.intersectsExtent = function(extent) { +_ol_geom_Circle_.prototype.intersectsExtent = function(extent) { var circleExtent = this.getExtent(); - if (ol.extent.intersects(extent, circleExtent)) { + if (_ol_extent_.intersects(extent, circleExtent)) { var center = this.getCenter(); if (extent[0] <= center[0] && extent[2] >= center[0]) { @@ -150,7 +151,7 @@ ol.geom.Circle.prototype.intersectsExtent = function(extent) { return true; } - return ol.extent.forEachCorner(extent, this.intersectsCoordinate, this); + return _ol_extent_.forEachCorner(extent, this.intersectsCoordinate, this); } return false; @@ -162,7 +163,7 @@ ol.geom.Circle.prototype.intersectsExtent = function(extent) { * @param {ol.Coordinate} center Center. * @api */ -ol.geom.Circle.prototype.setCenter = function(center) { +_ol_geom_Circle_.prototype.setCenter = function(center) { var stride = this.stride; var radius = this.flatCoordinates[stride] - this.flatCoordinates[0]; var flatCoordinates = center.slice(); @@ -183,9 +184,9 @@ ol.geom.Circle.prototype.setCenter = function(center) { * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.Circle.prototype.setCenterAndRadius = function(center, radius, opt_layout) { +_ol_geom_Circle_.prototype.setCenterAndRadius = function(center, radius, opt_layout) { if (!center) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null); } else { this.setLayout(opt_layout, center, 0); if (!this.flatCoordinates) { @@ -193,7 +194,7 @@ ol.geom.Circle.prototype.setCenterAndRadius = function(center, radius, opt_layou } /** @type {Array.} */ var flatCoordinates = this.flatCoordinates; - var offset = ol.geom.flat.deflate.coordinate( + var offset = _ol_geom_flat_deflate_.coordinate( flatCoordinates, 0, center, this.stride); flatCoordinates[offset++] = flatCoordinates[0] + radius; var i, ii; @@ -209,20 +210,20 @@ ol.geom.Circle.prototype.setCenterAndRadius = function(center, radius, opt_layou /** * @inheritDoc */ -ol.geom.Circle.prototype.getCoordinates = function() {}; +_ol_geom_Circle_.prototype.getCoordinates = function() {}; /** * @inheritDoc */ -ol.geom.Circle.prototype.setCoordinates = function(coordinates, opt_layout) {}; +_ol_geom_Circle_.prototype.setCoordinates = function(coordinates, opt_layout) {}; /** * @param {ol.geom.GeometryLayout} layout Layout. * @param {Array.} flatCoordinates Flat coordinates. */ -ol.geom.Circle.prototype.setFlatCoordinates = function(layout, flatCoordinates) { +_ol_geom_Circle_.prototype.setFlatCoordinates = function(layout, flatCoordinates) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.changed(); }; @@ -233,7 +234,7 @@ ol.geom.Circle.prototype.setFlatCoordinates = function(layout, flatCoordinates) * @param {number} radius Radius. * @api */ -ol.geom.Circle.prototype.setRadius = function(radius) { +_ol_geom_Circle_.prototype.setRadius = function(radius) { this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius; this.changed(); }; @@ -261,4 +262,5 @@ ol.geom.Circle.prototype.setRadius = function(radius) { * @function * @api */ -ol.geom.Circle.prototype.transform; +_ol_geom_Circle_.prototype.transform; +export default _ol_geom_Circle_; diff --git a/src/ol/geom/Geometry.js b/src/ol/geom/Geometry.js index 67c5498f0c..41426cf61e 100644 --- a/src/ol/geom/Geometry.js +++ b/src/ol/geom/Geometry.js @@ -1,14 +1,14 @@ -goog.provide('ol.geom.Geometry'); - -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.proj'); -goog.require('ol.proj.Units'); -goog.require('ol.transform'); - +/** + * @module ol/geom/Geometry + */ +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_extent_ from '../extent.js'; +import _ol_functions_ from '../functions.js'; +import _ol_geom_flat_transform_ from '../geom/flat/transform.js'; +import _ol_proj_ from '../proj.js'; +import _ol_proj_Units_ from '../proj/Units.js'; +import _ol_transform_ from '../transform.js'; /** * @classdesc @@ -24,15 +24,15 @@ goog.require('ol.transform'); * @extends {ol.Object} * @api */ -ol.geom.Geometry = function() { +var _ol_geom_Geometry_ = function() { - ol.Object.call(this); + _ol_Object_.call(this); /** * @private * @type {ol.Extent} */ - this.extent_ = ol.extent.createEmpty(); + this.extent_ = _ol_extent_.createEmpty(); /** * @private @@ -62,10 +62,11 @@ ol.geom.Geometry = function() { * @private * @type {ol.Transform} */ - this.tmpTransform_ = ol.transform.create(); + this.tmpTransform_ = _ol_transform_.create(); }; -ol.inherits(ol.geom.Geometry, ol.Object); + +_ol_.inherits(_ol_geom_Geometry_, _ol_Object_); /** @@ -73,7 +74,7 @@ ol.inherits(ol.geom.Geometry, ol.Object); * @abstract * @return {!ol.geom.Geometry} Clone. */ -ol.geom.Geometry.prototype.clone = function() {}; +_ol_geom_Geometry_.prototype.clone = function() {}; /** @@ -84,7 +85,7 @@ ol.geom.Geometry.prototype.clone = function() {}; * @param {number} minSquaredDistance Minimum squared distance. * @return {number} Minimum squared distance. */ -ol.geom.Geometry.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {}; +_ol_geom_Geometry_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {}; /** @@ -95,7 +96,7 @@ ol.geom.Geometry.prototype.closestPointXY = function(x, y, closestPoint, minSqua * @return {ol.Coordinate} Closest point. * @api */ -ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) { +_ol_geom_Geometry_.prototype.getClosestPoint = function(point, opt_closestPoint) { var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN]; this.closestPointXY(point[0], point[1], closestPoint, Infinity); return closestPoint; @@ -109,7 +110,7 @@ ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) { * @return {boolean} Contains coordinate. * @api */ -ol.geom.Geometry.prototype.intersectsCoordinate = function(coordinate) { +_ol_geom_Geometry_.prototype.intersectsCoordinate = function(coordinate) { return this.containsXY(coordinate[0], coordinate[1]); }; @@ -120,7 +121,7 @@ ol.geom.Geometry.prototype.intersectsCoordinate = function(coordinate) { * @protected * @return {ol.Extent} extent Extent. */ -ol.geom.Geometry.prototype.computeExtent = function(extent) {}; +_ol_geom_Geometry_.prototype.computeExtent = function(extent) {}; /** @@ -128,7 +129,7 @@ ol.geom.Geometry.prototype.computeExtent = function(extent) {}; * @param {number} y Y. * @return {boolean} Contains (x, y). */ -ol.geom.Geometry.prototype.containsXY = ol.functions.FALSE; +_ol_geom_Geometry_.prototype.containsXY = _ol_functions_.FALSE; /** @@ -137,12 +138,12 @@ ol.geom.Geometry.prototype.containsXY = ol.functions.FALSE; * @return {ol.Extent} extent Extent. * @api */ -ol.geom.Geometry.prototype.getExtent = function(opt_extent) { +_ol_geom_Geometry_.prototype.getExtent = function(opt_extent) { if (this.extentRevision_ != this.getRevision()) { this.extent_ = this.computeExtent(this.extent_); this.extentRevision_ = this.getRevision(); } - return ol.extent.returnOrUpdate(this.extent_, opt_extent); + return _ol_extent_.returnOrUpdate(this.extent_, opt_extent); }; @@ -154,7 +155,7 @@ ol.geom.Geometry.prototype.getExtent = function(opt_extent) { * @param {ol.Coordinate} anchor The rotation center. * @api */ -ol.geom.Geometry.prototype.rotate = function(angle, anchor) {}; +_ol_geom_Geometry_.prototype.rotate = function(angle, anchor) {}; /** @@ -168,7 +169,7 @@ ol.geom.Geometry.prototype.rotate = function(angle, anchor) {}; * of the geometry extent). * @api */ -ol.geom.Geometry.prototype.scale = function(sx, opt_sy, opt_anchor) {}; +_ol_geom_Geometry_.prototype.scale = function(sx, opt_sy, opt_anchor) {}; /** @@ -183,7 +184,7 @@ ol.geom.Geometry.prototype.scale = function(sx, opt_sy, opt_anchor) {}; * geometry. * @api */ -ol.geom.Geometry.prototype.simplify = function(tolerance) { +_ol_geom_Geometry_.prototype.simplify = function(tolerance) { return this.getSimplifiedGeometry(tolerance * tolerance); }; @@ -196,7 +197,7 @@ ol.geom.Geometry.prototype.simplify = function(tolerance) { * @param {number} squaredTolerance Squared tolerance. * @return {ol.geom.Geometry} Simplified geometry. */ -ol.geom.Geometry.prototype.getSimplifiedGeometry = function(squaredTolerance) {}; +_ol_geom_Geometry_.prototype.getSimplifiedGeometry = function(squaredTolerance) {}; /** @@ -204,7 +205,7 @@ ol.geom.Geometry.prototype.getSimplifiedGeometry = function(squaredTolerance) {} * @abstract * @return {ol.geom.GeometryType} Geometry type. */ -ol.geom.Geometry.prototype.getType = function() {}; +_ol_geom_Geometry_.prototype.getType = function() {}; /** @@ -215,7 +216,7 @@ ol.geom.Geometry.prototype.getType = function() {}; * @abstract * @param {ol.TransformFunction} transformFn Transform. */ -ol.geom.Geometry.prototype.applyTransform = function(transformFn) {}; +_ol_geom_Geometry_.prototype.applyTransform = function(transformFn) {}; /** @@ -224,7 +225,7 @@ ol.geom.Geometry.prototype.applyTransform = function(transformFn) {}; * @param {ol.Extent} extent Extent. * @return {boolean} `true` if the geometry and the extent intersect. */ -ol.geom.Geometry.prototype.intersectsExtent = function(extent) {}; +_ol_geom_Geometry_.prototype.intersectsExtent = function(extent) {}; /** @@ -234,7 +235,7 @@ ol.geom.Geometry.prototype.intersectsExtent = function(extent) {}; * @param {number} deltaX Delta X. * @param {number} deltaY Delta Y. */ -ol.geom.Geometry.prototype.translate = function(deltaX, deltaY) {}; +_ol_geom_Geometry_.prototype.translate = function(deltaX, deltaY) {}; /** @@ -252,23 +253,24 @@ ol.geom.Geometry.prototype.translate = function(deltaX, deltaY) {}; * modified in place. * @api */ -ol.geom.Geometry.prototype.transform = function(source, destination) { +_ol_geom_Geometry_.prototype.transform = function(source, destination) { var tmpTransform = this.tmpTransform_; - source = ol.proj.get(source); - var transformFn = source.getUnits() == ol.proj.Units.TILE_PIXELS ? + source = _ol_proj_.get(source); + var transformFn = source.getUnits() == _ol_proj_Units_.TILE_PIXELS ? function(inCoordinates, outCoordinates, stride) { var pixelExtent = source.getExtent(); var projectedExtent = source.getWorldExtent(); - var scale = ol.extent.getHeight(projectedExtent) / ol.extent.getHeight(pixelExtent); - ol.transform.compose(tmpTransform, + var scale = _ol_extent_.getHeight(projectedExtent) / _ol_extent_.getHeight(pixelExtent); + _ol_transform_.compose(tmpTransform, projectedExtent[0], projectedExtent[3], scale, -scale, 0, 0, 0); - ol.geom.flat.transform.transform2D(inCoordinates, 0, inCoordinates.length, stride, + _ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride, tmpTransform, outCoordinates); - return ol.proj.getTransform(source, destination)(inCoordinates, outCoordinates, stride); + return _ol_proj_.getTransform(source, destination)(inCoordinates, outCoordinates, stride); } : - ol.proj.getTransform(source, destination); + _ol_proj_.getTransform(source, destination); this.applyTransform(transformFn); return this; }; +export default _ol_geom_Geometry_; diff --git a/src/ol/geom/GeometryCollection.js b/src/ol/geom/GeometryCollection.js index 41b3ee2952..8d7abd0ee3 100644 --- a/src/ol/geom/GeometryCollection.js +++ b/src/ol/geom/GeometryCollection.js @@ -1,13 +1,13 @@ -goog.provide('ol.geom.GeometryCollection'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.geom.Geometry'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.obj'); - +/** + * @module ol/geom/GeometryCollection + */ +import _ol_ from '../index.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -18,9 +18,9 @@ goog.require('ol.obj'); * @param {Array.=} opt_geometries Geometries. * @api */ -ol.geom.GeometryCollection = function(opt_geometries) { +var _ol_geom_GeometryCollection_ = function(opt_geometries) { - ol.geom.Geometry.call(this); + _ol_geom_Geometry_.call(this); /** * @private @@ -30,7 +30,8 @@ ol.geom.GeometryCollection = function(opt_geometries) { this.listenGeometriesChange_(); }; -ol.inherits(ol.geom.GeometryCollection, ol.geom.Geometry); + +_ol_.inherits(_ol_geom_GeometryCollection_, _ol_geom_Geometry_); /** @@ -38,7 +39,7 @@ ol.inherits(ol.geom.GeometryCollection, ol.geom.Geometry); * @private * @return {Array.} Cloned geometries. */ -ol.geom.GeometryCollection.cloneGeometries_ = function(geometries) { +_ol_geom_GeometryCollection_.cloneGeometries_ = function(geometries) { var clonedGeometries = []; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -51,14 +52,14 @@ ol.geom.GeometryCollection.cloneGeometries_ = function(geometries) { /** * @private */ -ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() { +_ol_geom_GeometryCollection_.prototype.unlistenGeometriesChange_ = function() { var i, ii; if (!this.geometries_) { return; } for (i = 0, ii = this.geometries_.length; i < ii; ++i) { - ol.events.unlisten( - this.geometries_[i], ol.events.EventType.CHANGE, + _ol_events_.unlisten( + this.geometries_[i], _ol_events_EventType_.CHANGE, this.changed, this); } }; @@ -67,14 +68,14 @@ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() { /** * @private */ -ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() { +_ol_geom_GeometryCollection_.prototype.listenGeometriesChange_ = function() { var i, ii; if (!this.geometries_) { return; } for (i = 0, ii = this.geometries_.length; i < ii; ++i) { - ol.events.listen( - this.geometries_[i], ol.events.EventType.CHANGE, + _ol_events_.listen( + this.geometries_[i], _ol_events_EventType_.CHANGE, this.changed, this); } }; @@ -86,8 +87,8 @@ ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() { * @override * @api */ -ol.geom.GeometryCollection.prototype.clone = function() { - var geometryCollection = new ol.geom.GeometryCollection(null); +_ol_geom_GeometryCollection_.prototype.clone = function() { + var geometryCollection = new _ol_geom_GeometryCollection_(null); geometryCollection.setGeometries(this.geometries_); return geometryCollection; }; @@ -96,9 +97,9 @@ ol.geom.GeometryCollection.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.GeometryCollection.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_GeometryCollection_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } var geometries = this.geometries_; @@ -114,7 +115,7 @@ ol.geom.GeometryCollection.prototype.closestPointXY = function(x, y, closestPoin /** * @inheritDoc */ -ol.geom.GeometryCollection.prototype.containsXY = function(x, y) { +_ol_geom_GeometryCollection_.prototype.containsXY = function(x, y) { var geometries = this.geometries_; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -129,11 +130,11 @@ ol.geom.GeometryCollection.prototype.containsXY = function(x, y) { /** * @inheritDoc */ -ol.geom.GeometryCollection.prototype.computeExtent = function(extent) { - ol.extent.createOrUpdateEmpty(extent); +_ol_geom_GeometryCollection_.prototype.computeExtent = function(extent) { + _ol_extent_.createOrUpdateEmpty(extent); var geometries = this.geometries_; for (var i = 0, ii = geometries.length; i < ii; ++i) { - ol.extent.extend(extent, geometries[i].getExtent()); + _ol_extent_.extend(extent, geometries[i].getExtent()); } return extent; }; @@ -144,15 +145,15 @@ ol.geom.GeometryCollection.prototype.computeExtent = function(extent) { * @return {Array.} Geometries. * @api */ -ol.geom.GeometryCollection.prototype.getGeometries = function() { - return ol.geom.GeometryCollection.cloneGeometries_(this.geometries_); +_ol_geom_GeometryCollection_.prototype.getGeometries = function() { + return _ol_geom_GeometryCollection_.cloneGeometries_(this.geometries_); }; /** * @return {Array.} Geometries. */ -ol.geom.GeometryCollection.prototype.getGeometriesArray = function() { +_ol_geom_GeometryCollection_.prototype.getGeometriesArray = function() { return this.geometries_; }; @@ -160,9 +161,9 @@ ol.geom.GeometryCollection.prototype.getGeometriesArray = function() { /** * @inheritDoc */ -ol.geom.GeometryCollection.prototype.getSimplifiedGeometry = function(squaredTolerance) { +_ol_geom_GeometryCollection_.prototype.getSimplifiedGeometry = function(squaredTolerance) { if (this.simplifiedGeometryRevision != this.getRevision()) { - ol.obj.clear(this.simplifiedGeometryCache); + _ol_obj_.clear(this.simplifiedGeometryCache); this.simplifiedGeometryMaxMinSquaredTolerance = 0; this.simplifiedGeometryRevision = this.getRevision(); } @@ -188,7 +189,7 @@ ol.geom.GeometryCollection.prototype.getSimplifiedGeometry = function(squaredTol } } if (simplified) { - var simplifiedGeometryCollection = new ol.geom.GeometryCollection(null); + var simplifiedGeometryCollection = new _ol_geom_GeometryCollection_(null); simplifiedGeometryCollection.setGeometriesArray(simplifiedGeometries); this.simplifiedGeometryCache[key] = simplifiedGeometryCollection; return simplifiedGeometryCollection; @@ -204,8 +205,8 @@ ol.geom.GeometryCollection.prototype.getSimplifiedGeometry = function(squaredTol * @inheritDoc * @api */ -ol.geom.GeometryCollection.prototype.getType = function() { - return ol.geom.GeometryType.GEOMETRY_COLLECTION; +_ol_geom_GeometryCollection_.prototype.getType = function() { + return _ol_geom_GeometryType_.GEOMETRY_COLLECTION; }; @@ -213,7 +214,7 @@ ol.geom.GeometryCollection.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.GeometryCollection.prototype.intersectsExtent = function(extent) { +_ol_geom_GeometryCollection_.prototype.intersectsExtent = function(extent) { var geometries = this.geometries_; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -228,7 +229,7 @@ ol.geom.GeometryCollection.prototype.intersectsExtent = function(extent) { /** * @return {boolean} Is empty. */ -ol.geom.GeometryCollection.prototype.isEmpty = function() { +_ol_geom_GeometryCollection_.prototype.isEmpty = function() { return this.geometries_.length === 0; }; @@ -237,7 +238,7 @@ ol.geom.GeometryCollection.prototype.isEmpty = function() { * @inheritDoc * @api */ -ol.geom.GeometryCollection.prototype.rotate = function(angle, anchor) { +_ol_geom_GeometryCollection_.prototype.rotate = function(angle, anchor) { var geometries = this.geometries_; for (var i = 0, ii = geometries.length; i < ii; ++i) { geometries[i].rotate(angle, anchor); @@ -250,10 +251,10 @@ ol.geom.GeometryCollection.prototype.rotate = function(angle, anchor) { * @inheritDoc * @api */ -ol.geom.GeometryCollection.prototype.scale = function(sx, opt_sy, opt_anchor) { +_ol_geom_GeometryCollection_.prototype.scale = function(sx, opt_sy, opt_anchor) { var anchor = opt_anchor; if (!anchor) { - anchor = ol.extent.getCenter(this.getExtent()); + anchor = _ol_extent_.getCenter(this.getExtent()); } var geometries = this.geometries_; for (var i = 0, ii = geometries.length; i < ii; ++i) { @@ -268,16 +269,16 @@ ol.geom.GeometryCollection.prototype.scale = function(sx, opt_sy, opt_anchor) { * @param {Array.} geometries Geometries. * @api */ -ol.geom.GeometryCollection.prototype.setGeometries = function(geometries) { +_ol_geom_GeometryCollection_.prototype.setGeometries = function(geometries) { this.setGeometriesArray( - ol.geom.GeometryCollection.cloneGeometries_(geometries)); + _ol_geom_GeometryCollection_.cloneGeometries_(geometries)); }; /** * @param {Array.} geometries Geometries. */ -ol.geom.GeometryCollection.prototype.setGeometriesArray = function(geometries) { +_ol_geom_GeometryCollection_.prototype.setGeometriesArray = function(geometries) { this.unlistenGeometriesChange_(); this.geometries_ = geometries; this.listenGeometriesChange_(); @@ -289,7 +290,7 @@ ol.geom.GeometryCollection.prototype.setGeometriesArray = function(geometries) { * @inheritDoc * @api */ -ol.geom.GeometryCollection.prototype.applyTransform = function(transformFn) { +_ol_geom_GeometryCollection_.prototype.applyTransform = function(transformFn) { var geometries = this.geometries_; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -306,7 +307,7 @@ ol.geom.GeometryCollection.prototype.applyTransform = function(transformFn) { * @override * @api */ -ol.geom.GeometryCollection.prototype.translate = function(deltaX, deltaY) { +_ol_geom_GeometryCollection_.prototype.translate = function(deltaX, deltaY) { var geometries = this.geometries_; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -319,7 +320,8 @@ ol.geom.GeometryCollection.prototype.translate = function(deltaX, deltaY) { /** * @inheritDoc */ -ol.geom.GeometryCollection.prototype.disposeInternal = function() { +_ol_geom_GeometryCollection_.prototype.disposeInternal = function() { this.unlistenGeometriesChange_(); - ol.geom.Geometry.prototype.disposeInternal.call(this); + _ol_geom_Geometry_.prototype.disposeInternal.call(this); }; +export default _ol_geom_GeometryCollection_; diff --git a/src/ol/geom/GeometryLayout.js b/src/ol/geom/GeometryLayout.js index 3578e1ffe3..2112ac2031 100644 --- a/src/ol/geom/GeometryLayout.js +++ b/src/ol/geom/GeometryLayout.js @@ -1,15 +1,17 @@ -goog.provide('ol.geom.GeometryLayout'); - - +/** + * @module ol/geom/GeometryLayout + */ /** * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z') * or measure ('M') coordinate is available. Supported values are `'XY'`, * `'XYZ'`, `'XYM'`, `'XYZM'`. * @enum {string} */ -ol.geom.GeometryLayout = { +var _ol_geom_GeometryLayout_ = { XY: 'XY', XYZ: 'XYZ', XYM: 'XYM', XYZM: 'XYZM' }; + +export default _ol_geom_GeometryLayout_; diff --git a/src/ol/geom/GeometryType.js b/src/ol/geom/GeometryType.js index 9b1fde2c0d..c4823abd76 100644 --- a/src/ol/geom/GeometryType.js +++ b/src/ol/geom/GeometryType.js @@ -1,13 +1,13 @@ -goog.provide('ol.geom.GeometryType'); - - +/** + * @module ol/geom/GeometryType + */ /** * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`, * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`, * `'GeometryCollection'`, `'Circle'`. * @enum {string} */ -ol.geom.GeometryType = { +var _ol_geom_GeometryType_ = { POINT: 'Point', LINE_STRING: 'LineString', LINEAR_RING: 'LinearRing', @@ -18,3 +18,5 @@ ol.geom.GeometryType = { GEOMETRY_COLLECTION: 'GeometryCollection', CIRCLE: 'Circle' }; + +export default _ol_geom_GeometryType_; diff --git a/src/ol/geom/LineString.js b/src/ol/geom/LineString.js index 4ac9675809..850b00d2dc 100644 --- a/src/ol/geom/LineString.js +++ b/src/ol/geom/LineString.js @@ -1,20 +1,20 @@ -goog.provide('ol.geom.LineString'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.closest'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.interpolate'); -goog.require('ol.geom.flat.intersectsextent'); -goog.require('ol.geom.flat.length'); -goog.require('ol.geom.flat.segments'); -goog.require('ol.geom.flat.simplify'); - +/** + * @module ol/geom/LineString + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_closest_ from '../geom/flat/closest.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js'; +import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js'; +import _ol_geom_flat_length_ from '../geom/flat/length.js'; +import _ol_geom_flat_segments_ from '../geom/flat/segments.js'; +import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; /** * @classdesc @@ -26,9 +26,9 @@ goog.require('ol.geom.flat.simplify'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.LineString = function(coordinates, opt_layout) { +var _ol_geom_LineString_ = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); + _ol_geom_SimpleGeometry_.call(this); /** * @private @@ -57,7 +57,8 @@ ol.geom.LineString = function(coordinates, opt_layout) { this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.LineString, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_LineString_, _ol_geom_SimpleGeometry_); /** @@ -65,11 +66,11 @@ ol.inherits(ol.geom.LineString, ol.geom.SimpleGeometry); * @param {ol.Coordinate} coordinate Coordinate. * @api */ -ol.geom.LineString.prototype.appendCoordinate = function(coordinate) { +_ol_geom_LineString_.prototype.appendCoordinate = function(coordinate) { if (!this.flatCoordinates) { this.flatCoordinates = coordinate.slice(); } else { - ol.array.extend(this.flatCoordinates, coordinate); + _ol_array_.extend(this.flatCoordinates, coordinate); } this.changed(); }; @@ -81,8 +82,8 @@ ol.geom.LineString.prototype.appendCoordinate = function(coordinate) { * @override * @api */ -ol.geom.LineString.prototype.clone = function() { - var lineString = new ol.geom.LineString(null); +_ol_geom_LineString_.prototype.clone = function() { + var lineString = new _ol_geom_LineString_(null); lineString.setFlatCoordinates(this.layout, this.flatCoordinates.slice()); return lineString; }; @@ -91,17 +92,17 @@ ol.geom.LineString.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.LineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_LineString_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } if (this.maxDeltaRevision_ != this.getRevision()) { - this.maxDelta_ = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta( + this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0)); this.maxDeltaRevision_ = this.getRevision(); } - return ol.geom.flat.closest.getClosestPoint( + return _ol_geom_flat_closest_.getClosestPoint( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, this.maxDelta_, false, x, y, closestPoint, minSquaredDistance); }; @@ -120,8 +121,8 @@ ol.geom.LineString.prototype.closestPointXY = function(x, y, closestPoint, minSq * @template T,S * @api */ -ol.geom.LineString.prototype.forEachSegment = function(callback, opt_this) { - return ol.geom.flat.segments.forEach(this.flatCoordinates, 0, +_ol_geom_LineString_.prototype.forEachSegment = function(callback, opt_this) { + return _ol_geom_flat_segments_.forEach(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, callback, opt_this); }; @@ -140,13 +141,13 @@ ol.geom.LineString.prototype.forEachSegment = function(callback, opt_this) { * @return {ol.Coordinate} Coordinate. * @api */ -ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { - if (this.layout != ol.geom.GeometryLayout.XYM && - this.layout != ol.geom.GeometryLayout.XYZM) { +_ol_geom_LineString_.prototype.getCoordinateAtM = function(m, opt_extrapolate) { + if (this.layout != _ol_geom_GeometryLayout_.XYM && + this.layout != _ol_geom_GeometryLayout_.XYZM) { return null; } var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false; - return ol.geom.flat.interpolate.lineStringCoordinateAtM(this.flatCoordinates, 0, + return _ol_geom_flat_interpolate_.lineStringCoordinateAtM(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, m, extrapolate); }; @@ -157,8 +158,8 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) { * @override * @api */ -ol.geom.LineString.prototype.getCoordinates = function() { - return ol.geom.flat.inflate.coordinates( +_ol_geom_LineString_.prototype.getCoordinates = function() { + return _ol_geom_flat_inflate_.coordinates( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); }; @@ -173,8 +174,8 @@ ol.geom.LineString.prototype.getCoordinates = function() { * @return {ol.Coordinate} Coordinate of the interpolated point. * @api */ -ol.geom.LineString.prototype.getCoordinateAt = function(fraction, opt_dest) { - return ol.geom.flat.interpolate.lineString( +_ol_geom_LineString_.prototype.getCoordinateAt = function(fraction, opt_dest) { + return _ol_geom_flat_interpolate_.lineString( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, fraction, opt_dest); }; @@ -185,8 +186,8 @@ ol.geom.LineString.prototype.getCoordinateAt = function(fraction, opt_dest) { * @return {number} Length (on projected plane). * @api */ -ol.geom.LineString.prototype.getLength = function() { - return ol.geom.flat.length.lineString( +_ol_geom_LineString_.prototype.getLength = function() { + return _ol_geom_flat_length_.lineString( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); }; @@ -194,7 +195,7 @@ ol.geom.LineString.prototype.getLength = function() { /** * @return {Array.} Flat midpoint. */ -ol.geom.LineString.prototype.getFlatMidpoint = function() { +_ol_geom_LineString_.prototype.getFlatMidpoint = function() { if (this.flatMidpointRevision_ != this.getRevision()) { this.flatMidpoint_ = this.getCoordinateAt(0.5, this.flatMidpoint_); this.flatMidpointRevision_ = this.getRevision(); @@ -206,14 +207,14 @@ ol.geom.LineString.prototype.getFlatMidpoint = function() { /** * @inheritDoc */ -ol.geom.LineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_LineString_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { var simplifiedFlatCoordinates = []; - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0); - var simplifiedLineString = new ol.geom.LineString(null); + var simplifiedLineString = new _ol_geom_LineString_(null); simplifiedLineString.setFlatCoordinates( - ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates); + _ol_geom_GeometryLayout_.XY, simplifiedFlatCoordinates); return simplifiedLineString; }; @@ -222,8 +223,8 @@ ol.geom.LineString.prototype.getSimplifiedGeometryInternal = function(squaredTol * @inheritDoc * @api */ -ol.geom.LineString.prototype.getType = function() { - return ol.geom.GeometryType.LINE_STRING; +_ol_geom_LineString_.prototype.getType = function() { + return _ol_geom_GeometryType_.LINE_STRING; }; @@ -231,8 +232,8 @@ ol.geom.LineString.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.LineString.prototype.intersectsExtent = function(extent) { - return ol.geom.flat.intersectsextent.lineString( +_ol_geom_LineString_.prototype.intersectsExtent = function(extent) { + return _ol_geom_flat_intersectsextent_.lineString( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, extent); }; @@ -245,15 +246,15 @@ ol.geom.LineString.prototype.intersectsExtent = function(extent) { * @override * @api */ -ol.geom.LineString.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_LineString_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); if (!this.flatCoordinates) { this.flatCoordinates = []; } - this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( + this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates( this.flatCoordinates, 0, coordinates, this.stride); this.changed(); } @@ -264,7 +265,8 @@ ol.geom.LineString.prototype.setCoordinates = function(coordinates, opt_layout) * @param {ol.geom.GeometryLayout} layout Layout. * @param {Array.} flatCoordinates Flat coordinates. */ -ol.geom.LineString.prototype.setFlatCoordinates = function(layout, flatCoordinates) { +_ol_geom_LineString_.prototype.setFlatCoordinates = function(layout, flatCoordinates) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.changed(); }; +export default _ol_geom_LineString_; diff --git a/src/ol/geom/LinearRing.js b/src/ol/geom/LinearRing.js index fe0516cad7..a147126471 100644 --- a/src/ol/geom/LinearRing.js +++ b/src/ol/geom/LinearRing.js @@ -1,16 +1,16 @@ -goog.provide('ol.geom.LinearRing'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.area'); -goog.require('ol.geom.flat.closest'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.simplify'); - +/** + * @module ol/geom/LinearRing + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_area_ from '../geom/flat/area.js'; +import _ol_geom_flat_closest_ from '../geom/flat/closest.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; /** * @classdesc @@ -23,9 +23,9 @@ goog.require('ol.geom.flat.simplify'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.LinearRing = function(coordinates, opt_layout) { +var _ol_geom_LinearRing_ = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); + _ol_geom_SimpleGeometry_.call(this); /** * @private @@ -42,7 +42,8 @@ ol.geom.LinearRing = function(coordinates, opt_layout) { this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.LinearRing, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_LinearRing_, _ol_geom_SimpleGeometry_); /** @@ -51,8 +52,8 @@ ol.inherits(ol.geom.LinearRing, ol.geom.SimpleGeometry); * @override * @api */ -ol.geom.LinearRing.prototype.clone = function() { - var linearRing = new ol.geom.LinearRing(null); +_ol_geom_LinearRing_.prototype.clone = function() { + var linearRing = new _ol_geom_LinearRing_(null); linearRing.setFlatCoordinates(this.layout, this.flatCoordinates.slice()); return linearRing; }; @@ -61,17 +62,17 @@ ol.geom.LinearRing.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_LinearRing_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } if (this.maxDeltaRevision_ != this.getRevision()) { - this.maxDelta_ = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta( + this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, 0)); this.maxDeltaRevision_ = this.getRevision(); } - return ol.geom.flat.closest.getClosestPoint( + return _ol_geom_flat_closest_.getClosestPoint( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance); }; @@ -82,8 +83,8 @@ ol.geom.LinearRing.prototype.closestPointXY = function(x, y, closestPoint, minSq * @return {number} Area (on projected plane). * @api */ -ol.geom.LinearRing.prototype.getArea = function() { - return ol.geom.flat.area.linearRing( +_ol_geom_LinearRing_.prototype.getArea = function() { + return _ol_geom_flat_area_.linearRing( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); }; @@ -94,8 +95,8 @@ ol.geom.LinearRing.prototype.getArea = function() { * @override * @api */ -ol.geom.LinearRing.prototype.getCoordinates = function() { - return ol.geom.flat.inflate.coordinates( +_ol_geom_LinearRing_.prototype.getCoordinates = function() { + return _ol_geom_flat_inflate_.coordinates( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); }; @@ -103,14 +104,14 @@ ol.geom.LinearRing.prototype.getCoordinates = function() { /** * @inheritDoc */ -ol.geom.LinearRing.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_LinearRing_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { var simplifiedFlatCoordinates = []; - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0); - var simplifiedLinearRing = new ol.geom.LinearRing(null); + var simplifiedLinearRing = new _ol_geom_LinearRing_(null); simplifiedLinearRing.setFlatCoordinates( - ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates); + _ol_geom_GeometryLayout_.XY, simplifiedFlatCoordinates); return simplifiedLinearRing; }; @@ -119,15 +120,15 @@ ol.geom.LinearRing.prototype.getSimplifiedGeometryInternal = function(squaredTol * @inheritDoc * @api */ -ol.geom.LinearRing.prototype.getType = function() { - return ol.geom.GeometryType.LINEAR_RING; +_ol_geom_LinearRing_.prototype.getType = function() { + return _ol_geom_GeometryType_.LINEAR_RING; }; /** * @inheritDoc */ -ol.geom.LinearRing.prototype.intersectsExtent = function(extent) {}; +_ol_geom_LinearRing_.prototype.intersectsExtent = function(extent) {}; /** @@ -137,15 +138,15 @@ ol.geom.LinearRing.prototype.intersectsExtent = function(extent) {}; * @override * @api */ -ol.geom.LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_LinearRing_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); if (!this.flatCoordinates) { this.flatCoordinates = []; } - this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( + this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates( this.flatCoordinates, 0, coordinates, this.stride); this.changed(); } @@ -156,7 +157,8 @@ ol.geom.LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) * @param {ol.geom.GeometryLayout} layout Layout. * @param {Array.} flatCoordinates Flat coordinates. */ -ol.geom.LinearRing.prototype.setFlatCoordinates = function(layout, flatCoordinates) { +_ol_geom_LinearRing_.prototype.setFlatCoordinates = function(layout, flatCoordinates) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.changed(); }; +export default _ol_geom_LinearRing_; diff --git a/src/ol/geom/MultiLineString.js b/src/ol/geom/MultiLineString.js index 11827ceee8..fa492483ce 100644 --- a/src/ol/geom/MultiLineString.js +++ b/src/ol/geom/MultiLineString.js @@ -1,19 +1,19 @@ -goog.provide('ol.geom.MultiLineString'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.closest'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.interpolate'); -goog.require('ol.geom.flat.intersectsextent'); -goog.require('ol.geom.flat.simplify'); - +/** + * @module ol/geom/MultiLineString + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_closest_ from '../geom/flat/closest.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js'; +import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js'; +import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; /** * @classdesc @@ -25,9 +25,9 @@ goog.require('ol.geom.flat.simplify'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.MultiLineString = function(coordinates, opt_layout) { +var _ol_geom_MultiLineString_ = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); + _ol_geom_SimpleGeometry_.call(this); /** * @type {Array.} @@ -50,7 +50,8 @@ ol.geom.MultiLineString = function(coordinates, opt_layout) { this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_MultiLineString_, _ol_geom_SimpleGeometry_); /** @@ -58,11 +59,11 @@ ol.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry); * @param {ol.geom.LineString} lineString LineString. * @api */ -ol.geom.MultiLineString.prototype.appendLineString = function(lineString) { +_ol_geom_MultiLineString_.prototype.appendLineString = function(lineString) { if (!this.flatCoordinates) { this.flatCoordinates = lineString.getFlatCoordinates().slice(); } else { - ol.array.extend( + _ol_array_.extend( this.flatCoordinates, lineString.getFlatCoordinates().slice()); } this.ends_.push(this.flatCoordinates.length); @@ -76,8 +77,8 @@ ol.geom.MultiLineString.prototype.appendLineString = function(lineString) { * @override * @api */ -ol.geom.MultiLineString.prototype.clone = function() { - var multiLineString = new ol.geom.MultiLineString(null); +_ol_geom_MultiLineString_.prototype.clone = function() { + var multiLineString = new _ol_geom_MultiLineString_(null); multiLineString.setFlatCoordinates( this.layout, this.flatCoordinates.slice(), this.ends_.slice()); return multiLineString; @@ -87,17 +88,17 @@ ol.geom.MultiLineString.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.MultiLineString.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_MultiLineString_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } if (this.maxDeltaRevision_ != this.getRevision()) { - this.maxDelta_ = Math.sqrt(ol.geom.flat.closest.getsMaxSquaredDelta( + this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta( this.flatCoordinates, 0, this.ends_, this.stride, 0)); this.maxDeltaRevision_ = this.getRevision(); } - return ol.geom.flat.closest.getsClosestPoint( + return _ol_geom_flat_closest_.getsClosestPoint( this.flatCoordinates, 0, this.ends_, this.stride, this.maxDelta_, false, x, y, closestPoint, minSquaredDistance); }; @@ -125,15 +126,15 @@ ol.geom.MultiLineString.prototype.closestPointXY = function(x, y, closestPoint, * @return {ol.Coordinate} Coordinate. * @api */ -ol.geom.MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_interpolate) { - if ((this.layout != ol.geom.GeometryLayout.XYM && - this.layout != ol.geom.GeometryLayout.XYZM) || +_ol_geom_MultiLineString_.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_interpolate) { + if ((this.layout != _ol_geom_GeometryLayout_.XYM && + this.layout != _ol_geom_GeometryLayout_.XYZM) || this.flatCoordinates.length === 0) { return null; } var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false; var interpolate = opt_interpolate !== undefined ? opt_interpolate : false; - return ol.geom.flat.interpolate.lineStringsCoordinateAtM(this.flatCoordinates, 0, + return _ol_geom_flat_interpolate_.lineStringsCoordinateAtM(this.flatCoordinates, 0, this.ends_, this.stride, m, extrapolate, interpolate); }; @@ -144,8 +145,8 @@ ol.geom.MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate * @override * @api */ -ol.geom.MultiLineString.prototype.getCoordinates = function() { - return ol.geom.flat.inflate.coordinatess( +_ol_geom_MultiLineString_.prototype.getCoordinates = function() { + return _ol_geom_flat_inflate_.coordinatess( this.flatCoordinates, 0, this.ends_, this.stride); }; @@ -153,7 +154,7 @@ ol.geom.MultiLineString.prototype.getCoordinates = function() { /** * @return {Array.} Ends. */ -ol.geom.MultiLineString.prototype.getEnds = function() { +_ol_geom_MultiLineString_.prototype.getEnds = function() { return this.ends_; }; @@ -164,11 +165,11 @@ ol.geom.MultiLineString.prototype.getEnds = function() { * @return {ol.geom.LineString} LineString. * @api */ -ol.geom.MultiLineString.prototype.getLineString = function(index) { +_ol_geom_MultiLineString_.prototype.getLineString = function(index) { if (index < 0 || this.ends_.length <= index) { return null; } - var lineString = new ol.geom.LineString(null); + var lineString = new _ol_geom_LineString_(null); lineString.setFlatCoordinates(this.layout, this.flatCoordinates.slice( index === 0 ? 0 : this.ends_[index - 1], this.ends_[index])); return lineString; @@ -180,7 +181,7 @@ ol.geom.MultiLineString.prototype.getLineString = function(index) { * @return {Array.} LineStrings. * @api */ -ol.geom.MultiLineString.prototype.getLineStrings = function() { +_ol_geom_MultiLineString_.prototype.getLineStrings = function() { var flatCoordinates = this.flatCoordinates; var ends = this.ends_; var layout = this.layout; @@ -190,7 +191,7 @@ ol.geom.MultiLineString.prototype.getLineStrings = function() { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var lineString = new ol.geom.LineString(null); + var lineString = new _ol_geom_LineString_(null); lineString.setFlatCoordinates(layout, flatCoordinates.slice(offset, end)); lineStrings.push(lineString); offset = end; @@ -202,7 +203,7 @@ ol.geom.MultiLineString.prototype.getLineStrings = function() { /** * @return {Array.} Flat midpoints. */ -ol.geom.MultiLineString.prototype.getFlatMidpoints = function() { +_ol_geom_MultiLineString_.prototype.getFlatMidpoints = function() { var midpoints = []; var flatCoordinates = this.flatCoordinates; var offset = 0; @@ -211,9 +212,9 @@ ol.geom.MultiLineString.prototype.getFlatMidpoints = function() { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var midpoint = ol.geom.flat.interpolate.lineString( + var midpoint = _ol_geom_flat_interpolate_.lineString( flatCoordinates, offset, end, stride, 0.5); - ol.array.extend(midpoints, midpoint); + _ol_array_.extend(midpoints, midpoint); offset = end; } return midpoints; @@ -223,15 +224,15 @@ ol.geom.MultiLineString.prototype.getFlatMidpoints = function() { /** * @inheritDoc */ -ol.geom.MultiLineString.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_MultiLineString_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { var simplifiedFlatCoordinates = []; var simplifiedEnds = []; - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeuckers( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeuckers( this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0, simplifiedEnds); - var simplifiedMultiLineString = new ol.geom.MultiLineString(null); + var simplifiedMultiLineString = new _ol_geom_MultiLineString_(null); simplifiedMultiLineString.setFlatCoordinates( - ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds); + _ol_geom_GeometryLayout_.XY, simplifiedFlatCoordinates, simplifiedEnds); return simplifiedMultiLineString; }; @@ -240,8 +241,8 @@ ol.geom.MultiLineString.prototype.getSimplifiedGeometryInternal = function(squar * @inheritDoc * @api */ -ol.geom.MultiLineString.prototype.getType = function() { - return ol.geom.GeometryType.MULTI_LINE_STRING; +_ol_geom_MultiLineString_.prototype.getType = function() { + return _ol_geom_GeometryType_.MULTI_LINE_STRING; }; @@ -249,8 +250,8 @@ ol.geom.MultiLineString.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.MultiLineString.prototype.intersectsExtent = function(extent) { - return ol.geom.flat.intersectsextent.lineStrings( +_ol_geom_MultiLineString_.prototype.intersectsExtent = function(extent) { + return _ol_geom_flat_intersectsextent_.lineStrings( this.flatCoordinates, 0, this.ends_, this.stride, extent); }; @@ -262,15 +263,15 @@ ol.geom.MultiLineString.prototype.intersectsExtent = function(extent) { * @override * @api */ -ol.geom.MultiLineString.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_MultiLineString_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null, this.ends_); } else { this.setLayout(opt_layout, coordinates, 2); if (!this.flatCoordinates) { this.flatCoordinates = []; } - var ends = ol.geom.flat.deflate.coordinatess( + var ends = _ol_geom_flat_deflate_.coordinatess( this.flatCoordinates, 0, coordinates, this.stride, this.ends_); this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1]; this.changed(); @@ -283,7 +284,7 @@ ol.geom.MultiLineString.prototype.setCoordinates = function(coordinates, opt_lay * @param {Array.} flatCoordinates Flat coordinates. * @param {Array.} ends Ends. */ -ol.geom.MultiLineString.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) { +_ol_geom_MultiLineString_.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.ends_ = ends; this.changed(); @@ -293,7 +294,7 @@ ol.geom.MultiLineString.prototype.setFlatCoordinates = function(layout, flatCoor /** * @param {Array.} lineStrings LineStrings. */ -ol.geom.MultiLineString.prototype.setLineStrings = function(lineStrings) { +_ol_geom_MultiLineString_.prototype.setLineStrings = function(lineStrings) { var layout = this.getLayout(); var flatCoordinates = []; var ends = []; @@ -303,8 +304,9 @@ ol.geom.MultiLineString.prototype.setLineStrings = function(lineStrings) { if (i === 0) { layout = lineString.getLayout(); } - ol.array.extend(flatCoordinates, lineString.getFlatCoordinates()); + _ol_array_.extend(flatCoordinates, lineString.getFlatCoordinates()); ends.push(flatCoordinates.length); } this.setFlatCoordinates(layout, flatCoordinates, ends); }; +export default _ol_geom_MultiLineString_; diff --git a/src/ol/geom/MultiPoint.js b/src/ol/geom/MultiPoint.js index cfb7f377e3..0bfa364955 100644 --- a/src/ol/geom/MultiPoint.js +++ b/src/ol/geom/MultiPoint.js @@ -1,16 +1,16 @@ -goog.provide('ol.geom.MultiPoint'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.math'); - +/** + * @module ol/geom/MultiPoint + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_math_ from '../math.js'; /** * @classdesc @@ -22,11 +22,12 @@ goog.require('ol.math'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.MultiPoint = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); +var _ol_geom_MultiPoint_ = function(coordinates, opt_layout) { + _ol_geom_SimpleGeometry_.call(this); this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_MultiPoint_, _ol_geom_SimpleGeometry_); /** @@ -34,11 +35,11 @@ ol.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry); * @param {ol.geom.Point} point Point. * @api */ -ol.geom.MultiPoint.prototype.appendPoint = function(point) { +_ol_geom_MultiPoint_.prototype.appendPoint = function(point) { if (!this.flatCoordinates) { this.flatCoordinates = point.getFlatCoordinates().slice(); } else { - ol.array.extend(this.flatCoordinates, point.getFlatCoordinates()); + _ol_array_.extend(this.flatCoordinates, point.getFlatCoordinates()); } this.changed(); }; @@ -50,8 +51,8 @@ ol.geom.MultiPoint.prototype.appendPoint = function(point) { * @override * @api */ -ol.geom.MultiPoint.prototype.clone = function() { - var multiPoint = new ol.geom.MultiPoint(null); +_ol_geom_MultiPoint_.prototype.clone = function() { + var multiPoint = new _ol_geom_MultiPoint_(null); multiPoint.setFlatCoordinates(this.layout, this.flatCoordinates.slice()); return multiPoint; }; @@ -60,16 +61,16 @@ ol.geom.MultiPoint.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_MultiPoint_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } var flatCoordinates = this.flatCoordinates; var stride = this.stride; var i, ii, j; for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) { - var squaredDistance = ol.math.squaredDistance( + var squaredDistance = _ol_math_.squaredDistance( x, y, flatCoordinates[i], flatCoordinates[i + 1]); if (squaredDistance < minSquaredDistance) { minSquaredDistance = squaredDistance; @@ -89,8 +90,8 @@ ol.geom.MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSq * @override * @api */ -ol.geom.MultiPoint.prototype.getCoordinates = function() { - return ol.geom.flat.inflate.coordinates( +_ol_geom_MultiPoint_.prototype.getCoordinates = function() { + return _ol_geom_flat_inflate_.coordinates( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); }; @@ -101,13 +102,13 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() { * @return {ol.geom.Point} Point. * @api */ -ol.geom.MultiPoint.prototype.getPoint = function(index) { +_ol_geom_MultiPoint_.prototype.getPoint = function(index) { var n = !this.flatCoordinates ? 0 : this.flatCoordinates.length / this.stride; if (index < 0 || n <= index) { return null; } - var point = new ol.geom.Point(null); + var point = new _ol_geom_Point_(null); point.setFlatCoordinates(this.layout, this.flatCoordinates.slice( index * this.stride, (index + 1) * this.stride)); return point; @@ -119,7 +120,7 @@ ol.geom.MultiPoint.prototype.getPoint = function(index) { * @return {Array.} Points. * @api */ -ol.geom.MultiPoint.prototype.getPoints = function() { +_ol_geom_MultiPoint_.prototype.getPoints = function() { var flatCoordinates = this.flatCoordinates; var layout = this.layout; var stride = this.stride; @@ -127,7 +128,7 @@ ol.geom.MultiPoint.prototype.getPoints = function() { var points = []; var i, ii; for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) { - var point = new ol.geom.Point(null); + var point = new _ol_geom_Point_(null); point.setFlatCoordinates(layout, flatCoordinates.slice(i, i + stride)); points.push(point); } @@ -139,8 +140,8 @@ ol.geom.MultiPoint.prototype.getPoints = function() { * @inheritDoc * @api */ -ol.geom.MultiPoint.prototype.getType = function() { - return ol.geom.GeometryType.MULTI_POINT; +_ol_geom_MultiPoint_.prototype.getType = function() { + return _ol_geom_GeometryType_.MULTI_POINT; }; @@ -148,14 +149,14 @@ ol.geom.MultiPoint.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.MultiPoint.prototype.intersectsExtent = function(extent) { +_ol_geom_MultiPoint_.prototype.intersectsExtent = function(extent) { var flatCoordinates = this.flatCoordinates; var stride = this.stride; var i, ii, x, y; for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) { x = flatCoordinates[i]; y = flatCoordinates[i + 1]; - if (ol.extent.containsXY(extent, x, y)) { + if (_ol_extent_.containsXY(extent, x, y)) { return true; } } @@ -170,15 +171,15 @@ ol.geom.MultiPoint.prototype.intersectsExtent = function(extent) { * @override * @api */ -ol.geom.MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_MultiPoint_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); if (!this.flatCoordinates) { this.flatCoordinates = []; } - this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( + this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinates( this.flatCoordinates, 0, coordinates, this.stride); this.changed(); } @@ -189,7 +190,8 @@ ol.geom.MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) * @param {ol.geom.GeometryLayout} layout Layout. * @param {Array.} flatCoordinates Flat coordinates. */ -ol.geom.MultiPoint.prototype.setFlatCoordinates = function(layout, flatCoordinates) { +_ol_geom_MultiPoint_.prototype.setFlatCoordinates = function(layout, flatCoordinates) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.changed(); }; +export default _ol_geom_MultiPoint_; diff --git a/src/ol/geom/MultiPolygon.js b/src/ol/geom/MultiPolygon.js index 93e3a9b635..6ba72eb2d1 100644 --- a/src/ol/geom/MultiPolygon.js +++ b/src/ol/geom/MultiPolygon.js @@ -1,24 +1,24 @@ -goog.provide('ol.geom.MultiPolygon'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.area'); -goog.require('ol.geom.flat.center'); -goog.require('ol.geom.flat.closest'); -goog.require('ol.geom.flat.contains'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.interiorpoint'); -goog.require('ol.geom.flat.intersectsextent'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.geom.flat.simplify'); - +/** + * @module ol/geom/MultiPolygon + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_area_ from '../geom/flat/area.js'; +import _ol_geom_flat_center_ from '../geom/flat/center.js'; +import _ol_geom_flat_closest_ from '../geom/flat/closest.js'; +import _ol_geom_flat_contains_ from '../geom/flat/contains.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js'; +import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js'; +import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; +import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; /** * @classdesc @@ -30,9 +30,9 @@ goog.require('ol.geom.flat.simplify'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.MultiPolygon = function(coordinates, opt_layout) { +var _ol_geom_MultiPolygon_ = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); + _ol_geom_SimpleGeometry_.call(this); /** * @type {Array.>} @@ -79,7 +79,8 @@ ol.geom.MultiPolygon = function(coordinates, opt_layout) { this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_MultiPolygon_, _ol_geom_SimpleGeometry_); /** @@ -87,7 +88,7 @@ ol.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry); * @param {ol.geom.Polygon} polygon Polygon. * @api */ -ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) { +_ol_geom_MultiPolygon_.prototype.appendPolygon = function(polygon) { /** @type {Array.} */ var ends; if (!this.flatCoordinates) { @@ -96,7 +97,7 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) { this.endss_.push(); } else { var offset = this.flatCoordinates.length; - ol.array.extend(this.flatCoordinates, polygon.getFlatCoordinates()); + _ol_array_.extend(this.flatCoordinates, polygon.getFlatCoordinates()); ends = polygon.getEnds().slice(); var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { @@ -114,8 +115,8 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) { * @override * @api */ -ol.geom.MultiPolygon.prototype.clone = function() { - var multiPolygon = new ol.geom.MultiPolygon(null); +_ol_geom_MultiPolygon_.prototype.clone = function() { + var multiPolygon = new _ol_geom_MultiPolygon_(null); var len = this.endss_.length; var newEndss = new Array(len); @@ -132,17 +133,17 @@ ol.geom.MultiPolygon.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_MultiPolygon_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } if (this.maxDeltaRevision_ != this.getRevision()) { - this.maxDelta_ = Math.sqrt(ol.geom.flat.closest.getssMaxSquaredDelta( + this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getssMaxSquaredDelta( this.flatCoordinates, 0, this.endss_, this.stride, 0)); this.maxDeltaRevision_ = this.getRevision(); } - return ol.geom.flat.closest.getssClosestPoint( + return _ol_geom_flat_closest_.getssClosestPoint( this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance); }; @@ -151,8 +152,8 @@ ol.geom.MultiPolygon.prototype.closestPointXY = function(x, y, closestPoint, min /** * @inheritDoc */ -ol.geom.MultiPolygon.prototype.containsXY = function(x, y) { - return ol.geom.flat.contains.linearRingssContainsXY( +_ol_geom_MultiPolygon_.prototype.containsXY = function(x, y) { + return _ol_geom_flat_contains_.linearRingssContainsXY( this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, x, y); }; @@ -162,8 +163,8 @@ ol.geom.MultiPolygon.prototype.containsXY = function(x, y) { * @return {number} Area (on projected plane). * @api */ -ol.geom.MultiPolygon.prototype.getArea = function() { - return ol.geom.flat.area.linearRingss( +_ol_geom_MultiPolygon_.prototype.getArea = function() { + return _ol_geom_flat_area_.linearRingss( this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride); }; @@ -182,17 +183,17 @@ ol.geom.MultiPolygon.prototype.getArea = function() { * @override * @api */ -ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { +_ol_geom_MultiPolygon_.prototype.getCoordinates = function(opt_right) { var flatCoordinates; if (opt_right !== undefined) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); - ol.geom.flat.orient.orientLinearRingss( + _ol_geom_flat_orient_.orientLinearRingss( flatCoordinates, 0, this.endss_, this.stride, opt_right); } else { flatCoordinates = this.flatCoordinates; } - return ol.geom.flat.inflate.coordinatesss( + return _ol_geom_flat_inflate_.coordinatesss( flatCoordinates, 0, this.endss_, this.stride); }; @@ -200,7 +201,7 @@ ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { /** * @return {Array.>} Endss. */ -ol.geom.MultiPolygon.prototype.getEndss = function() { +_ol_geom_MultiPolygon_.prototype.getEndss = function() { return this.endss_; }; @@ -208,11 +209,11 @@ ol.geom.MultiPolygon.prototype.getEndss = function() { /** * @return {Array.} Flat interior points. */ -ol.geom.MultiPolygon.prototype.getFlatInteriorPoints = function() { +_ol_geom_MultiPolygon_.prototype.getFlatInteriorPoints = function() { if (this.flatInteriorPointsRevision_ != this.getRevision()) { - var flatCenters = ol.geom.flat.center.linearRingss( + var flatCenters = _ol_geom_flat_center_.linearRingss( this.flatCoordinates, 0, this.endss_, this.stride); - this.flatInteriorPoints_ = ol.geom.flat.interiorpoint.linearRingss( + this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss( this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, flatCenters); this.flatInteriorPointsRevision_ = this.getRevision(); @@ -227,9 +228,9 @@ ol.geom.MultiPolygon.prototype.getFlatInteriorPoints = function() { * the length of the horizontal intersection that the point belongs to. * @api */ -ol.geom.MultiPolygon.prototype.getInteriorPoints = function() { - var interiorPoints = new ol.geom.MultiPoint(null); - interiorPoints.setFlatCoordinates(ol.geom.GeometryLayout.XYM, +_ol_geom_MultiPolygon_.prototype.getInteriorPoints = function() { + var interiorPoints = new _ol_geom_MultiPoint_(null); + interiorPoints.setFlatCoordinates(_ol_geom_GeometryLayout_.XYM, this.getFlatInteriorPoints().slice()); return interiorPoints; }; @@ -238,16 +239,16 @@ ol.geom.MultiPolygon.prototype.getInteriorPoints = function() { /** * @return {Array.} Oriented flat coordinates. */ -ol.geom.MultiPolygon.prototype.getOrientedFlatCoordinates = function() { +_ol_geom_MultiPolygon_.prototype.getOrientedFlatCoordinates = function() { if (this.orientedRevision_ != this.getRevision()) { var flatCoordinates = this.flatCoordinates; - if (ol.geom.flat.orient.linearRingssAreOriented( + if (_ol_geom_flat_orient_.linearRingssAreOriented( flatCoordinates, 0, this.endss_, this.stride)) { this.orientedFlatCoordinates_ = flatCoordinates; } else { this.orientedFlatCoordinates_ = flatCoordinates.slice(); this.orientedFlatCoordinates_.length = - ol.geom.flat.orient.orientLinearRingss( + _ol_geom_flat_orient_.orientLinearRingss( this.orientedFlatCoordinates_, 0, this.endss_, this.stride); } this.orientedRevision_ = this.getRevision(); @@ -259,16 +260,16 @@ ol.geom.MultiPolygon.prototype.getOrientedFlatCoordinates = function() { /** * @inheritDoc */ -ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_MultiPolygon_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { var simplifiedFlatCoordinates = []; var simplifiedEndss = []; - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.quantizess( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizess( this.flatCoordinates, 0, this.endss_, this.stride, Math.sqrt(squaredTolerance), simplifiedFlatCoordinates, 0, simplifiedEndss); - var simplifiedMultiPolygon = new ol.geom.MultiPolygon(null); + var simplifiedMultiPolygon = new _ol_geom_MultiPolygon_(null); simplifiedMultiPolygon.setFlatCoordinates( - ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEndss); + _ol_geom_GeometryLayout_.XY, simplifiedFlatCoordinates, simplifiedEndss); return simplifiedMultiPolygon; }; @@ -279,7 +280,7 @@ ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal = function(squaredT * @return {ol.geom.Polygon} Polygon. * @api */ -ol.geom.MultiPolygon.prototype.getPolygon = function(index) { +_ol_geom_MultiPolygon_.prototype.getPolygon = function(index) { if (index < 0 || this.endss_.length <= index) { return null; } @@ -298,7 +299,7 @@ ol.geom.MultiPolygon.prototype.getPolygon = function(index) { ends[i] -= offset; } } - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); polygon.setFlatCoordinates( this.layout, this.flatCoordinates.slice(offset, end), ends); return polygon; @@ -310,7 +311,7 @@ ol.geom.MultiPolygon.prototype.getPolygon = function(index) { * @return {Array.} Polygons. * @api */ -ol.geom.MultiPolygon.prototype.getPolygons = function() { +_ol_geom_MultiPolygon_.prototype.getPolygons = function() { var layout = this.layout; var flatCoordinates = this.flatCoordinates; var endss = this.endss_; @@ -325,7 +326,7 @@ ol.geom.MultiPolygon.prototype.getPolygons = function() { ends[j] -= offset; } } - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); polygon.setFlatCoordinates( layout, flatCoordinates.slice(offset, end), ends); polygons.push(polygon); @@ -339,8 +340,8 @@ ol.geom.MultiPolygon.prototype.getPolygons = function() { * @inheritDoc * @api */ -ol.geom.MultiPolygon.prototype.getType = function() { - return ol.geom.GeometryType.MULTI_POLYGON; +_ol_geom_MultiPolygon_.prototype.getType = function() { + return _ol_geom_GeometryType_.MULTI_POLYGON; }; @@ -348,8 +349,8 @@ ol.geom.MultiPolygon.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.MultiPolygon.prototype.intersectsExtent = function(extent) { - return ol.geom.flat.intersectsextent.linearRingss( +_ol_geom_MultiPolygon_.prototype.intersectsExtent = function(extent) { + return _ol_geom_flat_intersectsextent_.linearRingss( this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, extent); }; @@ -361,15 +362,15 @@ ol.geom.MultiPolygon.prototype.intersectsExtent = function(extent) { * @override * @api */ -ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_MultiPolygon_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.endss_); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null, this.endss_); } else { this.setLayout(opt_layout, coordinates, 3); if (!this.flatCoordinates) { this.flatCoordinates = []; } - var endss = ol.geom.flat.deflate.coordinatesss( + var endss = _ol_geom_flat_deflate_.coordinatesss( this.flatCoordinates, 0, coordinates, this.stride, this.endss_); if (endss.length === 0) { this.flatCoordinates.length = 0; @@ -388,7 +389,7 @@ ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout * @param {Array.} flatCoordinates Flat coordinates. * @param {Array.>} endss Endss. */ -ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) { +_ol_geom_MultiPolygon_.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.endss_ = endss; this.changed(); @@ -398,7 +399,7 @@ ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordin /** * @param {Array.} polygons Polygons. */ -ol.geom.MultiPolygon.prototype.setPolygons = function(polygons) { +_ol_geom_MultiPolygon_.prototype.setPolygons = function(polygons) { var layout = this.getLayout(); var flatCoordinates = []; var endss = []; @@ -414,8 +415,9 @@ ol.geom.MultiPolygon.prototype.setPolygons = function(polygons) { for (j = 0, jj = ends.length; j < jj; ++j) { ends[j] += offset; } - ol.array.extend(flatCoordinates, polygon.getFlatCoordinates()); + _ol_array_.extend(flatCoordinates, polygon.getFlatCoordinates()); endss.push(ends); } this.setFlatCoordinates(layout, flatCoordinates, endss); }; +export default _ol_geom_MultiPolygon_; diff --git a/src/ol/geom/Point.js b/src/ol/geom/Point.js index 173aa83ce6..02c2a1abc2 100644 --- a/src/ol/geom/Point.js +++ b/src/ol/geom/Point.js @@ -1,13 +1,13 @@ -goog.provide('ol.geom.Point'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.math'); - +/** + * @module ol/geom/Point + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_math_ from '../math.js'; /** * @classdesc @@ -19,11 +19,12 @@ goog.require('ol.math'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.Point = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); +var _ol_geom_Point_ = function(coordinates, opt_layout) { + _ol_geom_SimpleGeometry_.call(this); this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.Point, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_Point_, _ol_geom_SimpleGeometry_); /** @@ -32,8 +33,8 @@ ol.inherits(ol.geom.Point, ol.geom.SimpleGeometry); * @override * @api */ -ol.geom.Point.prototype.clone = function() { - var point = new ol.geom.Point(null); +_ol_geom_Point_.prototype.clone = function() { + var point = new _ol_geom_Point_(null); point.setFlatCoordinates(this.layout, this.flatCoordinates.slice()); return point; }; @@ -42,9 +43,9 @@ ol.geom.Point.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.Point.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_Point_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { var flatCoordinates = this.flatCoordinates; - var squaredDistance = ol.math.squaredDistance( + var squaredDistance = _ol_math_.squaredDistance( x, y, flatCoordinates[0], flatCoordinates[1]); if (squaredDistance < minSquaredDistance) { var stride = this.stride; @@ -66,7 +67,7 @@ ol.geom.Point.prototype.closestPointXY = function(x, y, closestPoint, minSquared * @override * @api */ -ol.geom.Point.prototype.getCoordinates = function() { +_ol_geom_Point_.prototype.getCoordinates = function() { return !this.flatCoordinates ? [] : this.flatCoordinates.slice(); }; @@ -74,8 +75,8 @@ ol.geom.Point.prototype.getCoordinates = function() { /** * @inheritDoc */ -ol.geom.Point.prototype.computeExtent = function(extent) { - return ol.extent.createOrUpdateFromCoordinate(this.flatCoordinates, extent); +_ol_geom_Point_.prototype.computeExtent = function(extent) { + return _ol_extent_.createOrUpdateFromCoordinate(this.flatCoordinates, extent); }; @@ -83,8 +84,8 @@ ol.geom.Point.prototype.computeExtent = function(extent) { * @inheritDoc * @api */ -ol.geom.Point.prototype.getType = function() { - return ol.geom.GeometryType.POINT; +_ol_geom_Point_.prototype.getType = function() { + return _ol_geom_GeometryType_.POINT; }; @@ -92,8 +93,8 @@ ol.geom.Point.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.Point.prototype.intersectsExtent = function(extent) { - return ol.extent.containsXY(extent, +_ol_geom_Point_.prototype.intersectsExtent = function(extent) { + return _ol_extent_.containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]); }; @@ -102,15 +103,15 @@ ol.geom.Point.prototype.intersectsExtent = function(extent) { * @inheritDoc * @api */ -ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_Point_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null); } else { this.setLayout(opt_layout, coordinates, 0); if (!this.flatCoordinates) { this.flatCoordinates = []; } - this.flatCoordinates.length = ol.geom.flat.deflate.coordinate( + this.flatCoordinates.length = _ol_geom_flat_deflate_.coordinate( this.flatCoordinates, 0, coordinates, this.stride); this.changed(); } @@ -121,7 +122,8 @@ ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) { * @param {ol.geom.GeometryLayout} layout Layout. * @param {Array.} flatCoordinates Flat coordinates. */ -ol.geom.Point.prototype.setFlatCoordinates = function(layout, flatCoordinates) { +_ol_geom_Point_.prototype.setFlatCoordinates = function(layout, flatCoordinates) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.changed(); }; +export default _ol_geom_Point_; diff --git a/src/ol/geom/Polygon.js b/src/ol/geom/Polygon.js index 76d2795ab7..c85c655360 100644 --- a/src/ol/geom/Polygon.js +++ b/src/ol/geom/Polygon.js @@ -1,24 +1,24 @@ -goog.provide('ol.geom.Polygon'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.area'); -goog.require('ol.geom.flat.closest'); -goog.require('ol.geom.flat.contains'); -goog.require('ol.geom.flat.deflate'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.interiorpoint'); -goog.require('ol.geom.flat.intersectsextent'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.geom.flat.simplify'); -goog.require('ol.math'); - +/** + * @module ol/geom/Polygon + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LinearRing_ from '../geom/LinearRing.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; +import _ol_geom_flat_area_ from '../geom/flat/area.js'; +import _ol_geom_flat_closest_ from '../geom/flat/closest.js'; +import _ol_geom_flat_contains_ from '../geom/flat/contains.js'; +import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; +import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; +import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js'; +import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js'; +import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; +import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; +import _ol_math_ from '../math.js'; /** * @classdesc @@ -35,9 +35,9 @@ goog.require('ol.math'); * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api */ -ol.geom.Polygon = function(coordinates, opt_layout) { +var _ol_geom_Polygon_ = function(coordinates, opt_layout) { - ol.geom.SimpleGeometry.call(this); + _ol_geom_SimpleGeometry_.call(this); /** * @type {Array.} @@ -84,7 +84,8 @@ ol.geom.Polygon = function(coordinates, opt_layout) { this.setCoordinates(coordinates, opt_layout); }; -ol.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry); + +_ol_.inherits(_ol_geom_Polygon_, _ol_geom_SimpleGeometry_); /** @@ -92,11 +93,11 @@ ol.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry); * @param {ol.geom.LinearRing} linearRing Linear ring. * @api */ -ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) { +_ol_geom_Polygon_.prototype.appendLinearRing = function(linearRing) { if (!this.flatCoordinates) { this.flatCoordinates = linearRing.getFlatCoordinates().slice(); } else { - ol.array.extend(this.flatCoordinates, linearRing.getFlatCoordinates()); + _ol_array_.extend(this.flatCoordinates, linearRing.getFlatCoordinates()); } this.ends_.push(this.flatCoordinates.length); this.changed(); @@ -109,8 +110,8 @@ ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) { * @override * @api */ -ol.geom.Polygon.prototype.clone = function() { - var polygon = new ol.geom.Polygon(null); +_ol_geom_Polygon_.prototype.clone = function() { + var polygon = new _ol_geom_Polygon_(null); polygon.setFlatCoordinates( this.layout, this.flatCoordinates.slice(), this.ends_.slice()); return polygon; @@ -120,17 +121,17 @@ ol.geom.Polygon.prototype.clone = function() { /** * @inheritDoc */ -ol.geom.Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { +_ol_geom_Polygon_.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { if (minSquaredDistance < - ol.extent.closestSquaredDistanceXY(this.getExtent(), x, y)) { + _ol_extent_.closestSquaredDistanceXY(this.getExtent(), x, y)) { return minSquaredDistance; } if (this.maxDeltaRevision_ != this.getRevision()) { - this.maxDelta_ = Math.sqrt(ol.geom.flat.closest.getsMaxSquaredDelta( + this.maxDelta_ = Math.sqrt(_ol_geom_flat_closest_.getsMaxSquaredDelta( this.flatCoordinates, 0, this.ends_, this.stride, 0)); this.maxDeltaRevision_ = this.getRevision(); } - return ol.geom.flat.closest.getsClosestPoint( + return _ol_geom_flat_closest_.getsClosestPoint( this.flatCoordinates, 0, this.ends_, this.stride, this.maxDelta_, true, x, y, closestPoint, minSquaredDistance); }; @@ -139,8 +140,8 @@ ol.geom.Polygon.prototype.closestPointXY = function(x, y, closestPoint, minSquar /** * @inheritDoc */ -ol.geom.Polygon.prototype.containsXY = function(x, y) { - return ol.geom.flat.contains.linearRingsContainsXY( +_ol_geom_Polygon_.prototype.containsXY = function(x, y) { + return _ol_geom_flat_contains_.linearRingsContainsXY( this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, x, y); }; @@ -150,8 +151,8 @@ ol.geom.Polygon.prototype.containsXY = function(x, y) { * @return {number} Area (on projected plane). * @api */ -ol.geom.Polygon.prototype.getArea = function() { - return ol.geom.flat.area.linearRings( +_ol_geom_Polygon_.prototype.getArea = function() { + return _ol_geom_flat_area_.linearRings( this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride); }; @@ -170,17 +171,17 @@ ol.geom.Polygon.prototype.getArea = function() { * @override * @api */ -ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { +_ol_geom_Polygon_.prototype.getCoordinates = function(opt_right) { var flatCoordinates; if (opt_right !== undefined) { flatCoordinates = this.getOrientedFlatCoordinates().slice(); - ol.geom.flat.orient.orientLinearRings( + _ol_geom_flat_orient_.orientLinearRings( flatCoordinates, 0, this.ends_, this.stride, opt_right); } else { flatCoordinates = this.flatCoordinates; } - return ol.geom.flat.inflate.coordinatess( + return _ol_geom_flat_inflate_.coordinatess( flatCoordinates, 0, this.ends_, this.stride); }; @@ -188,7 +189,7 @@ ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { /** * @return {Array.} Ends. */ -ol.geom.Polygon.prototype.getEnds = function() { +_ol_geom_Polygon_.prototype.getEnds = function() { return this.ends_; }; @@ -196,10 +197,10 @@ ol.geom.Polygon.prototype.getEnds = function() { /** * @return {Array.} Interior point. */ -ol.geom.Polygon.prototype.getFlatInteriorPoint = function() { +_ol_geom_Polygon_.prototype.getFlatInteriorPoint = function() { if (this.flatInteriorPointRevision_ != this.getRevision()) { - var flatCenter = ol.extent.getCenter(this.getExtent()); - this.flatInteriorPoint_ = ol.geom.flat.interiorpoint.linearRings( + var flatCenter = _ol_extent_.getCenter(this.getExtent()); + this.flatInteriorPoint_ = _ol_geom_flat_interiorpoint_.linearRings( this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, flatCenter, 0); this.flatInteriorPointRevision_ = this.getRevision(); @@ -214,8 +215,8 @@ ol.geom.Polygon.prototype.getFlatInteriorPoint = function() { * length of the horizontal intersection that the point belongs to. * @api */ -ol.geom.Polygon.prototype.getInteriorPoint = function() { - return new ol.geom.Point(this.getFlatInteriorPoint(), ol.geom.GeometryLayout.XYM); +_ol_geom_Polygon_.prototype.getInteriorPoint = function() { + return new _ol_geom_Point_(this.getFlatInteriorPoint(), _ol_geom_GeometryLayout_.XYM); }; @@ -226,7 +227,7 @@ ol.geom.Polygon.prototype.getInteriorPoint = function() { * @return {number} Number of rings. * @api */ -ol.geom.Polygon.prototype.getLinearRingCount = function() { +_ol_geom_Polygon_.prototype.getLinearRingCount = function() { return this.ends_.length; }; @@ -241,11 +242,11 @@ ol.geom.Polygon.prototype.getLinearRingCount = function() { * @return {ol.geom.LinearRing} Linear ring. * @api */ -ol.geom.Polygon.prototype.getLinearRing = function(index) { +_ol_geom_Polygon_.prototype.getLinearRing = function(index) { if (index < 0 || this.ends_.length <= index) { return null; } - var linearRing = new ol.geom.LinearRing(null); + var linearRing = new _ol_geom_LinearRing_(null); linearRing.setFlatCoordinates(this.layout, this.flatCoordinates.slice( index === 0 ? 0 : this.ends_[index - 1], this.ends_[index])); return linearRing; @@ -257,7 +258,7 @@ ol.geom.Polygon.prototype.getLinearRing = function(index) { * @return {Array.} Linear rings. * @api */ -ol.geom.Polygon.prototype.getLinearRings = function() { +_ol_geom_Polygon_.prototype.getLinearRings = function() { var layout = this.layout; var flatCoordinates = this.flatCoordinates; var ends = this.ends_; @@ -266,7 +267,7 @@ ol.geom.Polygon.prototype.getLinearRings = function() { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var linearRing = new ol.geom.LinearRing(null); + var linearRing = new _ol_geom_LinearRing_(null); linearRing.setFlatCoordinates(layout, flatCoordinates.slice(offset, end)); linearRings.push(linearRing); offset = end; @@ -278,16 +279,16 @@ ol.geom.Polygon.prototype.getLinearRings = function() { /** * @return {Array.} Oriented flat coordinates. */ -ol.geom.Polygon.prototype.getOrientedFlatCoordinates = function() { +_ol_geom_Polygon_.prototype.getOrientedFlatCoordinates = function() { if (this.orientedRevision_ != this.getRevision()) { var flatCoordinates = this.flatCoordinates; - if (ol.geom.flat.orient.linearRingsAreOriented( + if (_ol_geom_flat_orient_.linearRingsAreOriented( flatCoordinates, 0, this.ends_, this.stride)) { this.orientedFlatCoordinates_ = flatCoordinates; } else { this.orientedFlatCoordinates_ = flatCoordinates.slice(); this.orientedFlatCoordinates_.length = - ol.geom.flat.orient.orientLinearRings( + _ol_geom_flat_orient_.orientLinearRings( this.orientedFlatCoordinates_, 0, this.ends_, this.stride); } this.orientedRevision_ = this.getRevision(); @@ -299,16 +300,16 @@ ol.geom.Polygon.prototype.getOrientedFlatCoordinates = function() { /** * @inheritDoc */ -ol.geom.Polygon.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_Polygon_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { var simplifiedFlatCoordinates = []; var simplifiedEnds = []; - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.quantizes( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.quantizes( this.flatCoordinates, 0, this.ends_, this.stride, Math.sqrt(squaredTolerance), simplifiedFlatCoordinates, 0, simplifiedEnds); - var simplifiedPolygon = new ol.geom.Polygon(null); + var simplifiedPolygon = new _ol_geom_Polygon_(null); simplifiedPolygon.setFlatCoordinates( - ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds); + _ol_geom_GeometryLayout_.XY, simplifiedFlatCoordinates, simplifiedEnds); return simplifiedPolygon; }; @@ -317,8 +318,8 @@ ol.geom.Polygon.prototype.getSimplifiedGeometryInternal = function(squaredTolera * @inheritDoc * @api */ -ol.geom.Polygon.prototype.getType = function() { - return ol.geom.GeometryType.POLYGON; +_ol_geom_Polygon_.prototype.getType = function() { + return _ol_geom_GeometryType_.POLYGON; }; @@ -326,8 +327,8 @@ ol.geom.Polygon.prototype.getType = function() { * @inheritDoc * @api */ -ol.geom.Polygon.prototype.intersectsExtent = function(extent) { - return ol.geom.flat.intersectsextent.linearRings( +_ol_geom_Polygon_.prototype.intersectsExtent = function(extent) { + return _ol_geom_flat_intersectsextent_.linearRings( this.getOrientedFlatCoordinates(), 0, this.ends_, this.stride, extent); }; @@ -339,15 +340,15 @@ ol.geom.Polygon.prototype.intersectsExtent = function(extent) { * @override * @api */ -ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) { +_ol_geom_Polygon_.prototype.setCoordinates = function(coordinates, opt_layout) { if (!coordinates) { - this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); + this.setFlatCoordinates(_ol_geom_GeometryLayout_.XY, null, this.ends_); } else { this.setLayout(opt_layout, coordinates, 2); if (!this.flatCoordinates) { this.flatCoordinates = []; } - var ends = ol.geom.flat.deflate.coordinatess( + var ends = _ol_geom_flat_deflate_.coordinatess( this.flatCoordinates, 0, coordinates, this.stride, this.ends_); this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1]; this.changed(); @@ -360,7 +361,7 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) { * @param {Array.} flatCoordinates Flat coordinates. * @param {Array.} ends Ends. */ -ol.geom.Polygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) { +_ol_geom_Polygon_.prototype.setFlatCoordinates = function(layout, flatCoordinates, ends) { this.setFlatCoordinatesInternal(layout, flatCoordinates); this.ends_ = ends; this.changed(); @@ -378,19 +379,19 @@ ol.geom.Polygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, * @return {ol.geom.Polygon} The "circular" polygon. * @api */ -ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) { +_ol_geom_Polygon_.circular = function(sphere, center, radius, opt_n) { var n = opt_n ? opt_n : 32; /** @type {Array.} */ var flatCoordinates = []; var i; for (i = 0; i < n; ++i) { - ol.array.extend( + _ol_array_.extend( flatCoordinates, sphere.offset(center, radius, 2 * Math.PI * i / n)); } flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]); - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); polygon.setFlatCoordinates( - ol.geom.GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]); + _ol_geom_GeometryLayout_.XY, flatCoordinates, [flatCoordinates.length]); return polygon; }; @@ -401,16 +402,16 @@ ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) { * @return {ol.geom.Polygon} The polygon. * @api */ -ol.geom.Polygon.fromExtent = function(extent) { +_ol_geom_Polygon_.fromExtent = function(extent) { var minX = extent[0]; var minY = extent[1]; var maxX = extent[2]; var maxY = extent[3]; var flatCoordinates = [minX, minY, minX, maxY, maxX, maxY, maxX, minY, minX, minY]; - var polygon = new ol.geom.Polygon(null); + var polygon = new _ol_geom_Polygon_(null); polygon.setFlatCoordinates( - ol.geom.GeometryLayout.XY, flatCoordinates, [flatCoordinates.length]); + _ol_geom_GeometryLayout_.XY, flatCoordinates, [flatCoordinates.length]); return polygon; }; @@ -424,11 +425,11 @@ ol.geom.Polygon.fromExtent = function(extent) { * @return {ol.geom.Polygon} Polygon geometry. * @api */ -ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) { +_ol_geom_Polygon_.fromCircle = function(circle, opt_sides, opt_angle) { var sides = opt_sides ? opt_sides : 32; var stride = circle.getStride(); var layout = circle.getLayout(); - var polygon = new ol.geom.Polygon(null, layout); + var polygon = new _ol_geom_Polygon_(null, layout); var arrayLength = stride * (sides + 1); var flatCoordinates = new Array(arrayLength); for (var i = 0; i < arrayLength; i++) { @@ -436,7 +437,7 @@ ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) { } var ends = [flatCoordinates.length]; polygon.setFlatCoordinates(layout, flatCoordinates, ends); - ol.geom.Polygon.makeRegular( + _ol_geom_Polygon_.makeRegular( polygon, circle.getCenter(), circle.getRadius(), opt_angle); return polygon; }; @@ -450,7 +451,7 @@ ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) { * @param {number=} opt_angle Start angle for the first vertex of the polygon in * radians. Default is 0. */ -ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) { +_ol_geom_Polygon_.makeRegular = function(polygon, center, radius, opt_angle) { var flatCoordinates = polygon.getFlatCoordinates(); var layout = polygon.getLayout(); var stride = polygon.getStride(); @@ -460,9 +461,10 @@ ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) { var angle, offset; for (var i = 0; i <= sides; ++i) { offset = i * stride; - angle = startAngle + (ol.math.modulo(i, sides) * 2 * Math.PI / sides); + angle = startAngle + (_ol_math_.modulo(i, sides) * 2 * Math.PI / sides); flatCoordinates[offset] = center[0] + (radius * Math.cos(angle)); flatCoordinates[offset + 1] = center[1] + (radius * Math.sin(angle)); } polygon.setFlatCoordinates(layout, flatCoordinates, ends); }; +export default _ol_geom_Polygon_; diff --git a/src/ol/geom/SimpleGeometry.js b/src/ol/geom/SimpleGeometry.js index ecd5626144..a01c06aecc 100644 --- a/src/ol/geom/SimpleGeometry.js +++ b/src/ol/geom/SimpleGeometry.js @@ -1,13 +1,13 @@ -goog.provide('ol.geom.SimpleGeometry'); - -goog.require('ol'); -goog.require('ol.functions'); -goog.require('ol.extent'); -goog.require('ol.geom.Geometry'); -goog.require('ol.geom.GeometryLayout'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.obj'); - +/** + * @module ol/geom/SimpleGeometry + */ +import _ol_ from '../index.js'; +import _ol_functions_ from '../functions.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_Geometry_ from '../geom/Geometry.js'; +import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; +import _ol_geom_flat_transform_ from '../geom/flat/transform.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -19,15 +19,15 @@ goog.require('ol.obj'); * @extends {ol.geom.Geometry} * @api */ -ol.geom.SimpleGeometry = function() { +var _ol_geom_SimpleGeometry_ = function() { - ol.geom.Geometry.call(this); + _ol_geom_Geometry_.call(this); /** * @protected * @type {ol.geom.GeometryLayout} */ - this.layout = ol.geom.GeometryLayout.XY; + this.layout = _ol_geom_GeometryLayout_.XY; /** * @protected @@ -42,7 +42,8 @@ ol.geom.SimpleGeometry = function() { this.flatCoordinates = null; }; -ol.inherits(ol.geom.SimpleGeometry, ol.geom.Geometry); + +_ol_.inherits(_ol_geom_SimpleGeometry_, _ol_geom_Geometry_); /** @@ -50,14 +51,14 @@ ol.inherits(ol.geom.SimpleGeometry, ol.geom.Geometry); * @private * @return {ol.geom.GeometryLayout} layout Layout. */ -ol.geom.SimpleGeometry.getLayoutForStride_ = function(stride) { +_ol_geom_SimpleGeometry_.getLayoutForStride_ = function(stride) { var layout; if (stride == 2) { - layout = ol.geom.GeometryLayout.XY; + layout = _ol_geom_GeometryLayout_.XY; } else if (stride == 3) { - layout = ol.geom.GeometryLayout.XYZ; + layout = _ol_geom_GeometryLayout_.XYZ; } else if (stride == 4) { - layout = ol.geom.GeometryLayout.XYZM; + layout = _ol_geom_GeometryLayout_.XYZM; } return /** @type {ol.geom.GeometryLayout} */ (layout); }; @@ -67,13 +68,13 @@ ol.geom.SimpleGeometry.getLayoutForStride_ = function(stride) { * @param {ol.geom.GeometryLayout} layout Layout. * @return {number} Stride. */ -ol.geom.SimpleGeometry.getStrideForLayout = function(layout) { +_ol_geom_SimpleGeometry_.getStrideForLayout = function(layout) { var stride; - if (layout == ol.geom.GeometryLayout.XY) { + if (layout == _ol_geom_GeometryLayout_.XY) { stride = 2; - } else if (layout == ol.geom.GeometryLayout.XYZ || layout == ol.geom.GeometryLayout.XYM) { + } else if (layout == _ol_geom_GeometryLayout_.XYZ || layout == _ol_geom_GeometryLayout_.XYM) { stride = 3; - } else if (layout == ol.geom.GeometryLayout.XYZM) { + } else if (layout == _ol_geom_GeometryLayout_.XYZM) { stride = 4; } return /** @type {number} */ (stride); @@ -83,14 +84,14 @@ ol.geom.SimpleGeometry.getStrideForLayout = function(layout) { /** * @inheritDoc */ -ol.geom.SimpleGeometry.prototype.containsXY = ol.functions.FALSE; +_ol_geom_SimpleGeometry_.prototype.containsXY = _ol_functions_.FALSE; /** * @inheritDoc */ -ol.geom.SimpleGeometry.prototype.computeExtent = function(extent) { - return ol.extent.createOrUpdateFromFlatCoordinates( +_ol_geom_SimpleGeometry_.prototype.computeExtent = function(extent) { + return _ol_extent_.createOrUpdateFromFlatCoordinates( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, extent); }; @@ -100,7 +101,7 @@ ol.geom.SimpleGeometry.prototype.computeExtent = function(extent) { * @abstract * @return {Array} Coordinates. */ -ol.geom.SimpleGeometry.prototype.getCoordinates = function() {}; +_ol_geom_SimpleGeometry_.prototype.getCoordinates = function() {}; /** @@ -108,7 +109,7 @@ ol.geom.SimpleGeometry.prototype.getCoordinates = function() {}; * @return {ol.Coordinate} First coordinate. * @api */ -ol.geom.SimpleGeometry.prototype.getFirstCoordinate = function() { +_ol_geom_SimpleGeometry_.prototype.getFirstCoordinate = function() { return this.flatCoordinates.slice(0, this.stride); }; @@ -116,7 +117,7 @@ ol.geom.SimpleGeometry.prototype.getFirstCoordinate = function() { /** * @return {Array.} Flat coordinates. */ -ol.geom.SimpleGeometry.prototype.getFlatCoordinates = function() { +_ol_geom_SimpleGeometry_.prototype.getFlatCoordinates = function() { return this.flatCoordinates; }; @@ -126,7 +127,7 @@ ol.geom.SimpleGeometry.prototype.getFlatCoordinates = function() { * @return {ol.Coordinate} Last point. * @api */ -ol.geom.SimpleGeometry.prototype.getLastCoordinate = function() { +_ol_geom_SimpleGeometry_.prototype.getLastCoordinate = function() { return this.flatCoordinates.slice(this.flatCoordinates.length - this.stride); }; @@ -136,7 +137,7 @@ ol.geom.SimpleGeometry.prototype.getLastCoordinate = function() { * @return {ol.geom.GeometryLayout} Layout. * @api */ -ol.geom.SimpleGeometry.prototype.getLayout = function() { +_ol_geom_SimpleGeometry_.prototype.getLayout = function() { return this.layout; }; @@ -144,9 +145,9 @@ ol.geom.SimpleGeometry.prototype.getLayout = function() { /** * @inheritDoc */ -ol.geom.SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredTolerance) { +_ol_geom_SimpleGeometry_.prototype.getSimplifiedGeometry = function(squaredTolerance) { if (this.simplifiedGeometryRevision != this.getRevision()) { - ol.obj.clear(this.simplifiedGeometryCache); + _ol_obj_.clear(this.simplifiedGeometryCache); this.simplifiedGeometryMaxMinSquaredTolerance = 0; this.simplifiedGeometryRevision = this.getRevision(); } @@ -186,7 +187,7 @@ ol.geom.SimpleGeometry.prototype.getSimplifiedGeometry = function(squaredToleran * @return {ol.geom.SimpleGeometry} Simplified geometry. * @protected */ -ol.geom.SimpleGeometry.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { +_ol_geom_SimpleGeometry_.prototype.getSimplifiedGeometryInternal = function(squaredTolerance) { return this; }; @@ -194,7 +195,7 @@ ol.geom.SimpleGeometry.prototype.getSimplifiedGeometryInternal = function(square /** * @return {number} Stride. */ -ol.geom.SimpleGeometry.prototype.getStride = function() { +_ol_geom_SimpleGeometry_.prototype.getStride = function() { return this.stride; }; @@ -204,8 +205,8 @@ ol.geom.SimpleGeometry.prototype.getStride = function() { * @param {Array.} flatCoordinates Flat coordinates. * @protected */ -ol.geom.SimpleGeometry.prototype.setFlatCoordinatesInternal = function(layout, flatCoordinates) { - this.stride = ol.geom.SimpleGeometry.getStrideForLayout(layout); +_ol_geom_SimpleGeometry_.prototype.setFlatCoordinatesInternal = function(layout, flatCoordinates) { + this.stride = _ol_geom_SimpleGeometry_.getStrideForLayout(layout); this.layout = layout; this.flatCoordinates = flatCoordinates; }; @@ -216,7 +217,7 @@ ol.geom.SimpleGeometry.prototype.setFlatCoordinatesInternal = function(layout, f * @param {Array} coordinates Coordinates. * @param {ol.geom.GeometryLayout=} opt_layout Layout. */ -ol.geom.SimpleGeometry.prototype.setCoordinates = function(coordinates, opt_layout) {}; +_ol_geom_SimpleGeometry_.prototype.setCoordinates = function(coordinates, opt_layout) {}; /** @@ -225,16 +226,16 @@ ol.geom.SimpleGeometry.prototype.setCoordinates = function(coordinates, opt_layo * @param {number} nesting Nesting. * @protected */ -ol.geom.SimpleGeometry.prototype.setLayout = function(layout, coordinates, nesting) { +_ol_geom_SimpleGeometry_.prototype.setLayout = function(layout, coordinates, nesting) { /** @type {number} */ var stride; if (layout) { - stride = ol.geom.SimpleGeometry.getStrideForLayout(layout); + stride = _ol_geom_SimpleGeometry_.getStrideForLayout(layout); } else { var i; for (i = 0; i < nesting; ++i) { if (coordinates.length === 0) { - this.layout = ol.geom.GeometryLayout.XY; + this.layout = _ol_geom_GeometryLayout_.XY; this.stride = 2; return; } else { @@ -242,7 +243,7 @@ ol.geom.SimpleGeometry.prototype.setLayout = function(layout, coordinates, nesti } } stride = coordinates.length; - layout = ol.geom.SimpleGeometry.getLayoutForStride_(stride); + layout = _ol_geom_SimpleGeometry_.getLayoutForStride_(stride); } this.layout = layout; this.stride = stride; @@ -253,7 +254,7 @@ ol.geom.SimpleGeometry.prototype.setLayout = function(layout, coordinates, nesti * @inheritDoc * @api */ -ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) { +_ol_geom_SimpleGeometry_.prototype.applyTransform = function(transformFn) { if (this.flatCoordinates) { transformFn(this.flatCoordinates, this.flatCoordinates, this.stride); this.changed(); @@ -265,11 +266,11 @@ ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) { * @inheritDoc * @api */ -ol.geom.SimpleGeometry.prototype.rotate = function(angle, anchor) { +_ol_geom_SimpleGeometry_.prototype.rotate = function(angle, anchor) { var flatCoordinates = this.getFlatCoordinates(); if (flatCoordinates) { var stride = this.getStride(); - ol.geom.flat.transform.rotate( + _ol_geom_flat_transform_.rotate( flatCoordinates, 0, flatCoordinates.length, stride, angle, anchor, flatCoordinates); this.changed(); @@ -281,19 +282,19 @@ ol.geom.SimpleGeometry.prototype.rotate = function(angle, anchor) { * @inheritDoc * @api */ -ol.geom.SimpleGeometry.prototype.scale = function(sx, opt_sy, opt_anchor) { +_ol_geom_SimpleGeometry_.prototype.scale = function(sx, opt_sy, opt_anchor) { var sy = opt_sy; if (sy === undefined) { sy = sx; } var anchor = opt_anchor; if (!anchor) { - anchor = ol.extent.getCenter(this.getExtent()); + anchor = _ol_extent_.getCenter(this.getExtent()); } var flatCoordinates = this.getFlatCoordinates(); if (flatCoordinates) { var stride = this.getStride(); - ol.geom.flat.transform.scale( + _ol_geom_flat_transform_.scale( flatCoordinates, 0, flatCoordinates.length, stride, sx, sy, anchor, flatCoordinates); this.changed(); @@ -305,11 +306,11 @@ ol.geom.SimpleGeometry.prototype.scale = function(sx, opt_sy, opt_anchor) { * @inheritDoc * @api */ -ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) { +_ol_geom_SimpleGeometry_.prototype.translate = function(deltaX, deltaY) { var flatCoordinates = this.getFlatCoordinates(); if (flatCoordinates) { var stride = this.getStride(); - ol.geom.flat.transform.translate( + _ol_geom_flat_transform_.translate( flatCoordinates, 0, flatCoordinates.length, stride, deltaX, deltaY, flatCoordinates); this.changed(); @@ -323,14 +324,15 @@ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) { * @param {Array.=} opt_dest Destination. * @return {Array.} Transformed flat coordinates. */ -ol.geom.SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) { +_ol_geom_SimpleGeometry_.transform2D = function(simpleGeometry, transform, opt_dest) { var flatCoordinates = simpleGeometry.getFlatCoordinates(); if (!flatCoordinates) { return null; } else { var stride = simpleGeometry.getStride(); - return ol.geom.flat.transform.transform2D( + return _ol_geom_flat_transform_.transform2D( flatCoordinates, 0, flatCoordinates.length, stride, transform, opt_dest); } }; +export default _ol_geom_SimpleGeometry_; diff --git a/src/ol/geom/flat/area.js b/src/ol/geom/flat/area.js index 074f50c25d..f4bcd552d0 100644 --- a/src/ol/geom/flat/area.js +++ b/src/ol/geom/flat/area.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.area'); +/** + * @module ol/geom/flat/area + */ +var _ol_geom_flat_area_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.geom.flat.area'); * @param {number} stride Stride. * @return {number} Area. */ -ol.geom.flat.area.linearRing = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_area_.linearRing = function(flatCoordinates, offset, end, stride) { var twiceArea = 0; var x1 = flatCoordinates[end - stride]; var y1 = flatCoordinates[end - stride + 1]; @@ -30,12 +33,12 @@ ol.geom.flat.area.linearRing = function(flatCoordinates, offset, end, stride) { * @param {number} stride Stride. * @return {number} Area. */ -ol.geom.flat.area.linearRings = function(flatCoordinates, offset, ends, stride) { +_ol_geom_flat_area_.linearRings = function(flatCoordinates, offset, ends, stride) { var area = 0; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - area += ol.geom.flat.area.linearRing(flatCoordinates, offset, end, stride); + area += _ol_geom_flat_area_.linearRing(flatCoordinates, offset, end, stride); offset = end; } return area; @@ -49,14 +52,15 @@ ol.geom.flat.area.linearRings = function(flatCoordinates, offset, ends, stride) * @param {number} stride Stride. * @return {number} Area. */ -ol.geom.flat.area.linearRingss = function(flatCoordinates, offset, endss, stride) { +_ol_geom_flat_area_.linearRingss = function(flatCoordinates, offset, endss, stride) { var area = 0; var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; area += - ol.geom.flat.area.linearRings(flatCoordinates, offset, ends, stride); + _ol_geom_flat_area_.linearRings(flatCoordinates, offset, ends, stride); offset = ends[ends.length - 1]; } return area; }; +export default _ol_geom_flat_area_; diff --git a/src/ol/geom/flat/center.js b/src/ol/geom/flat/center.js index a308c7e043..70eb13c7d3 100644 --- a/src/ol/geom/flat/center.js +++ b/src/ol/geom/flat/center.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.center'); - -goog.require('ol.extent'); +/** + * @module ol/geom/flat/center + */ +import _ol_extent_ from '../../extent.js'; +var _ol_geom_flat_center_ = {}; /** @@ -10,16 +12,17 @@ goog.require('ol.extent'); * @param {number} stride Stride. * @return {Array.} Flat centers. */ -ol.geom.flat.center.linearRingss = function(flatCoordinates, offset, endss, stride) { +_ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, stride) { var flatCenters = []; var i, ii; - var extent = ol.extent.createEmpty(); + var extent = _ol_extent_.createEmpty(); for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - extent = ol.extent.createOrUpdateFromFlatCoordinates( + extent = _ol_extent_.createOrUpdateFromFlatCoordinates( flatCoordinates, offset, ends[0], stride); flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2); offset = ends[ends.length - 1]; } return flatCenters; }; +export default _ol_geom_flat_center_; diff --git a/src/ol/geom/flat/closest.js b/src/ol/geom/flat/closest.js index 712b3f260e..aa4323fb5d 100644 --- a/src/ol/geom/flat/closest.js +++ b/src/ol/geom/flat/closest.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.closest'); - -goog.require('ol.math'); +/** + * @module ol/geom/flat/closest + */ +import _ol_math_ from '../../math.js'; +var _ol_geom_flat_closest_ = {}; /** @@ -15,7 +17,7 @@ goog.require('ol.math'); * @param {number} y Y. * @param {Array.} closestPoint Closest point. */ -ol.geom.flat.closest.point = function(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) { +_ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) { var x1 = flatCoordinates[offset1]; var y1 = flatCoordinates[offset1 + 1]; var dx = flatCoordinates[offset2] - x1; @@ -29,7 +31,7 @@ ol.geom.flat.closest.point = function(flatCoordinates, offset1, offset2, stride, offset = offset2; } else if (t > 0) { for (i = 0; i < stride; ++i) { - closestPoint[i] = ol.math.lerp(flatCoordinates[offset1 + i], + closestPoint[i] = _ol_math_.lerp(flatCoordinates[offset1 + i], flatCoordinates[offset2 + i], t); } closestPoint.length = stride; @@ -55,13 +57,13 @@ ol.geom.flat.closest.point = function(flatCoordinates, offset1, offset2, stride, * @param {number} maxSquaredDelta Max squared delta. * @return {number} Max squared delta. */ -ol.geom.flat.closest.getMaxSquaredDelta = function(flatCoordinates, offset, end, stride, maxSquaredDelta) { +_ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, end, stride, maxSquaredDelta) { var x1 = flatCoordinates[offset]; var y1 = flatCoordinates[offset + 1]; for (offset += stride; offset < end; offset += stride) { var x2 = flatCoordinates[offset]; var y2 = flatCoordinates[offset + 1]; - var squaredDelta = ol.math.squaredDistance(x1, y1, x2, y2); + var squaredDelta = _ol_math_.squaredDistance(x1, y1, x2, y2); if (squaredDelta > maxSquaredDelta) { maxSquaredDelta = squaredDelta; } @@ -80,11 +82,11 @@ ol.geom.flat.closest.getMaxSquaredDelta = function(flatCoordinates, offset, end, * @param {number} maxSquaredDelta Max squared delta. * @return {number} Max squared delta. */ -ol.geom.flat.closest.getsMaxSquaredDelta = function(flatCoordinates, offset, ends, stride, maxSquaredDelta) { +_ol_geom_flat_closest_.getsMaxSquaredDelta = function(flatCoordinates, offset, ends, stride, maxSquaredDelta) { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - maxSquaredDelta = ol.geom.flat.closest.getMaxSquaredDelta( + maxSquaredDelta = _ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, offset, end, stride, maxSquaredDelta); offset = end; } @@ -100,11 +102,11 @@ ol.geom.flat.closest.getsMaxSquaredDelta = function(flatCoordinates, offset, end * @param {number} maxSquaredDelta Max squared delta. * @return {number} Max squared delta. */ -ol.geom.flat.closest.getssMaxSquaredDelta = function(flatCoordinates, offset, endss, stride, maxSquaredDelta) { +_ol_geom_flat_closest_.getssMaxSquaredDelta = function(flatCoordinates, offset, endss, stride, maxSquaredDelta) { var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - maxSquaredDelta = ol.geom.flat.closest.getsMaxSquaredDelta( + maxSquaredDelta = _ol_geom_flat_closest_.getsMaxSquaredDelta( flatCoordinates, offset, ends, stride, maxSquaredDelta); offset = ends[ends.length - 1]; } @@ -126,7 +128,7 @@ ol.geom.flat.closest.getssMaxSquaredDelta = function(flatCoordinates, offset, en * @param {Array.=} opt_tmpPoint Temporary point object. * @return {number} Minimum squared distance. */ -ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, +_ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) { if (offset == end) { @@ -135,7 +137,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, var i, squaredDistance; if (maxDelta === 0) { // All points are identical, so just test the first point. - squaredDistance = ol.math.squaredDistance( + squaredDistance = _ol_math_.squaredDistance( x, y, flatCoordinates[offset], flatCoordinates[offset + 1]); if (squaredDistance < minSquaredDistance) { for (i = 0; i < stride; ++i) { @@ -150,9 +152,9 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var index = offset + stride; while (index < end) { - ol.geom.flat.closest.point( + _ol_geom_flat_closest_.point( flatCoordinates, index - stride, index, stride, x, y, tmpPoint); - squaredDistance = ol.math.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); + squaredDistance = _ol_math_.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); if (squaredDistance < minSquaredDistance) { minSquaredDistance = squaredDistance; for (i = 0; i < stride; ++i) { @@ -178,9 +180,9 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, } if (isRing) { // Check the closing segment. - ol.geom.flat.closest.point( + _ol_geom_flat_closest_.point( flatCoordinates, end - stride, offset, stride, x, y, tmpPoint); - squaredDistance = ol.math.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); + squaredDistance = _ol_math_.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); if (squaredDistance < minSquaredDistance) { minSquaredDistance = squaredDistance; for (i = 0; i < stride; ++i) { @@ -207,14 +209,14 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end, * @param {Array.=} opt_tmpPoint Temporary point object. * @return {number} Minimum squared distance. */ -ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends, +_ol_geom_flat_closest_.getsClosestPoint = function(flatCoordinates, offset, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) { var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - minSquaredDistance = ol.geom.flat.closest.getClosestPoint( + minSquaredDistance = _ol_geom_flat_closest_.getClosestPoint( flatCoordinates, offset, end, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint); offset = end; @@ -237,17 +239,18 @@ ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends, * @param {Array.=} opt_tmpPoint Temporary point object. * @return {number} Minimum squared distance. */ -ol.geom.flat.closest.getssClosestPoint = function(flatCoordinates, offset, +_ol_geom_flat_closest_.getssClosestPoint = function(flatCoordinates, offset, endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, opt_tmpPoint) { var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN]; var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - minSquaredDistance = ol.geom.flat.closest.getsClosestPoint( + minSquaredDistance = _ol_geom_flat_closest_.getsClosestPoint( flatCoordinates, offset, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint); offset = ends[ends.length - 1]; } return minSquaredDistance; }; +export default _ol_geom_flat_closest_; diff --git a/src/ol/geom/flat/contains.js b/src/ol/geom/flat/contains.js index a0248b82d5..ac468dd094 100644 --- a/src/ol/geom/flat/contains.js +++ b/src/ol/geom/flat/contains.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.contains'); - -goog.require('ol.extent'); +/** + * @module ol/geom/flat/contains + */ +import _ol_extent_ from '../../extent.js'; +var _ol_geom_flat_contains_ = {}; /** @@ -11,14 +13,14 @@ goog.require('ol.extent'); * @param {ol.Extent} extent Extent. * @return {boolean} Contains extent. */ -ol.geom.flat.contains.linearRingContainsExtent = function(flatCoordinates, offset, end, stride, extent) { - var outside = ol.extent.forEachCorner(extent, +_ol_geom_flat_contains_.linearRingContainsExtent = function(flatCoordinates, offset, end, stride, extent) { + var outside = _ol_extent_.forEachCorner(extent, /** * @param {ol.Coordinate} coordinate Coordinate. * @return {boolean} Contains (x, y). */ function(coordinate) { - return !ol.geom.flat.contains.linearRingContainsXY(flatCoordinates, + return !_ol_geom_flat_contains_.linearRingContainsXY(flatCoordinates, offset, end, stride, coordinate[0], coordinate[1]); }); return !outside; @@ -34,7 +36,7 @@ ol.geom.flat.contains.linearRingContainsExtent = function(flatCoordinates, offse * @param {number} y Y. * @return {boolean} Contains (x, y). */ -ol.geom.flat.contains.linearRingContainsXY = function(flatCoordinates, offset, end, stride, x, y) { +_ol_geom_flat_contains_.linearRingContainsXY = function(flatCoordinates, offset, end, stride, x, y) { // http://geomalgorithms.com/a03-_inclusion.html // Copyright 2000 softSurfer, 2012 Dan Sunday // This code may be freely used and modified for any purpose @@ -71,17 +73,17 @@ ol.geom.flat.contains.linearRingContainsXY = function(flatCoordinates, offset, e * @param {number} y Y. * @return {boolean} Contains (x, y). */ -ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) { +_ol_geom_flat_contains_.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) { if (ends.length === 0) { return false; } - if (!ol.geom.flat.contains.linearRingContainsXY( + if (!_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, offset, ends[0], stride, x, y)) { return false; } var i, ii; for (i = 1, ii = ends.length; i < ii; ++i) { - if (ol.geom.flat.contains.linearRingContainsXY( + if (_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, ends[i - 1], ends[i], stride, x, y)) { return false; } @@ -99,14 +101,14 @@ ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset, * @param {number} y Y. * @return {boolean} Contains (x, y). */ -ol.geom.flat.contains.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) { +_ol_geom_flat_contains_.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) { if (endss.length === 0) { return false; } var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - if (ol.geom.flat.contains.linearRingsContainsXY( + if (_ol_geom_flat_contains_.linearRingsContainsXY( flatCoordinates, offset, ends, stride, x, y)) { return true; } @@ -114,3 +116,4 @@ ol.geom.flat.contains.linearRingssContainsXY = function(flatCoordinates, offset, } return false; }; +export default _ol_geom_flat_contains_; diff --git a/src/ol/geom/flat/deflate.js b/src/ol/geom/flat/deflate.js index aa0388d119..66816e04f2 100644 --- a/src/ol/geom/flat/deflate.js +++ b/src/ol/geom/flat/deflate.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.deflate'); +/** + * @module ol/geom/flat/deflate + */ +var _ol_geom_flat_deflate_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.geom.flat.deflate'); * @param {number} stride Stride. * @return {number} offset Offset. */ -ol.geom.flat.deflate.coordinate = function(flatCoordinates, offset, coordinate, stride) { +_ol_geom_flat_deflate_.coordinate = function(flatCoordinates, offset, coordinate, stride) { var i, ii; for (i = 0, ii = coordinate.length; i < ii; ++i) { flatCoordinates[offset++] = coordinate[i]; @@ -24,7 +27,7 @@ ol.geom.flat.deflate.coordinate = function(flatCoordinates, offset, coordinate, * @param {number} stride Stride. * @return {number} offset Offset. */ -ol.geom.flat.deflate.coordinates = function(flatCoordinates, offset, coordinates, stride) { +_ol_geom_flat_deflate_.coordinates = function(flatCoordinates, offset, coordinates, stride) { var i, ii; for (i = 0, ii = coordinates.length; i < ii; ++i) { var coordinate = coordinates[i]; @@ -45,12 +48,12 @@ ol.geom.flat.deflate.coordinates = function(flatCoordinates, offset, coordinates * @param {Array.=} opt_ends Ends. * @return {Array.} Ends. */ -ol.geom.flat.deflate.coordinatess = function(flatCoordinates, offset, coordinatess, stride, opt_ends) { +_ol_geom_flat_deflate_.coordinatess = function(flatCoordinates, offset, coordinatess, stride, opt_ends) { var ends = opt_ends ? opt_ends : []; var i = 0; var j, jj; for (j = 0, jj = coordinatess.length; j < jj; ++j) { - var end = ol.geom.flat.deflate.coordinates( + var end = _ol_geom_flat_deflate_.coordinates( flatCoordinates, offset, coordinatess[j], stride); ends[i++] = end; offset = end; @@ -68,12 +71,12 @@ ol.geom.flat.deflate.coordinatess = function(flatCoordinates, offset, coordinate * @param {Array.>=} opt_endss Endss. * @return {Array.>} Endss. */ -ol.geom.flat.deflate.coordinatesss = function(flatCoordinates, offset, coordinatesss, stride, opt_endss) { +_ol_geom_flat_deflate_.coordinatesss = function(flatCoordinates, offset, coordinatesss, stride, opt_endss) { var endss = opt_endss ? opt_endss : []; var i = 0; var j, jj; for (j = 0, jj = coordinatesss.length; j < jj; ++j) { - var ends = ol.geom.flat.deflate.coordinatess( + var ends = _ol_geom_flat_deflate_.coordinatess( flatCoordinates, offset, coordinatesss[j], stride, endss[i]); endss[i++] = ends; offset = ends[ends.length - 1]; @@ -81,3 +84,4 @@ ol.geom.flat.deflate.coordinatesss = function(flatCoordinates, offset, coordinat endss.length = i; return endss; }; +export default _ol_geom_flat_deflate_; diff --git a/src/ol/geom/flat/flip.js b/src/ol/geom/flat/flip.js index cfbbe89c93..132d20a206 100644 --- a/src/ol/geom/flat/flip.js +++ b/src/ol/geom/flat/flip.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.flip'); +/** + * @module ol/geom/flat/flip + */ +var _ol_geom_flat_flip_ = {}; /** @@ -10,7 +13,7 @@ goog.provide('ol.geom.flat.flip'); * @param {number=} opt_destOffset Destination offset. * @return {Array.} Flat coordinates. */ -ol.geom.flat.flip.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) { +_ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) { var dest, destOffset; if (opt_dest !== undefined) { dest = opt_dest; @@ -31,3 +34,4 @@ ol.geom.flat.flip.flipXY = function(flatCoordinates, offset, end, stride, opt_de dest.length = destOffset; return dest; }; +export default _ol_geom_flat_flip_; diff --git a/src/ol/geom/flat/geodesic.js b/src/ol/geom/flat/geodesic.js index ed342d5ca8..2b20cce0be 100644 --- a/src/ol/geom/flat/geodesic.js +++ b/src/ol/geom/flat/geodesic.js @@ -1,7 +1,9 @@ -goog.provide('ol.geom.flat.geodesic'); - -goog.require('ol.math'); -goog.require('ol.proj'); +/** + * @module ol/geom/flat/geodesic + */ +import _ol_math_ from '../../math.js'; +import _ol_proj_ from '../../proj.js'; +var _ol_geom_flat_geodesic_ = {}; /** @@ -12,7 +14,7 @@ goog.require('ol.proj'); * @param {number} squaredTolerance Squared tolerance. * @return {Array.} Flat coordinates. */ -ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance) { +_ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredTolerance) { // FIXME reduce garbage generation // FIXME optimize stack operations @@ -57,7 +59,7 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance) fracM = (fracA + fracB) / 2; geoM = interpolate(fracM); m = transform(geoM); - if (ol.math.squaredSegmentDistance(m[0], m[1], a[0], a[1], + if (_ol_math_.squaredSegmentDistance(m[0], m[1], a[0], a[1], b[0], b[1]) < squaredTolerance) { // If the m point is sufficiently close to the straight line, then we // discard it. Just use the b coordinate and move on to the next line @@ -88,20 +90,20 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance) * @param {number} squaredTolerance Squared tolerance. * @return {Array.} Flat coordinates. */ -ol.geom.flat.geodesic.greatCircleArc = function( +_ol_geom_flat_geodesic_.greatCircleArc = function( lon1, lat1, lon2, lat2, projection, squaredTolerance) { - var geoProjection = ol.proj.get('EPSG:4326'); + var geoProjection = _ol_proj_.get('EPSG:4326'); - var cosLat1 = Math.cos(ol.math.toRadians(lat1)); - var sinLat1 = Math.sin(ol.math.toRadians(lat1)); - var cosLat2 = Math.cos(ol.math.toRadians(lat2)); - var sinLat2 = Math.sin(ol.math.toRadians(lat2)); - var cosDeltaLon = Math.cos(ol.math.toRadians(lon2 - lon1)); - var sinDeltaLon = Math.sin(ol.math.toRadians(lon2 - lon1)); + var cosLat1 = Math.cos(_ol_math_.toRadians(lat1)); + var sinLat1 = Math.sin(_ol_math_.toRadians(lat1)); + var cosLat2 = Math.cos(_ol_math_.toRadians(lat2)); + var sinLat2 = Math.sin(_ol_math_.toRadians(lat2)); + var cosDeltaLon = Math.cos(_ol_math_.toRadians(lon2 - lon1)); + var sinDeltaLon = Math.sin(_ol_math_.toRadians(lon2 - lon1)); var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon; - return ol.geom.flat.geodesic.line_( + return _ol_geom_flat_geodesic_.line_( /** * @param {number} frac Fraction. * @return {ol.Coordinate} Coordinate. @@ -117,11 +119,11 @@ ol.geom.flat.geodesic.greatCircleArc = function( var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon; var theta = Math.atan2(y, x); var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta)); - var lon = ol.math.toRadians(lon1) + + var lon = _ol_math_.toRadians(lon1) + Math.atan2(Math.sin(theta) * sinD * cosLat1, cosD - sinLat1 * Math.sin(lat)); - return [ol.math.toDegrees(lon), ol.math.toDegrees(lat)]; - }, ol.proj.getTransform(geoProjection, projection), squaredTolerance); + return [_ol_math_.toDegrees(lon), _ol_math_.toDegrees(lat)]; + }, _ol_proj_.getTransform(geoProjection, projection), squaredTolerance); }; @@ -134,9 +136,9 @@ ol.geom.flat.geodesic.greatCircleArc = function( * @param {number} squaredTolerance Squared tolerance. * @return {Array.} Flat coordinates. */ -ol.geom.flat.geodesic.meridian = function(lon, lat1, lat2, projection, squaredTolerance) { - var epsg4326Projection = ol.proj.get('EPSG:4326'); - return ol.geom.flat.geodesic.line_( +_ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) { + var epsg4326Projection = _ol_proj_.get('EPSG:4326'); + return _ol_geom_flat_geodesic_.line_( /** * @param {number} frac Fraction. * @return {ol.Coordinate} Coordinate. @@ -144,7 +146,7 @@ ol.geom.flat.geodesic.meridian = function(lon, lat1, lat2, projection, squaredTo function(frac) { return [lon, lat1 + ((lat2 - lat1) * frac)]; }, - ol.proj.getTransform(epsg4326Projection, projection), squaredTolerance); + _ol_proj_.getTransform(epsg4326Projection, projection), squaredTolerance); }; @@ -157,9 +159,9 @@ ol.geom.flat.geodesic.meridian = function(lon, lat1, lat2, projection, squaredTo * @param {number} squaredTolerance Squared tolerance. * @return {Array.} Flat coordinates. */ -ol.geom.flat.geodesic.parallel = function(lat, lon1, lon2, projection, squaredTolerance) { - var epsg4326Projection = ol.proj.get('EPSG:4326'); - return ol.geom.flat.geodesic.line_( +_ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) { + var epsg4326Projection = _ol_proj_.get('EPSG:4326'); + return _ol_geom_flat_geodesic_.line_( /** * @param {number} frac Fraction. * @return {ol.Coordinate} Coordinate. @@ -167,5 +169,6 @@ ol.geom.flat.geodesic.parallel = function(lat, lon1, lon2, projection, squaredTo function(frac) { return [lon1 + ((lon2 - lon1) * frac), lat]; }, - ol.proj.getTransform(epsg4326Projection, projection), squaredTolerance); + _ol_proj_.getTransform(epsg4326Projection, projection), squaredTolerance); }; +export default _ol_geom_flat_geodesic_; diff --git a/src/ol/geom/flat/inflate.js b/src/ol/geom/flat/inflate.js index 30cc11810c..825b3078d0 100644 --- a/src/ol/geom/flat/inflate.js +++ b/src/ol/geom/flat/inflate.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.inflate'); +/** + * @module ol/geom/flat/inflate + */ +var _ol_geom_flat_inflate_ = {}; /** @@ -9,7 +12,7 @@ goog.provide('ol.geom.flat.inflate'); * @param {Array.=} opt_coordinates Coordinates. * @return {Array.} Coordinates. */ -ol.geom.flat.inflate.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) { +_ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) { var coordinates = opt_coordinates !== undefined ? opt_coordinates : []; var i = 0; var j; @@ -29,13 +32,13 @@ ol.geom.flat.inflate.coordinates = function(flatCoordinates, offset, end, stride * @param {Array.>=} opt_coordinatess Coordinatess. * @return {Array.>} Coordinatess. */ -ol.geom.flat.inflate.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) { +_ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) { var coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : []; var i = 0; var j, jj; for (j = 0, jj = ends.length; j < jj; ++j) { var end = ends[j]; - coordinatess[i++] = ol.geom.flat.inflate.coordinates( + coordinatess[i++] = _ol_geom_flat_inflate_.coordinates( flatCoordinates, offset, end, stride, coordinatess[i]); offset = end; } @@ -53,16 +56,17 @@ ol.geom.flat.inflate.coordinatess = function(flatCoordinates, offset, ends, stri * Coordinatesss. * @return {Array.>>} Coordinatesss. */ -ol.geom.flat.inflate.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) { +_ol_geom_flat_inflate_.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) { var coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : []; var i = 0; var j, jj; for (j = 0, jj = endss.length; j < jj; ++j) { var ends = endss[j]; - coordinatesss[i++] = ol.geom.flat.inflate.coordinatess( + coordinatesss[i++] = _ol_geom_flat_inflate_.coordinatess( flatCoordinates, offset, ends, stride, coordinatesss[i]); offset = ends[ends.length - 1]; } coordinatesss.length = i; return coordinatesss; }; +export default _ol_geom_flat_inflate_; diff --git a/src/ol/geom/flat/interiorpoint.js b/src/ol/geom/flat/interiorpoint.js index 7886691825..699eb3b974 100644 --- a/src/ol/geom/flat/interiorpoint.js +++ b/src/ol/geom/flat/interiorpoint.js @@ -1,7 +1,9 @@ -goog.provide('ol.geom.flat.interiorpoint'); - -goog.require('ol.array'); -goog.require('ol.geom.flat.contains'); +/** + * @module ol/geom/flat/interiorpoint + */ +import _ol_array_ from '../../array.js'; +import _ol_geom_flat_contains_ from '../flat/contains.js'; +var _ol_geom_flat_interiorpoint_ = {}; /** @@ -17,7 +19,7 @@ goog.require('ol.geom.flat.contains'); * @return {Array.} Destination point as XYM coordinate, where M is the * length of the horizontal intersection that the point belongs to. */ -ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset, +_ol_geom_flat_interiorpoint_.linearRings = function(flatCoordinates, offset, ends, stride, flatCenters, flatCentersOffset, opt_dest) { var i, ii, x, x1, x2, y1, y2; var y = flatCenters[flatCentersOffset + 1]; @@ -43,14 +45,14 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset, // inside the linear ring. var pointX = NaN; var maxSegmentLength = -Infinity; - intersections.sort(ol.array.numberSafeCompareFunction); + intersections.sort(_ol_array_.numberSafeCompareFunction); x1 = intersections[0]; for (i = 1, ii = intersections.length; i < ii; ++i) { x2 = intersections[i]; var segmentLength = Math.abs(x2 - x1); if (segmentLength > maxSegmentLength) { x = (x1 + x2) / 2; - if (ol.geom.flat.contains.linearRingsContainsXY( + if (_ol_geom_flat_contains_.linearRingsContainsXY( flatCoordinates, offset, ends, stride, x, y)) { pointX = x; maxSegmentLength = segmentLength; @@ -81,14 +83,15 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset, * @return {Array.} Interior points as XYM coordinates, where M is the * length of the horizontal intersection that the point belongs to. */ -ol.geom.flat.interiorpoint.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) { +_ol_geom_flat_interiorpoint_.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) { var interiorPoints = []; var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - interiorPoints = ol.geom.flat.interiorpoint.linearRings(flatCoordinates, + interiorPoints = _ol_geom_flat_interiorpoint_.linearRings(flatCoordinates, offset, ends, stride, flatCenters, 2 * i, interiorPoints); offset = ends[ends.length - 1]; } return interiorPoints; }; +export default _ol_geom_flat_interiorpoint_; diff --git a/src/ol/geom/flat/interpolate.js b/src/ol/geom/flat/interpolate.js index b1c0c951ee..258ebf64b3 100644 --- a/src/ol/geom/flat/interpolate.js +++ b/src/ol/geom/flat/interpolate.js @@ -1,7 +1,9 @@ -goog.provide('ol.geom.flat.interpolate'); - -goog.require('ol.array'); -goog.require('ol.math'); +/** + * @module ol/geom/flat/interpolate + */ +import _ol_array_ from '../../array.js'; +import _ol_math_ from '../../math.js'; +var _ol_geom_flat_interpolate_ = {}; /** @@ -13,7 +15,7 @@ goog.require('ol.math'); * @param {Array.=} opt_dest Destination. * @return {Array.} Destination. */ -ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) { +_ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) { var pointX = NaN; var pointY = NaN; var n = (end - offset) / stride; @@ -40,14 +42,14 @@ ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, str y1 = y2; } var target = fraction * length; - var index = ol.array.binarySearch(cumulativeLengths, target); + var index = _ol_array_.binarySearch(cumulativeLengths, target); if (index < 0) { var t = (target - cumulativeLengths[-index - 2]) / (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]); var o = offset + (-index - 2) * stride; - pointX = ol.math.lerp( + pointX = _ol_math_.lerp( flatCoordinates[o], flatCoordinates[o + stride], t); - pointY = ol.math.lerp( + pointY = _ol_math_.lerp( flatCoordinates[o + 1], flatCoordinates[o + stride + 1], t); } else { pointX = flatCoordinates[offset + index * stride]; @@ -73,7 +75,7 @@ ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, str * @param {boolean} extrapolate Extrapolate. * @return {ol.Coordinate} Coordinate. */ -ol.geom.flat.interpolate.lineStringCoordinateAtM = function(flatCoordinates, offset, end, stride, m, extrapolate) { +_ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, offset, end, stride, m, extrapolate) { if (end == offset) { return null; } @@ -118,7 +120,7 @@ ol.geom.flat.interpolate.lineStringCoordinateAtM = function(flatCoordinates, off coordinate = []; var i; for (i = 0; i < stride - 1; ++i) { - coordinate.push(ol.math.lerp(flatCoordinates[(lo - 1) * stride + i], + coordinate.push(_ol_math_.lerp(flatCoordinates[(lo - 1) * stride + i], flatCoordinates[lo * stride + i], t)); } coordinate.push(m); @@ -136,10 +138,10 @@ ol.geom.flat.interpolate.lineStringCoordinateAtM = function(flatCoordinates, off * @param {boolean} interpolate Interpolate. * @return {ol.Coordinate} Coordinate. */ -ol.geom.flat.interpolate.lineStringsCoordinateAtM = function( +_ol_geom_flat_interpolate_.lineStringsCoordinateAtM = function( flatCoordinates, offset, ends, stride, m, extrapolate, interpolate) { if (interpolate) { - return ol.geom.flat.interpolate.lineStringCoordinateAtM( + return _ol_geom_flat_interpolate_.lineStringCoordinateAtM( flatCoordinates, offset, ends[ends.length - 1], stride, m, extrapolate); } var coordinate; @@ -170,10 +172,11 @@ ol.geom.flat.interpolate.lineStringsCoordinateAtM = function( if (m < flatCoordinates[offset + stride - 1]) { return null; } else if (m <= flatCoordinates[end - 1]) { - return ol.geom.flat.interpolate.lineStringCoordinateAtM( + return _ol_geom_flat_interpolate_.lineStringCoordinateAtM( flatCoordinates, offset, end, stride, m, false); } offset = end; } return null; }; +export default _ol_geom_flat_interpolate_; diff --git a/src/ol/geom/flat/intersectsextent.js b/src/ol/geom/flat/intersectsextent.js index 10d64fc623..31b21eb608 100644 --- a/src/ol/geom/flat/intersectsextent.js +++ b/src/ol/geom/flat/intersectsextent.js @@ -1,8 +1,10 @@ -goog.provide('ol.geom.flat.intersectsextent'); - -goog.require('ol.extent'); -goog.require('ol.geom.flat.contains'); -goog.require('ol.geom.flat.segments'); +/** + * @module ol/geom/flat/intersectsextent + */ +import _ol_extent_ from '../../extent.js'; +import _ol_geom_flat_contains_ from '../flat/contains.js'; +import _ol_geom_flat_segments_ from '../flat/segments.js'; +var _ol_geom_flat_intersectsextent_ = {}; /** @@ -13,13 +15,13 @@ goog.require('ol.geom.flat.segments'); * @param {ol.Extent} extent Extent. * @return {boolean} True if the geometry and the extent intersect. */ -ol.geom.flat.intersectsextent.lineString = function(flatCoordinates, offset, end, stride, extent) { - var coordinatesExtent = ol.extent.extendFlatCoordinates( - ol.extent.createEmpty(), flatCoordinates, offset, end, stride); - if (!ol.extent.intersects(extent, coordinatesExtent)) { +_ol_geom_flat_intersectsextent_.lineString = function(flatCoordinates, offset, end, stride, extent) { + var coordinatesExtent = _ol_extent_.extendFlatCoordinates( + _ol_extent_.createEmpty(), flatCoordinates, offset, end, stride); + if (!_ol_extent_.intersects(extent, coordinatesExtent)) { return false; } - if (ol.extent.containsExtent(extent, coordinatesExtent)) { + if (_ol_extent_.containsExtent(extent, coordinatesExtent)) { return true; } if (coordinatesExtent[0] >= extent[0] && @@ -30,7 +32,7 @@ ol.geom.flat.intersectsextent.lineString = function(flatCoordinates, offset, end coordinatesExtent[3] <= extent[3]) { return true; } - return ol.geom.flat.segments.forEach(flatCoordinates, offset, end, stride, + return _ol_geom_flat_segments_.forEach(flatCoordinates, offset, end, stride, /** * @param {ol.Coordinate} point1 Start point. * @param {ol.Coordinate} point2 End point. @@ -38,7 +40,7 @@ ol.geom.flat.intersectsextent.lineString = function(flatCoordinates, offset, end * `false` otherwise. */ function(point1, point2) { - return ol.extent.intersectsSegment(extent, point1, point2); + return _ol_extent_.intersectsSegment(extent, point1, point2); }); }; @@ -51,10 +53,10 @@ ol.geom.flat.intersectsextent.lineString = function(flatCoordinates, offset, end * @param {ol.Extent} extent Extent. * @return {boolean} True if the geometry and the extent intersect. */ -ol.geom.flat.intersectsextent.lineStrings = function(flatCoordinates, offset, ends, stride, extent) { +_ol_geom_flat_intersectsextent_.lineStrings = function(flatCoordinates, offset, ends, stride, extent) { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { - if (ol.geom.flat.intersectsextent.lineString( + if (_ol_geom_flat_intersectsextent_.lineString( flatCoordinates, offset, ends[i], stride, extent)) { return true; } @@ -72,24 +74,24 @@ ol.geom.flat.intersectsextent.lineStrings = function(flatCoordinates, offset, en * @param {ol.Extent} extent Extent. * @return {boolean} True if the geometry and the extent intersect. */ -ol.geom.flat.intersectsextent.linearRing = function(flatCoordinates, offset, end, stride, extent) { - if (ol.geom.flat.intersectsextent.lineString( +_ol_geom_flat_intersectsextent_.linearRing = function(flatCoordinates, offset, end, stride, extent) { + if (_ol_geom_flat_intersectsextent_.lineString( flatCoordinates, offset, end, stride, extent)) { return true; } - if (ol.geom.flat.contains.linearRingContainsXY( + if (_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, offset, end, stride, extent[0], extent[1])) { return true; } - if (ol.geom.flat.contains.linearRingContainsXY( + if (_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, offset, end, stride, extent[0], extent[3])) { return true; } - if (ol.geom.flat.contains.linearRingContainsXY( + if (_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, offset, end, stride, extent[2], extent[1])) { return true; } - if (ol.geom.flat.contains.linearRingContainsXY( + if (_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinates, offset, end, stride, extent[2], extent[3])) { return true; } @@ -105,8 +107,8 @@ ol.geom.flat.intersectsextent.linearRing = function(flatCoordinates, offset, end * @param {ol.Extent} extent Extent. * @return {boolean} True if the geometry and the extent intersect. */ -ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, ends, stride, extent) { - if (!ol.geom.flat.intersectsextent.linearRing( +_ol_geom_flat_intersectsextent_.linearRings = function(flatCoordinates, offset, ends, stride, extent) { + if (!_ol_geom_flat_intersectsextent_.linearRing( flatCoordinates, offset, ends[0], stride, extent)) { return false; } @@ -115,7 +117,7 @@ ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, en } var i, ii; for (i = 1, ii = ends.length; i < ii; ++i) { - if (ol.geom.flat.contains.linearRingContainsExtent( + if (_ol_geom_flat_contains_.linearRingContainsExtent( flatCoordinates, ends[i - 1], ends[i], stride, extent)) { return false; } @@ -132,11 +134,11 @@ ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, en * @param {ol.Extent} extent Extent. * @return {boolean} True if the geometry and the extent intersect. */ -ol.geom.flat.intersectsextent.linearRingss = function(flatCoordinates, offset, endss, stride, extent) { +_ol_geom_flat_intersectsextent_.linearRingss = function(flatCoordinates, offset, endss, stride, extent) { var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; - if (ol.geom.flat.intersectsextent.linearRings( + if (_ol_geom_flat_intersectsextent_.linearRings( flatCoordinates, offset, ends, stride, extent)) { return true; } @@ -144,3 +146,4 @@ ol.geom.flat.intersectsextent.linearRingss = function(flatCoordinates, offset, e } return false; }; +export default _ol_geom_flat_intersectsextent_; diff --git a/src/ol/geom/flat/length.js b/src/ol/geom/flat/length.js index 70b7a54d67..fff03e7933 100644 --- a/src/ol/geom/flat/length.js +++ b/src/ol/geom/flat/length.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.length'); +/** + * @module ol/geom/flat/length + */ +var _ol_geom_flat_length_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.geom.flat.length'); * @param {number} stride Stride. * @return {number} Length. */ -ol.geom.flat.length.lineString = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride) { var x1 = flatCoordinates[offset]; var y1 = flatCoordinates[offset + 1]; var length = 0; @@ -31,11 +34,12 @@ ol.geom.flat.length.lineString = function(flatCoordinates, offset, end, stride) * @param {number} stride Stride. * @return {number} Perimeter. */ -ol.geom.flat.length.linearRing = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_length_.linearRing = function(flatCoordinates, offset, end, stride) { var perimeter = - ol.geom.flat.length.lineString(flatCoordinates, offset, end, stride); + _ol_geom_flat_length_.lineString(flatCoordinates, offset, end, stride); var dx = flatCoordinates[end - stride] - flatCoordinates[offset]; var dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1]; perimeter += Math.sqrt(dx * dx + dy * dy); return perimeter; }; +export default _ol_geom_flat_length_; diff --git a/src/ol/geom/flat/orient.js b/src/ol/geom/flat/orient.js index 79aaf2e803..83591e14ac 100644 --- a/src/ol/geom/flat/orient.js +++ b/src/ol/geom/flat/orient.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.orient'); - -goog.require('ol.geom.flat.reverse'); +/** + * @module ol/geom/flat/orient + */ +import _ol_geom_flat_reverse_ from '../flat/reverse.js'; +var _ol_geom_flat_orient_ = {}; /** @@ -10,7 +12,7 @@ goog.require('ol.geom.flat.reverse'); * @param {number} stride Stride. * @return {boolean} Is clockwise. */ -ol.geom.flat.orient.linearRingIsClockwise = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_orient_.linearRingIsClockwise = function(flatCoordinates, offset, end, stride) { // http://tinyurl.com/clockwise-method // https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrlinearring.cpp var edge = 0; @@ -40,12 +42,12 @@ ol.geom.flat.orient.linearRingIsClockwise = function(flatCoordinates, offset, en * (counter-clockwise exterior ring and clockwise interior rings). * @return {boolean} Rings are correctly oriented. */ -ol.geom.flat.orient.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) { +_ol_geom_flat_orient_.linearRingsAreOriented = function(flatCoordinates, offset, ends, stride, opt_right) { var right = opt_right !== undefined ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var isClockwise = ol.geom.flat.orient.linearRingIsClockwise( + var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise( flatCoordinates, offset, end, stride); if (i === 0) { if ((right && isClockwise) || (!right && !isClockwise)) { @@ -75,10 +77,10 @@ ol.geom.flat.orient.linearRingsAreOriented = function(flatCoordinates, offset, e * (counter-clockwise exterior ring and clockwise interior rings). * @return {boolean} Rings are correctly oriented. */ -ol.geom.flat.orient.linearRingssAreOriented = function(flatCoordinates, offset, endss, stride, opt_right) { +_ol_geom_flat_orient_.linearRingssAreOriented = function(flatCoordinates, offset, endss, stride, opt_right) { var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { - if (!ol.geom.flat.orient.linearRingsAreOriented( + if (!_ol_geom_flat_orient_.linearRingsAreOriented( flatCoordinates, offset, endss[i], stride, opt_right)) { return false; } @@ -100,18 +102,18 @@ ol.geom.flat.orient.linearRingssAreOriented = function(flatCoordinates, offset, * @param {boolean=} opt_right Follow the right-hand rule for orientation. * @return {number} End. */ -ol.geom.flat.orient.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) { +_ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends, stride, opt_right) { var right = opt_right !== undefined ? opt_right : false; var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var isClockwise = ol.geom.flat.orient.linearRingIsClockwise( + var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise( flatCoordinates, offset, end, stride); var reverse = i === 0 ? (right && isClockwise) || (!right && !isClockwise) : (right && !isClockwise) || (!right && isClockwise); if (reverse) { - ol.geom.flat.reverse.coordinates(flatCoordinates, offset, end, stride); + _ol_geom_flat_reverse_.coordinates(flatCoordinates, offset, end, stride); } offset = end; } @@ -132,11 +134,12 @@ ol.geom.flat.orient.orientLinearRings = function(flatCoordinates, offset, ends, * @param {boolean=} opt_right Follow the right-hand rule for orientation. * @return {number} End. */ -ol.geom.flat.orient.orientLinearRingss = function(flatCoordinates, offset, endss, stride, opt_right) { +_ol_geom_flat_orient_.orientLinearRingss = function(flatCoordinates, offset, endss, stride, opt_right) { var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { - offset = ol.geom.flat.orient.orientLinearRings( + offset = _ol_geom_flat_orient_.orientLinearRings( flatCoordinates, offset, endss[i], stride, opt_right); } return offset; }; +export default _ol_geom_flat_orient_; diff --git a/src/ol/geom/flat/reverse.js b/src/ol/geom/flat/reverse.js index 5202ae1966..9cec4840a0 100644 --- a/src/ol/geom/flat/reverse.js +++ b/src/ol/geom/flat/reverse.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.reverse'); +/** + * @module ol/geom/flat/reverse + */ +var _ol_geom_flat_reverse_ = {}; /** @@ -7,7 +10,7 @@ goog.provide('ol.geom.flat.reverse'); * @param {number} end End. * @param {number} stride Stride. */ -ol.geom.flat.reverse.coordinates = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stride) { while (offset < end - stride) { var i; for (i = 0; i < stride; ++i) { @@ -19,3 +22,4 @@ ol.geom.flat.reverse.coordinates = function(flatCoordinates, offset, end, stride end -= stride; } }; +export default _ol_geom_flat_reverse_; diff --git a/src/ol/geom/flat/segments.js b/src/ol/geom/flat/segments.js index 21403117ce..cc9bd61007 100644 --- a/src/ol/geom/flat/segments.js +++ b/src/ol/geom/flat/segments.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.segments'); +/** + * @module ol/geom/flat/segments + */ +var _ol_geom_flat_segments_ = {}; /** @@ -16,7 +19,7 @@ goog.provide('ol.geom.flat.segments'); * @return {T|boolean} Value. * @template T,S */ -ol.geom.flat.segments.forEach = function(flatCoordinates, offset, end, stride, callback, opt_this) { +_ol_geom_flat_segments_.forEach = function(flatCoordinates, offset, end, stride, callback, opt_this) { var point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]]; var point2 = []; var ret; @@ -32,3 +35,4 @@ ol.geom.flat.segments.forEach = function(flatCoordinates, offset, end, stride, c } return false; }; +export default _ol_geom_flat_segments_; diff --git a/src/ol/geom/flat/simplify.js b/src/ol/geom/flat/simplify.js index 7823faaaa5..ed396c4d04 100644 --- a/src/ol/geom/flat/simplify.js +++ b/src/ol/geom/flat/simplify.js @@ -1,3 +1,6 @@ +/** + * @module ol/geom/flat/simplify + */ // Based on simplify-js https://github.com/mourner/simplify-js // Copyright (c) 2012, Vladimir Agafonkin // All rights reserved. @@ -24,9 +27,8 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.geom.flat.simplify'); - -goog.require('ol.math'); +import _ol_math_ from '../../math.js'; +var _ol_geom_flat_simplify_ = {}; /** @@ -40,19 +42,19 @@ goog.require('ol.math'); * coordinates. * @return {Array.} Simplified line string. */ -ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end, +_ol_geom_flat_simplify_.lineString = function(flatCoordinates, offset, end, stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) { var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ? opt_simplifiedFlatCoordinates : []; if (!highQuality) { - end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end, + end = _ol_geom_flat_simplify_.radialDistance(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, 0); flatCoordinates = simplifiedFlatCoordinates; offset = 0; stride = 2; } - simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker( + simplifiedFlatCoordinates.length = _ol_geom_flat_simplify_.douglasPeucker( flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, 0); return simplifiedFlatCoordinates; @@ -70,7 +72,7 @@ ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end, * @param {number} simplifiedOffset Simplified offset. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.douglasPeucker = function(flatCoordinates, offset, end, +_ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) { var n = (end - offset) / stride; if (n < 3) { @@ -101,7 +103,7 @@ ol.geom.flat.simplify.douglasPeucker = function(flatCoordinates, offset, end, for (i = first + stride; i < last; i += stride) { var x = flatCoordinates[i]; var y = flatCoordinates[i + 1]; - var squaredDistance = ol.math.squaredSegmentDistance( + var squaredDistance = _ol_math_.squaredSegmentDistance( x, y, x1, y1, x2, y2); if (squaredDistance > maxSquaredDistance) { index = i; @@ -142,13 +144,13 @@ ol.geom.flat.simplify.douglasPeucker = function(flatCoordinates, offset, end, * @param {Array.} simplifiedEnds Simplified ends. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.douglasPeuckers = function(flatCoordinates, offset, +_ol_geom_flat_simplify_.douglasPeuckers = function(flatCoordinates, offset, ends, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - simplifiedOffset = ol.geom.flat.simplify.douglasPeucker( + simplifiedOffset = _ol_geom_flat_simplify_.douglasPeucker( flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset); simplifiedEnds.push(simplifiedOffset); @@ -170,14 +172,14 @@ ol.geom.flat.simplify.douglasPeuckers = function(flatCoordinates, offset, * @param {Array.>} simplifiedEndss Simplified endss. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.douglasPeuckerss = function( +_ol_geom_flat_simplify_.douglasPeuckerss = function( flatCoordinates, offset, endss, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) { var i, ii; for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; var simplifiedEnds = []; - simplifiedOffset = ol.geom.flat.simplify.douglasPeuckers( + simplifiedOffset = _ol_geom_flat_simplify_.douglasPeuckers( flatCoordinates, offset, ends, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds); simplifiedEndss.push(simplifiedEnds); @@ -198,7 +200,7 @@ ol.geom.flat.simplify.douglasPeuckerss = function( * @param {number} simplifiedOffset Simplified offset. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.radialDistance = function(flatCoordinates, offset, end, +_ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) { if (end <= offset + stride) { // zero or one point, no simplification possible, so copy and return @@ -219,7 +221,7 @@ ol.geom.flat.simplify.radialDistance = function(flatCoordinates, offset, end, for (offset += stride; offset < end; offset += stride) { x2 = flatCoordinates[offset]; y2 = flatCoordinates[offset + 1]; - if (ol.math.squaredDistance(x1, y1, x2, y2) > squaredTolerance) { + if (_ol_math_.squaredDistance(x1, y1, x2, y2) > squaredTolerance) { // copy point at offset simplifiedFlatCoordinates[simplifiedOffset++] = x2; simplifiedFlatCoordinates[simplifiedOffset++] = y2; @@ -241,7 +243,7 @@ ol.geom.flat.simplify.radialDistance = function(flatCoordinates, offset, end, * @param {number} tolerance Tolerance. * @return {number} Rounded value. */ -ol.geom.flat.simplify.snap = function(value, tolerance) { +_ol_geom_flat_simplify_.snap = function(value, tolerance) { return tolerance * Math.round(value / tolerance); }; @@ -265,15 +267,15 @@ ol.geom.flat.simplify.snap = function(value, tolerance) { * @param {number} simplifiedOffset Simplified offset. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.quantize = function(flatCoordinates, offset, end, stride, +_ol_geom_flat_simplify_.quantize = function(flatCoordinates, offset, end, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset) { // do nothing if the line is empty if (offset == end) { return simplifiedOffset; } // snap the first coordinate (P1) - var x1 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance); - var y1 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance); + var x1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance); + var y1 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance); offset += stride; // add the first coordinate to the output simplifiedFlatCoordinates[simplifiedOffset++] = x1; @@ -282,8 +284,8 @@ ol.geom.flat.simplify.quantize = function(flatCoordinates, offset, end, stride, // coordinate (P2) var x2, y2; do { - x2 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance); - y2 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance); + x2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance); + y2 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance); offset += stride; if (offset == end) { // all coordinates snap to the same value, the line collapses to a point @@ -298,8 +300,8 @@ ol.geom.flat.simplify.quantize = function(flatCoordinates, offset, end, stride, while (offset < end) { var x3, y3; // snap the next coordinate (P3) - x3 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance); - y3 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance); + x3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset], tolerance); + y3 = _ol_geom_flat_simplify_.snap(flatCoordinates[offset + 1], tolerance); offset += stride; // skip P3 if it is equal to P2 if (x3 == x2 && y3 == y2) { @@ -351,14 +353,14 @@ ol.geom.flat.simplify.quantize = function(flatCoordinates, offset, end, stride, * @param {Array.} simplifiedEnds Simplified ends. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.quantizes = function( +_ol_geom_flat_simplify_.quantizes = function( flatCoordinates, offset, ends, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - simplifiedOffset = ol.geom.flat.simplify.quantize( + simplifiedOffset = _ol_geom_flat_simplify_.quantize( flatCoordinates, offset, end, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset); @@ -381,7 +383,7 @@ ol.geom.flat.simplify.quantizes = function( * @param {Array.>} simplifiedEndss Simplified endss. * @return {number} Simplified offset. */ -ol.geom.flat.simplify.quantizess = function( +_ol_geom_flat_simplify_.quantizess = function( flatCoordinates, offset, endss, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) { @@ -389,7 +391,7 @@ ol.geom.flat.simplify.quantizess = function( for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; var simplifiedEnds = []; - simplifiedOffset = ol.geom.flat.simplify.quantizes( + simplifiedOffset = _ol_geom_flat_simplify_.quantizes( flatCoordinates, offset, ends, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds); @@ -398,3 +400,4 @@ ol.geom.flat.simplify.quantizess = function( } return simplifiedOffset; }; +export default _ol_geom_flat_simplify_; diff --git a/src/ol/geom/flat/straightchunk.js b/src/ol/geom/flat/straightchunk.js index a33dcac391..d985bf3bd1 100644 --- a/src/ol/geom/flat/straightchunk.js +++ b/src/ol/geom/flat/straightchunk.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.straightchunk'); +/** + * @module ol/geom/flat/straightchunk + */ +var _ol_geom_flat_straightchunk_ = {}; /** @@ -10,7 +13,7 @@ goog.provide('ol.geom.flat.straightchunk'); * @return {Array.} Start and end of the first suitable chunk of the * given `flatCoordinates`. */ -ol.geom.flat.straightchunk.lineString = function(maxAngle, flatCoordinates, offset, end, stride) { +_ol_geom_flat_straightchunk_.lineString = function(maxAngle, flatCoordinates, offset, end, stride) { var chunkStart = offset; var chunkEnd = offset; var chunkM = 0; @@ -47,3 +50,4 @@ ol.geom.flat.straightchunk.lineString = function(maxAngle, flatCoordinates, offs m += m23; return m > chunkM ? [start, i] : [chunkStart, chunkEnd]; }; +export default _ol_geom_flat_straightchunk_; diff --git a/src/ol/geom/flat/textpath.js b/src/ol/geom/flat/textpath.js index 87a20d607c..1b0569f3ea 100644 --- a/src/ol/geom/flat/textpath.js +++ b/src/ol/geom/flat/textpath.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.textpath'); - -goog.require('ol.math'); +/** + * @module ol/geom/flat/textpath + */ +import _ol_math_ from '../../math.js'; +var _ol_geom_flat_textpath_ = {}; /** @@ -16,7 +18,7 @@ goog.require('ol.math'); * @return {Array.>} The result array of null if `maxAngle` was * exceeded. Entries of the array are x, y, anchorX, angle, chunk. */ -ol.geom.flat.textpath.lineString = function( +_ol_geom_flat_textpath_.lineString = function( flatCoordinates, offset, end, stride, text, measure, startM, maxAngle) { var result = []; @@ -65,8 +67,8 @@ ol.geom.flat.textpath.lineString = function( } } var interpolate = segmentPos / segmentLength; - var x = ol.math.lerp(x1, x2, interpolate); - var y = ol.math.lerp(y1, y2, interpolate); + var x = _ol_math_.lerp(x1, x2, interpolate); + var y = _ol_math_.lerp(y1, y2, interpolate); if (previousAngle == angle) { if (reverse) { data[0] = x; @@ -89,3 +91,4 @@ ol.geom.flat.textpath.lineString = function( } return result; }; +export default _ol_geom_flat_textpath_; diff --git a/src/ol/geom/flat/topology.js b/src/ol/geom/flat/topology.js index a1b9f053f5..912e3dcd0a 100644 --- a/src/ol/geom/flat/topology.js +++ b/src/ol/geom/flat/topology.js @@ -1,6 +1,8 @@ -goog.provide('ol.geom.flat.topology'); - -goog.require('ol.geom.flat.area'); +/** + * @module ol/geom/flat/topology + */ +import _ol_geom_flat_area_ from '../flat/area.js'; +var _ol_geom_flat_topology_ = {}; /** * Check if the linestring is a boundary. @@ -10,11 +12,12 @@ goog.require('ol.geom.flat.area'); * @param {number} stride Stride. * @return {boolean} The linestring is a boundary. */ -ol.geom.flat.topology.lineStringIsClosed = function(flatCoordinates, offset, end, stride) { +_ol_geom_flat_topology_.lineStringIsClosed = function(flatCoordinates, offset, end, stride) { var lastCoord = end - stride; if (flatCoordinates[offset] === flatCoordinates[lastCoord] && flatCoordinates[offset + 1] === flatCoordinates[lastCoord + 1] && (end - offset) / stride > 3) { - return !!ol.geom.flat.area.linearRing(flatCoordinates, offset, end, stride); + return !!_ol_geom_flat_area_.linearRing(flatCoordinates, offset, end, stride); } return false; }; +export default _ol_geom_flat_topology_; diff --git a/src/ol/geom/flat/transform.js b/src/ol/geom/flat/transform.js index 12b2b203e3..1d23f33747 100644 --- a/src/ol/geom/flat/transform.js +++ b/src/ol/geom/flat/transform.js @@ -1,4 +1,7 @@ -goog.provide('ol.geom.flat.transform'); +/** + * @module ol/geom/flat/transform + */ +var _ol_geom_flat_transform_ = {}; /** @@ -10,7 +13,7 @@ goog.provide('ol.geom.flat.transform'); * @param {Array.=} opt_dest Destination. * @return {Array.} Transformed coordinates. */ -ol.geom.flat.transform.transform2D = function(flatCoordinates, offset, end, stride, transform, opt_dest) { +_ol_geom_flat_transform_.transform2D = function(flatCoordinates, offset, end, stride, transform, opt_dest) { var dest = opt_dest ? opt_dest : []; var i = 0; var j; @@ -37,7 +40,7 @@ ol.geom.flat.transform.transform2D = function(flatCoordinates, offset, end, stri * @param {Array.=} opt_dest Destination. * @return {Array.} Transformed coordinates. */ -ol.geom.flat.transform.rotate = function(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) { +_ol_geom_flat_transform_.rotate = function(flatCoordinates, offset, end, stride, angle, anchor, opt_dest) { var dest = opt_dest ? opt_dest : []; var cos = Math.cos(angle); var sin = Math.sin(angle); @@ -72,7 +75,7 @@ ol.geom.flat.transform.rotate = function(flatCoordinates, offset, end, stride, a * @param {Array.=} opt_dest Destination. * @return {Array.} Transformed coordinates. */ -ol.geom.flat.transform.scale = function(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) { +_ol_geom_flat_transform_.scale = function(flatCoordinates, offset, end, stride, sx, sy, anchor, opt_dest) { var dest = opt_dest ? opt_dest : []; var anchorX = anchor[0]; var anchorY = anchor[1]; @@ -103,7 +106,7 @@ ol.geom.flat.transform.scale = function(flatCoordinates, offset, end, stride, sx * @param {Array.=} opt_dest Destination. * @return {Array.} Transformed coordinates. */ -ol.geom.flat.transform.translate = function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) { +_ol_geom_flat_transform_.translate = function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) { var dest = opt_dest ? opt_dest : []; var i = 0; var j, k; @@ -119,3 +122,4 @@ ol.geom.flat.transform.translate = function(flatCoordinates, offset, end, stride } return dest; }; +export default _ol_geom_flat_transform_; diff --git a/src/ol/has.js b/src/ol/has.js index e396a1dfc1..62a0208f8b 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -1,7 +1,9 @@ -goog.provide('ol.has'); - -goog.require('ol'); -goog.require('ol.webgl'); +/** + * @module ol/has + */ +import _ol_ from './index.js'; +import _ol_webgl_ from './webgl.js'; +var _ol_has_ = {}; var ua = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase() : ''; @@ -10,25 +12,25 @@ var ua = typeof navigator !== 'undefined' ? * User agent string says we are dealing with Firefox as browser. * @type {boolean} */ -ol.has.FIREFOX = ua.indexOf('firefox') !== -1; +_ol_has_.FIREFOX = ua.indexOf('firefox') !== -1; /** * User agent string says we are dealing with Safari as browser. * @type {boolean} */ -ol.has.SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') == -1; +_ol_has_.SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') == -1; /** * User agent string says we are dealing with a WebKit engine. * @type {boolean} */ -ol.has.WEBKIT = ua.indexOf('webkit') !== -1 && ua.indexOf('edge') == -1; +_ol_has_.WEBKIT = ua.indexOf('webkit') !== -1 && ua.indexOf('edge') == -1; /** * User agent string says we are dealing with a Mac as platform. * @type {boolean} */ -ol.has.MAC = ua.indexOf('macintosh') !== -1; +_ol_has_.MAC = ua.indexOf('macintosh') !== -1; /** @@ -38,14 +40,14 @@ ol.has.MAC = ua.indexOf('macintosh') !== -1; * @type {number} * @api */ -ol.has.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; +_ol_has_.DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; /** * True if the browser's Canvas implementation implements {get,set}LineDash. * @type {boolean} */ -ol.has.CANVAS_LINE_DASH = false; +_ol_has_.CANVAS_LINE_DASH = false; /** @@ -55,7 +57,7 @@ ol.has.CANVAS_LINE_DASH = false; * @type {boolean} * @api */ -ol.has.CANVAS = ol.ENABLE_CANVAS && ( +_ol_has_.CANVAS = _ol_.ENABLE_CANVAS && ( /** * @return {boolean} Canvas supported. */ @@ -69,7 +71,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && ( return false; } else { if (context.setLineDash !== undefined) { - ol.has.CANVAS_LINE_DASH = true; + _ol_has_.CANVAS_LINE_DASH = true; } return true; } @@ -85,7 +87,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && ( * @type {boolean} * @api */ -ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in window; +_ol_has_.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in window; /** @@ -94,7 +96,7 @@ ol.has.DEVICE_ORIENTATION = 'DeviceOrientationEvent' in window; * @type {boolean} * @api */ -ol.has.GEOLOCATION = 'geolocation' in navigator; +_ol_has_.GEOLOCATION = 'geolocation' in navigator; /** @@ -103,7 +105,7 @@ ol.has.GEOLOCATION = 'geolocation' in navigator; * @type {boolean} * @api */ -ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in window; +_ol_has_.TOUCH = _ol_.ASSUME_TOUCH || 'ontouchstart' in window; /** @@ -111,7 +113,7 @@ ol.has.TOUCH = ol.ASSUME_TOUCH || 'ontouchstart' in window; * @const * @type {boolean} */ -ol.has.POINTER = 'PointerEvent' in window; +_ol_has_.POINTER = 'PointerEvent' in window; /** @@ -119,7 +121,7 @@ ol.has.POINTER = 'PointerEvent' in window; * @const * @type {boolean} */ -ol.has.MSPOINTER = !!(navigator.msPointerEnabled); +_ol_has_.MSPOINTER = !!(navigator.msPointerEnabled); /** @@ -129,11 +131,11 @@ ol.has.MSPOINTER = !!(navigator.msPointerEnabled); * @type {boolean} * @api */ -ol.has.WEBGL; +_ol_has_.WEBGL; (function() { - if (ol.ENABLE_WEBGL) { + if (_ol_.ENABLE_WEBGL) { var hasWebGL = false; var textureSize; var /** @type {Array.} */ extensions = []; @@ -142,7 +144,7 @@ ol.has.WEBGL; try { var canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS')); - var gl = ol.webgl.getContext(canvas, { + var gl = _ol_webgl_.getContext(canvas, { failIfMajorPerformanceCaveat: true }); if (gl) { @@ -155,8 +157,9 @@ ol.has.WEBGL; // pass } } - ol.has.WEBGL = hasWebGL; - ol.WEBGL_EXTENSIONS = extensions; - ol.WEBGL_MAX_TEXTURE_SIZE = textureSize; + _ol_has_.WEBGL = hasWebGL; + _ol_.WEBGL_EXTENSIONS = extensions; + _ol_.WEBGL_MAX_TEXTURE_SIZE = textureSize; } })(); +export default _ol_has_; diff --git a/src/ol/index.js b/src/ol/index.js index a210863de8..b2d34ff1d5 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -1,4 +1,7 @@ -goog.provide('ol'); +/** + * @module ol/index + */ +var _ol_ = {}; /** @@ -11,7 +14,7 @@ goog.provide('ol'); /** * @define {boolean} Assume touch. Default is `false`. */ -ol.ASSUME_TOUCH = false; +_ol_.ASSUME_TOUCH = false; /** @@ -19,32 +22,32 @@ ol.ASSUME_TOUCH = false; * see https://github.com/openlayers/openlayers/issues/2076 * @define {number} Default maximum zoom for default tile grids. */ -ol.DEFAULT_MAX_ZOOM = 42; +_ol_.DEFAULT_MAX_ZOOM = 42; /** * @define {number} Default min zoom level for the map view. Default is `0`. */ -ol.DEFAULT_MIN_ZOOM = 0; +_ol_.DEFAULT_MIN_ZOOM = 0; /** * @define {number} Default maximum allowed threshold (in pixels) for * reprojection triangulation. Default is `0.5`. */ -ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5; +_ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5; /** * @define {number} Default tile size. */ -ol.DEFAULT_TILE_SIZE = 256; +_ol_.DEFAULT_TILE_SIZE = 256; /** * @define {string} Default WMS version. */ -ol.DEFAULT_WMS_VERSION = '1.3.0'; +_ol_.DEFAULT_WMS_VERSION = '1.3.0'; /** @@ -52,21 +55,21 @@ ol.DEFAULT_WMS_VERSION = '1.3.0'; * this to false at compile time in advanced mode removes all code * supporting the Canvas renderer from the build. */ -ol.ENABLE_CANVAS = true; +_ol_.ENABLE_CANVAS = true; /** * @define {boolean} Enable integration with the Proj4js library. Default is * `true`. */ -ol.ENABLE_PROJ4JS = true; +_ol_.ENABLE_PROJ4JS = true; /** * @define {boolean} Enable automatic reprojection of raster sources. Default is * `true`. */ -ol.ENABLE_RASTER_REPROJECTION = true; +_ol_.ENABLE_RASTER_REPROJECTION = true; /** @@ -74,7 +77,7 @@ ol.ENABLE_RASTER_REPROJECTION = true; * this to false at compile time in advanced mode removes all code * supporting the WebGL renderer from the build. */ -ol.ENABLE_WEBGL = true; +_ol_.ENABLE_WEBGL = true; /** @@ -82,14 +85,14 @@ ol.ENABLE_WEBGL = true; * This should be set to `false` for production builds (if `ol.ENABLE_WEBGL` * is `true`). */ -ol.DEBUG_WEBGL = true; +_ol_.DEBUG_WEBGL = true; /** * @define {number} The size in pixels of the first atlas image. Default is * `256`. */ -ol.INITIAL_ATLAS_SIZE = 256; +_ol_.INITIAL_ATLAS_SIZE = 256; /** @@ -97,27 +100,27 @@ ol.INITIAL_ATLAS_SIZE = 256; * `-1`, meaning it is not used (and `ol.WEBGL_MAX_TEXTURE_SIZE` is * used instead). */ -ol.MAX_ATLAS_SIZE = -1; +_ol_.MAX_ATLAS_SIZE = -1; /** * @define {number} Maximum mouse wheel delta. */ -ol.MOUSEWHEELZOOM_MAXDELTA = 1; +_ol_.MOUSEWHEELZOOM_MAXDELTA = 1; /** * @define {number} Maximum width and/or height extent ratio that determines * when the overview map should be zoomed out. */ -ol.OVERVIEWMAP_MAX_RATIO = 0.75; +_ol_.OVERVIEWMAP_MAX_RATIO = 0.75; /** * @define {number} Minimum width and/or height extent ratio that determines * when the overview map should be zoomed in. */ -ol.OVERVIEWMAP_MIN_RATIO = 0.1; +_ol_.OVERVIEWMAP_MIN_RATIO = 0.1; /** @@ -130,7 +133,7 @@ ol.OVERVIEWMAP_MIN_RATIO = 0.1; * If too many tiles are required, no tiles are loaded and * `ol.TileState.ERROR` state is set. Default is `100`. */ -ol.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100; +_ol_.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100; /** @@ -140,7 +143,7 @@ ol.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100; * At most `2*(2^this)` triangles are created for each triangulated * extent (tile/image). Default is `10`. */ -ol.RASTER_REPROJECTION_MAX_SUBDIVISION = 10; +_ol_.RASTER_REPROJECTION_MAX_SUBDIVISION = 10; /** @@ -152,25 +155,25 @@ ol.RASTER_REPROJECTION_MAX_SUBDIVISION = 10; * subdivison is forced (up to `ol.RASTER_REPROJECTION_MAX_SUBDIVISION`). * Default is `0.25`. */ -ol.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25; +_ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25; /** * @define {number} Tolerance for geometry simplification in device pixels. */ -ol.SIMPLIFY_TOLERANCE = 0.5; +_ol_.SIMPLIFY_TOLERANCE = 0.5; /** * @define {number} Texture cache high water mark. */ -ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024; +_ol_.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024; /** * @define {string} OpenLayers version. */ -ol.VERSION = ''; +_ol_.VERSION = 'v4.6.4'; /** @@ -179,7 +182,7 @@ ol.VERSION = ''; * @const * @type {number|undefined} */ -ol.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has` +_ol_.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has` /** @@ -187,7 +190,7 @@ ol.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has` * @const * @type {Array.} */ -ol.WEBGL_EXTENSIONS; // value is set in `ol.has` +_ol_.WEBGL_EXTENSIONS; // value is set in `ol.has` /** @@ -212,7 +215,7 @@ ol.WEBGL_EXTENSIONS; // value is set in `ol.has` * @function * @api */ -ol.inherits = function(childCtor, parentCtor) { +_ol_.inherits = function(childCtor, parentCtor) { childCtor.prototype = Object.create(parentCtor.prototype); childCtor.prototype.constructor = childCtor; }; @@ -223,7 +226,7 @@ ol.inherits = function(childCtor, parentCtor) { * * @return {undefined} Nothing. */ -ol.nullFunction = function() {}; +_ol_.nullFunction = function() {}; /** @@ -234,9 +237,9 @@ ol.nullFunction = function() {}; * @param {Object} obj The object to get the unique ID for. * @return {number} The unique ID for the object. */ -ol.getUid = function(obj) { +_ol_.getUid = function(obj) { return obj.ol_uid || - (obj.ol_uid = ++ol.uidCounter_); + (obj.ol_uid = ++_ol_.uidCounter_); }; @@ -245,4 +248,5 @@ ol.getUid = function(obj) { * @type {number} * @private */ -ol.uidCounter_ = 0; +_ol_.uidCounter_ = 0; +export default _ol_; diff --git a/src/ol/interaction.js b/src/ol/interaction.js index b759771d95..f322e36bd0 100644 --- a/src/ol/interaction.js +++ b/src/ol/interaction.js @@ -1,16 +1,18 @@ -goog.provide('ol.interaction'); - -goog.require('ol.Collection'); -goog.require('ol.Kinetic'); -goog.require('ol.interaction.DoubleClickZoom'); -goog.require('ol.interaction.DragPan'); -goog.require('ol.interaction.DragRotate'); -goog.require('ol.interaction.DragZoom'); -goog.require('ol.interaction.KeyboardPan'); -goog.require('ol.interaction.KeyboardZoom'); -goog.require('ol.interaction.MouseWheelZoom'); -goog.require('ol.interaction.PinchRotate'); -goog.require('ol.interaction.PinchZoom'); +/** + * @module ol/interaction + */ +import _ol_Collection_ from './Collection.js'; +import _ol_Kinetic_ from './Kinetic.js'; +import _ol_interaction_DoubleClickZoom_ from './interaction/DoubleClickZoom.js'; +import _ol_interaction_DragPan_ from './interaction/DragPan.js'; +import _ol_interaction_DragRotate_ from './interaction/DragRotate.js'; +import _ol_interaction_DragZoom_ from './interaction/DragZoom.js'; +import _ol_interaction_KeyboardPan_ from './interaction/KeyboardPan.js'; +import _ol_interaction_KeyboardZoom_ from './interaction/KeyboardZoom.js'; +import _ol_interaction_MouseWheelZoom_ from './interaction/MouseWheelZoom.js'; +import _ol_interaction_PinchRotate_ from './interaction/PinchRotate.js'; +import _ol_interaction_PinchZoom_ from './interaction/PinchZoom.js'; +var _ol_interaction_ = {}; /** @@ -36,24 +38,24 @@ goog.require('ol.interaction.PinchZoom'); * interactions to be used with the ol.Map constructor's interactions option. * @api */ -ol.interaction.defaults = function(opt_options) { +_ol_interaction_.defaults = function(opt_options) { var options = opt_options ? opt_options : {}; - var interactions = new ol.Collection(); + var interactions = new _ol_Collection_(); - var kinetic = new ol.Kinetic(-0.005, 0.05, 100); + var kinetic = new _ol_Kinetic_(-0.005, 0.05, 100); var altShiftDragRotate = options.altShiftDragRotate !== undefined ? options.altShiftDragRotate : true; if (altShiftDragRotate) { - interactions.push(new ol.interaction.DragRotate()); + interactions.push(new _ol_interaction_DragRotate_()); } var doubleClickZoom = options.doubleClickZoom !== undefined ? options.doubleClickZoom : true; if (doubleClickZoom) { - interactions.push(new ol.interaction.DoubleClickZoom({ + interactions.push(new _ol_interaction_DoubleClickZoom_({ delta: options.zoomDelta, duration: options.zoomDuration })); @@ -61,7 +63,7 @@ ol.interaction.defaults = function(opt_options) { var dragPan = options.dragPan !== undefined ? options.dragPan : true; if (dragPan) { - interactions.push(new ol.interaction.DragPan({ + interactions.push(new _ol_interaction_DragPan_({ kinetic: kinetic })); } @@ -69,12 +71,12 @@ ol.interaction.defaults = function(opt_options) { var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate : true; if (pinchRotate) { - interactions.push(new ol.interaction.PinchRotate()); + interactions.push(new _ol_interaction_PinchRotate_()); } var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true; if (pinchZoom) { - interactions.push(new ol.interaction.PinchZoom({ + interactions.push(new _ol_interaction_PinchZoom_({ constrainResolution: options.constrainResolution, duration: options.zoomDuration })); @@ -82,8 +84,8 @@ ol.interaction.defaults = function(opt_options) { var keyboard = options.keyboard !== undefined ? options.keyboard : true; if (keyboard) { - interactions.push(new ol.interaction.KeyboardPan()); - interactions.push(new ol.interaction.KeyboardZoom({ + interactions.push(new _ol_interaction_KeyboardPan_()); + interactions.push(new _ol_interaction_KeyboardZoom_({ delta: options.zoomDelta, duration: options.zoomDuration })); @@ -92,7 +94,7 @@ ol.interaction.defaults = function(opt_options) { var mouseWheelZoom = options.mouseWheelZoom !== undefined ? options.mouseWheelZoom : true; if (mouseWheelZoom) { - interactions.push(new ol.interaction.MouseWheelZoom({ + interactions.push(new _ol_interaction_MouseWheelZoom_({ constrainResolution: options.constrainResolution, duration: options.zoomDuration })); @@ -101,7 +103,7 @@ ol.interaction.defaults = function(opt_options) { var shiftDragZoom = options.shiftDragZoom !== undefined ? options.shiftDragZoom : true; if (shiftDragZoom) { - interactions.push(new ol.interaction.DragZoom({ + interactions.push(new _ol_interaction_DragZoom_({ duration: options.zoomDuration })); } @@ -109,3 +111,4 @@ ol.interaction.defaults = function(opt_options) { return interactions; }; +export default _ol_interaction_; diff --git a/src/ol/interaction/DoubleClickZoom.js b/src/ol/interaction/DoubleClickZoom.js index 74290d4227..1cdc375b66 100644 --- a/src/ol/interaction/DoubleClickZoom.js +++ b/src/ol/interaction/DoubleClickZoom.js @@ -1,9 +1,9 @@ -goog.provide('ol.interaction.DoubleClickZoom'); - -goog.require('ol'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.interaction.Interaction'); - +/** + * @module ol/interaction/DoubleClickZoom + */ +import _ol_ from '../index.js'; +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; /** * @classdesc @@ -14,7 +14,7 @@ goog.require('ol.interaction.Interaction'); * @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options. * @api */ -ol.interaction.DoubleClickZoom = function(opt_options) { +var _ol_interaction_DoubleClickZoom_ = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -24,8 +24,8 @@ ol.interaction.DoubleClickZoom = function(opt_options) { */ this.delta_ = options.delta ? options.delta : 1; - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.DoubleClickZoom.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_DoubleClickZoom_.handleEvent }); /** @@ -35,7 +35,8 @@ ol.interaction.DoubleClickZoom = function(opt_options) { this.duration_ = options.duration !== undefined ? options.duration : 250; }; -ol.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_DoubleClickZoom_, _ol_interaction_Interaction_); /** @@ -46,18 +47,19 @@ ol.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction); * @this {ol.interaction.DoubleClickZoom} * @api */ -ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) { +_ol_interaction_DoubleClickZoom_.handleEvent = function(mapBrowserEvent) { var stopEvent = false; var browserEvent = mapBrowserEvent.originalEvent; - if (mapBrowserEvent.type == ol.MapBrowserEventType.DBLCLICK) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.DBLCLICK) { var map = mapBrowserEvent.map; var anchor = mapBrowserEvent.coordinate; var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_; var view = map.getView(); - ol.interaction.Interaction.zoomByDelta( + _ol_interaction_Interaction_.zoomByDelta( view, delta, anchor, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; } return !stopEvent; }; +export default _ol_interaction_DoubleClickZoom_; diff --git a/src/ol/interaction/DragAndDrop.js b/src/ol/interaction/DragAndDrop.js index 4476bd42b9..1bf6ce05ec 100644 --- a/src/ol/interaction/DragAndDrop.js +++ b/src/ol/interaction/DragAndDrop.js @@ -1,15 +1,15 @@ +/** + * @module ol/interaction/DragAndDrop + */ // FIXME should handle all geo-referenced data, not just vector data -goog.provide('ol.interaction.DragAndDrop'); - -goog.require('ol'); -goog.require('ol.functions'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.proj'); - +import _ol_ from '../index.js'; +import _ol_functions_ from '../functions.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -21,12 +21,12 @@ goog.require('ol.proj'); * @param {olx.interaction.DragAndDropOptions=} opt_options Options. * @api */ -ol.interaction.DragAndDrop = function(opt_options) { +var _ol_interaction_DragAndDrop_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.DragAndDrop.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_DragAndDrop_.handleEvent }); /** @@ -41,7 +41,7 @@ ol.interaction.DragAndDrop = function(opt_options) { * @type {ol.proj.Projection} */ this.projection_ = options.projection ? - ol.proj.get(options.projection) : null; + _ol_proj_.get(options.projection) : null; /** * @private @@ -62,7 +62,8 @@ ol.interaction.DragAndDrop = function(opt_options) { this.target = options.target ? options.target : null; }; -ol.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_DragAndDrop_, _ol_interaction_Interaction_); /** @@ -70,13 +71,13 @@ ol.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction); * @this {ol.interaction.DragAndDrop} * @private */ -ol.interaction.DragAndDrop.handleDrop_ = function(event) { +_ol_interaction_DragAndDrop_.handleDrop_ = function(event) { var files = event.dataTransfer.files; var i, ii, file; for (i = 0, ii = files.length; i < ii; ++i) { file = files.item(i); var reader = new FileReader(); - reader.addEventListener(ol.events.EventType.LOAD, + reader.addEventListener(_ol_events_EventType_.LOAD, this.handleResult_.bind(this, file)); reader.readAsText(file); } @@ -87,7 +88,7 @@ ol.interaction.DragAndDrop.handleDrop_ = function(event) { * @param {Event} event Event. * @private */ -ol.interaction.DragAndDrop.handleStop_ = function(event) { +_ol_interaction_DragAndDrop_.handleStop_ = function(event) { event.stopPropagation(); event.preventDefault(); event.dataTransfer.dropEffect = 'copy'; @@ -99,7 +100,7 @@ ol.interaction.DragAndDrop.handleStop_ = function(event) { * @param {Event} event Load event. * @private */ -ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) { +_ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) { var result = event.target.result; var map = this.getMap(); var projection = this.projection_; @@ -133,8 +134,8 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) { this.source_.addFeatures(features); } this.dispatchEvent( - new ol.interaction.DragAndDrop.Event( - ol.interaction.DragAndDrop.EventType_.ADD_FEATURES, file, + new _ol_interaction_DragAndDrop_.Event( + _ol_interaction_DragAndDrop_.EventType_.ADD_FEATURES, file, features, projection)); }; @@ -147,25 +148,25 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) { * @this {ol.interaction.DragAndDrop} * @api */ -ol.interaction.DragAndDrop.handleEvent = ol.functions.TRUE; +_ol_interaction_DragAndDrop_.handleEvent = _ol_functions_.TRUE; /** * @private */ -ol.interaction.DragAndDrop.prototype.registerListeners_ = function() { +_ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() { var map = this.getMap(); if (map) { var dropArea = this.target ? this.target : map.getViewport(); this.dropListenKeys_ = [ - ol.events.listen(dropArea, ol.events.EventType.DROP, - ol.interaction.DragAndDrop.handleDrop_, this), - ol.events.listen(dropArea, ol.events.EventType.DRAGENTER, - ol.interaction.DragAndDrop.handleStop_, this), - ol.events.listen(dropArea, ol.events.EventType.DRAGOVER, - ol.interaction.DragAndDrop.handleStop_, this), - ol.events.listen(dropArea, ol.events.EventType.DROP, - ol.interaction.DragAndDrop.handleStop_, this) + _ol_events_.listen(dropArea, _ol_events_EventType_.DROP, + _ol_interaction_DragAndDrop_.handleDrop_, this), + _ol_events_.listen(dropArea, _ol_events_EventType_.DRAGENTER, + _ol_interaction_DragAndDrop_.handleStop_, this), + _ol_events_.listen(dropArea, _ol_events_EventType_.DRAGOVER, + _ol_interaction_DragAndDrop_.handleStop_, this), + _ol_events_.listen(dropArea, _ol_events_EventType_.DROP, + _ol_interaction_DragAndDrop_.handleStop_, this) ]; } }; @@ -174,8 +175,8 @@ ol.interaction.DragAndDrop.prototype.registerListeners_ = function() { /** * @inheritDoc */ -ol.interaction.DragAndDrop.prototype.setActive = function(active) { - ol.interaction.Interaction.prototype.setActive.call(this, active); +_ol_interaction_DragAndDrop_.prototype.setActive = function(active) { + _ol_interaction_Interaction_.prototype.setActive.call(this, active); if (active) { this.registerListeners_(); } else { @@ -187,9 +188,9 @@ ol.interaction.DragAndDrop.prototype.setActive = function(active) { /** * @inheritDoc */ -ol.interaction.DragAndDrop.prototype.setMap = function(map) { +_ol_interaction_DragAndDrop_.prototype.setMap = function(map) { this.unregisterListeners_(); - ol.interaction.Interaction.prototype.setMap.call(this, map); + _ol_interaction_Interaction_.prototype.setMap.call(this, map); if (this.getActive()) { this.registerListeners_(); } @@ -203,7 +204,7 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) { * @private * @return {Array.} Features. */ -ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) { +_ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text, options) { try { return format.readFeatures(text, options); } catch (e) { @@ -215,9 +216,9 @@ ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, o /** * @private */ -ol.interaction.DragAndDrop.prototype.unregisterListeners_ = function() { +_ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() { if (this.dropListenKeys_) { - this.dropListenKeys_.forEach(ol.events.unlistenByKey); + this.dropListenKeys_.forEach(_ol_events_.unlistenByKey); this.dropListenKeys_ = null; } }; @@ -227,7 +228,7 @@ ol.interaction.DragAndDrop.prototype.unregisterListeners_ = function() { * @enum {string} * @private */ -ol.interaction.DragAndDrop.EventType_ = { +_ol_interaction_DragAndDrop_.EventType_ = { /** * Triggered when features are added * @event ol.interaction.DragAndDrop.Event#addfeatures @@ -250,9 +251,9 @@ ol.interaction.DragAndDrop.EventType_ = { * @param {Array.=} opt_features Features. * @param {ol.proj.Projection=} opt_projection Projection. */ -ol.interaction.DragAndDrop.Event = function(type, file, opt_features, opt_projection) { +_ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_projection) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The features parsed from dropped data. @@ -276,4 +277,5 @@ ol.interaction.DragAndDrop.Event = function(type, file, opt_features, opt_projec this.projection = opt_projection; }; -ol.inherits(ol.interaction.DragAndDrop.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_DragAndDrop_.Event, _ol_events_Event_); +export default _ol_interaction_DragAndDrop_; diff --git a/src/ol/interaction/DragBox.js b/src/ol/interaction/DragBox.js index e22304a48c..50974faf1f 100644 --- a/src/ol/interaction/DragBox.js +++ b/src/ol/interaction/DragBox.js @@ -1,12 +1,12 @@ +/** + * @module ol/interaction/DragBox + */ // FIXME draw drag box -goog.provide('ol.interaction.DragBox'); - -goog.require('ol.events.Event'); -goog.require('ol'); -goog.require('ol.events.condition'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.render.Box'); - +import _ol_events_Event_ from '../events/Event.js'; +import _ol_ from '../index.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_render_Box_ from '../render/Box.js'; /** * @classdesc @@ -25,12 +25,12 @@ goog.require('ol.render.Box'); * @param {olx.interaction.DragBoxOptions=} opt_options Options. * @api */ -ol.interaction.DragBox = function(opt_options) { +var _ol_interaction_DragBox_ = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.DragBox.handleDownEvent_, - handleDragEvent: ol.interaction.DragBox.handleDragEvent_, - handleUpEvent: ol.interaction.DragBox.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_DragBox_.handleDownEvent_, + handleDragEvent: _ol_interaction_DragBox_.handleDragEvent_, + handleUpEvent: _ol_interaction_DragBox_.handleUpEvent_ }); var options = opt_options ? opt_options : {}; @@ -39,7 +39,7 @@ ol.interaction.DragBox = function(opt_options) { * @type {ol.render.Box} * @private */ - this.box_ = new ol.render.Box(options.className || 'ol-dragbox'); + this.box_ = new _ol_render_Box_(options.className || 'ol-dragbox'); /** * @type {number} @@ -58,16 +58,17 @@ ol.interaction.DragBox = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.always; + options.condition : _ol_events_condition_.always; /** * @private * @type {ol.DragBoxEndConditionType} */ this.boxEndCondition_ = options.boxEndCondition ? - options.boxEndCondition : ol.interaction.DragBox.defaultBoxEndCondition; + options.boxEndCondition : _ol_interaction_DragBox_.defaultBoxEndCondition; }; -ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_DragBox_, _ol_interaction_Pointer_); /** @@ -80,7 +81,7 @@ ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer); * @return {boolean} Whether or not the boxend condition should be fired. * @this {ol.interaction.DragBox} */ -ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) { +_ol_interaction_DragBox_.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) { var width = endPixel[0] - startPixel[0]; var height = endPixel[1] - startPixel[1]; return width * width + height * height >= this.minArea_; @@ -92,14 +93,14 @@ ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startP * @this {ol.interaction.DragBox} * @private */ -ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragBox_.handleDragEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return; } this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel); - this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXDRAG, + this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXDRAG, mapBrowserEvent.coordinate, mapBrowserEvent)); }; @@ -109,7 +110,7 @@ ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) { * @return {ol.geom.Polygon} Geometry. * @api */ -ol.interaction.DragBox.prototype.getGeometry = function() { +_ol_interaction_DragBox_.prototype.getGeometry = function() { return this.box_.getGeometry(); }; @@ -120,7 +121,7 @@ ol.interaction.DragBox.prototype.getGeometry = function() { * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @protected */ -ol.interaction.DragBox.prototype.onBoxEnd = ol.nullFunction; +_ol_interaction_DragBox_.prototype.onBoxEnd = _ol_.nullFunction; /** @@ -129,8 +130,8 @@ ol.interaction.DragBox.prototype.onBoxEnd = ol.nullFunction; * @this {ol.interaction.DragBox} * @private */ -ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragBox_.handleUpEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return true; } @@ -139,7 +140,7 @@ ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) { if (this.boxEndCondition_(mapBrowserEvent, this.startPixel_, mapBrowserEvent.pixel)) { this.onBoxEnd(mapBrowserEvent); - this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXEND, + this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXEND, mapBrowserEvent.coordinate, mapBrowserEvent)); } return false; @@ -152,17 +153,17 @@ ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragBox} * @private */ -ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragBox_.handleDownEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return false; } - if (ol.events.condition.mouseActionButton(mapBrowserEvent) && + if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) { this.startPixel_ = mapBrowserEvent.pixel; this.box_.setMap(mapBrowserEvent.map); this.box_.setPixels(this.startPixel_, this.startPixel_); - this.dispatchEvent(new ol.interaction.DragBox.Event(ol.interaction.DragBox.EventType_.BOXSTART, + this.dispatchEvent(new _ol_interaction_DragBox_.Event(_ol_interaction_DragBox_.EventType_.BOXSTART, mapBrowserEvent.coordinate, mapBrowserEvent)); return true; } else { @@ -175,7 +176,7 @@ ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) { * @enum {string} * @private */ -ol.interaction.DragBox.EventType_ = { +_ol_interaction_DragBox_.EventType_ = { /** * Triggered upon drag box start. * @event ol.interaction.DragBox.Event#boxstart @@ -211,8 +212,8 @@ ol.interaction.DragBox.EventType_ = { * @constructor * @implements {oli.DragBoxEvent} */ -ol.interaction.DragBox.Event = function(type, coordinate, mapBrowserEvent) { - ol.events.Event.call(this, type); +_ol_interaction_DragBox_.Event = function(type, coordinate, mapBrowserEvent) { + _ol_events_Event_.call(this, type); /** * The coordinate of the drag event. @@ -230,4 +231,5 @@ ol.interaction.DragBox.Event = function(type, coordinate, mapBrowserEvent) { this.mapBrowserEvent = mapBrowserEvent; }; -ol.inherits(ol.interaction.DragBox.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_DragBox_.Event, _ol_events_Event_); +export default _ol_interaction_DragBox_; diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index c11b23a55e..7cdc0acd65 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -1,13 +1,13 @@ -goog.provide('ol.interaction.DragPan'); - -goog.require('ol'); -goog.require('ol.ViewHint'); -goog.require('ol.coordinate'); -goog.require('ol.easing'); -goog.require('ol.events.condition'); -goog.require('ol.functions'); -goog.require('ol.interaction.Pointer'); - +/** + * @module ol/interaction/DragPan + */ +import _ol_ from '../index.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_easing_ from '../easing.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_functions_ from '../functions.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; /** * @classdesc @@ -18,12 +18,12 @@ goog.require('ol.interaction.Pointer'); * @param {olx.interaction.DragPanOptions=} opt_options Options. * @api */ -ol.interaction.DragPan = function(opt_options) { +var _ol_interaction_DragPan_ = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.DragPan.handleDownEvent_, - handleDragEvent: ol.interaction.DragPan.handleDragEvent_, - handleUpEvent: ol.interaction.DragPan.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_DragPan_.handleDownEvent_, + handleDragEvent: _ol_interaction_DragPan_.handleDragEvent_, + handleUpEvent: _ol_interaction_DragPan_.handleUpEvent_ }); var options = opt_options ? opt_options : {}; @@ -49,7 +49,7 @@ ol.interaction.DragPan = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.noModifierKeys; + options.condition : _ol_events_condition_.noModifierKeys; /** * @private @@ -58,7 +58,8 @@ ol.interaction.DragPan = function(opt_options) { this.noKinetic_ = false; }; -ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_DragPan_, _ol_interaction_Pointer_); /** @@ -66,10 +67,10 @@ ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer); * @this {ol.interaction.DragPan} * @private */ -ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) { +_ol_interaction_DragPan_.handleDragEvent_ = function(mapBrowserEvent) { var targetPointers = this.targetPointers; var centroid = - ol.interaction.Pointer.centroid(targetPointers); + _ol_interaction_Pointer_.centroid(targetPointers); if (targetPointers.length == this.lastPointersCount_) { if (this.kinetic_) { this.kinetic_.update(centroid[0], centroid[1]); @@ -81,9 +82,9 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) { var view = map.getView(); var viewState = view.getState(); var center = [deltaX, deltaY]; - ol.coordinate.scale(center, viewState.resolution); - ol.coordinate.rotate(center, viewState.rotation); - ol.coordinate.add(center, viewState.center); + _ol_coordinate_.scale(center, viewState.resolution); + _ol_coordinate_.rotate(center, viewState.rotation); + _ol_coordinate_.add(center, viewState.center); center = view.constrainCenter(center); view.setCenter(center); } @@ -103,7 +104,7 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragPan} * @private */ -ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) { +_ol_interaction_DragPan_.handleUpEvent_ = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var view = map.getView(); if (this.targetPointers.length === 0) { @@ -119,10 +120,10 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) { view.animate({ center: view.constrainCenter(dest), duration: 500, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); } - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); return false; } else { if (this.kinetic_) { @@ -142,13 +143,13 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragPan} * @private */ -ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) { +_ol_interaction_DragPan_.handleDownEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) { var map = mapBrowserEvent.map; var view = map.getView(); this.lastCentroid = null; if (!this.handlingDownUpSequence) { - view.setHint(ol.ViewHint.INTERACTING, 1); + view.setHint(_ol_ViewHint_.INTERACTING, 1); } // stop any current animation if (view.getAnimating()) { @@ -170,4 +171,5 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) { /** * @inheritDoc */ -ol.interaction.DragPan.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_DragPan_.prototype.shouldStopEvent = _ol_functions_.FALSE; +export default _ol_interaction_DragPan_; diff --git a/src/ol/interaction/DragRotate.js b/src/ol/interaction/DragRotate.js index c830822d99..2ba9bb4911 100644 --- a/src/ol/interaction/DragRotate.js +++ b/src/ol/interaction/DragRotate.js @@ -1,13 +1,13 @@ -goog.provide('ol.interaction.DragRotate'); - -goog.require('ol'); -goog.require('ol.RotationConstraint'); -goog.require('ol.ViewHint'); -goog.require('ol.events.condition'); -goog.require('ol.functions'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.Pointer'); - +/** + * @module ol/interaction/DragRotate + */ +import _ol_ from '../index.js'; +import _ol_RotationConstraint_ from '../RotationConstraint.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_functions_ from '../functions.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; /** * @classdesc @@ -22,14 +22,14 @@ goog.require('ol.interaction.Pointer'); * @param {olx.interaction.DragRotateOptions=} opt_options Options. * @api */ -ol.interaction.DragRotate = function(opt_options) { +var _ol_interaction_DragRotate_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.DragRotate.handleDownEvent_, - handleDragEvent: ol.interaction.DragRotate.handleDragEvent_, - handleUpEvent: ol.interaction.DragRotate.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_DragRotate_.handleDownEvent_, + handleDragEvent: _ol_interaction_DragRotate_.handleDragEvent_, + handleUpEvent: _ol_interaction_DragRotate_.handleUpEvent_ }); /** @@ -37,7 +37,7 @@ ol.interaction.DragRotate = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.altShiftKeysOnly; + options.condition : _ol_events_condition_.altShiftKeysOnly; /** * @private @@ -51,7 +51,8 @@ ol.interaction.DragRotate = function(opt_options) { */ this.duration_ = options.duration !== undefined ? options.duration : 250; }; -ol.inherits(ol.interaction.DragRotate, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_DragRotate_, _ol_interaction_Pointer_); /** @@ -59,14 +60,14 @@ ol.inherits(ol.interaction.DragRotate, ol.interaction.Pointer); * @this {ol.interaction.DragRotate} * @private */ -ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotate_.handleDragEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return; } var map = mapBrowserEvent.map; var view = map.getView(); - if (view.getConstraints().rotation === ol.RotationConstraint.disable) { + if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) { return; } var size = map.getSize(); @@ -76,7 +77,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { if (this.lastAngle_ !== undefined) { var delta = theta - this.lastAngle_; var rotation = view.getRotation(); - ol.interaction.Interaction.rotateWithoutConstraints( + _ol_interaction_Interaction_.rotateWithoutConstraints( view, rotation - delta); } this.lastAngle_ = theta; @@ -89,16 +90,16 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragRotate} * @private */ -ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotate_.handleUpEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return true; } var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); var rotation = view.getRotation(); - ol.interaction.Interaction.rotate(view, rotation, + _ol_interaction_Interaction_.rotate(view, rotation, undefined, this.duration_); return false; }; @@ -110,15 +111,15 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragRotate} * @private */ -ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotate_.handleDownEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return false; } - if (ol.events.condition.mouseActionButton(mapBrowserEvent) && + if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) { var map = mapBrowserEvent.map; - map.getView().setHint(ol.ViewHint.INTERACTING, 1); + map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); this.lastAngle_ = undefined; return true; } else { @@ -130,4 +131,5 @@ ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) { /** * @inheritDoc */ -ol.interaction.DragRotate.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_DragRotate_.prototype.shouldStopEvent = _ol_functions_.FALSE; +export default _ol_interaction_DragRotate_; diff --git a/src/ol/interaction/DragRotateAndZoom.js b/src/ol/interaction/DragRotateAndZoom.js index a2bb054aa1..8810f50b99 100644 --- a/src/ol/interaction/DragRotateAndZoom.js +++ b/src/ol/interaction/DragRotateAndZoom.js @@ -1,12 +1,12 @@ -goog.provide('ol.interaction.DragRotateAndZoom'); - -goog.require('ol'); -goog.require('ol.RotationConstraint'); -goog.require('ol.ViewHint'); -goog.require('ol.events.condition'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.Pointer'); - +/** + * @module ol/interaction/DragRotateAndZoom + */ +import _ol_ from '../index.js'; +import _ol_RotationConstraint_ from '../RotationConstraint.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; /** * @classdesc @@ -23,14 +23,14 @@ goog.require('ol.interaction.Pointer'); * @param {olx.interaction.DragRotateAndZoomOptions=} opt_options Options. * @api */ -ol.interaction.DragRotateAndZoom = function(opt_options) { +var _ol_interaction_DragRotateAndZoom_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_, - handleDragEvent: ol.interaction.DragRotateAndZoom.handleDragEvent_, - handleUpEvent: ol.interaction.DragRotateAndZoom.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_DragRotateAndZoom_.handleDownEvent_, + handleDragEvent: _ol_interaction_DragRotateAndZoom_.handleDragEvent_, + handleUpEvent: _ol_interaction_DragRotateAndZoom_.handleUpEvent_ }); /** @@ -38,7 +38,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.shiftKeyOnly; + options.condition : _ol_events_condition_.shiftKeyOnly; /** * @private @@ -65,7 +65,8 @@ ol.interaction.DragRotateAndZoom = function(opt_options) { this.duration_ = options.duration !== undefined ? options.duration : 400; }; -ol.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_DragRotateAndZoom_, _ol_interaction_Pointer_); /** @@ -73,8 +74,8 @@ ol.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer); * @this {ol.interaction.DragRotateAndZoom} * @private */ -ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotateAndZoom_.handleDragEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return; } @@ -86,15 +87,15 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { var theta = Math.atan2(deltaY, deltaX); var magnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY); var view = map.getView(); - if (view.getConstraints().rotation !== ol.RotationConstraint.disable && this.lastAngle_ !== undefined) { + if (view.getConstraints().rotation !== _ol_RotationConstraint_.disable && this.lastAngle_ !== undefined) { var angleDelta = theta - this.lastAngle_; - ol.interaction.Interaction.rotateWithoutConstraints( + _ol_interaction_Interaction_.rotateWithoutConstraints( view, view.getRotation() - angleDelta); } this.lastAngle_ = theta; if (this.lastMagnitude_ !== undefined) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); - ol.interaction.Interaction.zoomWithoutConstraints(view, resolution); + _ol_interaction_Interaction_.zoomWithoutConstraints(view, resolution); } if (this.lastMagnitude_ !== undefined) { this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; @@ -109,17 +110,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragRotateAndZoom} * @private */ -ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotateAndZoom_.handleUpEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return true; } var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); var direction = this.lastScaleDelta_ - 1; - ol.interaction.Interaction.rotate(view, view.getRotation()); - ol.interaction.Interaction.zoom(view, view.getResolution(), + _ol_interaction_Interaction_.rotate(view, view.getRotation()); + _ol_interaction_Interaction_.zoom(view, view.getResolution(), undefined, this.duration_, direction); this.lastScaleDelta_ = 0; return false; @@ -132,13 +133,13 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.DragRotateAndZoom} * @private */ -ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) { - if (!ol.events.condition.mouseOnly(mapBrowserEvent)) { +_ol_interaction_DragRotateAndZoom_.handleDownEvent_ = function(mapBrowserEvent) { + if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { return false; } if (this.condition_(mapBrowserEvent)) { - mapBrowserEvent.map.getView().setHint(ol.ViewHint.INTERACTING, 1); + mapBrowserEvent.map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); this.lastAngle_ = undefined; this.lastMagnitude_ = undefined; return true; @@ -146,3 +147,4 @@ ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) { return false; } }; +export default _ol_interaction_DragRotateAndZoom_; diff --git a/src/ol/interaction/DragZoom.js b/src/ol/interaction/DragZoom.js index d3c139df12..1783d537be 100644 --- a/src/ol/interaction/DragZoom.js +++ b/src/ol/interaction/DragZoom.js @@ -1,11 +1,11 @@ -goog.provide('ol.interaction.DragZoom'); - -goog.require('ol'); -goog.require('ol.easing'); -goog.require('ol.events.condition'); -goog.require('ol.extent'); -goog.require('ol.interaction.DragBox'); - +/** + * @module ol/interaction/DragZoom + */ +import _ol_ from '../index.js'; +import _ol_easing_ from '../easing.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_extent_ from '../extent.js'; +import _ol_interaction_DragBox_ from '../interaction/DragBox.js'; /** * @classdesc @@ -21,11 +21,11 @@ goog.require('ol.interaction.DragBox'); * @param {olx.interaction.DragZoomOptions=} opt_options Options. * @api */ -ol.interaction.DragZoom = function(opt_options) { +var _ol_interaction_DragZoom_ = function(opt_options) { var options = opt_options ? opt_options : {}; var condition = options.condition ? - options.condition : ol.events.condition.shiftKeyOnly; + options.condition : _ol_events_condition_.shiftKeyOnly; /** * @private @@ -39,19 +39,20 @@ ol.interaction.DragZoom = function(opt_options) { */ this.out_ = options.out !== undefined ? options.out : false; - ol.interaction.DragBox.call(this, { + _ol_interaction_DragBox_.call(this, { condition: condition, className: options.className || 'ol-dragzoom' }); }; -ol.inherits(ol.interaction.DragZoom, ol.interaction.DragBox); + +_ol_.inherits(_ol_interaction_DragZoom_, _ol_interaction_DragBox_); /** * @inheritDoc */ -ol.interaction.DragZoom.prototype.onBoxEnd = function() { +_ol_interaction_DragZoom_.prototype.onBoxEnd = function() { var map = this.getMap(); var view = /** @type {!ol.View} */ (map.getView()); @@ -62,26 +63,27 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() { if (this.out_) { var mapExtent = view.calculateExtent(size); - var boxPixelExtent = ol.extent.createOrUpdateFromCoordinates([ - map.getPixelFromCoordinate(ol.extent.getBottomLeft(extent)), - map.getPixelFromCoordinate(ol.extent.getTopRight(extent))]); + var boxPixelExtent = _ol_extent_.createOrUpdateFromCoordinates([ + map.getPixelFromCoordinate(_ol_extent_.getBottomLeft(extent)), + map.getPixelFromCoordinate(_ol_extent_.getTopRight(extent))]); var factor = view.getResolutionForExtent(boxPixelExtent, size); - ol.extent.scaleFromCenter(mapExtent, 1 / factor); + _ol_extent_.scaleFromCenter(mapExtent, 1 / factor); extent = mapExtent; } var resolution = view.constrainResolution( view.getResolutionForExtent(extent, size)); - var center = ol.extent.getCenter(extent); + var center = _ol_extent_.getCenter(extent); center = view.constrainCenter(center); view.animate({ resolution: resolution, center: center, duration: this.duration_, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); }; +export default _ol_interaction_DragZoom_; diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index 6e596eaa64..d657ad6e36 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -1,30 +1,30 @@ -goog.provide('ol.interaction.Draw'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.Object'); -goog.require('ol.coordinate'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.condition'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.DrawEventType'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.interaction.Property'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); - +/** + * @module ol/interaction/Draw + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_Object_ from '../Object.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_extent_ from '../extent.js'; +import _ol_functions_ from '../functions.js'; +import _ol_geom_Circle_ from '../geom/Circle.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_LineString_ from '../geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_interaction_DrawEventType_ from '../interaction/DrawEventType.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_interaction_Property_ from '../interaction/Property.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_source_Vector_ from '../source/Vector.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -36,12 +36,12 @@ goog.require('ol.style.Style'); * @param {olx.interaction.DrawOptions} options Options. * @api */ -ol.interaction.Draw = function(options) { +var _ol_interaction_Draw_ = function(options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.Draw.handleDownEvent_, - handleEvent: ol.interaction.Draw.handleEvent, - handleUpEvent: ol.interaction.Draw.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_Draw_.handleDownEvent_, + handleEvent: _ol_interaction_Draw_.handleEvent, + handleUpEvent: _ol_interaction_Draw_.handleUpEvent_ }); /** @@ -95,7 +95,7 @@ ol.interaction.Draw = function(options) { * @type {ol.interaction.Draw.Mode_} * @private */ - this.mode_ = ol.interaction.Draw.getMode_(this.type_); + this.mode_ = _ol_interaction_Draw_.getMode_(this.type_); /** * Stop click, singleclick, and doubleclick events from firing during drawing. @@ -114,7 +114,7 @@ ol.interaction.Draw = function(options) { */ this.minPoints_ = options.minPoints ? options.minPoints : - (this.mode_ === ol.interaction.Draw.Mode_.POLYGON ? 3 : 2); + (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON ? 3 : 2); /** * The number of points that can be drawn before a polygon ring or line string @@ -129,11 +129,11 @@ ol.interaction.Draw = function(options) { * @private * @type {ol.EventsConditionType} */ - this.finishCondition_ = options.finishCondition ? options.finishCondition : ol.functions.TRUE; + this.finishCondition_ = options.finishCondition ? options.finishCondition : _ol_functions_.TRUE; var geometryFunction = options.geometryFunction; if (!geometryFunction) { - if (this.type_ === ol.geom.GeometryType.CIRCLE) { + if (this.type_ === _ol_geom_GeometryType_.CIRCLE) { /** * @param {!Array.} coordinates * The coordinates. @@ -142,8 +142,8 @@ ol.interaction.Draw = function(options) { */ geometryFunction = function(coordinates, opt_geometry) { var circle = opt_geometry ? /** @type {ol.geom.Circle} */ (opt_geometry) : - new ol.geom.Circle([NaN, NaN]); - var squaredLength = ol.coordinate.squaredDistance( + new _ol_geom_Circle_([NaN, NaN]); + var squaredLength = _ol_coordinate_.squaredDistance( coordinates[0], coordinates[1]); circle.setCenterAndRadius(coordinates[0], Math.sqrt(squaredLength)); return circle; @@ -151,12 +151,12 @@ ol.interaction.Draw = function(options) { } else { var Constructor; var mode = this.mode_; - if (mode === ol.interaction.Draw.Mode_.POINT) { - Constructor = ol.geom.Point; - } else if (mode === ol.interaction.Draw.Mode_.LINE_STRING) { - Constructor = ol.geom.LineString; - } else if (mode === ol.interaction.Draw.Mode_.POLYGON) { - Constructor = ol.geom.Polygon; + if (mode === _ol_interaction_Draw_.Mode_.POINT) { + Constructor = _ol_geom_Point_; + } else if (mode === _ol_interaction_Draw_.Mode_.LINE_STRING) { + Constructor = _ol_geom_LineString_; + } else if (mode === _ol_interaction_Draw_.Mode_.POLYGON) { + Constructor = _ol_geom_Polygon_; } /** * @param {!Array.} coordinates @@ -167,7 +167,7 @@ ol.interaction.Draw = function(options) { geometryFunction = function(coordinates, opt_geometry) { var geometry = opt_geometry; if (geometry) { - if (mode === ol.interaction.Draw.Mode_.POLYGON) { + if (mode === _ol_interaction_Draw_.Mode_.POLYGON) { if (coordinates[0].length) { // Add a closing coordinate to match the first geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]); @@ -249,13 +249,13 @@ ol.interaction.Draw = function(options) { * @type {ol.layer.Vector} * @private */ - this.overlay_ = new ol.layer.Vector({ - source: new ol.source.Vector({ + this.overlay_ = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ useSpatialIndex: false, wrapX: options.wrapX ? options.wrapX : false }), style: options.style ? options.style : - ol.interaction.Draw.getDefaultStyleFunction() + _ol_interaction_Draw_.getDefaultStyleFunction() }); /** @@ -270,7 +270,7 @@ ol.interaction.Draw = function(options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.noModifierKeys; + options.condition : _ol_events_condition_.noModifierKeys; /** * @private @@ -278,25 +278,26 @@ ol.interaction.Draw = function(options) { */ this.freehandCondition_; if (options.freehand) { - this.freehandCondition_ = ol.events.condition.always; + this.freehandCondition_ = _ol_events_condition_.always; } else { this.freehandCondition_ = options.freehandCondition ? - options.freehandCondition : ol.events.condition.shiftKeyOnly; + options.freehandCondition : _ol_events_condition_.shiftKeyOnly; } - ol.events.listen(this, - ol.Object.getChangeEventType(ol.interaction.Property.ACTIVE), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_interaction_Property_.ACTIVE), this.updateState_, this); }; -ol.inherits(ol.interaction.Draw, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_Draw_, _ol_interaction_Pointer_); /** * @return {ol.StyleFunction} Styles. */ -ol.interaction.Draw.getDefaultStyleFunction = function() { - var styles = ol.style.Style.createDefaultEditing(); +_ol_interaction_Draw_.getDefaultStyleFunction = function() { + var styles = _ol_style_Style_.createDefaultEditing(); return function(feature, resolution) { return styles[feature.getGeometry().getType()]; }; @@ -306,8 +307,8 @@ ol.interaction.Draw.getDefaultStyleFunction = function() { /** * @inheritDoc */ -ol.interaction.Draw.prototype.setMap = function(map) { - ol.interaction.Pointer.prototype.setMap.call(this, map); +_ol_interaction_Draw_.prototype.setMap = function(map) { + _ol_interaction_Pointer_.prototype.setMap.call(this, map); this.updateState_(); }; @@ -320,23 +321,23 @@ ol.interaction.Draw.prototype.setMap = function(map) { * @this {ol.interaction.Draw} * @api */ -ol.interaction.Draw.handleEvent = function(event) { - this.freehand_ = this.mode_ !== ol.interaction.Draw.Mode_.POINT && this.freehandCondition_(event); +_ol_interaction_Draw_.handleEvent = function(event) { + this.freehand_ = this.mode_ !== _ol_interaction_Draw_.Mode_.POINT && this.freehandCondition_(event); var pass = true; if (this.freehand_ && - event.type === ol.MapBrowserEventType.POINTERDRAG && + event.type === _ol_MapBrowserEventType_.POINTERDRAG && this.sketchFeature_ !== null) { this.addToDrawing_(event); pass = false; } else if (this.freehand_ && - event.type === ol.MapBrowserEventType.POINTERDOWN) { + event.type === _ol_MapBrowserEventType_.POINTERDOWN) { pass = false; - } else if (event.type === ol.MapBrowserEventType.POINTERMOVE) { + } else if (event.type === _ol_MapBrowserEventType_.POINTERMOVE) { pass = this.handlePointerMove_(event); - } else if (event.type === ol.MapBrowserEventType.DBLCLICK) { + } else if (event.type === _ol_MapBrowserEventType_.DBLCLICK) { pass = false; } - return ol.interaction.Pointer.handleEvent.call(this, event) && pass; + return _ol_interaction_Pointer_.handleEvent.call(this, event) && pass; }; @@ -346,7 +347,7 @@ ol.interaction.Draw.handleEvent = function(event) { * @this {ol.interaction.Draw} * @private */ -ol.interaction.Draw.handleDownEvent_ = function(event) { +_ol_interaction_Draw_.handleDownEvent_ = function(event) { this.shouldHandle_ = !this.freehand_; if (this.freehand_) { @@ -370,17 +371,17 @@ ol.interaction.Draw.handleDownEvent_ = function(event) { * @this {ol.interaction.Draw} * @private */ -ol.interaction.Draw.handleUpEvent_ = function(event) { +_ol_interaction_Draw_.handleUpEvent_ = function(event) { var pass = true; this.handlePointerMove_(event); - var circleMode = this.mode_ === ol.interaction.Draw.Mode_.CIRCLE; + var circleMode = this.mode_ === _ol_interaction_Draw_.Mode_.CIRCLE; if (this.shouldHandle_) { if (!this.finishCoordinate_) { this.startDrawing_(event); - if (this.mode_ === ol.interaction.Draw.Mode_.POINT) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) { this.finishDrawing(); } } else if (this.freehand_ || circleMode) { @@ -410,7 +411,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) { * @return {boolean} Pass the event to other interactions. * @private */ -ol.interaction.Draw.prototype.handlePointerMove_ = function(event) { +_ol_interaction_Draw_.prototype.handlePointerMove_ = function(event) { if (this.downPx_ && ((!this.freehand_ && this.shouldHandle_) || (this.freehand_ && !this.shouldHandle_))) { @@ -439,14 +440,14 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) { * @return {boolean} The event is within the snapping tolerance of the start. * @private */ -ol.interaction.Draw.prototype.atFinish_ = function(event) { +_ol_interaction_Draw_.prototype.atFinish_ = function(event) { var at = false; if (this.sketchFeature_) { var potentiallyDone = false; var potentiallyFinishCoordinates = [this.finishCoordinate_]; - if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) { potentiallyDone = this.sketchCoords_.length > this.minPoints_; - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { potentiallyDone = this.sketchCoords_[0].length > this.minPoints_; potentiallyFinishCoordinates = [this.sketchCoords_[0][0], @@ -477,10 +478,10 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) { * @param {ol.MapBrowserEvent} event Event. * @private */ -ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) { +_ol_interaction_Draw_.prototype.createOrUpdateSketchPoint_ = function(event) { var coordinates = event.coordinate.slice(); if (!this.sketchPoint_) { - this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates)); + this.sketchPoint_ = new _ol_Feature_(new _ol_geom_Point_(coordinates)); this.updateSketchFeatures_(); } else { var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry()); @@ -494,33 +495,33 @@ ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) { * @param {ol.MapBrowserEvent} event Event. * @private */ -ol.interaction.Draw.prototype.startDrawing_ = function(event) { +_ol_interaction_Draw_.prototype.startDrawing_ = function(event) { var start = event.coordinate; this.finishCoordinate_ = start; - if (this.mode_ === ol.interaction.Draw.Mode_.POINT) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) { this.sketchCoords_ = start.slice(); - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { this.sketchCoords_ = [[start.slice(), start.slice()]]; this.sketchLineCoords_ = this.sketchCoords_[0]; } else { this.sketchCoords_ = [start.slice(), start.slice()]; - if (this.mode_ === ol.interaction.Draw.Mode_.CIRCLE) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.CIRCLE) { this.sketchLineCoords_ = this.sketchCoords_; } } if (this.sketchLineCoords_) { - this.sketchLine_ = new ol.Feature( - new ol.geom.LineString(this.sketchLineCoords_)); + this.sketchLine_ = new _ol_Feature_( + new _ol_geom_LineString_(this.sketchLineCoords_)); } var geometry = this.geometryFunction_(this.sketchCoords_); - this.sketchFeature_ = new ol.Feature(); + this.sketchFeature_ = new _ol_Feature_(); if (this.geometryName_) { this.sketchFeature_.setGeometryName(this.geometryName_); } this.sketchFeature_.setGeometry(geometry); this.updateSketchFeatures_(); - this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_)); + this.dispatchEvent(new _ol_interaction_Draw_.Event( + _ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_)); }; @@ -529,13 +530,13 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) { * @param {ol.MapBrowserEvent} event Event. * @private */ -ol.interaction.Draw.prototype.modifyDrawing_ = function(event) { +_ol_interaction_Draw_.prototype.modifyDrawing_ = function(event) { var coordinate = event.coordinate; var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry()); var coordinates, last; - if (this.mode_ === ol.interaction.Draw.Mode_.POINT) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.POINT) { last = this.sketchCoords_; - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { coordinates = this.sketchCoords_[0]; last = coordinates[coordinates.length - 1]; if (this.atFinish_(event)) { @@ -554,10 +555,10 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) { sketchPointGeom.setCoordinates(coordinate); } var sketchLineGeom; - if (geometry instanceof ol.geom.Polygon && - this.mode_ !== ol.interaction.Draw.Mode_.POLYGON) { + if (geometry instanceof _ol_geom_Polygon_ && + this.mode_ !== _ol_interaction_Draw_.Mode_.POLYGON) { if (!this.sketchLine_) { - this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null)); + this.sketchLine_ = new _ol_Feature_(new _ol_geom_LineString_(null)); } var ring = geometry.getLinearRing(0); sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry()); @@ -576,12 +577,12 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) { * @param {ol.MapBrowserEvent} event Event. * @private */ -ol.interaction.Draw.prototype.addToDrawing_ = function(event) { +_ol_interaction_Draw_.prototype.addToDrawing_ = function(event) { var coordinate = event.coordinate; var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry()); var done; var coordinates; - if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) { this.finishCoordinate_ = coordinate.slice(); coordinates = this.sketchCoords_; if (coordinates.length >= this.maxPoints_) { @@ -593,7 +594,7 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) { } coordinates.push(coordinate.slice()); this.geometryFunction_(coordinates, geometry); - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { coordinates = this.sketchCoords_[0]; if (coordinates.length >= this.maxPoints_) { if (this.freehand_) { @@ -619,20 +620,20 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) { * Remove last point of the feature currently being drawn. * @api */ -ol.interaction.Draw.prototype.removeLastPoint = function() { +_ol_interaction_Draw_.prototype.removeLastPoint = function() { if (!this.sketchFeature_) { return; } var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry()); var coordinates, sketchLineGeom; - if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) { coordinates = this.sketchCoords_; coordinates.splice(-2, 1); this.geometryFunction_(coordinates, geometry); if (coordinates.length >= 2) { this.finishCoordinate_ = coordinates[coordinates.length - 2].slice(); } - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { coordinates = this.sketchCoords_[0]; coordinates.splice(-2, 1); sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry()); @@ -654,15 +655,15 @@ ol.interaction.Draw.prototype.removeLastPoint = function() { * inserting the feature. * @api */ -ol.interaction.Draw.prototype.finishDrawing = function() { +_ol_interaction_Draw_.prototype.finishDrawing = function() { var sketchFeature = this.abortDrawing_(); var coordinates = this.sketchCoords_; var geometry = /** @type {ol.geom.SimpleGeometry} */ (sketchFeature.getGeometry()); - if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) { + if (this.mode_ === _ol_interaction_Draw_.Mode_.LINE_STRING) { // remove the redundant last point coordinates.pop(); this.geometryFunction_(coordinates, geometry); - } else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) { + } else if (this.mode_ === _ol_interaction_Draw_.Mode_.POLYGON) { // remove the redundant last point in ring coordinates[0].pop(); this.geometryFunction_(coordinates, geometry); @@ -670,17 +671,17 @@ ol.interaction.Draw.prototype.finishDrawing = function() { } // cast multi-part geometries - if (this.type_ === ol.geom.GeometryType.MULTI_POINT) { - sketchFeature.setGeometry(new ol.geom.MultiPoint([coordinates])); - } else if (this.type_ === ol.geom.GeometryType.MULTI_LINE_STRING) { - sketchFeature.setGeometry(new ol.geom.MultiLineString([coordinates])); - } else if (this.type_ === ol.geom.GeometryType.MULTI_POLYGON) { - sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates])); + if (this.type_ === _ol_geom_GeometryType_.MULTI_POINT) { + sketchFeature.setGeometry(new _ol_geom_MultiPoint_([coordinates])); + } else if (this.type_ === _ol_geom_GeometryType_.MULTI_LINE_STRING) { + sketchFeature.setGeometry(new _ol_geom_MultiLineString_([coordinates])); + } else if (this.type_ === _ol_geom_GeometryType_.MULTI_POLYGON) { + sketchFeature.setGeometry(new _ol_geom_MultiPolygon_([coordinates])); } // First dispatch event to allow full set up of feature - this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.DrawEventType.DRAWEND, sketchFeature)); + this.dispatchEvent(new _ol_interaction_Draw_.Event( + _ol_interaction_DrawEventType_.DRAWEND, sketchFeature)); // Then insert feature if (this.features_) { @@ -697,7 +698,7 @@ ol.interaction.Draw.prototype.finishDrawing = function() { * @return {ol.Feature} The sketch feature (or null if none). * @private */ -ol.interaction.Draw.prototype.abortDrawing_ = function() { +_ol_interaction_Draw_.prototype.abortDrawing_ = function() { this.finishCoordinate_ = null; var sketchFeature = this.sketchFeature_; if (sketchFeature) { @@ -717,7 +718,7 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() { * @param {!ol.Feature} feature Feature to be extended. * @api */ -ol.interaction.Draw.prototype.extend = function(feature) { +_ol_interaction_Draw_.prototype.extend = function(feature) { var geometry = feature.getGeometry(); var lineString = /** @type {ol.geom.LineString} */ (geometry); this.sketchFeature_ = feature; @@ -726,22 +727,22 @@ ol.interaction.Draw.prototype.extend = function(feature) { this.finishCoordinate_ = last.slice(); this.sketchCoords_.push(last.slice()); this.updateSketchFeatures_(); - this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_)); + this.dispatchEvent(new _ol_interaction_Draw_.Event( + _ol_interaction_DrawEventType_.DRAWSTART, this.sketchFeature_)); }; /** * @inheritDoc */ -ol.interaction.Draw.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_Draw_.prototype.shouldStopEvent = _ol_functions_.FALSE; /** * Redraw the sketch features. * @private */ -ol.interaction.Draw.prototype.updateSketchFeatures_ = function() { +_ol_interaction_Draw_.prototype.updateSketchFeatures_ = function() { var sketchFeatures = []; if (this.sketchFeature_) { sketchFeatures.push(this.sketchFeature_); @@ -761,7 +762,7 @@ ol.interaction.Draw.prototype.updateSketchFeatures_ = function() { /** * @private */ -ol.interaction.Draw.prototype.updateState_ = function() { +_ol_interaction_Draw_.prototype.updateState_ = function() { var map = this.getMap(); var active = this.getActive(); if (!map || !active) { @@ -784,23 +785,23 @@ ol.interaction.Draw.prototype.updateState_ = function() { * polygon. * @api */ -ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) { +_ol_interaction_Draw_.createRegularPolygon = function(opt_sides, opt_angle) { return ( - /** - * @param {ol.Coordinate|Array.|Array.>} coordinates - * @param {ol.geom.SimpleGeometry=} opt_geometry - * @return {ol.geom.SimpleGeometry} - */ + /** + * @param {ol.Coordinate|Array.|Array.>} coordinates + * @param {ol.geom.SimpleGeometry=} opt_geometry + * @return {ol.geom.SimpleGeometry} + */ function(coordinates, opt_geometry) { var center = coordinates[0]; var end = coordinates[1]; var radius = Math.sqrt( - ol.coordinate.squaredDistance(center, end)); + _ol_coordinate_.squaredDistance(center, end)); var geometry = opt_geometry ? /** @type {ol.geom.Polygon} */ (opt_geometry) : - ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides); + _ol_geom_Polygon_.fromCircle(new _ol_geom_Circle_(center), opt_sides); var angle = opt_angle ? opt_angle : Math.atan((end[1] - center[1]) / (end[0] - center[0])); - ol.geom.Polygon.makeRegular(geometry, center, radius, angle); + _ol_geom_Polygon_.makeRegular(geometry, center, radius, angle); return geometry; } ); @@ -814,7 +815,7 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) { * @return {ol.DrawGeometryFunctionType} Function that draws a box-shaped polygon. * @api */ -ol.interaction.Draw.createBox = function() { +_ol_interaction_Draw_.createBox = function() { return ( /** * @param {Array.} coordinates @@ -822,14 +823,14 @@ ol.interaction.Draw.createBox = function() { * @return {ol.geom.SimpleGeometry} */ function(coordinates, opt_geometry) { - var extent = ol.extent.boundingExtent(coordinates); - var geometry = opt_geometry || new ol.geom.Polygon(null); + var extent = _ol_extent_.boundingExtent(coordinates); + var geometry = opt_geometry || new _ol_geom_Polygon_(null); geometry.setCoordinates([[ - ol.extent.getBottomLeft(extent), - ol.extent.getBottomRight(extent), - ol.extent.getTopRight(extent), - ol.extent.getTopLeft(extent), - ol.extent.getBottomLeft(extent) + _ol_extent_.getBottomLeft(extent), + _ol_extent_.getBottomRight(extent), + _ol_extent_.getTopRight(extent), + _ol_extent_.getTopLeft(extent), + _ol_extent_.getBottomLeft(extent) ]]); return geometry; } @@ -844,19 +845,19 @@ ol.interaction.Draw.createBox = function() { * @return {ol.interaction.Draw.Mode_} Drawing mode. * @private */ -ol.interaction.Draw.getMode_ = function(type) { +_ol_interaction_Draw_.getMode_ = function(type) { var mode; - if (type === ol.geom.GeometryType.POINT || - type === ol.geom.GeometryType.MULTI_POINT) { - mode = ol.interaction.Draw.Mode_.POINT; - } else if (type === ol.geom.GeometryType.LINE_STRING || - type === ol.geom.GeometryType.MULTI_LINE_STRING) { - mode = ol.interaction.Draw.Mode_.LINE_STRING; - } else if (type === ol.geom.GeometryType.POLYGON || - type === ol.geom.GeometryType.MULTI_POLYGON) { - mode = ol.interaction.Draw.Mode_.POLYGON; - } else if (type === ol.geom.GeometryType.CIRCLE) { - mode = ol.interaction.Draw.Mode_.CIRCLE; + if (type === _ol_geom_GeometryType_.POINT || + type === _ol_geom_GeometryType_.MULTI_POINT) { + mode = _ol_interaction_Draw_.Mode_.POINT; + } else if (type === _ol_geom_GeometryType_.LINE_STRING || + type === _ol_geom_GeometryType_.MULTI_LINE_STRING) { + mode = _ol_interaction_Draw_.Mode_.LINE_STRING; + } else if (type === _ol_geom_GeometryType_.POLYGON || + type === _ol_geom_GeometryType_.MULTI_POLYGON) { + mode = _ol_interaction_Draw_.Mode_.POLYGON; + } else if (type === _ol_geom_GeometryType_.CIRCLE) { + mode = _ol_interaction_Draw_.Mode_.CIRCLE; } return /** @type {!ol.interaction.Draw.Mode_} */ (mode); }; @@ -868,7 +869,7 @@ ol.interaction.Draw.getMode_ = function(type) { * @enum {string} * @private */ -ol.interaction.Draw.Mode_ = { +_ol_interaction_Draw_.Mode_ = { POINT: 'Point', LINE_STRING: 'LineString', POLYGON: 'Polygon', @@ -886,9 +887,9 @@ ol.interaction.Draw.Mode_ = { * @param {ol.interaction.DrawEventType} type Type. * @param {ol.Feature} feature The feature drawn. */ -ol.interaction.Draw.Event = function(type, feature) { +_ol_interaction_Draw_.Event = function(type, feature) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The feature being drawn. @@ -898,4 +899,5 @@ ol.interaction.Draw.Event = function(type, feature) { this.feature = feature; }; -ol.inherits(ol.interaction.Draw.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_Draw_.Event, _ol_events_Event_); +export default _ol_interaction_Draw_; diff --git a/src/ol/interaction/DrawEventType.js b/src/ol/interaction/DrawEventType.js index 0193ce4e99..325c929a91 100644 --- a/src/ol/interaction/DrawEventType.js +++ b/src/ol/interaction/DrawEventType.js @@ -1,10 +1,10 @@ -goog.provide('ol.interaction.DrawEventType'); - - +/** + * @module ol/interaction/DrawEventType + */ /** * @enum {string} */ -ol.interaction.DrawEventType = { +var _ol_interaction_DrawEventType_ = { /** * Triggered upon feature draw start * @event ol.interaction.Draw.Event#drawstart @@ -18,3 +18,5 @@ ol.interaction.DrawEventType = { */ DRAWEND: 'drawend' }; + +export default _ol_interaction_DrawEventType_; diff --git a/src/ol/interaction/Extent.js b/src/ol/interaction/Extent.js index 0443b5e7e4..7cf26c6b87 100644 --- a/src/ol/interaction/Extent.js +++ b/src/ol/interaction/Extent.js @@ -1,21 +1,21 @@ -goog.provide('ol.interaction.Extent'); - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.coordinate'); -goog.require('ol.events.Event'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.ExtentEventType'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); - +/** + * @module ol/interaction/Extent + */ +import _ol_ from '../index.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_interaction_ExtentEventType_ from '../interaction/ExtentEventType.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_source_Vector_ from '../source/Vector.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -29,7 +29,7 @@ goog.require('ol.style.Style'); * @param {olx.interaction.ExtentOptions=} opt_options Options. * @api */ -ol.interaction.Extent = function(opt_options) { +var _ol_interaction_Extent_ = function(opt_options) { var options = opt_options || {}; @@ -81,11 +81,11 @@ ol.interaction.Extent = function(opt_options) { } /* Inherit ol.interaction.Pointer */ - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.Extent.handleDownEvent_, - handleDragEvent: ol.interaction.Extent.handleDragEvent_, - handleEvent: ol.interaction.Extent.handleEvent_, - handleUpEvent: ol.interaction.Extent.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_Extent_.handleDownEvent_, + handleDragEvent: _ol_interaction_Extent_.handleDragEvent_, + handleEvent: _ol_interaction_Extent_.handleEvent_, + handleUpEvent: _ol_interaction_Extent_.handleUpEvent_ }); /** @@ -93,12 +93,12 @@ ol.interaction.Extent = function(opt_options) { * @type {ol.layer.Vector} * @private */ - this.extentOverlay_ = new ol.layer.Vector({ - source: new ol.source.Vector({ + this.extentOverlay_ = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ useSpatialIndex: false, wrapX: !!opt_options.wrapX }), - style: opt_options.boxStyle ? opt_options.boxStyle : ol.interaction.Extent.getDefaultExtentStyleFunction_(), + style: opt_options.boxStyle ? opt_options.boxStyle : _ol_interaction_Extent_.getDefaultExtentStyleFunction_(), updateWhileAnimating: true, updateWhileInteracting: true }); @@ -108,12 +108,12 @@ ol.interaction.Extent = function(opt_options) { * @type {ol.layer.Vector} * @private */ - this.vertexOverlay_ = new ol.layer.Vector({ - source: new ol.source.Vector({ + this.vertexOverlay_ = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ useSpatialIndex: false, wrapX: !!opt_options.wrapX }), - style: opt_options.pointerStyle ? opt_options.pointerStyle : ol.interaction.Extent.getDefaultPointerStyleFunction_(), + style: opt_options.pointerStyle ? opt_options.pointerStyle : _ol_interaction_Extent_.getDefaultPointerStyleFunction_(), updateWhileAnimating: true, updateWhileInteracting: true }); @@ -123,7 +123,7 @@ ol.interaction.Extent = function(opt_options) { } }; -ol.inherits(ol.interaction.Extent, ol.interaction.Pointer); +_ol_.inherits(_ol_interaction_Extent_, _ol_interaction_Pointer_); /** * @param {ol.MapBrowserEvent} mapBrowserEvent Event. @@ -131,16 +131,16 @@ ol.inherits(ol.interaction.Extent, ol.interaction.Pointer); * @this {ol.interaction.Extent} * @private */ -ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) { - if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) { +_ol_interaction_Extent_.handleEvent_ = function(mapBrowserEvent) { + if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) { return true; } //display pointer (if not dragging) - if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE && !this.handlingDownUpSequence) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE && !this.handlingDownUpSequence) { this.handlePointerMove_(mapBrowserEvent); } //call pointer to determine up/down/drag - ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent); + _ol_interaction_Pointer_.handleEvent.call(this, mapBrowserEvent); //return false to stop propagation return false; }; @@ -151,7 +151,7 @@ ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.Extent} * @private */ -ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) { +_ol_interaction_Extent_.handleDownEvent_ = function(mapBrowserEvent) { var pixel = mapBrowserEvent.pixel; var map = mapBrowserEvent.map; @@ -183,15 +183,15 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) { //snap to point if (x !== null && y !== null) { - this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(getOpposingPoint(vertex)); + this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(getOpposingPoint(vertex)); //snap to edge } else if (x !== null) { - this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_( + this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_( getOpposingPoint([x, extent[1]]), getOpposingPoint([x, extent[3]]) ); } else if (y !== null) { - this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_( + this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_( getOpposingPoint([extent[0], y]), getOpposingPoint([extent[2], y]) ); @@ -200,7 +200,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) { } else { vertex = map.getCoordinateFromPixel(pixel); this.setExtent([vertex[0], vertex[1], vertex[0], vertex[1]]); - this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(vertex); + this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(vertex); } return true; //event handled; start downup sequence }; @@ -211,7 +211,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.Extent} * @private */ -ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) { +_ol_interaction_Extent_.handleDragEvent_ = function(mapBrowserEvent) { if (this.pointerHandler_) { var pixelCoordinate = mapBrowserEvent.coordinate; this.setExtent(this.pointerHandler_(pixelCoordinate)); @@ -226,11 +226,11 @@ ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.Extent} * @private */ -ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) { +_ol_interaction_Extent_.handleUpEvent_ = function(mapBrowserEvent) { this.pointerHandler_ = null; //If bbox is zero area, set to null; var extent = this.getExtent(); - if (!extent || ol.extent.getArea(extent) === 0) { + if (!extent || _ol_extent_.getArea(extent) === 0) { this.setExtent(null); } return false; //Stop handling downup sequence @@ -242,10 +242,10 @@ ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) { * @return {ol.StyleFunction} Default Extent style * @private */ -ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() { - var style = ol.style.Style.createDefaultEditing(); +_ol_interaction_Extent_.getDefaultExtentStyleFunction_ = function() { + var style = _ol_style_Style_.createDefaultEditing(); return function(feature, resolution) { - return style[ol.geom.GeometryType.POLYGON]; + return style[_ol_geom_GeometryType_.POLYGON]; }; }; @@ -255,10 +255,10 @@ ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() { * @return {ol.StyleFunction} Default pointer style * @private */ -ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() { - var style = ol.style.Style.createDefaultEditing(); +_ol_interaction_Extent_.getDefaultPointerStyleFunction_ = function() { + var style = _ol_style_Style_.createDefaultEditing(); return function(feature, resolution) { - return style[ol.geom.GeometryType.POINT]; + return style[_ol_geom_GeometryType_.POINT]; }; }; @@ -267,9 +267,9 @@ ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() { * @returns {function (ol.Coordinate): ol.Extent} event handler * @private */ -ol.interaction.Extent.getPointHandler_ = function(fixedPoint) { +_ol_interaction_Extent_.getPointHandler_ = function(fixedPoint) { return function(point) { - return ol.extent.boundingExtent([fixedPoint, point]); + return _ol_extent_.boundingExtent([fixedPoint, point]); }; }; @@ -279,14 +279,14 @@ ol.interaction.Extent.getPointHandler_ = function(fixedPoint) { * @returns {function (ol.Coordinate): ol.Extent|null} event handler * @private */ -ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) { +_ol_interaction_Extent_.getEdgeHandler_ = function(fixedP1, fixedP2) { if (fixedP1[0] == fixedP2[0]) { return function(point) { - return ol.extent.boundingExtent([fixedP1, [point[0], fixedP2[1]]]); + return _ol_extent_.boundingExtent([fixedP1, [point[0], fixedP2[1]]]); }; } else if (fixedP1[1] == fixedP2[1]) { return function(point) { - return ol.extent.boundingExtent([fixedP1, [fixedP2[0], point[1]]]); + return _ol_extent_.boundingExtent([fixedP1, [fixedP2[0], point[1]]]); }; } else { return null; @@ -298,7 +298,7 @@ ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) { * @returns {Array>} extent line segments * @private */ -ol.interaction.Extent.getSegments_ = function(extent) { +_ol_interaction_Extent_.getSegments_ = function(extent) { return [ [[extent[0], extent[1]], [extent[0], extent[3]]], [[extent[0], extent[3]], [extent[2], extent[3]]], @@ -313,30 +313,30 @@ ol.interaction.Extent.getSegments_ = function(extent) { * @returns {ol.Coordinate|null} snapped vertex on extent * @private */ -ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) { +_ol_interaction_Extent_.prototype.snapToVertex_ = function(pixel, map) { var pixelCoordinate = map.getCoordinateFromPixel(pixel); var sortByDistance = function(a, b) { - return ol.coordinate.squaredDistanceToSegment(pixelCoordinate, a) - - ol.coordinate.squaredDistanceToSegment(pixelCoordinate, b); + return _ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, a) - + _ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, b); }; var extent = this.getExtent(); if (extent) { //convert extents to line segments and find the segment closest to pixelCoordinate - var segments = ol.interaction.Extent.getSegments_(extent); + var segments = _ol_interaction_Extent_.getSegments_(extent); segments.sort(sortByDistance); var closestSegment = segments[0]; - var vertex = (ol.coordinate.closestOnSegment(pixelCoordinate, + var vertex = (_ol_coordinate_.closestOnSegment(pixelCoordinate, closestSegment)); var vertexPixel = map.getPixelFromCoordinate(vertex); //if the distance is within tolerance, snap to the segment - if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) { + if (_ol_coordinate_.distance(pixel, vertexPixel) <= this.pixelTolerance_) { //test if we should further snap to a vertex var pixel1 = map.getPixelFromCoordinate(closestSegment[0]); var pixel2 = map.getPixelFromCoordinate(closestSegment[1]); - var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1); - var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2); + var squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1); + var squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2); var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); this.snappedToVertex_ = dist <= this.pixelTolerance_; if (this.snappedToVertex_) { @@ -353,7 +353,7 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) { * @param {ol.MapBrowserEvent} mapBrowserEvent pointer move event * @private */ -ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) { +_ol_interaction_Extent_.prototype.handlePointerMove_ = function(mapBrowserEvent) { var pixel = mapBrowserEvent.pixel; var map = mapBrowserEvent.map; @@ -369,14 +369,14 @@ ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) { * @returns {ol.Feature} extent as featrue * @private */ -ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent) { +_ol_interaction_Extent_.prototype.createOrUpdateExtentFeature_ = function(extent) { var extentFeature = this.extentFeature_; if (!extentFeature) { if (!extent) { - extentFeature = new ol.Feature({}); + extentFeature = new _ol_Feature_({}); } else { - extentFeature = new ol.Feature(ol.geom.Polygon.fromExtent(extent)); + extentFeature = new _ol_Feature_(_ol_geom_Polygon_.fromExtent(extent)); } this.extentFeature_ = extentFeature; this.extentOverlay_.getSource().addFeature(extentFeature); @@ -384,7 +384,7 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent) if (!extent) { extentFeature.setGeometry(undefined); } else { - extentFeature.setGeometry(ol.geom.Polygon.fromExtent(extent)); + extentFeature.setGeometry(_ol_geom_Polygon_.fromExtent(extent)); } } return extentFeature; @@ -396,10 +396,10 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent) * @returns {ol.Feature} vertex as feature * @private */ -ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex) { +_ol_interaction_Extent_.prototype.createOrUpdatePointerFeature_ = function(vertex) { var vertexFeature = this.vertexFeature_; if (!vertexFeature) { - vertexFeature = new ol.Feature(new ol.geom.Point(vertex)); + vertexFeature = new _ol_Feature_(new _ol_geom_Point_(vertex)); this.vertexFeature_ = vertexFeature; this.vertexOverlay_.getSource().addFeature(vertexFeature); } else { @@ -413,10 +413,10 @@ ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex) /** * @inheritDoc */ -ol.interaction.Extent.prototype.setMap = function(map) { +_ol_interaction_Extent_.prototype.setMap = function(map) { this.extentOverlay_.setMap(map); this.vertexOverlay_.setMap(map); - ol.interaction.Pointer.prototype.setMap.call(this, map); + _ol_interaction_Pointer_.prototype.setMap.call(this, map); }; /** @@ -425,7 +425,7 @@ ol.interaction.Extent.prototype.setMap = function(map) { * @return {ol.Extent} Drawn extent in the view projection. * @api */ -ol.interaction.Extent.prototype.getExtent = function() { +_ol_interaction_Extent_.prototype.getExtent = function() { return this.extent_; }; @@ -435,11 +435,11 @@ ol.interaction.Extent.prototype.getExtent = function() { * @param {ol.Extent} extent Extent * @api */ -ol.interaction.Extent.prototype.setExtent = function(extent) { +_ol_interaction_Extent_.prototype.setExtent = function(extent) { //Null extent means no bbox this.extent_ = extent ? extent : null; this.createOrUpdateExtentFeature_(extent); - this.dispatchEvent(new ol.interaction.Extent.Event(this.extent_)); + this.dispatchEvent(new _ol_interaction_Extent_.Event(this.extent_)); }; @@ -453,8 +453,8 @@ ol.interaction.Extent.prototype.setExtent = function(extent) { * @param {ol.Extent} extent the new extent * @extends {ol.events.Event} */ -ol.interaction.Extent.Event = function(extent) { - ol.events.Event.call(this, ol.interaction.ExtentEventType.EXTENTCHANGED); +_ol_interaction_Extent_.Event = function(extent) { + _ol_events_Event_.call(this, _ol_interaction_ExtentEventType_.EXTENTCHANGED); /** * The current extent. @@ -464,4 +464,5 @@ ol.interaction.Extent.Event = function(extent) { this.extent = extent; }; -ol.inherits(ol.interaction.Extent.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_Extent_.Event, _ol_events_Event_); +export default _ol_interaction_Extent_; diff --git a/src/ol/interaction/ExtentEventType.js b/src/ol/interaction/ExtentEventType.js index 57a5a13a86..d87ad54d85 100644 --- a/src/ol/interaction/ExtentEventType.js +++ b/src/ol/interaction/ExtentEventType.js @@ -1,10 +1,10 @@ -goog.provide('ol.interaction.ExtentEventType'); - - +/** + * @module ol/interaction/ExtentEventType + */ /** * @enum {string} */ -ol.interaction.ExtentEventType = { +var _ol_interaction_ExtentEventType_ = { /** * Triggered after the extent is changed * @event ol.interaction.Extent.Event#extentchanged @@ -12,3 +12,5 @@ ol.interaction.ExtentEventType = { */ EXTENTCHANGED: 'extentchanged' }; + +export default _ol_interaction_ExtentEventType_; diff --git a/src/ol/interaction/Interaction.js b/src/ol/interaction/Interaction.js index fdc4b83b06..03ce2752ba 100644 --- a/src/ol/interaction/Interaction.js +++ b/src/ol/interaction/Interaction.js @@ -1,13 +1,13 @@ +/** + * @module ol/interaction/Interaction + */ // FIXME factor out key precondition (shift et. al) -goog.provide('ol.interaction.Interaction'); - -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.easing'); -goog.require('ol.interaction.Property'); -goog.require('ol.math'); - +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_easing_ from '../easing.js'; +import _ol_interaction_Property_ from '../interaction/Property.js'; +import _ol_math_ from '../math.js'; /** * @classdesc @@ -26,9 +26,9 @@ goog.require('ol.math'); * @extends {ol.Object} * @api */ -ol.interaction.Interaction = function(options) { +var _ol_interaction_Interaction_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @private @@ -44,7 +44,8 @@ ol.interaction.Interaction = function(options) { this.handleEvent = options.handleEvent; }; -ol.inherits(ol.interaction.Interaction, ol.Object); + +_ol_.inherits(_ol_interaction_Interaction_, _ol_Object_); /** @@ -53,9 +54,10 @@ ol.inherits(ol.interaction.Interaction, ol.Object); * @observable * @api */ -ol.interaction.Interaction.prototype.getActive = function() { - return /** @type {boolean} */ ( - this.get(ol.interaction.Property.ACTIVE)); +_ol_interaction_Interaction_.prototype.getActive = function() { + return ( + /** @type {boolean} */ this.get(_ol_interaction_Property_.ACTIVE) + ); }; @@ -64,7 +66,7 @@ ol.interaction.Interaction.prototype.getActive = function() { * @return {ol.PluggableMap} Map. * @api */ -ol.interaction.Interaction.prototype.getMap = function() { +_ol_interaction_Interaction_.prototype.getMap = function() { return this.map_; }; @@ -75,8 +77,8 @@ ol.interaction.Interaction.prototype.getMap = function() { * @observable * @api */ -ol.interaction.Interaction.prototype.setActive = function(active) { - this.set(ol.interaction.Property.ACTIVE, active); +_ol_interaction_Interaction_.prototype.setActive = function(active) { + this.set(_ol_interaction_Property_.ACTIVE, active); }; @@ -86,7 +88,7 @@ ol.interaction.Interaction.prototype.setActive = function(active) { * the map here. * @param {ol.PluggableMap} map Map. */ -ol.interaction.Interaction.prototype.setMap = function(map) { +_ol_interaction_Interaction_.prototype.setMap = function(map) { this.map_ = map; }; @@ -96,7 +98,7 @@ ol.interaction.Interaction.prototype.setMap = function(map) { * @param {ol.Coordinate} delta Delta. * @param {number=} opt_duration Duration. */ -ol.interaction.Interaction.pan = function(view, delta, opt_duration) { +_ol_interaction_Interaction_.pan = function(view, delta, opt_duration) { var currentCenter = view.getCenter(); if (currentCenter) { var center = view.constrainCenter( @@ -104,7 +106,7 @@ ol.interaction.Interaction.pan = function(view, delta, opt_duration) { if (opt_duration) { view.animate({ duration: opt_duration, - easing: ol.easing.linear, + easing: _ol_easing_.linear, center: center }); } else { @@ -120,9 +122,9 @@ ol.interaction.Interaction.pan = function(view, delta, opt_duration) { * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.interaction.Interaction.rotate = function(view, rotation, opt_anchor, opt_duration) { +_ol_interaction_Interaction_.rotate = function(view, rotation, opt_anchor, opt_duration) { rotation = view.constrainRotation(rotation, 0); - ol.interaction.Interaction.rotateWithoutConstraints( + _ol_interaction_Interaction_.rotateWithoutConstraints( view, rotation, opt_anchor, opt_duration); }; @@ -133,7 +135,7 @@ ol.interaction.Interaction.rotate = function(view, rotation, opt_anchor, opt_dur * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) { +_ol_interaction_Interaction_.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) { if (rotation !== undefined) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); @@ -142,7 +144,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, o rotation: rotation, anchor: opt_anchor, duration: opt_duration, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); } else { view.rotate(rotation, opt_anchor); @@ -165,9 +167,9 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, o * will select the nearest resolution. If not defined 0 is * assumed. */ -ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) { +_ol_interaction_Interaction_.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) { resolution = view.constrainResolution(resolution, 0, opt_direction); - ol.interaction.Interaction.zoomWithoutConstraints( + _ol_interaction_Interaction_.zoomWithoutConstraints( view, resolution, opt_anchor, opt_duration); }; @@ -178,13 +180,13 @@ ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_dur * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) { +_ol_interaction_Interaction_.zoomByDelta = function(view, delta, opt_anchor, opt_duration) { var currentResolution = view.getResolution(); var resolution = view.constrainResolution(currentResolution, delta, 0); if (resolution !== undefined) { var resolutions = view.getResolutions(); - resolution = ol.math.clamp( + resolution = _ol_math_.clamp( resolution, view.getMinResolution() || resolutions[resolutions.length - 1], view.getMaxResolution() || resolutions[0]); @@ -206,7 +208,7 @@ ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_d ]; } - ol.interaction.Interaction.zoomWithoutConstraints( + _ol_interaction_Interaction_.zoomWithoutConstraints( view, resolution, opt_anchor, opt_duration); }; @@ -217,7 +219,7 @@ ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_d * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) { +_ol_interaction_Interaction_.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) { if (resolution) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); @@ -227,7 +229,7 @@ ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, o resolution: resolution, anchor: opt_anchor, duration: opt_duration, - easing: ol.easing.easeOut + easing: _ol_easing_.easeOut }); } else { if (opt_anchor) { @@ -238,3 +240,4 @@ ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, o } } }; +export default _ol_interaction_Interaction_; diff --git a/src/ol/interaction/KeyboardPan.js b/src/ol/interaction/KeyboardPan.js index 603c682c50..3fdb68fa4c 100644 --- a/src/ol/interaction/KeyboardPan.js +++ b/src/ol/interaction/KeyboardPan.js @@ -1,12 +1,12 @@ -goog.provide('ol.interaction.KeyboardPan'); - -goog.require('ol'); -goog.require('ol.coordinate'); -goog.require('ol.events.EventType'); -goog.require('ol.events.KeyCode'); -goog.require('ol.events.condition'); -goog.require('ol.interaction.Interaction'); - +/** + * @module ol/interaction/KeyboardPan + */ +import _ol_ from '../index.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_events_KeyCode_ from '../events/KeyCode.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; /** * @classdesc @@ -25,10 +25,10 @@ goog.require('ol.interaction.Interaction'); * @param {olx.interaction.KeyboardPanOptions=} opt_options Options. * @api */ -ol.interaction.KeyboardPan = function(opt_options) { +var _ol_interaction_KeyboardPan_ = function(opt_options) { - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.KeyboardPan.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_KeyboardPan_.handleEvent }); var options = opt_options || {}; @@ -39,8 +39,8 @@ ol.interaction.KeyboardPan = function(opt_options) { * @return {boolean} Combined condition result. */ this.defaultCondition_ = function(mapBrowserEvent) { - return ol.events.condition.noModifierKeys(mapBrowserEvent) && - ol.events.condition.targetNotEditable(mapBrowserEvent); + return _ol_events_condition_.noModifierKeys(mapBrowserEvent) && + _ol_events_condition_.targetNotEditable(mapBrowserEvent); }; /** @@ -64,7 +64,8 @@ ol.interaction.KeyboardPan = function(opt_options) { options.pixelDelta : 128; }; -ol.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_KeyboardPan_, _ol_interaction_Interaction_); /** * Handles the {@link ol.MapBrowserEvent map browser event} if it was a @@ -75,35 +76,36 @@ ol.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); * @this {ol.interaction.KeyboardPan} * @api */ -ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) { +_ol_interaction_KeyboardPan_.handleEvent = function(mapBrowserEvent) { var stopEvent = false; - if (mapBrowserEvent.type == ol.events.EventType.KEYDOWN) { + if (mapBrowserEvent.type == _ol_events_EventType_.KEYDOWN) { var keyEvent = mapBrowserEvent.originalEvent; var keyCode = keyEvent.keyCode; if (this.condition_(mapBrowserEvent) && - (keyCode == ol.events.KeyCode.DOWN || - keyCode == ol.events.KeyCode.LEFT || - keyCode == ol.events.KeyCode.RIGHT || - keyCode == ol.events.KeyCode.UP)) { + (keyCode == _ol_events_KeyCode_.DOWN || + keyCode == _ol_events_KeyCode_.LEFT || + keyCode == _ol_events_KeyCode_.RIGHT || + keyCode == _ol_events_KeyCode_.UP)) { var map = mapBrowserEvent.map; var view = map.getView(); var mapUnitsDelta = view.getResolution() * this.pixelDelta_; var deltaX = 0, deltaY = 0; - if (keyCode == ol.events.KeyCode.DOWN) { + if (keyCode == _ol_events_KeyCode_.DOWN) { deltaY = -mapUnitsDelta; - } else if (keyCode == ol.events.KeyCode.LEFT) { + } else if (keyCode == _ol_events_KeyCode_.LEFT) { deltaX = -mapUnitsDelta; - } else if (keyCode == ol.events.KeyCode.RIGHT) { + } else if (keyCode == _ol_events_KeyCode_.RIGHT) { deltaX = mapUnitsDelta; } else { deltaY = mapUnitsDelta; } var delta = [deltaX, deltaY]; - ol.coordinate.rotate(delta, view.getRotation()); - ol.interaction.Interaction.pan(view, delta, this.duration_); + _ol_coordinate_.rotate(delta, view.getRotation()); + _ol_interaction_Interaction_.pan(view, delta, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; } } return !stopEvent; }; +export default _ol_interaction_KeyboardPan_; diff --git a/src/ol/interaction/KeyboardZoom.js b/src/ol/interaction/KeyboardZoom.js index c5667a800a..e6d3f1fad0 100644 --- a/src/ol/interaction/KeyboardZoom.js +++ b/src/ol/interaction/KeyboardZoom.js @@ -1,10 +1,10 @@ -goog.provide('ol.interaction.KeyboardZoom'); - -goog.require('ol'); -goog.require('ol.events.EventType'); -goog.require('ol.events.condition'); -goog.require('ol.interaction.Interaction'); - +/** + * @module ol/interaction/KeyboardZoom + */ +import _ol_ from '../index.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; /** * @classdesc @@ -23,10 +23,10 @@ goog.require('ol.interaction.Interaction'); * @extends {ol.interaction.Interaction} * @api */ -ol.interaction.KeyboardZoom = function(opt_options) { +var _ol_interaction_KeyboardZoom_ = function(opt_options) { - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.KeyboardZoom.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_KeyboardZoom_.handleEvent }); var options = opt_options ? opt_options : {}; @@ -36,7 +36,7 @@ ol.interaction.KeyboardZoom = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? options.condition : - ol.events.condition.targetNotEditable; + _ol_events_condition_.targetNotEditable; /** * @private @@ -51,7 +51,8 @@ ol.interaction.KeyboardZoom = function(opt_options) { this.duration_ = options.duration !== undefined ? options.duration : 100; }; -ol.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_KeyboardZoom_, _ol_interaction_Interaction_); /** @@ -63,10 +64,10 @@ ol.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction); * @this {ol.interaction.KeyboardZoom} * @api */ -ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) { +_ol_interaction_KeyboardZoom_.handleEvent = function(mapBrowserEvent) { var stopEvent = false; - if (mapBrowserEvent.type == ol.events.EventType.KEYDOWN || - mapBrowserEvent.type == ol.events.EventType.KEYPRESS) { + if (mapBrowserEvent.type == _ol_events_EventType_.KEYDOWN || + mapBrowserEvent.type == _ol_events_EventType_.KEYPRESS) { var keyEvent = mapBrowserEvent.originalEvent; var charCode = keyEvent.charCode; if (this.condition_(mapBrowserEvent) && @@ -74,7 +75,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_; var view = map.getView(); - ol.interaction.Interaction.zoomByDelta( + _ol_interaction_Interaction_.zoomByDelta( view, delta, undefined, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; @@ -82,3 +83,4 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) { } return !stopEvent; }; +export default _ol_interaction_KeyboardZoom_; diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 6b070c9278..6a12f817bf 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -1,27 +1,28 @@ -goog.provide('ol.interaction.Modify'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); -goog.require('ol.Feature'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.array'); -goog.require('ol.coordinate'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.events.condition'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.Point'); -goog.require('ol.interaction.ModifyEventType'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.source.VectorEventType'); -goog.require('ol.structs.RBush'); -goog.require('ol.style.Style'); +/** + * @module ol/interaction/Modify + */ +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js'; +import _ol_array_ from '../array.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_interaction_ModifyEventType_ from '../interaction/ModifyEventType.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_source_Vector_ from '../source/Vector.js'; +import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; +import _ol_structs_RBush_ from '../structs/RBush.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -42,13 +43,13 @@ goog.require('ol.style.Style'); * @fires ol.interaction.Modify.Event * @api */ -ol.interaction.Modify = function(options) { +var _ol_interaction_Modify_ = function(options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.Modify.handleDownEvent_, - handleDragEvent: ol.interaction.Modify.handleDragEvent_, - handleEvent: ol.interaction.Modify.handleEvent, - handleUpEvent: ol.interaction.Modify.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_Modify_.handleDownEvent_, + handleDragEvent: _ol_interaction_Modify_.handleDragEvent_, + handleEvent: _ol_interaction_Modify_.handleEvent, + handleUpEvent: _ol_interaction_Modify_.handleUpEvent_ }); /** @@ -56,7 +57,7 @@ ol.interaction.Modify = function(options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.primaryAction; + options.condition : _ol_events_condition_.primaryAction; /** @@ -65,8 +66,8 @@ ol.interaction.Modify = function(options) { * @return {boolean} Combined condition result. */ this.defaultDeleteCondition_ = function(mapBrowserEvent) { - return ol.events.condition.altKeyOnly(mapBrowserEvent) && - ol.events.condition.singleClick(mapBrowserEvent); + return _ol_events_condition_.altKeyOnly(mapBrowserEvent) && + _ol_events_condition_.singleClick(mapBrowserEvent); }; /** @@ -81,7 +82,7 @@ ol.interaction.Modify = function(options) { * @private */ this.insertVertexCondition_ = options.insertVertexCondition ? - options.insertVertexCondition : ol.events.condition.always; + options.insertVertexCondition : _ol_events_condition_.always; /** * Editing vertex. @@ -122,7 +123,7 @@ ol.interaction.Modify = function(options) { * @type {ol.structs.RBush.} * @private */ - this.rBush_ = new ol.structs.RBush(); + this.rBush_ = new _ol_structs_RBush_(); /** * @type {number} @@ -156,13 +157,13 @@ ol.interaction.Modify = function(options) { * @type {ol.layer.Vector} * @private */ - this.overlay_ = new ol.layer.Vector({ - source: new ol.source.Vector({ + this.overlay_ = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ useSpatialIndex: false, wrapX: !!options.wrapX }), style: options.style ? options.style : - ol.interaction.Modify.getDefaultStyleFunction(), + _ol_interaction_Modify_.getDefaultStyleFunction(), updateWhileAnimating: true, updateWhileInteracting: true }); @@ -194,10 +195,10 @@ ol.interaction.Modify = function(options) { var features; if (options.source) { this.source_ = options.source; - features = new ol.Collection(this.source_.getFeatures()); - ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE, + features = new _ol_Collection_(this.source_.getFeatures()); + _ol_events_.listen(this.source_, _ol_source_VectorEventType_.ADDFEATURE, this.handleSourceAdd_, this); - ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE, + _ol_events_.listen(this.source_, _ol_source_VectorEventType_.REMOVEFEATURE, this.handleSourceRemove_, this); } else { features = options.features; @@ -213,9 +214,9 @@ ol.interaction.Modify = function(options) { this.features_ = features; this.features_.forEach(this.addFeature_, this); - ol.events.listen(this.features_, ol.CollectionEventType.ADD, + _ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, this.handleFeatureAdd_, this); - ol.events.listen(this.features_, ol.CollectionEventType.REMOVE, + _ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, this.handleFeatureRemove_, this); /** @@ -225,27 +226,28 @@ ol.interaction.Modify = function(options) { this.lastPointerEvent_ = null; }; -ol.inherits(ol.interaction.Modify, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_Modify_, _ol_interaction_Pointer_); /** * @define {number} The segment index assigned to a circle's center when * breaking up a cicrle into ModifySegmentDataType segments. */ -ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX = 0; +_ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX = 0; /** * @define {number} The segment index assigned to a circle's circumference when * breaking up a circle into ModifySegmentDataType segments. */ -ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX = 1; +_ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX = 1; /** * @param {ol.Feature} feature Feature. * @private */ -ol.interaction.Modify.prototype.addFeature_ = function(feature) { +_ol_interaction_Modify_.prototype.addFeature_ = function(feature) { var geometry = feature.getGeometry(); if (geometry && geometry.getType() in this.SEGMENT_WRITERS_) { this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry); @@ -254,7 +256,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) { if (map && map.isRendered() && this.getActive()) { this.handlePointerAtPixel_(this.lastPixel_, map); } - ol.events.listen(feature, ol.events.EventType.CHANGE, + _ol_events_.listen(feature, _ol_events_EventType_.CHANGE, this.handleFeatureChange_, this); }; @@ -263,11 +265,11 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) { * @param {ol.MapBrowserPointerEvent} evt Map browser event * @private */ -ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) { +_ol_interaction_Modify_.prototype.willModifyFeatures_ = function(evt) { if (!this.modified_) { this.modified_ = true; - this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.ModifyEventType.MODIFYSTART, this.features_, evt)); + this.dispatchEvent(new _ol_interaction_Modify_.Event( + _ol_interaction_ModifyEventType_.MODIFYSTART, this.features_, evt)); } }; @@ -276,7 +278,7 @@ ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) { * @param {ol.Feature} feature Feature. * @private */ -ol.interaction.Modify.prototype.removeFeature_ = function(feature) { +_ol_interaction_Modify_.prototype.removeFeature_ = function(feature) { this.removeFeatureSegmentData_(feature); // Remove the vertex feature if the collection of canditate features // is empty. @@ -284,7 +286,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) { this.overlay_.getSource().removeFeature(this.vertexFeature_); this.vertexFeature_ = null; } - ol.events.unlisten(feature, ol.events.EventType.CHANGE, + _ol_events_.unlisten(feature, _ol_events_EventType_.CHANGE, this.handleFeatureChange_, this); }; @@ -293,7 +295,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) { * @param {ol.Feature} feature Feature. * @private */ -ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) { +_ol_interaction_Modify_.prototype.removeFeatureSegmentData_ = function(feature) { var rBush = this.rBush_; var /** @type {Array.} */ nodesToRemove = []; rBush.forEach( @@ -314,21 +316,21 @@ ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) { /** * @inheritDoc */ -ol.interaction.Modify.prototype.setActive = function(active) { +_ol_interaction_Modify_.prototype.setActive = function(active) { if (this.vertexFeature_ && !active) { this.overlay_.getSource().removeFeature(this.vertexFeature_); this.vertexFeature_ = null; } - ol.interaction.Pointer.prototype.setActive.call(this, active); + _ol_interaction_Pointer_.prototype.setActive.call(this, active); }; /** * @inheritDoc */ -ol.interaction.Modify.prototype.setMap = function(map) { +_ol_interaction_Modify_.prototype.setMap = function(map) { this.overlay_.setMap(map); - ol.interaction.Pointer.prototype.setMap.call(this, map); + _ol_interaction_Pointer_.prototype.setMap.call(this, map); }; @@ -336,7 +338,7 @@ ol.interaction.Modify.prototype.setMap = function(map) { * @param {ol.source.Vector.Event} event Event. * @private */ -ol.interaction.Modify.prototype.handleSourceAdd_ = function(event) { +_ol_interaction_Modify_.prototype.handleSourceAdd_ = function(event) { if (event.feature) { this.features_.push(event.feature); } @@ -347,7 +349,7 @@ ol.interaction.Modify.prototype.handleSourceAdd_ = function(event) { * @param {ol.source.Vector.Event} event Event. * @private */ -ol.interaction.Modify.prototype.handleSourceRemove_ = function(event) { +_ol_interaction_Modify_.prototype.handleSourceRemove_ = function(event) { if (event.feature) { this.features_.remove(event.feature); } @@ -358,7 +360,7 @@ ol.interaction.Modify.prototype.handleSourceRemove_ = function(event) { * @param {ol.Collection.Event} evt Event. * @private */ -ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) { +_ol_interaction_Modify_.prototype.handleFeatureAdd_ = function(evt) { this.addFeature_(/** @type {ol.Feature} */ (evt.element)); }; @@ -367,7 +369,7 @@ ol.interaction.Modify.prototype.handleFeatureAdd_ = function(evt) { * @param {ol.events.Event} evt Event. * @private */ -ol.interaction.Modify.prototype.handleFeatureChange_ = function(evt) { +_ol_interaction_Modify_.prototype.handleFeatureChange_ = function(evt) { if (!this.changingFeature_) { var feature = /** @type {ol.Feature} */ (evt.target); this.removeFeature_(feature); @@ -380,7 +382,7 @@ ol.interaction.Modify.prototype.handleFeatureChange_ = function(evt) { * @param {ol.Collection.Event} evt Event. * @private */ -ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) { +_ol_interaction_Modify_.prototype.handleFeatureRemove_ = function(evt) { var feature = /** @type {ol.Feature} */ (evt.element); this.removeFeature_(feature); }; @@ -391,7 +393,7 @@ ol.interaction.Modify.prototype.handleFeatureRemove_ = function(evt) { * @param {ol.geom.Point} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writePointGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writePointGeometry_ = function(feature, geometry) { var coordinates = geometry.getCoordinates(); var segmentData = /** @type {ol.ModifySegmentDataType} */ ({ feature: feature, @@ -407,7 +409,7 @@ ol.interaction.Modify.prototype.writePointGeometry_ = function(feature, geometry * @param {ol.geom.MultiPoint} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeMultiPointGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeMultiPointGeometry_ = function(feature, geometry) { var points = geometry.getCoordinates(); var coordinates, i, ii, segmentData; for (i = 0, ii = points.length; i < ii; ++i) { @@ -429,7 +431,7 @@ ol.interaction.Modify.prototype.writeMultiPointGeometry_ = function(feature, geo * @param {ol.geom.LineString} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeLineStringGeometry_ = function(feature, geometry) { var coordinates = geometry.getCoordinates(); var i, ii, segment, segmentData; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { @@ -440,7 +442,7 @@ ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geo index: i, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } }; @@ -450,7 +452,7 @@ ol.interaction.Modify.prototype.writeLineStringGeometry_ = function(feature, geo * @param {ol.geom.MultiLineString} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { var lines = geometry.getCoordinates(); var coordinates, i, ii, j, jj, segment, segmentData; for (j = 0, jj = lines.length; j < jj; ++j) { @@ -464,7 +466,7 @@ ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature index: i, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } }; @@ -475,7 +477,7 @@ ol.interaction.Modify.prototype.writeMultiLineStringGeometry_ = function(feature * @param {ol.geom.Polygon} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writePolygonGeometry_ = function(feature, geometry) { var rings = geometry.getCoordinates(); var coordinates, i, ii, j, jj, segment, segmentData; for (j = 0, jj = rings.length; j < jj; ++j) { @@ -489,7 +491,7 @@ ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geomet index: i, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } }; @@ -500,7 +502,7 @@ ol.interaction.Modify.prototype.writePolygonGeometry_ = function(feature, geomet * @param {ol.geom.MultiPolygon} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { var polygons = geometry.getCoordinates(); var coordinates, i, ii, j, jj, k, kk, rings, segment, segmentData; for (k = 0, kk = polygons.length; k < kk; ++k) { @@ -516,7 +518,7 @@ ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, g index: i, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } } @@ -534,23 +536,23 @@ ol.interaction.Modify.prototype.writeMultiPolygonGeometry_ = function(feature, g * @param {ol.geom.Circle} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeCircleGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeCircleGeometry_ = function(feature, geometry) { var coordinates = geometry.getCenter(); var centerSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ feature: feature, geometry: geometry, - index: ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX, + index: _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX, segment: [coordinates, coordinates] }); var circumferenceSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ feature: feature, geometry: geometry, - index: ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX, + index: _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX, segment: [coordinates, coordinates] }); var featureSegments = [centerSegmentData, circumferenceSegmentData]; centerSegmentData.featureSegments = circumferenceSegmentData.featureSegments = featureSegments; - this.rBush_.insert(ol.extent.createOrUpdateFromCoordinate(coordinates), centerSegmentData); + this.rBush_.insert(_ol_extent_.createOrUpdateFromCoordinate(coordinates), centerSegmentData); this.rBush_.insert(geometry.getExtent(), circumferenceSegmentData); }; @@ -560,7 +562,7 @@ ol.interaction.Modify.prototype.writeCircleGeometry_ = function(feature, geometr * @param {ol.geom.GeometryCollection} geometry Geometry. * @private */ -ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { +_ol_interaction_Modify_.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { var i, geometries = geometry.getGeometriesArray(); for (i = 0; i < geometries.length; ++i) { this.SEGMENT_WRITERS_[geometries[i].getType()].call( @@ -574,10 +576,10 @@ ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ = function(feat * @return {ol.Feature} Vertex feature. * @private */ -ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ = function(coordinates) { +_ol_interaction_Modify_.prototype.createOrUpdateVertexFeature_ = function(coordinates) { var vertexFeature = this.vertexFeature_; if (!vertexFeature) { - vertexFeature = new ol.Feature(new ol.geom.Point(coordinates)); + vertexFeature = new _ol_Feature_(new _ol_geom_Point_(coordinates)); this.vertexFeature_ = vertexFeature; this.overlay_.getSource().addFeature(vertexFeature); } else { @@ -594,7 +596,7 @@ ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ = function(coordina * @return {number} The difference in indexes. * @private */ -ol.interaction.Modify.compareIndexes_ = function(a, b) { +_ol_interaction_Modify_.compareIndexes_ = function(a, b) { return a.index - b.index; }; @@ -605,7 +607,7 @@ ol.interaction.Modify.compareIndexes_ = function(a, b) { * @this {ol.interaction.Modify} * @private */ -ol.interaction.Modify.handleDownEvent_ = function(evt) { +_ol_interaction_Modify_.handleDownEvent_ = function(evt) { if (!this.condition_(evt)) { return false; } @@ -618,14 +620,14 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) { var insertVertices = []; var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry()); var vertex = geometry.getCoordinates(); - var vertexExtent = ol.extent.boundingExtent([vertex]); + var vertexExtent = _ol_extent_.boundingExtent([vertex]); var segmentDataMatches = this.rBush_.getInExtent(vertexExtent); var componentSegments = {}; - segmentDataMatches.sort(ol.interaction.Modify.compareIndexes_); + segmentDataMatches.sort(_ol_interaction_Modify_.compareIndexes_); for (var i = 0, ii = segmentDataMatches.length; i < ii; ++i) { var segmentDataMatch = segmentDataMatches[i]; var segment = segmentDataMatch.segment; - var uid = ol.getUid(segmentDataMatch.feature); + var uid = _ol_.getUid(segmentDataMatch.feature); var depth = segmentDataMatch.depth; if (depth) { uid += '-' + depth.join('-'); // separate feature components @@ -633,26 +635,26 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) { if (!componentSegments[uid]) { componentSegments[uid] = new Array(2); } - if (segmentDataMatch.geometry.getType() === ol.geom.GeometryType.CIRCLE && - segmentDataMatch.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { + if (segmentDataMatch.geometry.getType() === _ol_geom_GeometryType_.CIRCLE && + segmentDataMatch.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { - var closestVertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, segmentDataMatch); - if (ol.coordinate.equals(closestVertex, vertex) && !componentSegments[uid][0]) { + var closestVertex = _ol_interaction_Modify_.closestOnSegmentData_(pixelCoordinate, segmentDataMatch); + if (_ol_coordinate_.equals(closestVertex, vertex) && !componentSegments[uid][0]) { this.dragSegments_.push([segmentDataMatch, 0]); componentSegments[uid][0] = segmentDataMatch; } - } else if (ol.coordinate.equals(segment[0], vertex) && + } else if (_ol_coordinate_.equals(segment[0], vertex) && !componentSegments[uid][0]) { this.dragSegments_.push([segmentDataMatch, 0]); componentSegments[uid][0] = segmentDataMatch; - } else if (ol.coordinate.equals(segment[1], vertex) && + } else if (_ol_coordinate_.equals(segment[1], vertex) && !componentSegments[uid][1]) { // prevent dragging closed linestrings by the connecting node if ((segmentDataMatch.geometry.getType() === - ol.geom.GeometryType.LINE_STRING || + _ol_geom_GeometryType_.LINE_STRING || segmentDataMatch.geometry.getType() === - ol.geom.GeometryType.MULTI_LINE_STRING) && + _ol_geom_GeometryType_.MULTI_LINE_STRING) && componentSegments[uid][0] && componentSegments[uid][0].index === 0) { continue; @@ -660,7 +662,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) { this.dragSegments_.push([segmentDataMatch, 1]); componentSegments[uid][1] = segmentDataMatch; - } else if (this.insertVertexCondition_(evt) && ol.getUid(segment) in this.vertexSegments_ && + } else if (this.insertVertexCondition_(evt) && _ol_.getUid(segment) in this.vertexSegments_ && (!componentSegments[uid][0] && !componentSegments[uid][1])) { insertVertices.push([segmentDataMatch, vertex]); } @@ -681,7 +683,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) { * @this {ol.interaction.Modify} * @private */ -ol.interaction.Modify.handleDragEvent_ = function(evt) { +_ol_interaction_Modify_.handleDragEvent_ = function(evt) { this.ignoreNextSingleClick_ = false; this.willModifyFeatures_(evt); @@ -700,44 +702,44 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) { } switch (geometry.getType()) { - case ol.geom.GeometryType.POINT: + case _ol_geom_GeometryType_.POINT: coordinates = vertex; segment[0] = segment[1] = vertex; break; - case ol.geom.GeometryType.MULTI_POINT: + case _ol_geom_GeometryType_.MULTI_POINT: coordinates = geometry.getCoordinates(); coordinates[segmentData.index] = vertex; segment[0] = segment[1] = vertex; break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: coordinates = geometry.getCoordinates(); coordinates[segmentData.index + index] = vertex; segment[index] = vertex; break; - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: coordinates = geometry.getCoordinates(); coordinates[depth[0]][segmentData.index + index] = vertex; segment[index] = vertex; break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: coordinates = geometry.getCoordinates(); coordinates[depth[0]][segmentData.index + index] = vertex; segment[index] = vertex; break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: coordinates = geometry.getCoordinates(); coordinates[depth[1]][depth[0]][segmentData.index + index] = vertex; segment[index] = vertex; break; - case ol.geom.GeometryType.CIRCLE: + case _ol_geom_GeometryType_.CIRCLE: segment[0] = segment[1] = vertex; - if (segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX) { + if (segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CENTER_INDEX) { this.changingFeature_ = true; geometry.setCenter(vertex); this.changingFeature_ = false; } else { // We're dragging the circle's circumference: this.changingFeature_ = true; - geometry.setRadius(ol.coordinate.distance(geometry.getCenter(), vertex)); + geometry.setRadius(_ol_coordinate_.distance(geometry.getCenter(), vertex)); this.changingFeature_ = false; } break; @@ -759,29 +761,29 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) { * @this {ol.interaction.Modify} * @private */ -ol.interaction.Modify.handleUpEvent_ = function(evt) { +_ol_interaction_Modify_.handleUpEvent_ = function(evt) { var segmentData; var geometry; for (var i = this.dragSegments_.length - 1; i >= 0; --i) { segmentData = this.dragSegments_[i][0]; geometry = segmentData.geometry; - if (geometry.getType() === ol.geom.GeometryType.CIRCLE) { + if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE) { // Update a circle object in the R* bush: var coordinates = geometry.getCenter(); var centerSegmentData = segmentData.featureSegments[0]; var circumferenceSegmentData = segmentData.featureSegments[1]; centerSegmentData.segment[0] = centerSegmentData.segment[1] = coordinates; circumferenceSegmentData.segment[0] = circumferenceSegmentData.segment[1] = coordinates; - this.rBush_.update(ol.extent.createOrUpdateFromCoordinate(coordinates), centerSegmentData); + this.rBush_.update(_ol_extent_.createOrUpdateFromCoordinate(coordinates), centerSegmentData); this.rBush_.update(geometry.getExtent(), circumferenceSegmentData); } else { - this.rBush_.update(ol.extent.boundingExtent(segmentData.segment), + this.rBush_.update(_ol_extent_.boundingExtent(segmentData.segment), segmentData); } } if (this.modified_) { - this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt)); + this.dispatchEvent(new _ol_interaction_Modify_.Event( + _ol_interaction_ModifyEventType_.MODIFYEND, this.features_, evt)); this.modified_ = false; } return false; @@ -796,20 +798,20 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) { * @this {ol.interaction.Modify} * @api */ -ol.interaction.Modify.handleEvent = function(mapBrowserEvent) { - if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) { +_ol_interaction_Modify_.handleEvent = function(mapBrowserEvent) { + if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) { return true; } this.lastPointerEvent_ = mapBrowserEvent; var handled; if (!mapBrowserEvent.map.getView().getInteracting() && - mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE && + mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE && !this.handlingDownUpSequence) { this.handlePointerMove_(mapBrowserEvent); } if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) { - if (mapBrowserEvent.type != ol.MapBrowserEventType.SINGLECLICK || + if (mapBrowserEvent.type != _ol_MapBrowserEventType_.SINGLECLICK || !this.ignoreNextSingleClick_) { handled = this.removePoint(); } else { @@ -817,11 +819,11 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) { } } - if (mapBrowserEvent.type == ol.MapBrowserEventType.SINGLECLICK) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.SINGLECLICK) { this.ignoreNextSingleClick_ = false; } - return ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent) && + return _ol_interaction_Pointer_.handleEvent.call(this, mapBrowserEvent) && !handled; }; @@ -830,7 +832,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) { * @param {ol.MapBrowserEvent} evt Event. * @private */ -ol.interaction.Modify.prototype.handlePointerMove_ = function(evt) { +_ol_interaction_Modify_.prototype.handlePointerMove_ = function(evt) { this.lastPixel_ = evt.pixel; this.handlePointerAtPixel_(evt.pixel, evt.map); }; @@ -841,15 +843,15 @@ ol.interaction.Modify.prototype.handlePointerMove_ = function(evt) { * @param {ol.PluggableMap} map Map. * @private */ -ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { +_ol_interaction_Modify_.prototype.handlePointerAtPixel_ = function(pixel, map) { var pixelCoordinate = map.getCoordinateFromPixel(pixel); var sortByDistance = function(a, b) { - return ol.interaction.Modify.pointDistanceToSegmentDataSquared_(pixelCoordinate, a) - - ol.interaction.Modify.pointDistanceToSegmentDataSquared_(pixelCoordinate, b); + return _ol_interaction_Modify_.pointDistanceToSegmentDataSquared_(pixelCoordinate, a) - + _ol_interaction_Modify_.pointDistanceToSegmentDataSquared_(pixelCoordinate, b); }; - var box = ol.extent.buffer( - ol.extent.createOrUpdateFromCoordinate(pixelCoordinate), + var box = _ol_extent_.buffer( + _ol_extent_.createOrUpdateFromCoordinate(pixelCoordinate), map.getView().getResolution() * this.pixelTolerance_); var rBush = this.rBush_; @@ -858,22 +860,22 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { nodes.sort(sortByDistance); var node = nodes[0]; var closestSegment = node.segment; - var vertex = ol.interaction.Modify.closestOnSegmentData_(pixelCoordinate, node); + var vertex = _ol_interaction_Modify_.closestOnSegmentData_(pixelCoordinate, node); var vertexPixel = map.getPixelFromCoordinate(vertex); - var dist = ol.coordinate.distance(pixel, vertexPixel); + var dist = _ol_coordinate_.distance(pixel, vertexPixel); if (dist <= this.pixelTolerance_) { var vertexSegments = {}; - if (node.geometry.getType() === ol.geom.GeometryType.CIRCLE && - node.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { + if (node.geometry.getType() === _ol_geom_GeometryType_.CIRCLE && + node.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { this.snappedToVertex_ = true; this.createOrUpdateVertexFeature_(vertex); } else { var pixel1 = map.getPixelFromCoordinate(closestSegment[0]); var pixel2 = map.getPixelFromCoordinate(closestSegment[1]); - var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1); - var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2); + var squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1); + var squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2); dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); this.snappedToVertex_ = dist <= this.pixelTolerance_; if (this.snappedToVertex_) { @@ -884,18 +886,18 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { var segment; for (var i = 1, ii = nodes.length; i < ii; ++i) { segment = nodes[i].segment; - if ((ol.coordinate.equals(closestSegment[0], segment[0]) && - ol.coordinate.equals(closestSegment[1], segment[1]) || - (ol.coordinate.equals(closestSegment[0], segment[1]) && - ol.coordinate.equals(closestSegment[1], segment[0])))) { - vertexSegments[ol.getUid(segment)] = true; + if ((_ol_coordinate_.equals(closestSegment[0], segment[0]) && + _ol_coordinate_.equals(closestSegment[1], segment[1]) || + (_ol_coordinate_.equals(closestSegment[0], segment[1]) && + _ol_coordinate_.equals(closestSegment[1], segment[0])))) { + vertexSegments[_ol_.getUid(segment)] = true; } else { break; } } } - vertexSegments[ol.getUid(closestSegment)] = true; + vertexSegments[_ol_.getUid(closestSegment)] = true; this.vertexSegments_ = vertexSegments; return; } @@ -916,21 +918,21 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { * segment we are calculating the distance to. * @return {number} The square of the distance between a point and a line segment. */ -ol.interaction.Modify.pointDistanceToSegmentDataSquared_ = function(pointCoordinates, segmentData) { +_ol_interaction_Modify_.pointDistanceToSegmentDataSquared_ = function(pointCoordinates, segmentData) { var geometry = segmentData.geometry; - if (geometry.getType() === ol.geom.GeometryType.CIRCLE) { + if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE) { var circleGeometry = /** @type {ol.geom.Circle} */ (geometry); - if (segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { + if (segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { var distanceToCenterSquared = - ol.coordinate.squaredDistance(circleGeometry.getCenter(), pointCoordinates); + _ol_coordinate_.squaredDistance(circleGeometry.getCenter(), pointCoordinates); var distanceToCircumference = Math.sqrt(distanceToCenterSquared) - circleGeometry.getRadius(); return distanceToCircumference * distanceToCircumference; } } - return ol.coordinate.squaredDistanceToSegment(pointCoordinates, segmentData.segment); + return _ol_coordinate_.squaredDistanceToSegment(pointCoordinates, segmentData.segment); }; /** @@ -942,14 +944,14 @@ ol.interaction.Modify.pointDistanceToSegmentDataSquared_ = function(pointCoordin * segment which should contain the closest point. * @return {ol.Coordinate} The point closest to the specified line segment. */ -ol.interaction.Modify.closestOnSegmentData_ = function(pointCoordinates, segmentData) { +_ol_interaction_Modify_.closestOnSegmentData_ = function(pointCoordinates, segmentData) { var geometry = segmentData.geometry; - if (geometry.getType() === ol.geom.GeometryType.CIRCLE && - segmentData.index === ol.interaction.Modify.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { + if (geometry.getType() === _ol_geom_GeometryType_.CIRCLE && + segmentData.index === _ol_interaction_Modify_.MODIFY_SEGMENT_CIRCLE_CIRCUMFERENCE_INDEX) { return geometry.getClosestPoint(pointCoordinates); } - return ol.coordinate.closestOnSegment(pointCoordinates, segmentData.segment); + return _ol_coordinate_.closestOnSegment(pointCoordinates, segmentData.segment); }; @@ -958,7 +960,7 @@ ol.interaction.Modify.closestOnSegmentData_ = function(pointCoordinates, segment * @param {ol.Coordinate} vertex Vertex. * @private */ -ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { +_ol_interaction_Modify_.prototype.insertVertex_ = function(segmentData, vertex) { var segment = segmentData.segment; var feature = segmentData.feature; var geometry = segmentData.geometry; @@ -971,19 +973,19 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { } switch (geometry.getType()) { - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: coordinates = geometry.getCoordinates(); coordinates[depth[0]].splice(index + 1, 0, vertex); break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: coordinates = geometry.getCoordinates(); coordinates[depth[0]].splice(index + 1, 0, vertex); break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: coordinates = geometry.getCoordinates(); coordinates[depth[1]][depth[0]].splice(index + 1, 0, vertex); break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: coordinates = geometry.getCoordinates(); coordinates.splice(index + 1, 0, vertex); break; @@ -1002,7 +1004,7 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { depth: depth, index: index }); - rTree.insert(ol.extent.boundingExtent(newSegmentData.segment), + rTree.insert(_ol_extent_.boundingExtent(newSegmentData.segment), newSegmentData); this.dragSegments_.push([newSegmentData, 1]); @@ -1013,7 +1015,7 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { depth: depth, index: index + 1 }); - rTree.insert(ol.extent.boundingExtent(newSegmentData2.segment), + rTree.insert(_ol_extent_.boundingExtent(newSegmentData2.segment), newSegmentData2); this.dragSegments_.push([newSegmentData2, 0]); this.ignoreNextSingleClick_ = true; @@ -1024,13 +1026,13 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) { * @return {boolean} True when a vertex was removed. * @api */ -ol.interaction.Modify.prototype.removePoint = function() { - if (this.lastPointerEvent_ && this.lastPointerEvent_.type != ol.MapBrowserEventType.POINTERDRAG) { +_ol_interaction_Modify_.prototype.removePoint = function() { + if (this.lastPointerEvent_ && this.lastPointerEvent_.type != _ol_MapBrowserEventType_.POINTERDRAG) { var evt = this.lastPointerEvent_; this.willModifyFeatures_(evt); this.removeVertex_(); - this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt)); + this.dispatchEvent(new _ol_interaction_Modify_.Event( + _ol_interaction_ModifyEventType_.MODIFYEND, this.features_, evt)); this.modified_ = false; return true; } @@ -1042,7 +1044,7 @@ ol.interaction.Modify.prototype.removePoint = function() { * @return {boolean} True when a vertex was removed. * @private */ -ol.interaction.Modify.prototype.removeVertex_ = function() { +_ol_interaction_Modify_.prototype.removeVertex_ = function() { var dragSegments = this.dragSegments_; var segmentsByFeature = {}; var deleted = false; @@ -1051,7 +1053,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { for (i = dragSegments.length - 1; i >= 0; --i) { dragSegment = dragSegments[i]; segmentData = dragSegment[0]; - uid = ol.getUid(segmentData.feature); + uid = _ol_.getUid(segmentData.feature); if (segmentData.depth) { // separate feature components uid += '-' + segmentData.depth.join('-'); @@ -1086,22 +1088,22 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { component = coordinates; deleted = false; switch (geometry.getType()) { - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: if (coordinates[segmentData.depth[0]].length > 2) { coordinates[segmentData.depth[0]].splice(index, 1); deleted = true; } break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: if (coordinates.length > 2) { coordinates.splice(index, 1); deleted = true; } break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: component = component[segmentData.depth[1]]; /* falls through */ - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: component = component[segmentData.depth[0]]; if (component.length > 4) { if (index == component.length - 1) { @@ -1140,7 +1142,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { index: newIndex, segment: segments }); - this.rBush_.insert(ol.extent.boundingExtent(newSegmentData.segment), + this.rBush_.insert(_ol_extent_.boundingExtent(newSegmentData.segment), newSegmentData); } this.updateSegmentIndices_(geometry, index, segmentData.depth, -1); @@ -1161,7 +1163,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() { * @param {Array} coordinates Coordinates. * @private */ -ol.interaction.Modify.prototype.setGeometryCoordinates_ = function(geometry, coordinates) { +_ol_interaction_Modify_.prototype.setGeometryCoordinates_ = function(geometry, coordinates) { this.changingFeature_ = true; geometry.setCoordinates(coordinates); this.changingFeature_ = false; @@ -1175,12 +1177,12 @@ ol.interaction.Modify.prototype.setGeometryCoordinates_ = function(geometry, coo * @param {number} delta Delta (1 or -1). * @private */ -ol.interaction.Modify.prototype.updateSegmentIndices_ = function( +_ol_interaction_Modify_.prototype.updateSegmentIndices_ = function( geometry, index, depth, delta) { this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) { if (segmentDataMatch.geometry === geometry && (depth === undefined || segmentDataMatch.depth === undefined || - ol.array.equals(segmentDataMatch.depth, depth)) && + _ol_array_.equals(segmentDataMatch.depth, depth)) && segmentDataMatch.index > index) { segmentDataMatch.index += delta; } @@ -1191,10 +1193,10 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function( /** * @return {ol.StyleFunction} Styles. */ -ol.interaction.Modify.getDefaultStyleFunction = function() { - var style = ol.style.Style.createDefaultEditing(); +_ol_interaction_Modify_.getDefaultStyleFunction = function() { + var style = _ol_style_Style_.createDefaultEditing(); return function(feature, resolution) { - return style[ol.geom.GeometryType.POINT]; + return style[_ol_geom_GeometryType_.POINT]; }; }; @@ -1212,9 +1214,9 @@ ol.interaction.Modify.getDefaultStyleFunction = function() { * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated * {@link ol.MapBrowserPointerEvent}. */ -ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) { +_ol_interaction_Modify_.Event = function(type, features, mapBrowserPointerEvent) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The features being modified. @@ -1230,4 +1232,5 @@ ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) { */ this.mapBrowserEvent = mapBrowserPointerEvent; }; -ol.inherits(ol.interaction.Modify.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_Modify_.Event, _ol_events_Event_); +export default _ol_interaction_Modify_; diff --git a/src/ol/interaction/ModifyEventType.js b/src/ol/interaction/ModifyEventType.js index 6a5a386c1b..ce7e798a98 100644 --- a/src/ol/interaction/ModifyEventType.js +++ b/src/ol/interaction/ModifyEventType.js @@ -1,10 +1,10 @@ -goog.provide('ol.interaction.ModifyEventType'); - - +/** + * @module ol/interaction/ModifyEventType + */ /** * @enum {string} */ -ol.interaction.ModifyEventType = { +var _ol_interaction_ModifyEventType_ = { /** * Triggered upon feature modification start * @event ol.interaction.Modify.Event#modifystart @@ -18,3 +18,5 @@ ol.interaction.ModifyEventType = { */ MODIFYEND: 'modifyend' }; + +export default _ol_interaction_ModifyEventType_; diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 213b7a0ae8..3a229f1f3d 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -1,13 +1,13 @@ -goog.provide('ol.interaction.MouseWheelZoom'); - -goog.require('ol'); -goog.require('ol.ViewHint'); -goog.require('ol.easing'); -goog.require('ol.events.EventType'); -goog.require('ol.has'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.math'); - +/** + * @module ol/interaction/MouseWheelZoom + */ +import _ol_ from '../index.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_easing_ from '../easing.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_has_ from '../has.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_math_ from '../math.js'; /** * @classdesc @@ -18,10 +18,10 @@ goog.require('ol.math'); * @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options. * @api */ -ol.interaction.MouseWheelZoom = function(opt_options) { +var _ol_interaction_MouseWheelZoom_ = function(opt_options) { - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.MouseWheelZoom.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_MouseWheelZoom_.handleEvent }); var options = opt_options || {}; @@ -107,7 +107,8 @@ ol.interaction.MouseWheelZoom = function(opt_options) { this.trackpadZoomBuffer_ = 1.5; }; -ol.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_MouseWheelZoom_, _ol_interaction_Interaction_); /** @@ -118,9 +119,9 @@ ol.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction); * @this {ol.interaction.MouseWheelZoom} * @api */ -ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { +_ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) { var type = mapBrowserEvent.type; - if (type !== ol.events.EventType.WHEEL && type !== ol.events.EventType.MOUSEWHEEL) { + if (type !== _ol_events_EventType_.WHEEL && type !== _ol_events_EventType_.MOUSEWHEEL) { return true; } @@ -136,18 +137,18 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { // Delta normalisation inspired by // https://github.com/mapbox/mapbox-gl-js/blob/001c7b9/js/ui/handler/scroll_zoom.js var delta; - if (mapBrowserEvent.type == ol.events.EventType.WHEEL) { + if (mapBrowserEvent.type == _ol_events_EventType_.WHEEL) { delta = wheelEvent.deltaY; - if (ol.has.FIREFOX && + if (_ol_has_.FIREFOX && wheelEvent.deltaMode === WheelEvent.DOM_DELTA_PIXEL) { - delta /= ol.has.DEVICE_PIXEL_RATIO; + delta /= _ol_has_.DEVICE_PIXEL_RATIO; } if (wheelEvent.deltaMode === WheelEvent.DOM_DELTA_LINE) { delta *= 40; } - } else if (mapBrowserEvent.type == ol.events.EventType.MOUSEWHEEL) { + } else if (mapBrowserEvent.type == _ol_events_EventType_.MOUSEWHEEL) { delta = -wheelEvent.wheelDeltaY; - if (ol.has.SAFARI) { + if (_ol_has_.SAFARI) { delta /= 3; } } @@ -164,16 +165,16 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) { this.mode_ = Math.abs(delta) < 4 ? - ol.interaction.MouseWheelZoom.Mode_.TRACKPAD : - ol.interaction.MouseWheelZoom.Mode_.WHEEL; + _ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD : + _ol_interaction_MouseWheelZoom_.Mode_.WHEEL; } - if (this.mode_ === ol.interaction.MouseWheelZoom.Mode_.TRACKPAD) { + if (this.mode_ === _ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD) { var view = map.getView(); if (this.trackpadTimeoutId_) { clearTimeout(this.trackpadTimeoutId_); } else { - view.setHint(ol.ViewHint.INTERACTING, 1); + view.setHint(_ol_ViewHint_.INTERACTING, 1); } this.trackpadTimeoutId_ = setTimeout(this.decrementInteractingHint_.bind(this), this.trackpadEventGap_); var resolution = view.getResolution() * Math.pow(2, delta / this.trackpadDeltaPerZoom_); @@ -196,7 +197,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { if (rebound === 0 && this.constrainResolution_) { view.animate({ resolution: view.constrainResolution(resolution, delta > 0 ? -1 : 1), - easing: ol.easing.easeOut, + easing: _ol_easing_.easeOut, anchor: this.lastAnchor_, duration: this.duration_ }); @@ -205,14 +206,14 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { if (rebound > 0) { view.animate({ resolution: minResolution, - easing: ol.easing.easeOut, + easing: _ol_easing_.easeOut, anchor: this.lastAnchor_, duration: 500 }); } else if (rebound < 0) { view.animate({ resolution: maxResolution, - easing: ol.easing.easeOut, + easing: _ol_easing_.easeOut, anchor: this.lastAnchor_, duration: 500 }); @@ -235,10 +236,10 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) { /** * @private */ -ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() { +_ol_interaction_MouseWheelZoom_.prototype.decrementInteractingHint_ = function() { this.trackpadTimeoutId_ = undefined; var view = this.getMap().getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); }; @@ -246,14 +247,14 @@ ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() { * @private * @param {ol.PluggableMap} map Map. */ -ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) { +_ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) { var view = map.getView(); if (view.getAnimating()) { view.cancelAnimations(); } - var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA; - var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta); - ol.interaction.Interaction.zoomByDelta(view, -delta, this.lastAnchor_, + var maxDelta = _ol_.MOUSEWHEELZOOM_MAXDELTA; + var delta = _ol_math_.clamp(this.delta_, -maxDelta, maxDelta); + _ol_interaction_Interaction_.zoomByDelta(view, -delta, this.lastAnchor_, this.duration_); this.mode_ = undefined; this.delta_ = 0; @@ -269,7 +270,7 @@ ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) { * to zoom to the center of the map * @api */ -ol.interaction.MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) { +_ol_interaction_MouseWheelZoom_.prototype.setMouseAnchor = function(useAnchor) { this.useAnchor_ = useAnchor; if (!useAnchor) { this.lastAnchor_ = null; @@ -281,7 +282,8 @@ ol.interaction.MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) { * @enum {string} * @private */ -ol.interaction.MouseWheelZoom.Mode_ = { +_ol_interaction_MouseWheelZoom_.Mode_ = { TRACKPAD: 'trackpad', WHEEL: 'wheel' }; +export default _ol_interaction_MouseWheelZoom_; diff --git a/src/ol/interaction/PinchRotate.js b/src/ol/interaction/PinchRotate.js index 4f41baf5e8..1cb0ca088c 100644 --- a/src/ol/interaction/PinchRotate.js +++ b/src/ol/interaction/PinchRotate.js @@ -1,12 +1,12 @@ -goog.provide('ol.interaction.PinchRotate'); - -goog.require('ol'); -goog.require('ol.ViewHint'); -goog.require('ol.functions'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.RotationConstraint'); - +/** + * @module ol/interaction/PinchRotate + */ +import _ol_ from '../index.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_functions_ from '../functions.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_RotationConstraint_ from '../RotationConstraint.js'; /** * @classdesc @@ -18,12 +18,12 @@ goog.require('ol.RotationConstraint'); * @param {olx.interaction.PinchRotateOptions=} opt_options Options. * @api */ -ol.interaction.PinchRotate = function(opt_options) { +var _ol_interaction_PinchRotate_ = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.PinchRotate.handleDownEvent_, - handleDragEvent: ol.interaction.PinchRotate.handleDragEvent_, - handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_PinchRotate_.handleDownEvent_, + handleDragEvent: _ol_interaction_PinchRotate_.handleDragEvent_, + handleUpEvent: _ol_interaction_PinchRotate_.handleUpEvent_ }); var options = opt_options || {}; @@ -65,7 +65,8 @@ ol.interaction.PinchRotate = function(opt_options) { this.duration_ = options.duration !== undefined ? options.duration : 250; }; -ol.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_PinchRotate_, _ol_interaction_Pointer_); /** @@ -73,7 +74,7 @@ ol.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); * @this {ol.interaction.PinchRotate} * @private */ -ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchRotate_.handleDragEvent_ = function(mapBrowserEvent) { var rotationDelta = 0.0; var touch0 = this.targetPointers[0]; @@ -97,7 +98,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var view = map.getView(); - if (view.getConstraints().rotation === ol.RotationConstraint.disable) { + if (view.getConstraints().rotation === _ol_RotationConstraint_.disable) { return; } @@ -105,7 +106,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { // FIXME: should be the intersection point between the lines: // touch0,touch1 and previousTouch0,previousTouch1 var viewportPosition = map.getViewport().getBoundingClientRect(); - var centroid = ol.interaction.Pointer.centroid(this.targetPointers); + var centroid = _ol_interaction_Pointer_.centroid(this.targetPointers); centroid[0] -= viewportPosition.left; centroid[1] -= viewportPosition.top; this.anchor_ = map.getCoordinateFromPixel(centroid); @@ -114,7 +115,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { if (this.rotating_) { var rotation = view.getRotation(); map.render(); - ol.interaction.Interaction.rotateWithoutConstraints(view, + _ol_interaction_Interaction_.rotateWithoutConstraints(view, rotation + rotationDelta, this.anchor_); } }; @@ -126,14 +127,14 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.PinchRotate} * @private */ -ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchRotate_.handleUpEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length < 2) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); if (this.rotating_) { var rotation = view.getRotation(); - ol.interaction.Interaction.rotate( + _ol_interaction_Interaction_.rotate( view, rotation, this.anchor_, this.duration_); } return false; @@ -149,7 +150,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.PinchRotate} * @private */ -ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchRotate_.handleDownEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length >= 2) { var map = mapBrowserEvent.map; this.anchor_ = null; @@ -157,7 +158,7 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) { this.rotating_ = false; this.rotationDelta_ = 0.0; if (!this.handlingDownUpSequence) { - map.getView().setHint(ol.ViewHint.INTERACTING, 1); + map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); } return true; } else { @@ -169,4 +170,5 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) { /** * @inheritDoc */ -ol.interaction.PinchRotate.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_PinchRotate_.prototype.shouldStopEvent = _ol_functions_.FALSE; +export default _ol_interaction_PinchRotate_; diff --git a/src/ol/interaction/PinchZoom.js b/src/ol/interaction/PinchZoom.js index c24c1a8d4d..47c051a95d 100644 --- a/src/ol/interaction/PinchZoom.js +++ b/src/ol/interaction/PinchZoom.js @@ -1,11 +1,11 @@ -goog.provide('ol.interaction.PinchZoom'); - -goog.require('ol'); -goog.require('ol.ViewHint'); -goog.require('ol.functions'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.Pointer'); - +/** + * @module ol/interaction/PinchZoom + */ +import _ol_ from '../index.js'; +import _ol_ViewHint_ from '../ViewHint.js'; +import _ol_functions_ from '../functions.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; /** * @classdesc @@ -17,12 +17,12 @@ goog.require('ol.interaction.Pointer'); * @param {olx.interaction.PinchZoomOptions=} opt_options Options. * @api */ -ol.interaction.PinchZoom = function(opt_options) { +var _ol_interaction_PinchZoom_ = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.PinchZoom.handleDownEvent_, - handleDragEvent: ol.interaction.PinchZoom.handleDragEvent_, - handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_PinchZoom_.handleDownEvent_, + handleDragEvent: _ol_interaction_PinchZoom_.handleDragEvent_, + handleUpEvent: _ol_interaction_PinchZoom_.handleUpEvent_ }); var options = opt_options ? opt_options : {}; @@ -58,7 +58,8 @@ ol.interaction.PinchZoom = function(opt_options) { this.lastScaleDelta_ = 1; }; -ol.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_PinchZoom_, _ol_interaction_Pointer_); /** @@ -66,7 +67,7 @@ ol.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer); * @this {ol.interaction.PinchZoom} * @private */ -ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchZoom_.handleDragEvent_ = function(mapBrowserEvent) { var scaleDelta = 1.0; var touch0 = this.targetPointers[0]; @@ -103,14 +104,14 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) { // scale anchor point. var viewportPosition = map.getViewport().getBoundingClientRect(); - var centroid = ol.interaction.Pointer.centroid(this.targetPointers); + var centroid = _ol_interaction_Pointer_.centroid(this.targetPointers); centroid[0] -= viewportPosition.left; centroid[1] -= viewportPosition.top; this.anchor_ = map.getCoordinateFromPixel(centroid); // scale, bypass the resolution constraint map.render(); - ol.interaction.Interaction.zoomWithoutConstraints(view, newResolution, this.anchor_); + _ol_interaction_Interaction_.zoomWithoutConstraints(view, newResolution, this.anchor_); }; @@ -120,11 +121,11 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.PinchZoom} * @private */ -ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchZoom_.handleUpEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length < 2) { var map = mapBrowserEvent.map; var view = map.getView(); - view.setHint(ol.ViewHint.INTERACTING, -1); + view.setHint(_ol_ViewHint_.INTERACTING, -1); var resolution = view.getResolution(); if (this.constrainResolution_ || resolution < view.getMinResolution() || @@ -133,7 +134,7 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) { // direction not to zoom out/in if user was pinching in/out. // Direction is > 0 if pinching out, and < 0 if pinching in. var direction = this.lastScaleDelta_ - 1; - ol.interaction.Interaction.zoom(view, resolution, + _ol_interaction_Interaction_.zoom(view, resolution, this.anchor_, this.duration_, direction); } return false; @@ -149,14 +150,14 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) { * @this {ol.interaction.PinchZoom} * @private */ -ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) { +_ol_interaction_PinchZoom_.handleDownEvent_ = function(mapBrowserEvent) { if (this.targetPointers.length >= 2) { var map = mapBrowserEvent.map; this.anchor_ = null; this.lastDistance_ = undefined; this.lastScaleDelta_ = 1; if (!this.handlingDownUpSequence) { - map.getView().setHint(ol.ViewHint.INTERACTING, 1); + map.getView().setHint(_ol_ViewHint_.INTERACTING, 1); } return true; } else { @@ -168,4 +169,5 @@ ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) { /** * @inheritDoc */ -ol.interaction.PinchZoom.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_PinchZoom_.prototype.shouldStopEvent = _ol_functions_.FALSE; +export default _ol_interaction_PinchZoom_; diff --git a/src/ol/interaction/Pointer.js b/src/ol/interaction/Pointer.js index e288738370..e15a1bbadf 100644 --- a/src/ol/interaction/Pointer.js +++ b/src/ol/interaction/Pointer.js @@ -1,12 +1,12 @@ -goog.provide('ol.interaction.Pointer'); - -goog.require('ol'); -goog.require('ol.functions'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.obj'); - +/** + * @module ol/interaction/Pointer + */ +import _ol_ from '../index.js'; +import _ol_functions_ from '../functions.js'; +import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js'; +import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -23,14 +23,14 @@ goog.require('ol.obj'); * @extends {ol.interaction.Interaction} * @api */ -ol.interaction.Pointer = function(opt_options) { +var _ol_interaction_Pointer_ = function(opt_options) { var options = opt_options ? opt_options : {}; var handleEvent = options.handleEvent ? - options.handleEvent : ol.interaction.Pointer.handleEvent; + options.handleEvent : _ol_interaction_Pointer_.handleEvent; - ol.interaction.Interaction.call(this, { + _ol_interaction_Interaction_.call(this, { handleEvent: handleEvent }); @@ -39,28 +39,28 @@ ol.interaction.Pointer = function(opt_options) { * @private */ this.handleDownEvent_ = options.handleDownEvent ? - options.handleDownEvent : ol.interaction.Pointer.handleDownEvent; + options.handleDownEvent : _ol_interaction_Pointer_.handleDownEvent; /** * @type {function(ol.MapBrowserPointerEvent)} * @private */ this.handleDragEvent_ = options.handleDragEvent ? - options.handleDragEvent : ol.interaction.Pointer.handleDragEvent; + options.handleDragEvent : _ol_interaction_Pointer_.handleDragEvent; /** * @type {function(ol.MapBrowserPointerEvent)} * @private */ this.handleMoveEvent_ = options.handleMoveEvent ? - options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent; + options.handleMoveEvent : _ol_interaction_Pointer_.handleMoveEvent; /** * @type {function(ol.MapBrowserPointerEvent):boolean} * @private */ this.handleUpEvent_ = options.handleUpEvent ? - options.handleUpEvent : ol.interaction.Pointer.handleUpEvent; + options.handleUpEvent : _ol_interaction_Pointer_.handleUpEvent; /** * @type {boolean} @@ -81,14 +81,15 @@ ol.interaction.Pointer = function(opt_options) { this.targetPointers = []; }; -ol.inherits(ol.interaction.Pointer, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_Pointer_, _ol_interaction_Interaction_); /** * @param {Array.} pointerEvents List of events. * @return {ol.Pixel} Centroid pixel. */ -ol.interaction.Pointer.centroid = function(pointerEvents) { +_ol_interaction_Pointer_.centroid = function(pointerEvents) { var length = pointerEvents.length; var clientX = 0; var clientY = 0; @@ -106,12 +107,11 @@ ol.interaction.Pointer.centroid = function(pointerEvents) { * or pointerup event. * @private */ -ol.interaction.Pointer.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) { +_ol_interaction_Pointer_.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) { var type = mapBrowserEvent.type; - return ( - type === ol.MapBrowserEventType.POINTERDOWN || - type === ol.MapBrowserEventType.POINTERDRAG || - type === ol.MapBrowserEventType.POINTERUP); + return type === _ol_MapBrowserEventType_.POINTERDOWN || + type === _ol_MapBrowserEventType_.POINTERDRAG || + type === _ol_MapBrowserEventType_.POINTERUP; }; @@ -119,21 +119,21 @@ ol.interaction.Pointer.prototype.isPointerDraggingEvent_ = function(mapBrowserEv * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @private */ -ol.interaction.Pointer.prototype.updateTrackedPointers_ = function(mapBrowserEvent) { +_ol_interaction_Pointer_.prototype.updateTrackedPointers_ = function(mapBrowserEvent) { if (this.isPointerDraggingEvent_(mapBrowserEvent)) { var event = mapBrowserEvent.pointerEvent; var id = event.pointerId.toString(); - if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERUP) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) { delete this.trackedPointers_[id]; } else if (mapBrowserEvent.type == - ol.MapBrowserEventType.POINTERDOWN) { + _ol_MapBrowserEventType_.POINTERDOWN) { this.trackedPointers_[id] = event; } else if (id in this.trackedPointers_) { // update only when there was a pointerdown event for this pointer this.trackedPointers_[id] = event; } - this.targetPointers = ol.obj.getValues(this.trackedPointers_); + this.targetPointers = _ol_obj_.getValues(this.trackedPointers_); } }; @@ -142,7 +142,7 @@ ol.interaction.Pointer.prototype.updateTrackedPointers_ = function(mapBrowserEve * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @this {ol.interaction.Pointer} */ -ol.interaction.Pointer.handleDragEvent = ol.nullFunction; +_ol_interaction_Pointer_.handleDragEvent = _ol_.nullFunction; /** @@ -150,7 +150,7 @@ ol.interaction.Pointer.handleDragEvent = ol.nullFunction; * @return {boolean} Capture dragging. * @this {ol.interaction.Pointer} */ -ol.interaction.Pointer.handleUpEvent = ol.functions.FALSE; +_ol_interaction_Pointer_.handleUpEvent = _ol_functions_.FALSE; /** @@ -158,14 +158,14 @@ ol.interaction.Pointer.handleUpEvent = ol.functions.FALSE; * @return {boolean} Capture dragging. * @this {ol.interaction.Pointer} */ -ol.interaction.Pointer.handleDownEvent = ol.functions.FALSE; +_ol_interaction_Pointer_.handleDownEvent = _ol_functions_.FALSE; /** * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @this {ol.interaction.Pointer} */ -ol.interaction.Pointer.handleMoveEvent = ol.nullFunction; +_ol_interaction_Pointer_.handleMoveEvent = _ol_.nullFunction; /** @@ -177,26 +177,26 @@ ol.interaction.Pointer.handleMoveEvent = ol.nullFunction; * @this {ol.interaction.Pointer} * @api */ -ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) { - if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) { +_ol_interaction_Pointer_.handleEvent = function(mapBrowserEvent) { + if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) { return true; } var stopEvent = false; this.updateTrackedPointers_(mapBrowserEvent); if (this.handlingDownUpSequence) { - if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERDRAG) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDRAG) { this.handleDragEvent_(mapBrowserEvent); - } else if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERUP) { + } else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) { var handledUp = this.handleUpEvent_(mapBrowserEvent); this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0; } } else { - if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERDOWN) { + if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDOWN) { var handled = this.handleDownEvent_(mapBrowserEvent); this.handlingDownUpSequence = handled; stopEvent = this.shouldStopEvent(handled); - } else if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE) { + } else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE) { this.handleMoveEvent_(mapBrowserEvent); } } @@ -217,6 +217,7 @@ ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) { * @return {boolean} Should the event be stopped? * @protected */ -ol.interaction.Pointer.prototype.shouldStopEvent = function(handled) { +_ol_interaction_Pointer_.prototype.shouldStopEvent = function(handled) { return handled; }; +export default _ol_interaction_Pointer_; diff --git a/src/ol/interaction/Property.js b/src/ol/interaction/Property.js index 3bd134dcf2..864fcfa590 100644 --- a/src/ol/interaction/Property.js +++ b/src/ol/interaction/Property.js @@ -1,8 +1,11 @@ -goog.provide('ol.interaction.Property'); - +/** + * @module ol/interaction/Property + */ /** * @enum {string} */ -ol.interaction.Property = { +var _ol_interaction_Property_ = { ACTIVE: 'active' }; + +export default _ol_interaction_Property_; diff --git a/src/ol/interaction/Select.js b/src/ol/interaction/Select.js index a72e70ca55..4d89194bc6 100644 --- a/src/ol/interaction/Select.js +++ b/src/ol/interaction/Select.js @@ -1,19 +1,19 @@ -goog.provide('ol.interaction.Select'); - -goog.require('ol'); -goog.require('ol.CollectionEventType'); -goog.require('ol.array'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.condition'); -goog.require('ol.functions'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.layer.Vector'); -goog.require('ol.obj'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); - +/** + * @module ol/interaction/Select + */ +import _ol_ from '../index.js'; +import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import _ol_array_ from '../array.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_condition_ from '../events/condition.js'; +import _ol_functions_ from '../functions.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_Vector_ from '../source/Vector.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -33,10 +33,10 @@ goog.require('ol.style.Style'); * @fires ol.interaction.Select.Event * @api */ -ol.interaction.Select = function(opt_options) { +var _ol_interaction_Select_ = function(opt_options) { - ol.interaction.Interaction.call(this, { - handleEvent: ol.interaction.Select.handleEvent + _ol_interaction_Interaction_.call(this, { + handleEvent: _ol_interaction_Select_.handleEvent }); var options = opt_options ? opt_options : {}; @@ -46,28 +46,28 @@ ol.interaction.Select = function(opt_options) { * @type {ol.EventsConditionType} */ this.condition_ = options.condition ? - options.condition : ol.events.condition.singleClick; + options.condition : _ol_events_condition_.singleClick; /** * @private * @type {ol.EventsConditionType} */ this.addCondition_ = options.addCondition ? - options.addCondition : ol.events.condition.never; + options.addCondition : _ol_events_condition_.never; /** * @private * @type {ol.EventsConditionType} */ this.removeCondition_ = options.removeCondition ? - options.removeCondition : ol.events.condition.never; + options.removeCondition : _ol_events_condition_.never; /** * @private * @type {ol.EventsConditionType} */ this.toggleCondition_ = options.toggleCondition ? - options.toggleCondition : ol.events.condition.shiftKeyOnly; + options.toggleCondition : _ol_events_condition_.shiftKeyOnly; /** * @private @@ -80,7 +80,7 @@ ol.interaction.Select = function(opt_options) { * @type {ol.SelectFilterFunction} */ this.filter_ = options.filter ? options.filter : - ol.functions.TRUE; + _ol_functions_.TRUE; /** * @private @@ -88,14 +88,14 @@ ol.interaction.Select = function(opt_options) { */ this.hitTolerance_ = options.hitTolerance ? options.hitTolerance : 0; - var featureOverlay = new ol.layer.Vector({ - source: new ol.source.Vector({ + var featureOverlay = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ useSpatialIndex: false, features: options.features, wrapX: options.wrapX }), style: options.style ? options.style : - ol.interaction.Select.getDefaultStyleFunction(), + _ol_interaction_Select_.getDefaultStyleFunction(), updateWhileAnimating: true, updateWhileInteracting: true }); @@ -114,11 +114,11 @@ ol.interaction.Select = function(opt_options) { } else { var layers = options.layers; layerFilter = function(layer) { - return ol.array.includes(layers, layer); + return _ol_array_.includes(layers, layer); }; } } else { - layerFilter = ol.functions.TRUE; + layerFilter = _ol_functions_.TRUE; } /** @@ -136,13 +136,14 @@ ol.interaction.Select = function(opt_options) { this.featureLayerAssociation_ = {}; var features = this.featureOverlay_.getSource().getFeaturesCollection(); - ol.events.listen(features, ol.CollectionEventType.ADD, + _ol_events_.listen(features, _ol_CollectionEventType_.ADD, this.addFeature_, this); - ol.events.listen(features, ol.CollectionEventType.REMOVE, + _ol_events_.listen(features, _ol_CollectionEventType_.REMOVE, this.removeFeature_, this); }; -ol.inherits(ol.interaction.Select, ol.interaction.Interaction); + +_ol_.inherits(_ol_interaction_Select_, _ol_interaction_Interaction_); /** @@ -150,8 +151,8 @@ ol.inherits(ol.interaction.Select, ol.interaction.Interaction); * @param {ol.layer.Layer} layer Layer. * @private */ -ol.interaction.Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) { - var key = ol.getUid(feature); +_ol_interaction_Select_.prototype.addFeatureLayerAssociation_ = function(feature, layer) { + var key = _ol_.getUid(feature); this.featureLayerAssociation_[key] = layer; }; @@ -161,7 +162,7 @@ ol.interaction.Select.prototype.addFeatureLayerAssociation_ = function(feature, * @return {ol.Collection.} Features collection. * @api */ -ol.interaction.Select.prototype.getFeatures = function() { +_ol_interaction_Select_.prototype.getFeatures = function() { return this.featureOverlay_.getSource().getFeaturesCollection(); }; @@ -171,7 +172,7 @@ ol.interaction.Select.prototype.getFeatures = function() { * @returns {number} Hit tolerance in pixels. * @api */ -ol.interaction.Select.prototype.getHitTolerance = function() { +_ol_interaction_Select_.prototype.getHitTolerance = function() { return this.hitTolerance_; }; @@ -185,8 +186,8 @@ ol.interaction.Select.prototype.getHitTolerance = function() { * @return {ol.layer.Vector} Layer. * @api */ -ol.interaction.Select.prototype.getLayer = function(feature) { - var key = ol.getUid(feature); +_ol_interaction_Select_.prototype.getLayer = function(feature) { + var key = _ol_.getUid(feature); return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]); }; @@ -199,7 +200,7 @@ ol.interaction.Select.prototype.getLayer = function(feature) { * @this {ol.interaction.Select} * @api */ -ol.interaction.Select.handleEvent = function(mapBrowserEvent) { +_ol_interaction_Select_.handleEvent = function(mapBrowserEvent) { if (!this.condition_(mapBrowserEvent)) { return true; } @@ -215,7 +216,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { // Replace the currently selected feature(s) with the feature(s) at the // pixel, or clear the selected feature(s) if there is no feature at // the pixel. - ol.obj.clear(this.featureLayerAssociation_); + _ol_obj_.clear(this.featureLayerAssociation_); map.forEachFeatureAtPixel(mapBrowserEvent.pixel, ( /** @@ -260,11 +261,11 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { function(feature, layer) { if (this.filter_(feature, layer)) { if ((add || toggle) && - !ol.array.includes(features.getArray(), feature)) { + !_ol_array_.includes(features.getArray(), feature)) { selected.push(feature); this.addFeatureLayerAssociation_(feature, layer); } else if ((remove || toggle) && - ol.array.includes(features.getArray(), feature)) { + _ol_array_.includes(features.getArray(), feature)) { deselected.push(feature); this.removeFeatureLayerAssociation_(feature); } @@ -282,10 +283,10 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { } if (selected.length > 0 || deselected.length > 0) { this.dispatchEvent( - new ol.interaction.Select.Event(ol.interaction.Select.EventType_.SELECT, + new _ol_interaction_Select_.Event(_ol_interaction_Select_.EventType_.SELECT, selected, deselected, mapBrowserEvent)); } - return ol.events.condition.pointerMove(mapBrowserEvent); + return _ol_events_condition_.pointerMove(mapBrowserEvent); }; @@ -296,7 +297,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { * @param {number} hitTolerance Hit tolerance in pixels. * @api */ -ol.interaction.Select.prototype.setHitTolerance = function(hitTolerance) { +_ol_interaction_Select_.prototype.setHitTolerance = function(hitTolerance) { this.hitTolerance_ = hitTolerance; }; @@ -308,14 +309,14 @@ ol.interaction.Select.prototype.setHitTolerance = function(hitTolerance) { * @override * @api */ -ol.interaction.Select.prototype.setMap = function(map) { +_ol_interaction_Select_.prototype.setMap = function(map) { var currentMap = this.getMap(); var selectedFeatures = this.featureOverlay_.getSource().getFeaturesCollection(); if (currentMap) { selectedFeatures.forEach(currentMap.unskipFeature, currentMap); } - ol.interaction.Interaction.prototype.setMap.call(this, map); + _ol_interaction_Interaction_.prototype.setMap.call(this, map); this.featureOverlay_.setMap(map); if (map) { selectedFeatures.forEach(map.skipFeature, map); @@ -326,12 +327,12 @@ ol.interaction.Select.prototype.setMap = function(map) { /** * @return {ol.StyleFunction} Styles. */ -ol.interaction.Select.getDefaultStyleFunction = function() { - var styles = ol.style.Style.createDefaultEditing(); - ol.array.extend(styles[ol.geom.GeometryType.POLYGON], - styles[ol.geom.GeometryType.LINE_STRING]); - ol.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION], - styles[ol.geom.GeometryType.LINE_STRING]); +_ol_interaction_Select_.getDefaultStyleFunction = function() { + var styles = _ol_style_Style_.createDefaultEditing(); + _ol_array_.extend(styles[_ol_geom_GeometryType_.POLYGON], + styles[_ol_geom_GeometryType_.LINE_STRING]); + _ol_array_.extend(styles[_ol_geom_GeometryType_.GEOMETRY_COLLECTION], + styles[_ol_geom_GeometryType_.LINE_STRING]); return function(feature, resolution) { if (!feature.getGeometry()) { @@ -346,7 +347,7 @@ ol.interaction.Select.getDefaultStyleFunction = function() { * @param {ol.Collection.Event} evt Event. * @private */ -ol.interaction.Select.prototype.addFeature_ = function(evt) { +_ol_interaction_Select_.prototype.addFeature_ = function(evt) { var map = this.getMap(); if (map) { map.skipFeature(/** @type {ol.Feature} */ (evt.element)); @@ -358,7 +359,7 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) { * @param {ol.Collection.Event} evt Event. * @private */ -ol.interaction.Select.prototype.removeFeature_ = function(evt) { +_ol_interaction_Select_.prototype.removeFeature_ = function(evt) { var map = this.getMap(); if (map) { map.unskipFeature(/** @type {ol.Feature} */ (evt.element)); @@ -370,8 +371,8 @@ ol.interaction.Select.prototype.removeFeature_ = function(evt) { * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.interaction.Select.prototype.removeFeatureLayerAssociation_ = function(feature) { - var key = ol.getUid(feature); +_ol_interaction_Select_.prototype.removeFeatureLayerAssociation_ = function(feature) { + var key = _ol_.getUid(feature); delete this.featureLayerAssociation_[key]; }; @@ -390,8 +391,8 @@ ol.interaction.Select.prototype.removeFeatureLayerAssociation_ = function(featur * @extends {ol.events.Event} * @constructor */ -ol.interaction.Select.Event = function(type, selected, deselected, mapBrowserEvent) { - ol.events.Event.call(this, type); +_ol_interaction_Select_.Event = function(type, selected, deselected, mapBrowserEvent) { + _ol_events_Event_.call(this, type); /** * Selected features array. @@ -414,14 +415,14 @@ ol.interaction.Select.Event = function(type, selected, deselected, mapBrowserEve */ this.mapBrowserEvent = mapBrowserEvent; }; -ol.inherits(ol.interaction.Select.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_Select_.Event, _ol_events_Event_); /** * @enum {string} * @private */ -ol.interaction.Select.EventType_ = { +_ol_interaction_Select_.EventType_ = { /** * Triggered when feature(s) has been (de)selected. * @event ol.interaction.Select.Event#select @@ -429,3 +430,4 @@ ol.interaction.Select.EventType_ = { */ SELECT: 'select' }; +export default _ol_interaction_Select_; diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index 6f5fc75c41..594a606172 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -1,21 +1,21 @@ -goog.provide('ol.interaction.Snap'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); -goog.require('ol.coordinate'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.obj'); -goog.require('ol.source.Vector'); -goog.require('ol.source.VectorEventType'); -goog.require('ol.structs.RBush'); - +/** + * @module ol/interaction/Snap + */ +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_functions_ from '../functions.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_Vector_ from '../source/Vector.js'; +import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; +import _ol_structs_RBush_ from '../structs/RBush.js'; /** * @classdesc @@ -39,12 +39,12 @@ goog.require('ol.structs.RBush'); * @param {olx.interaction.SnapOptions=} opt_options Options. * @api */ -ol.interaction.Snap = function(opt_options) { +var _ol_interaction_Snap_ = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleEvent: ol.interaction.Snap.handleEvent_, - handleDownEvent: ol.functions.TRUE, - handleUpEvent: ol.interaction.Snap.handleUpEvent_ + _ol_interaction_Pointer_.call(this, { + handleEvent: _ol_interaction_Snap_.handleEvent_, + handleDownEvent: _ol_functions_.TRUE, + handleUpEvent: _ol_interaction_Snap_.handleUpEvent_ }); var options = opt_options ? opt_options : {}; @@ -120,7 +120,7 @@ ol.interaction.Snap = function(opt_options) { * @type {function(ol.SnapSegmentDataType, ol.SnapSegmentDataType): number} * @private */ - this.sortByDistance_ = ol.interaction.Snap.sortByDistance.bind(this); + this.sortByDistance_ = _ol_interaction_Snap_.sortByDistance.bind(this); /** @@ -128,7 +128,7 @@ ol.interaction.Snap = function(opt_options) { * @type {ol.structs.RBush.} * @private */ - this.rBush_ = new ol.structs.RBush(); + this.rBush_ = new _ol_structs_RBush_(); /** @@ -148,7 +148,8 @@ ol.interaction.Snap = function(opt_options) { 'Circle': this.writeCircleGeometry_ }; }; -ol.inherits(ol.interaction.Snap, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_Snap_, _ol_interaction_Pointer_); /** @@ -158,23 +159,23 @@ ol.inherits(ol.interaction.Snap, ol.interaction.Pointer); * Defaults to `true`. * @api */ -ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { +_ol_interaction_Snap_.prototype.addFeature = function(feature, opt_listen) { var listen = opt_listen !== undefined ? opt_listen : true; - var feature_uid = ol.getUid(feature); + var feature_uid = _ol_.getUid(feature); var geometry = feature.getGeometry(); if (geometry) { var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()]; if (segmentWriter) { this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent( - ol.extent.createEmpty()); + _ol_extent_.createEmpty()); segmentWriter.call(this, feature, geometry); } } if (listen) { - this.featureChangeListenerKeys_[feature_uid] = ol.events.listen( + this.featureChangeListenerKeys_[feature_uid] = _ol_events_.listen( feature, - ol.events.EventType.CHANGE, + _ol_events_EventType_.CHANGE, this.handleFeatureChange_, this); } }; @@ -184,7 +185,7 @@ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { * @param {ol.Feature} feature Feature. * @private */ -ol.interaction.Snap.prototype.forEachFeatureAdd_ = function(feature) { +_ol_interaction_Snap_.prototype.forEachFeatureAdd_ = function(feature) { this.addFeature(feature); }; @@ -193,7 +194,7 @@ ol.interaction.Snap.prototype.forEachFeatureAdd_ = function(feature) { * @param {ol.Feature} feature Feature. * @private */ -ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) { +_ol_interaction_Snap_.prototype.forEachFeatureRemove_ = function(feature) { this.removeFeature(feature); }; @@ -202,7 +203,7 @@ ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) { * @return {ol.Collection.|Array.} Features. * @private */ -ol.interaction.Snap.prototype.getFeatures_ = function() { +_ol_interaction_Snap_.prototype.getFeatures_ = function() { var features; if (this.features_) { features = this.features_; @@ -217,11 +218,11 @@ ol.interaction.Snap.prototype.getFeatures_ = function() { * @param {ol.source.Vector.Event|ol.Collection.Event} evt Event. * @private */ -ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) { +_ol_interaction_Snap_.prototype.handleFeatureAdd_ = function(evt) { var feature; - if (evt instanceof ol.source.Vector.Event) { + if (evt instanceof _ol_source_Vector_.Event) { feature = evt.feature; - } else if (evt instanceof ol.Collection.Event) { + } else if (evt instanceof _ol_Collection_.Event) { feature = evt.element; } this.addFeature(/** @type {ol.Feature} */ (feature)); @@ -232,11 +233,11 @@ ol.interaction.Snap.prototype.handleFeatureAdd_ = function(evt) { * @param {ol.source.Vector.Event|ol.Collection.Event} evt Event. * @private */ -ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) { +_ol_interaction_Snap_.prototype.handleFeatureRemove_ = function(evt) { var feature; - if (evt instanceof ol.source.Vector.Event) { + if (evt instanceof _ol_source_Vector_.Event) { feature = evt.feature; - } else if (evt instanceof ol.Collection.Event) { + } else if (evt instanceof _ol_Collection_.Event) { feature = evt.element; } this.removeFeature(/** @type {ol.Feature} */ (feature)); @@ -247,10 +248,10 @@ ol.interaction.Snap.prototype.handleFeatureRemove_ = function(evt) { * @param {ol.events.Event} evt Event. * @private */ -ol.interaction.Snap.prototype.handleFeatureChange_ = function(evt) { +_ol_interaction_Snap_.prototype.handleFeatureChange_ = function(evt) { var feature = /** @type {ol.Feature} */ (evt.target); if (this.handlingDownUpSequence) { - var uid = ol.getUid(feature); + var uid = _ol_.getUid(feature); if (!(uid in this.pendingFeatures_)) { this.pendingFeatures_[uid] = feature; } @@ -267,9 +268,9 @@ ol.interaction.Snap.prototype.handleFeatureChange_ = function(evt) { * or not. Defaults to `true`. * @api */ -ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { +_ol_interaction_Snap_.prototype.removeFeature = function(feature, opt_unlisten) { var unlisten = opt_unlisten !== undefined ? opt_unlisten : true; - var feature_uid = ol.getUid(feature); + var feature_uid = _ol_.getUid(feature); var extent = this.indexedFeaturesExtents_[feature_uid]; if (extent) { var rBush = this.rBush_; @@ -285,7 +286,7 @@ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { } if (unlisten) { - ol.events.unlistenByKey(this.featureChangeListenerKeys_[feature_uid]); + _ol_events_.unlistenByKey(this.featureChangeListenerKeys_[feature_uid]); delete this.featureChangeListenerKeys_[feature_uid]; } }; @@ -294,31 +295,31 @@ ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { /** * @inheritDoc */ -ol.interaction.Snap.prototype.setMap = function(map) { +_ol_interaction_Snap_.prototype.setMap = function(map) { var currentMap = this.getMap(); var keys = this.featuresListenerKeys_; var features = this.getFeatures_(); if (currentMap) { - keys.forEach(ol.events.unlistenByKey); + keys.forEach(_ol_events_.unlistenByKey); keys.length = 0; features.forEach(this.forEachFeatureRemove_, this); } - ol.interaction.Pointer.prototype.setMap.call(this, map); + _ol_interaction_Pointer_.prototype.setMap.call(this, map); if (map) { if (this.features_) { keys.push( - ol.events.listen(this.features_, ol.CollectionEventType.ADD, + _ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, this.handleFeatureAdd_, this), - ol.events.listen(this.features_, ol.CollectionEventType.REMOVE, + _ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, this.handleFeatureRemove_, this) ); } else if (this.source_) { keys.push( - ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE, + _ol_events_.listen(this.source_, _ol_source_VectorEventType_.ADDFEATURE, this.handleFeatureAdd_, this), - ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE, + _ol_events_.listen(this.source_, _ol_source_VectorEventType_.REMOVEFEATURE, this.handleFeatureRemove_, this) ); } @@ -330,7 +331,7 @@ ol.interaction.Snap.prototype.setMap = function(map) { /** * @inheritDoc */ -ol.interaction.Snap.prototype.shouldStopEvent = ol.functions.FALSE; +_ol_interaction_Snap_.prototype.shouldStopEvent = _ol_functions_.FALSE; /** @@ -339,13 +340,13 @@ ol.interaction.Snap.prototype.shouldStopEvent = ol.functions.FALSE; * @param {ol.PluggableMap} map Map. * @return {ol.SnapResultType} Snap result */ -ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { +_ol_interaction_Snap_.prototype.snapTo = function(pixel, pixelCoordinate, map) { var lowerLeft = map.getCoordinateFromPixel( [pixel[0] - this.pixelTolerance_, pixel[1] + this.pixelTolerance_]); var upperRight = map.getCoordinateFromPixel( [pixel[0] + this.pixelTolerance_, pixel[1] - this.pixelTolerance_]); - var box = ol.extent.boundingExtent([lowerLeft, upperRight]); + var box = _ol_extent_.boundingExtent([lowerLeft, upperRight]); var segments = this.rBush_.getInExtent(box); @@ -353,7 +354,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { if (this.vertex_ && !this.edge_) { segments = segments.filter(function(segment) { return segment.feature.getGeometry().getType() !== - ol.geom.GeometryType.CIRCLE; + _ol_geom_GeometryType_.CIRCLE; }); } @@ -367,12 +368,12 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { segments.sort(this.sortByDistance_); var closestSegment = segments[0].segment; var isCircle = segments[0].feature.getGeometry().getType() === - ol.geom.GeometryType.CIRCLE; + _ol_geom_GeometryType_.CIRCLE; if (this.vertex_ && !this.edge_) { pixel1 = map.getPixelFromCoordinate(closestSegment[0]); pixel2 = map.getPixelFromCoordinate(closestSegment[1]); - squaredDist1 = ol.coordinate.squaredDistance(pixel, pixel1); - squaredDist2 = ol.coordinate.squaredDistance(pixel, pixel2); + squaredDist1 = _ol_coordinate_.squaredDistance(pixel, pixel1); + squaredDist2 = _ol_coordinate_.squaredDistance(pixel, pixel2); dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); snappedToVertex = dist <= this.pixelTolerance_; if (snappedToVertex) { @@ -383,20 +384,20 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { } } else if (this.edge_) { if (isCircle) { - vertex = ol.coordinate.closestOnCircle(pixelCoordinate, + vertex = _ol_coordinate_.closestOnCircle(pixelCoordinate, /** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry())); } else { - vertex = (ol.coordinate.closestOnSegment(pixelCoordinate, + vertex = (_ol_coordinate_.closestOnSegment(pixelCoordinate, closestSegment)); } vertexPixel = map.getPixelFromCoordinate(vertex); - if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) { + if (_ol_coordinate_.distance(pixel, vertexPixel) <= this.pixelTolerance_) { snapped = true; if (this.vertex_ && !isCircle) { pixel1 = map.getPixelFromCoordinate(closestSegment[0]); pixel2 = map.getPixelFromCoordinate(closestSegment[1]); - squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1); - squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2); + squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1); + squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2); dist = Math.sqrt(Math.min(squaredDist1, squaredDist2)); snappedToVertex = dist <= this.pixelTolerance_; if (snappedToVertex) { @@ -423,7 +424,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { * @param {ol.Feature} feature Feature * @private */ -ol.interaction.Snap.prototype.updateFeature_ = function(feature) { +_ol_interaction_Snap_.prototype.updateFeature_ = function(feature) { this.removeFeature(feature, false); this.addFeature(feature, false); }; @@ -434,8 +435,8 @@ ol.interaction.Snap.prototype.updateFeature_ = function(feature) { * @param {ol.geom.Circle} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry) { - var polygon = ol.geom.Polygon.fromCircle(geometry); +_ol_interaction_Snap_.prototype.writeCircleGeometry_ = function(feature, geometry) { + var polygon = _ol_geom_Polygon_.fromCircle(geometry); var coordinates = polygon.getCoordinates()[0]; var i, ii, segment, segmentData; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { @@ -444,7 +445,7 @@ ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry) feature: feature, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } }; @@ -454,7 +455,7 @@ ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry) * @param {ol.geom.GeometryCollection} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writeGeometryCollectionGeometry_ = function(feature, geometry) { var i, geometries = geometry.getGeometriesArray(); for (i = 0; i < geometries.length; ++i) { var segmentWriter = this.SEGMENT_WRITERS_[geometries[i].getType()]; @@ -470,7 +471,7 @@ ol.interaction.Snap.prototype.writeGeometryCollectionGeometry_ = function(featur * @param {ol.geom.LineString} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writeLineStringGeometry_ = function(feature, geometry) { var coordinates = geometry.getCoordinates(); var i, ii, segment, segmentData; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { @@ -479,7 +480,7 @@ ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geome feature: feature, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } }; @@ -489,7 +490,7 @@ ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geome * @param {ol.geom.MultiLineString} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { var lines = geometry.getCoordinates(); var coordinates, i, ii, j, jj, segment, segmentData; for (j = 0, jj = lines.length; j < jj; ++j) { @@ -500,7 +501,7 @@ ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature, feature: feature, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } }; @@ -511,7 +512,7 @@ ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature, * @param {ol.geom.MultiPoint} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeMultiPointGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writeMultiPointGeometry_ = function(feature, geometry) { var points = geometry.getCoordinates(); var coordinates, i, ii, segmentData; for (i = 0, ii = points.length; i < ii; ++i) { @@ -530,7 +531,7 @@ ol.interaction.Snap.prototype.writeMultiPointGeometry_ = function(feature, geome * @param {ol.geom.MultiPolygon} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { var polygons = geometry.getCoordinates(); var coordinates, i, ii, j, jj, k, kk, rings, segment, segmentData; for (k = 0, kk = polygons.length; k < kk; ++k) { @@ -543,7 +544,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo feature: feature, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } } @@ -555,7 +556,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo * @param {ol.geom.Point} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writePointGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writePointGeometry_ = function(feature, geometry) { var coordinates = geometry.getCoordinates(); var segmentData = /** @type {ol.SnapSegmentDataType} */ ({ feature: feature, @@ -570,7 +571,7 @@ ol.interaction.Snap.prototype.writePointGeometry_ = function(feature, geometry) * @param {ol.geom.Polygon} geometry Geometry. * @private */ -ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry) { +_ol_interaction_Snap_.prototype.writePolygonGeometry_ = function(feature, geometry) { var rings = geometry.getCoordinates(); var coordinates, i, ii, j, jj, segment, segmentData; for (j = 0, jj = rings.length; j < jj; ++j) { @@ -581,7 +582,7 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry feature: feature, segment: segment }); - this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData); + this.rBush_.insert(_ol_extent_.boundingExtent(segment), segmentData); } } }; @@ -594,13 +595,13 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry * @this {ol.interaction.Snap} * @private */ -ol.interaction.Snap.handleEvent_ = function(evt) { +_ol_interaction_Snap_.handleEvent_ = function(evt) { var result = this.snapTo(evt.pixel, evt.coordinate, evt.map); if (result.snapped) { evt.coordinate = result.vertex.slice(0, 2); evt.pixel = result.vertexPixel; } - return ol.interaction.Pointer.handleEvent.call(this, evt); + return _ol_interaction_Pointer_.handleEvent.call(this, evt); }; @@ -610,8 +611,8 @@ ol.interaction.Snap.handleEvent_ = function(evt) { * @this {ol.interaction.Snap} * @private */ -ol.interaction.Snap.handleUpEvent_ = function(evt) { - var featuresToUpdate = ol.obj.getValues(this.pendingFeatures_); +_ol_interaction_Snap_.handleUpEvent_ = function(evt) { + var featuresToUpdate = _ol_obj_.getValues(this.pendingFeatures_); if (featuresToUpdate.length) { featuresToUpdate.forEach(this.updateFeature_, this); this.pendingFeatures_ = {}; @@ -627,9 +628,10 @@ ol.interaction.Snap.handleUpEvent_ = function(evt) { * @return {number} The difference in distance. * @this {ol.interaction.Snap} */ -ol.interaction.Snap.sortByDistance = function(a, b) { - return ol.coordinate.squaredDistanceToSegment( +_ol_interaction_Snap_.sortByDistance = function(a, b) { + return _ol_coordinate_.squaredDistanceToSegment( this.pixelCoordinate_, a.segment) - - ol.coordinate.squaredDistanceToSegment( + _ol_coordinate_.squaredDistanceToSegment( this.pixelCoordinate_, b.segment); }; +export default _ol_interaction_Snap_; diff --git a/src/ol/interaction/Translate.js b/src/ol/interaction/Translate.js index dc13926510..675149a18c 100644 --- a/src/ol/interaction/Translate.js +++ b/src/ol/interaction/Translate.js @@ -1,16 +1,16 @@ -goog.provide('ol.interaction.Translate'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.Object'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.functions'); -goog.require('ol.array'); -goog.require('ol.interaction.Pointer'); -goog.require('ol.interaction.Property'); -goog.require('ol.interaction.TranslateEventType'); - +/** + * @module ol/interaction/Translate + */ +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_Object_ from '../Object.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_functions_ from '../functions.js'; +import _ol_array_ from '../array.js'; +import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; +import _ol_interaction_Property_ from '../interaction/Property.js'; +import _ol_interaction_TranslateEventType_ from '../interaction/TranslateEventType.js'; /** * @classdesc @@ -22,12 +22,12 @@ goog.require('ol.interaction.TranslateEventType'); * @param {olx.interaction.TranslateOptions=} opt_options Options. * @api */ -ol.interaction.Translate = function(opt_options) { - ol.interaction.Pointer.call(this, { - handleDownEvent: ol.interaction.Translate.handleDownEvent_, - handleDragEvent: ol.interaction.Translate.handleDragEvent_, - handleMoveEvent: ol.interaction.Translate.handleMoveEvent_, - handleUpEvent: ol.interaction.Translate.handleUpEvent_ +var _ol_interaction_Translate_ = function(opt_options) { + _ol_interaction_Pointer_.call(this, { + handleDownEvent: _ol_interaction_Translate_.handleDownEvent_, + handleDragEvent: _ol_interaction_Translate_.handleDragEvent_, + handleMoveEvent: _ol_interaction_Translate_.handleMoveEvent_, + handleUpEvent: _ol_interaction_Translate_.handleUpEvent_ }); var options = opt_options ? opt_options : {}; @@ -54,11 +54,11 @@ ol.interaction.Translate = function(opt_options) { } else { var layers = options.layers; layerFilter = function(layer) { - return ol.array.includes(layers, layer); + return _ol_array_.includes(layers, layer); }; } } else { - layerFilter = ol.functions.TRUE; + layerFilter = _ol_functions_.TRUE; } /** @@ -79,12 +79,13 @@ ol.interaction.Translate = function(opt_options) { */ this.lastFeature_ = null; - ol.events.listen(this, - ol.Object.getChangeEventType(ol.interaction.Property.ACTIVE), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_interaction_Property_.ACTIVE), this.handleActiveChanged_, this); }; -ol.inherits(ol.interaction.Translate, ol.interaction.Pointer); + +_ol_.inherits(_ol_interaction_Translate_, _ol_interaction_Pointer_); /** @@ -93,17 +94,17 @@ ol.inherits(ol.interaction.Translate, ol.interaction.Pointer); * @this {ol.interaction.Translate} * @private */ -ol.interaction.Translate.handleDownEvent_ = function(event) { +_ol_interaction_Translate_.handleDownEvent_ = function(event) { this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map); if (!this.lastCoordinate_ && this.lastFeature_) { this.lastCoordinate_ = event.coordinate; - ol.interaction.Translate.handleMoveEvent_.call(this, event); + _ol_interaction_Translate_.handleMoveEvent_.call(this, event); - var features = this.features_ || new ol.Collection([this.lastFeature_]); + var features = this.features_ || new _ol_Collection_([this.lastFeature_]); this.dispatchEvent( - new ol.interaction.Translate.Event( - ol.interaction.TranslateEventType.TRANSLATESTART, features, + new _ol_interaction_Translate_.Event( + _ol_interaction_TranslateEventType_.TRANSLATESTART, features, event.coordinate)); return true; } @@ -117,16 +118,16 @@ ol.interaction.Translate.handleDownEvent_ = function(event) { * @this {ol.interaction.Translate} * @private */ -ol.interaction.Translate.handleUpEvent_ = function(event) { +_ol_interaction_Translate_.handleUpEvent_ = function(event) { if (this.lastCoordinate_) { this.lastCoordinate_ = null; - ol.interaction.Translate.handleMoveEvent_.call(this, event); + _ol_interaction_Translate_.handleMoveEvent_.call(this, event); - var features = this.features_ || new ol.Collection([this.lastFeature_]); + var features = this.features_ || new _ol_Collection_([this.lastFeature_]); this.dispatchEvent( - new ol.interaction.Translate.Event( - ol.interaction.TranslateEventType.TRANSLATEEND, features, + new _ol_interaction_Translate_.Event( + _ol_interaction_TranslateEventType_.TRANSLATEEND, features, event.coordinate)); return true; } @@ -139,13 +140,13 @@ ol.interaction.Translate.handleUpEvent_ = function(event) { * @this {ol.interaction.Translate} * @private */ -ol.interaction.Translate.handleDragEvent_ = function(event) { +_ol_interaction_Translate_.handleDragEvent_ = function(event) { if (this.lastCoordinate_) { var newCoordinate = event.coordinate; var deltaX = newCoordinate[0] - this.lastCoordinate_[0]; var deltaY = newCoordinate[1] - this.lastCoordinate_[1]; - var features = this.features_ || new ol.Collection([this.lastFeature_]); + var features = this.features_ || new _ol_Collection_([this.lastFeature_]); features.forEach(function(feature) { var geom = feature.getGeometry(); @@ -155,8 +156,8 @@ ol.interaction.Translate.handleDragEvent_ = function(event) { this.lastCoordinate_ = newCoordinate; this.dispatchEvent( - new ol.interaction.Translate.Event( - ol.interaction.TranslateEventType.TRANSLATING, features, + new _ol_interaction_Translate_.Event( + _ol_interaction_TranslateEventType_.TRANSLATING, features, newCoordinate)); } }; @@ -167,7 +168,7 @@ ol.interaction.Translate.handleDragEvent_ = function(event) { * @this {ol.interaction.Translate} * @private */ -ol.interaction.Translate.handleMoveEvent_ = function(event) { +_ol_interaction_Translate_.handleMoveEvent_ = function(event) { var elem = event.map.getViewport(); // Change the cursor to grab/grabbing if hovering any of the features managed @@ -190,11 +191,11 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) { * coordinates. * @private */ -ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) { +_ol_interaction_Translate_.prototype.featuresAtPixel_ = function(pixel, map) { return map.forEachFeatureAtPixel(pixel, function(feature) { if (!this.features_ || - ol.array.includes(this.features_.getArray(), feature)) { + _ol_array_.includes(this.features_.getArray(), feature)) { return feature; } }.bind(this), { @@ -209,7 +210,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) { * @returns {number} Hit tolerance in pixels. * @api */ -ol.interaction.Translate.prototype.getHitTolerance = function() { +_ol_interaction_Translate_.prototype.getHitTolerance = function() { return this.hitTolerance_; }; @@ -221,7 +222,7 @@ ol.interaction.Translate.prototype.getHitTolerance = function() { * @param {number} hitTolerance Hit tolerance in pixels. * @api */ -ol.interaction.Translate.prototype.setHitTolerance = function(hitTolerance) { +_ol_interaction_Translate_.prototype.setHitTolerance = function(hitTolerance) { this.hitTolerance_ = hitTolerance; }; @@ -229,9 +230,9 @@ ol.interaction.Translate.prototype.setHitTolerance = function(hitTolerance) { /** * @inheritDoc */ -ol.interaction.Translate.prototype.setMap = function(map) { +_ol_interaction_Translate_.prototype.setMap = function(map) { var oldMap = this.getMap(); - ol.interaction.Pointer.prototype.setMap.call(this, map); + _ol_interaction_Pointer_.prototype.setMap.call(this, map); this.updateState_(oldMap); }; @@ -239,7 +240,7 @@ ol.interaction.Translate.prototype.setMap = function(map) { /** * @private */ -ol.interaction.Translate.prototype.handleActiveChanged_ = function() { +_ol_interaction_Translate_.prototype.handleActiveChanged_ = function() { this.updateState_(null); }; @@ -248,7 +249,7 @@ ol.interaction.Translate.prototype.handleActiveChanged_ = function() { * @param {ol.PluggableMap} oldMap Old map. * @private */ -ol.interaction.Translate.prototype.updateState_ = function(oldMap) { +_ol_interaction_Translate_.prototype.updateState_ = function(oldMap) { var map = this.getMap(); var active = this.getActive(); if (!map || !active) { @@ -273,9 +274,9 @@ ol.interaction.Translate.prototype.updateState_ = function(oldMap) { * @param {ol.Collection.} features The features translated. * @param {ol.Coordinate} coordinate The event coordinate. */ -ol.interaction.Translate.Event = function(type, features, coordinate) { +_ol_interaction_Translate_.Event = function(type, features, coordinate) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The features being translated. @@ -292,4 +293,5 @@ ol.interaction.Translate.Event = function(type, features, coordinate) { */ this.coordinate = coordinate; }; -ol.inherits(ol.interaction.Translate.Event, ol.events.Event); +_ol_.inherits(_ol_interaction_Translate_.Event, _ol_events_Event_); +export default _ol_interaction_Translate_; diff --git a/src/ol/interaction/TranslateEventType.js b/src/ol/interaction/TranslateEventType.js index a9e138b250..9cde982408 100644 --- a/src/ol/interaction/TranslateEventType.js +++ b/src/ol/interaction/TranslateEventType.js @@ -1,10 +1,10 @@ -goog.provide('ol.interaction.TranslateEventType'); - - +/** + * @module ol/interaction/TranslateEventType + */ /** * @enum {string} */ -ol.interaction.TranslateEventType = { +var _ol_interaction_TranslateEventType_ = { /** * Triggered upon feature translation start. * @event ol.interaction.Translate.Event#translatestart @@ -24,3 +24,5 @@ ol.interaction.TranslateEventType = { */ TRANSLATEEND: 'translateend' }; + +export default _ol_interaction_TranslateEventType_; diff --git a/src/ol/layer/Base.js b/src/ol/layer/Base.js index adc0d3da45..d3e6308214 100644 --- a/src/ol/layer/Base.js +++ b/src/ol/layer/Base.js @@ -1,11 +1,11 @@ -goog.provide('ol.layer.Base'); - -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.layer.Property'); -goog.require('ol.math'); -goog.require('ol.obj'); - +/** + * @module ol/layer/Base + */ +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_layer_Property_ from '../layer/Property.js'; +import _ol_math_ from '../math.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -21,23 +21,23 @@ goog.require('ol.obj'); * @param {olx.layer.BaseOptions} options Layer options. * @api */ -ol.layer.Base = function(options) { +var _ol_layer_Base_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @type {Object.} */ - var properties = ol.obj.assign({}, options); - properties[ol.layer.Property.OPACITY] = + var properties = _ol_obj_.assign({}, options); + properties[_ol_layer_Property_.OPACITY] = options.opacity !== undefined ? options.opacity : 1; - properties[ol.layer.Property.VISIBLE] = + properties[_ol_layer_Property_.VISIBLE] = options.visible !== undefined ? options.visible : true; - properties[ol.layer.Property.Z_INDEX] = + properties[_ol_layer_Property_.Z_INDEX] = options.zIndex !== undefined ? options.zIndex : 0; - properties[ol.layer.Property.MAX_RESOLUTION] = + properties[_ol_layer_Property_.MAX_RESOLUTION] = options.maxResolution !== undefined ? options.maxResolution : Infinity; - properties[ol.layer.Property.MIN_RESOLUTION] = + properties[_ol_layer_Property_.MIN_RESOLUTION] = options.minResolution !== undefined ? options.minResolution : 0; this.setProperties(properties); @@ -59,14 +59,15 @@ ol.layer.Base = function(options) { this.type; }; -ol.inherits(ol.layer.Base, ol.Object); + +_ol_.inherits(_ol_layer_Base_, _ol_Object_); /** * Get the layer type (used when creating a layer renderer). * @return {ol.LayerType} The layer type. */ -ol.layer.Base.prototype.getType = function() { +_ol_layer_Base_.prototype.getType = function() { return this.type; }; @@ -74,8 +75,8 @@ ol.layer.Base.prototype.getType = function() { /** * @return {ol.LayerState} Layer state. */ -ol.layer.Base.prototype.getLayerState = function() { - this.state_.opacity = ol.math.clamp(this.getOpacity(), 0, 1); +_ol_layer_Base_.prototype.getLayerState = function() { + this.state_.opacity = _ol_math_.clamp(this.getOpacity(), 0, 1); this.state_.sourceState = this.getSourceState(); this.state_.visible = this.getVisible(); this.state_.extent = this.getExtent(); @@ -93,7 +94,7 @@ ol.layer.Base.prototype.getLayerState = function() { * modified in place). * @return {Array.} Array of layers. */ -ol.layer.Base.prototype.getLayersArray = function(opt_array) {}; +_ol_layer_Base_.prototype.getLayersArray = function(opt_array) {}; /** @@ -102,7 +103,7 @@ ol.layer.Base.prototype.getLayersArray = function(opt_array) {}; * states (to be modified in place). * @return {Array.} List of layer states. */ -ol.layer.Base.prototype.getLayerStatesArray = function(opt_states) {}; +_ol_layer_Base_.prototype.getLayerStatesArray = function(opt_states) {}; /** @@ -112,9 +113,10 @@ ol.layer.Base.prototype.getLayerStatesArray = function(opt_states) {}; * @observable * @api */ -ol.layer.Base.prototype.getExtent = function() { - return /** @type {ol.Extent|undefined} */ ( - this.get(ol.layer.Property.EXTENT)); +_ol_layer_Base_.prototype.getExtent = function() { + return ( + /** @type {ol.Extent|undefined} */ this.get(_ol_layer_Property_.EXTENT) + ); }; @@ -124,9 +126,10 @@ ol.layer.Base.prototype.getExtent = function() { * @observable * @api */ -ol.layer.Base.prototype.getMaxResolution = function() { - return /** @type {number} */ ( - this.get(ol.layer.Property.MAX_RESOLUTION)); +_ol_layer_Base_.prototype.getMaxResolution = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Property_.MAX_RESOLUTION) + ); }; @@ -136,9 +139,10 @@ ol.layer.Base.prototype.getMaxResolution = function() { * @observable * @api */ -ol.layer.Base.prototype.getMinResolution = function() { - return /** @type {number} */ ( - this.get(ol.layer.Property.MIN_RESOLUTION)); +_ol_layer_Base_.prototype.getMinResolution = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Property_.MIN_RESOLUTION) + ); }; @@ -148,8 +152,10 @@ ol.layer.Base.prototype.getMinResolution = function() { * @observable * @api */ -ol.layer.Base.prototype.getOpacity = function() { - return /** @type {number} */ (this.get(ol.layer.Property.OPACITY)); +_ol_layer_Base_.prototype.getOpacity = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Property_.OPACITY) + ); }; @@ -157,7 +163,7 @@ ol.layer.Base.prototype.getOpacity = function() { * @abstract * @return {ol.source.State} Source state. */ -ol.layer.Base.prototype.getSourceState = function() {}; +_ol_layer_Base_.prototype.getSourceState = function() {}; /** @@ -166,8 +172,10 @@ ol.layer.Base.prototype.getSourceState = function() {}; * @observable * @api */ -ol.layer.Base.prototype.getVisible = function() { - return /** @type {boolean} */ (this.get(ol.layer.Property.VISIBLE)); +_ol_layer_Base_.prototype.getVisible = function() { + return ( + /** @type {boolean} */ this.get(_ol_layer_Property_.VISIBLE) + ); }; @@ -178,8 +186,10 @@ ol.layer.Base.prototype.getVisible = function() { * @observable * @api */ -ol.layer.Base.prototype.getZIndex = function() { - return /** @type {number} */ (this.get(ol.layer.Property.Z_INDEX)); +_ol_layer_Base_.prototype.getZIndex = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Property_.Z_INDEX) + ); }; @@ -190,8 +200,8 @@ ol.layer.Base.prototype.getZIndex = function() { * @observable * @api */ -ol.layer.Base.prototype.setExtent = function(extent) { - this.set(ol.layer.Property.EXTENT, extent); +_ol_layer_Base_.prototype.setExtent = function(extent) { + this.set(_ol_layer_Property_.EXTENT, extent); }; @@ -201,8 +211,8 @@ ol.layer.Base.prototype.setExtent = function(extent) { * @observable * @api */ -ol.layer.Base.prototype.setMaxResolution = function(maxResolution) { - this.set(ol.layer.Property.MAX_RESOLUTION, maxResolution); +_ol_layer_Base_.prototype.setMaxResolution = function(maxResolution) { + this.set(_ol_layer_Property_.MAX_RESOLUTION, maxResolution); }; @@ -212,8 +222,8 @@ ol.layer.Base.prototype.setMaxResolution = function(maxResolution) { * @observable * @api */ -ol.layer.Base.prototype.setMinResolution = function(minResolution) { - this.set(ol.layer.Property.MIN_RESOLUTION, minResolution); +_ol_layer_Base_.prototype.setMinResolution = function(minResolution) { + this.set(_ol_layer_Property_.MIN_RESOLUTION, minResolution); }; @@ -223,8 +233,8 @@ ol.layer.Base.prototype.setMinResolution = function(minResolution) { * @observable * @api */ -ol.layer.Base.prototype.setOpacity = function(opacity) { - this.set(ol.layer.Property.OPACITY, opacity); +_ol_layer_Base_.prototype.setOpacity = function(opacity) { + this.set(_ol_layer_Property_.OPACITY, opacity); }; @@ -234,8 +244,8 @@ ol.layer.Base.prototype.setOpacity = function(opacity) { * @observable * @api */ -ol.layer.Base.prototype.setVisible = function(visible) { - this.set(ol.layer.Property.VISIBLE, visible); +_ol_layer_Base_.prototype.setVisible = function(visible) { + this.set(_ol_layer_Property_.VISIBLE, visible); }; @@ -246,6 +256,7 @@ ol.layer.Base.prototype.setVisible = function(visible) { * @observable * @api */ -ol.layer.Base.prototype.setZIndex = function(zindex) { - this.set(ol.layer.Property.Z_INDEX, zindex); +_ol_layer_Base_.prototype.setZIndex = function(zindex) { + this.set(_ol_layer_Property_.Z_INDEX, zindex); }; +export default _ol_layer_Base_; diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index 53cc68dee8..f144c3d47b 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -1,18 +1,18 @@ -goog.provide('ol.layer.Group'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); -goog.require('ol.Object'); -goog.require('ol.ObjectEventType'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.layer.Base'); -goog.require('ol.obj'); -goog.require('ol.source.State'); - +/** + * @module ol/layer/Group + */ +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import _ol_Object_ from '../Object.js'; +import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_layer_Base_ from '../layer/Base.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_State_ from '../source/State.js'; /** * @classdesc @@ -25,16 +25,16 @@ goog.require('ol.source.State'); * @param {olx.layer.GroupOptions=} opt_options Layer options. * @api */ -ol.layer.Group = function(opt_options) { +var _ol_layer_Group_ = function(opt_options) { var options = opt_options || {}; var baseOptions = /** @type {olx.layer.GroupOptions} */ - (ol.obj.assign({}, options)); + (_ol_obj_.assign({}, options)); delete baseOptions.layers; var layers = options.layers; - ol.layer.Base.call(this, baseOptions); + _ol_layer_Base_.call(this, baseOptions); /** * @private @@ -48,32 +48,33 @@ ol.layer.Group = function(opt_options) { */ this.listenerKeys_ = {}; - ol.events.listen(this, - ol.Object.getChangeEventType(ol.layer.Group.Property_.LAYERS), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_layer_Group_.Property_.LAYERS), this.handleLayersChanged_, this); if (layers) { if (Array.isArray(layers)) { - layers = new ol.Collection(layers.slice(), {unique: true}); + layers = new _ol_Collection_(layers.slice(), {unique: true}); } else { - ol.asserts.assert(layers instanceof ol.Collection, + _ol_asserts_.assert(layers instanceof _ol_Collection_, 43); // Expected `layers` to be an array or an `ol.Collection` layers = layers; } } else { - layers = new ol.Collection(undefined, {unique: true}); + layers = new _ol_Collection_(undefined, {unique: true}); } this.setLayers(layers); }; -ol.inherits(ol.layer.Group, ol.layer.Base); + +_ol_.inherits(_ol_layer_Group_, _ol_layer_Base_); /** * @private */ -ol.layer.Group.prototype.handleLayerChange_ = function() { +_ol_layer_Group_.prototype.handleLayerChange_ = function() { this.changed(); }; @@ -82,30 +83,30 @@ ol.layer.Group.prototype.handleLayerChange_ = function() { * @param {ol.events.Event} event Event. * @private */ -ol.layer.Group.prototype.handleLayersChanged_ = function(event) { - this.layersListenerKeys_.forEach(ol.events.unlistenByKey); +_ol_layer_Group_.prototype.handleLayersChanged_ = function(event) { + this.layersListenerKeys_.forEach(_ol_events_.unlistenByKey); this.layersListenerKeys_.length = 0; var layers = this.getLayers(); this.layersListenerKeys_.push( - ol.events.listen(layers, ol.CollectionEventType.ADD, + _ol_events_.listen(layers, _ol_CollectionEventType_.ADD, this.handleLayersAdd_, this), - ol.events.listen(layers, ol.CollectionEventType.REMOVE, + _ol_events_.listen(layers, _ol_CollectionEventType_.REMOVE, this.handleLayersRemove_, this)); for (var id in this.listenerKeys_) { - this.listenerKeys_[id].forEach(ol.events.unlistenByKey); + this.listenerKeys_[id].forEach(_ol_events_.unlistenByKey); } - ol.obj.clear(this.listenerKeys_); + _ol_obj_.clear(this.listenerKeys_); var layersArray = layers.getArray(); var i, ii, layer; for (i = 0, ii = layersArray.length; i < ii; i++) { layer = layersArray[i]; - this.listenerKeys_[ol.getUid(layer).toString()] = [ - ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE, + this.listenerKeys_[_ol_.getUid(layer).toString()] = [ + _ol_events_.listen(layer, _ol_ObjectEventType_.PROPERTYCHANGE, this.handleLayerChange_, this), - ol.events.listen(layer, ol.events.EventType.CHANGE, + _ol_events_.listen(layer, _ol_events_EventType_.CHANGE, this.handleLayerChange_, this) ]; } @@ -118,13 +119,13 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) { * @param {ol.Collection.Event} collectionEvent Collection event. * @private */ -ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) { +_ol_layer_Group_.prototype.handleLayersAdd_ = function(collectionEvent) { var layer = /** @type {ol.layer.Base} */ (collectionEvent.element); - var key = ol.getUid(layer).toString(); + var key = _ol_.getUid(layer).toString(); this.listenerKeys_[key] = [ - ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE, + _ol_events_.listen(layer, _ol_ObjectEventType_.PROPERTYCHANGE, this.handleLayerChange_, this), - ol.events.listen(layer, ol.events.EventType.CHANGE, + _ol_events_.listen(layer, _ol_events_EventType_.CHANGE, this.handleLayerChange_, this) ]; this.changed(); @@ -135,10 +136,10 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) { * @param {ol.Collection.Event} collectionEvent Collection event. * @private */ -ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) { +_ol_layer_Group_.prototype.handleLayersRemove_ = function(collectionEvent) { var layer = /** @type {ol.layer.Base} */ (collectionEvent.element); - var key = ol.getUid(layer).toString(); - this.listenerKeys_[key].forEach(ol.events.unlistenByKey); + var key = _ol_.getUid(layer).toString(); + this.listenerKeys_[key].forEach(_ol_events_.unlistenByKey); delete this.listenerKeys_[key]; this.changed(); }; @@ -152,9 +153,11 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) { * @observable * @api */ -ol.layer.Group.prototype.getLayers = function() { - return /** @type {!ol.Collection.} */ (this.get( - ol.layer.Group.Property_.LAYERS)); +_ol_layer_Group_.prototype.getLayers = function() { + return ( + /** @type {!ol.Collection.} */ this.get( + _ol_layer_Group_.Property_.LAYERS) + ); }; @@ -166,15 +169,15 @@ ol.layer.Group.prototype.getLayers = function() { * @observable * @api */ -ol.layer.Group.prototype.setLayers = function(layers) { - this.set(ol.layer.Group.Property_.LAYERS, layers); +_ol_layer_Group_.prototype.setLayers = function(layers) { + this.set(_ol_layer_Group_.Property_.LAYERS, layers); }; /** * @inheritDoc */ -ol.layer.Group.prototype.getLayersArray = function(opt_array) { +_ol_layer_Group_.prototype.getLayersArray = function(opt_array) { var array = opt_array !== undefined ? opt_array : []; this.getLayers().forEach(function(layer) { layer.getLayersArray(array); @@ -186,7 +189,7 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) { /** * @inheritDoc */ -ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { +_ol_layer_Group_.prototype.getLayerStatesArray = function(opt_states) { var states = opt_states !== undefined ? opt_states : []; var pos = states.length; @@ -207,7 +210,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { layerState.minResolution, ownLayerState.minResolution); if (ownLayerState.extent !== undefined) { if (layerState.extent !== undefined) { - layerState.extent = ol.extent.getIntersection( + layerState.extent = _ol_extent_.getIntersection( layerState.extent, ownLayerState.extent); } else { layerState.extent = ownLayerState.extent; @@ -222,14 +225,15 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { /** * @inheritDoc */ -ol.layer.Group.prototype.getSourceState = function() { - return ol.source.State.READY; +_ol_layer_Group_.prototype.getSourceState = function() { + return _ol_source_State_.READY; }; /** * @enum {string} * @private */ -ol.layer.Group.Property_ = { +_ol_layer_Group_.Property_ = { LAYERS: 'layers' }; +export default _ol_layer_Group_; diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index 6d41d8f72d..57e9729084 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -1,16 +1,16 @@ -goog.provide('ol.layer.Heatmap'); - -goog.require('ol.events'); -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.dom'); -goog.require('ol.layer.Vector'); -goog.require('ol.math'); -goog.require('ol.obj'); -goog.require('ol.render.EventType'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); - +/** + * @module ol/layer/Heatmap + */ +import _ol_events_ from '../events.js'; +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_dom_ from '../dom.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_math_ from '../math.js'; +import _ol_obj_ from '../obj.js'; +import _ol_render_EventType_ from '../render/EventType.js'; +import _ol_style_Icon_ from '../style/Icon.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -25,17 +25,17 @@ goog.require('ol.style.Style'); * @param {olx.layer.HeatmapOptions=} opt_options Options. * @api */ -ol.layer.Heatmap = function(opt_options) { +var _ol_layer_Heatmap_ = function(opt_options) { var options = opt_options ? opt_options : {}; - var baseOptions = ol.obj.assign({}, options); + var baseOptions = _ol_obj_.assign({}, options); delete baseOptions.gradient; delete baseOptions.radius; delete baseOptions.blur; delete baseOptions.shadow; delete baseOptions.weight; - ol.layer.Vector.call(this, /** @type {olx.layer.VectorOptions} */ (baseOptions)); + _ol_layer_Vector_.call(this, /** @type {olx.layer.VectorOptions} */ (baseOptions)); /** * @private @@ -61,22 +61,22 @@ ol.layer.Heatmap = function(opt_options) { */ this.styleCache_ = null; - ol.events.listen(this, - ol.Object.getChangeEventType(ol.layer.Heatmap.Property_.GRADIENT), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.GRADIENT), this.handleGradientChanged_, this); this.setGradient(options.gradient ? - options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT); + options.gradient : _ol_layer_Heatmap_.DEFAULT_GRADIENT); this.setBlur(options.blur !== undefined ? options.blur : 15); this.setRadius(options.radius !== undefined ? options.radius : 8); - ol.events.listen(this, - ol.Object.getChangeEventType(ol.layer.Heatmap.Property_.BLUR), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.BLUR), this.handleStyleChanged_, this); - ol.events.listen(this, - ol.Object.getChangeEventType(ol.layer.Heatmap.Property_.RADIUS), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.RADIUS), this.handleStyleChanged_, this); this.handleStyleChanged_(); @@ -93,14 +93,14 @@ ol.layer.Heatmap = function(opt_options) { this.setStyle(function(feature, resolution) { var weight = weightFunction(feature); - var opacity = weight !== undefined ? ol.math.clamp(weight, 0, 1) : 1; + var opacity = weight !== undefined ? _ol_math_.clamp(weight, 0, 1) : 1; // cast to 8 bits var index = (255 * opacity) | 0; var style = this.styleCache_[index]; if (!style) { style = [ - new ol.style.Style({ - image: new ol.style.Icon({ + new _ol_style_Style_({ + image: new _ol_style_Icon_({ opacity: opacity, src: this.circleImage_ }) @@ -115,16 +115,17 @@ ol.layer.Heatmap = function(opt_options) { // The render order is not relevant for a heatmap representation. this.setRenderOrder(null); - ol.events.listen(this, ol.render.EventType.RENDER, this.handleRender_, this); + _ol_events_.listen(this, _ol_render_EventType_.RENDER, this.handleRender_, this); }; -ol.inherits(ol.layer.Heatmap, ol.layer.Vector); + +_ol_.inherits(_ol_layer_Heatmap_, _ol_layer_Vector_); /** * @const * @type {Array.} */ -ol.layer.Heatmap.DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; +_ol_layer_Heatmap_.DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; /** @@ -132,10 +133,10 @@ ol.layer.Heatmap.DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; * @return {Uint8ClampedArray} An array. * @private */ -ol.layer.Heatmap.createGradient_ = function(colors) { +_ol_layer_Heatmap_.createGradient_ = function(colors) { var width = 1; var height = 256; - var context = ol.dom.createCanvasContext2D(width, height); + var context = _ol_dom_.createCanvasContext2D(width, height); var gradient = context.createLinearGradient(0, 0, width, height); var step = 1 / (colors.length - 1); @@ -154,12 +155,12 @@ ol.layer.Heatmap.createGradient_ = function(colors) { * @return {string} Data URL for a circle. * @private */ -ol.layer.Heatmap.prototype.createCircle_ = function() { +_ol_layer_Heatmap_.prototype.createCircle_ = function() { var radius = this.getRadius(); var blur = this.getBlur(); var halfSize = radius + blur + 1; var size = 2 * halfSize; - var context = ol.dom.createCanvasContext2D(size, size); + var context = _ol_dom_.createCanvasContext2D(size, size); context.shadowOffsetX = context.shadowOffsetY = this.shadow_; context.shadowBlur = blur; context.shadowColor = '#000'; @@ -177,8 +178,10 @@ ol.layer.Heatmap.prototype.createCircle_ = function() { * @api * @observable */ -ol.layer.Heatmap.prototype.getBlur = function() { - return /** @type {number} */ (this.get(ol.layer.Heatmap.Property_.BLUR)); +_ol_layer_Heatmap_.prototype.getBlur = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Heatmap_.Property_.BLUR) + ); }; @@ -188,9 +191,10 @@ ol.layer.Heatmap.prototype.getBlur = function() { * @api * @observable */ -ol.layer.Heatmap.prototype.getGradient = function() { - return /** @type {Array.} */ ( - this.get(ol.layer.Heatmap.Property_.GRADIENT)); +_ol_layer_Heatmap_.prototype.getGradient = function() { + return ( + /** @type {Array.} */ this.get(_ol_layer_Heatmap_.Property_.GRADIENT) + ); }; @@ -200,23 +204,25 @@ ol.layer.Heatmap.prototype.getGradient = function() { * @api * @observable */ -ol.layer.Heatmap.prototype.getRadius = function() { - return /** @type {number} */ (this.get(ol.layer.Heatmap.Property_.RADIUS)); +_ol_layer_Heatmap_.prototype.getRadius = function() { + return ( + /** @type {number} */ this.get(_ol_layer_Heatmap_.Property_.RADIUS) + ); }; /** * @private */ -ol.layer.Heatmap.prototype.handleGradientChanged_ = function() { - this.gradient_ = ol.layer.Heatmap.createGradient_(this.getGradient()); +_ol_layer_Heatmap_.prototype.handleGradientChanged_ = function() { + this.gradient_ = _ol_layer_Heatmap_.createGradient_(this.getGradient()); }; /** * @private */ -ol.layer.Heatmap.prototype.handleStyleChanged_ = function() { +_ol_layer_Heatmap_.prototype.handleStyleChanged_ = function() { this.circleImage_ = this.createCircle_(); this.styleCache_ = new Array(256); this.changed(); @@ -227,7 +233,7 @@ ol.layer.Heatmap.prototype.handleStyleChanged_ = function() { * @param {ol.render.Event} event Post compose event * @private */ -ol.layer.Heatmap.prototype.handleRender_ = function(event) { +_ol_layer_Heatmap_.prototype.handleRender_ = function(event) { var context = event.context; var canvas = context.canvas; var image = context.getImageData(0, 0, canvas.width, canvas.height); @@ -251,8 +257,8 @@ ol.layer.Heatmap.prototype.handleRender_ = function(event) { * @api * @observable */ -ol.layer.Heatmap.prototype.setBlur = function(blur) { - this.set(ol.layer.Heatmap.Property_.BLUR, blur); +_ol_layer_Heatmap_.prototype.setBlur = function(blur) { + this.set(_ol_layer_Heatmap_.Property_.BLUR, blur); }; @@ -262,8 +268,8 @@ ol.layer.Heatmap.prototype.setBlur = function(blur) { * @api * @observable */ -ol.layer.Heatmap.prototype.setGradient = function(colors) { - this.set(ol.layer.Heatmap.Property_.GRADIENT, colors); +_ol_layer_Heatmap_.prototype.setGradient = function(colors) { + this.set(_ol_layer_Heatmap_.Property_.GRADIENT, colors); }; @@ -273,8 +279,8 @@ ol.layer.Heatmap.prototype.setGradient = function(colors) { * @api * @observable */ -ol.layer.Heatmap.prototype.setRadius = function(radius) { - this.set(ol.layer.Heatmap.Property_.RADIUS, radius); +_ol_layer_Heatmap_.prototype.setRadius = function(radius) { + this.set(_ol_layer_Heatmap_.Property_.RADIUS, radius); }; @@ -282,8 +288,9 @@ ol.layer.Heatmap.prototype.setRadius = function(radius) { * @enum {string} * @private */ -ol.layer.Heatmap.Property_ = { +_ol_layer_Heatmap_.Property_ = { BLUR: 'blur', GRADIENT: 'gradient', RADIUS: 'radius' }; +export default _ol_layer_Heatmap_; diff --git a/src/ol/layer/Image.js b/src/ol/layer/Image.js index 9efa10dfbe..35de5b8d42 100644 --- a/src/ol/layer/Image.js +++ b/src/ol/layer/Image.js @@ -1,9 +1,9 @@ -goog.provide('ol.layer.Image'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.layer.Layer'); - +/** + * @module ol/layer/Image + */ +import _ol_ from '../index.js'; +import _ol_LayerType_ from '../LayerType.js'; +import _ol_layer_Layer_ from '../layer/Layer.js'; /** * @classdesc @@ -19,19 +19,20 @@ goog.require('ol.layer.Layer'); * @param {olx.layer.ImageOptions=} opt_options Layer options. * @api */ -ol.layer.Image = function(opt_options) { +var _ol_layer_Image_ = function(opt_options) { var options = opt_options ? opt_options : {}; - ol.layer.Layer.call(this, /** @type {olx.layer.LayerOptions} */ (options)); + _ol_layer_Layer_.call(this, /** @type {olx.layer.LayerOptions} */ (options)); /** * The layer type. * @protected * @type {ol.LayerType} */ - this.type = ol.LayerType.IMAGE; + this.type = _ol_LayerType_.IMAGE; }; -ol.inherits(ol.layer.Image, ol.layer.Layer); + +_ol_.inherits(_ol_layer_Image_, _ol_layer_Layer_); /** @@ -40,4 +41,5 @@ ol.inherits(ol.layer.Image, ol.layer.Layer); * @return {ol.source.Image} Source. * @api */ -ol.layer.Image.prototype.getSource; +_ol_layer_Image_.prototype.getSource; +export default _ol_layer_Image_; diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index 2e3089012b..a850da96fb 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -1,15 +1,15 @@ -goog.provide('ol.layer.Layer'); - -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol'); -goog.require('ol.Object'); -goog.require('ol.layer.Base'); -goog.require('ol.layer.Property'); -goog.require('ol.obj'); -goog.require('ol.render.EventType'); -goog.require('ol.source.State'); - +/** + * @module ol/layer/Layer + */ +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_ from '../index.js'; +import _ol_Object_ from '../Object.js'; +import _ol_layer_Base_ from '../layer/Base.js'; +import _ol_layer_Property_ from '../layer/Property.js'; +import _ol_obj_ from '../obj.js'; +import _ol_render_EventType_ from '../render/EventType.js'; +import _ol_source_State_ from '../source/State.js'; /** * @classdesc @@ -33,12 +33,12 @@ goog.require('ol.source.State'); * @param {olx.layer.LayerOptions} options Layer options. * @api */ -ol.layer.Layer = function(options) { +var _ol_layer_Layer_ = function(options) { - var baseOptions = ol.obj.assign({}, options); + var baseOptions = _ol_obj_.assign({}, options); delete baseOptions.source; - ol.layer.Base.call(this, /** @type {olx.layer.BaseOptions} */ (baseOptions)); + _ol_layer_Base_.call(this, /** @type {olx.layer.BaseOptions} */ (baseOptions)); /** * @private @@ -62,14 +62,15 @@ ol.layer.Layer = function(options) { this.setMap(options.map); } - ol.events.listen(this, - ol.Object.getChangeEventType(ol.layer.Property.SOURCE), + _ol_events_.listen(this, + _ol_Object_.getChangeEventType(_ol_layer_Property_.SOURCE), this.handleSourcePropertyChange_, this); var source = options.source ? options.source : null; this.setSource(source); }; -ol.inherits(ol.layer.Layer, ol.layer.Base); + +_ol_.inherits(_ol_layer_Layer_, _ol_layer_Base_); /** @@ -80,7 +81,7 @@ ol.inherits(ol.layer.Layer, ol.layer.Base); * @param {number} resolution Resolution. * @return {boolean} The layer is visible at the given resolution. */ -ol.layer.Layer.visibleAtResolution = function(layerState, resolution) { +_ol_layer_Layer_.visibleAtResolution = function(layerState, resolution) { return layerState.visible && resolution >= layerState.minResolution && resolution < layerState.maxResolution; }; @@ -89,7 +90,7 @@ ol.layer.Layer.visibleAtResolution = function(layerState, resolution) { /** * @inheritDoc */ -ol.layer.Layer.prototype.getLayersArray = function(opt_array) { +_ol_layer_Layer_.prototype.getLayersArray = function(opt_array) { var array = opt_array ? opt_array : []; array.push(this); return array; @@ -99,7 +100,7 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) { /** * @inheritDoc */ -ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { +_ol_layer_Layer_.prototype.getLayerStatesArray = function(opt_states) { var states = opt_states ? opt_states : []; states.push(this.getLayerState()); return states; @@ -112,8 +113,8 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { * @observable * @api */ -ol.layer.Layer.prototype.getSource = function() { - var source = this.get(ol.layer.Property.SOURCE); +_ol_layer_Layer_.prototype.getSource = function() { + var source = this.get(_ol_layer_Property_.SOURCE); return /** @type {ol.source.Source} */ (source) || null; }; @@ -121,16 +122,16 @@ ol.layer.Layer.prototype.getSource = function() { /** * @inheritDoc */ -ol.layer.Layer.prototype.getSourceState = function() { +_ol_layer_Layer_.prototype.getSourceState = function() { var source = this.getSource(); - return !source ? ol.source.State.UNDEFINED : source.getState(); + return !source ? _ol_source_State_.UNDEFINED : source.getState(); }; /** * @private */ -ol.layer.Layer.prototype.handleSourceChange_ = function() { +_ol_layer_Layer_.prototype.handleSourceChange_ = function() { this.changed(); }; @@ -138,15 +139,15 @@ ol.layer.Layer.prototype.handleSourceChange_ = function() { /** * @private */ -ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() { +_ol_layer_Layer_.prototype.handleSourcePropertyChange_ = function() { if (this.sourceChangeKey_) { - ol.events.unlistenByKey(this.sourceChangeKey_); + _ol_events_.unlistenByKey(this.sourceChangeKey_); this.sourceChangeKey_ = null; } var source = this.getSource(); if (source) { - this.sourceChangeKey_ = ol.events.listen(source, - ol.events.EventType.CHANGE, this.handleSourceChange_, this); + this.sourceChangeKey_ = _ol_events_.listen(source, + _ol_events_EventType_.CHANGE, this.handleSourceChange_, this); } this.changed(); }; @@ -164,29 +165,29 @@ ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() { * @param {ol.PluggableMap} map Map. * @api */ -ol.layer.Layer.prototype.setMap = function(map) { +_ol_layer_Layer_.prototype.setMap = function(map) { if (this.mapPrecomposeKey_) { - ol.events.unlistenByKey(this.mapPrecomposeKey_); + _ol_events_.unlistenByKey(this.mapPrecomposeKey_); this.mapPrecomposeKey_ = null; } if (!map) { this.changed(); } if (this.mapRenderKey_) { - ol.events.unlistenByKey(this.mapRenderKey_); + _ol_events_.unlistenByKey(this.mapRenderKey_); this.mapRenderKey_ = null; } if (map) { - this.mapPrecomposeKey_ = ol.events.listen( - map, ol.render.EventType.PRECOMPOSE, function(evt) { + this.mapPrecomposeKey_ = _ol_events_.listen( + map, _ol_render_EventType_.PRECOMPOSE, function(evt) { var layerState = this.getLayerState(); layerState.managed = false; layerState.zIndex = Infinity; evt.frameState.layerStatesArray.push(layerState); - evt.frameState.layerStates[ol.getUid(this)] = layerState; + evt.frameState.layerStates[_ol_.getUid(this)] = layerState; }, this); - this.mapRenderKey_ = ol.events.listen( - this, ol.events.EventType.CHANGE, map.render, map); + this.mapRenderKey_ = _ol_events_.listen( + this, _ol_events_EventType_.CHANGE, map.render, map); this.changed(); } }; @@ -198,6 +199,7 @@ ol.layer.Layer.prototype.setMap = function(map) { * @observable * @api */ -ol.layer.Layer.prototype.setSource = function(source) { - this.set(ol.layer.Property.SOURCE, source); +_ol_layer_Layer_.prototype.setSource = function(source) { + this.set(_ol_layer_Property_.SOURCE, source); }; +export default _ol_layer_Layer_; diff --git a/src/ol/layer/Property.js b/src/ol/layer/Property.js index 5fa8038691..9714dd31a9 100644 --- a/src/ol/layer/Property.js +++ b/src/ol/layer/Property.js @@ -1,9 +1,10 @@ -goog.provide('ol.layer.Property'); - +/** + * @module ol/layer/Property + */ /** * @enum {string} */ -ol.layer.Property = { +var _ol_layer_Property_ = { OPACITY: 'opacity', VISIBLE: 'visible', EXTENT: 'extent', @@ -12,3 +13,5 @@ ol.layer.Property = { MIN_RESOLUTION: 'minResolution', SOURCE: 'source' }; + +export default _ol_layer_Property_; diff --git a/src/ol/layer/Tile.js b/src/ol/layer/Tile.js index 61c70f443a..808543d4d4 100644 --- a/src/ol/layer/Tile.js +++ b/src/ol/layer/Tile.js @@ -1,11 +1,11 @@ -goog.provide('ol.layer.Tile'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.layer.Layer'); -goog.require('ol.layer.TileProperty'); -goog.require('ol.obj'); - +/** + * @module ol/layer/Tile + */ +import _ol_ from '../index.js'; +import _ol_LayerType_ from '../LayerType.js'; +import _ol_layer_Layer_ from '../layer/Layer.js'; +import _ol_layer_TileProperty_ from '../layer/TileProperty.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -21,14 +21,14 @@ goog.require('ol.obj'); * @param {olx.layer.TileOptions=} opt_options Tile layer options. * @api */ -ol.layer.Tile = function(opt_options) { +var _ol_layer_Tile_ = function(opt_options) { var options = opt_options ? opt_options : {}; - var baseOptions = ol.obj.assign({}, options); + var baseOptions = _ol_obj_.assign({}, options); delete baseOptions.preload; delete baseOptions.useInterimTilesOnError; - ol.layer.Layer.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); + _ol_layer_Layer_.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); this.setPreload(options.preload !== undefined ? options.preload : 0); this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ? @@ -39,10 +39,11 @@ ol.layer.Tile = function(opt_options) { * @protected * @type {ol.LayerType} */ - this.type = ol.LayerType.TILE; + this.type = _ol_LayerType_.TILE; }; -ol.inherits(ol.layer.Tile, ol.layer.Layer); + +_ol_.inherits(_ol_layer_Tile_, _ol_layer_Layer_); /** @@ -51,8 +52,10 @@ ol.inherits(ol.layer.Tile, ol.layer.Layer); * @observable * @api */ -ol.layer.Tile.prototype.getPreload = function() { - return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD)); +_ol_layer_Tile_.prototype.getPreload = function() { + return ( + /** @type {number} */ this.get(_ol_layer_TileProperty_.PRELOAD) + ); }; @@ -62,7 +65,7 @@ ol.layer.Tile.prototype.getPreload = function() { * @return {ol.source.Tile} Source. * @api */ -ol.layer.Tile.prototype.getSource; +_ol_layer_Tile_.prototype.getSource; /** @@ -71,8 +74,8 @@ ol.layer.Tile.prototype.getSource; * @observable * @api */ -ol.layer.Tile.prototype.setPreload = function(preload) { - this.set(ol.layer.TileProperty.PRELOAD, preload); +_ol_layer_Tile_.prototype.setPreload = function(preload) { + this.set(_ol_layer_TileProperty_.PRELOAD, preload); }; @@ -82,9 +85,10 @@ ol.layer.Tile.prototype.setPreload = function(preload) { * @observable * @api */ -ol.layer.Tile.prototype.getUseInterimTilesOnError = function() { - return /** @type {boolean} */ ( - this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR)); +_ol_layer_Tile_.prototype.getUseInterimTilesOnError = function() { + return ( + /** @type {boolean} */ this.get(_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR) + ); }; @@ -94,7 +98,8 @@ ol.layer.Tile.prototype.getUseInterimTilesOnError = function() { * @observable * @api */ -ol.layer.Tile.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { +_ol_layer_Tile_.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { this.set( - ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError); + _ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError); }; +export default _ol_layer_Tile_; diff --git a/src/ol/layer/TileProperty.js b/src/ol/layer/TileProperty.js index 71cba03390..53390f7349 100644 --- a/src/ol/layer/TileProperty.js +++ b/src/ol/layer/TileProperty.js @@ -1,9 +1,12 @@ -goog.provide('ol.layer.TileProperty'); - +/** + * @module ol/layer/TileProperty + */ /** * @enum {string} */ -ol.layer.TileProperty = { +var _ol_layer_TileProperty_ = { PRELOAD: 'preload', USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError' }; + +export default _ol_layer_TileProperty_; diff --git a/src/ol/layer/Vector.js b/src/ol/layer/Vector.js index 34674ff02a..5954f0892b 100644 --- a/src/ol/layer/Vector.js +++ b/src/ol/layer/Vector.js @@ -1,12 +1,12 @@ -goog.provide('ol.layer.Vector'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.layer.Layer'); -goog.require('ol.layer.VectorRenderType'); -goog.require('ol.obj'); -goog.require('ol.style.Style'); - +/** + * @module ol/layer/Vector + */ +import _ol_ from '../index.js'; +import _ol_LayerType_ from '../LayerType.js'; +import _ol_layer_Layer_ from '../layer/Layer.js'; +import _ol_layer_VectorRenderType_ from '../layer/VectorRenderType.js'; +import _ol_obj_ from '../obj.js'; +import _ol_style_Style_ from '../style/Style.js'; /** * @classdesc @@ -21,17 +21,17 @@ goog.require('ol.style.Style'); * @param {olx.layer.VectorOptions=} opt_options Options. * @api */ -ol.layer.Vector = function(opt_options) { +var _ol_layer_Vector_ = function(opt_options) { var options = opt_options ? opt_options : /** @type {olx.layer.VectorOptions} */ ({}); - var baseOptions = ol.obj.assign({}, options); + var baseOptions = _ol_obj_.assign({}, options); delete baseOptions.style; delete baseOptions.renderBuffer; delete baseOptions.updateWhileAnimating; delete baseOptions.updateWhileInteracting; - ol.layer.Layer.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); + _ol_layer_Layer_.call(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); /** * @private @@ -80,23 +80,24 @@ ol.layer.Vector = function(opt_options) { * @private * @type {ol.layer.VectorTileRenderType|string} */ - this.renderMode_ = options.renderMode || ol.layer.VectorRenderType.VECTOR; + this.renderMode_ = options.renderMode || _ol_layer_VectorRenderType_.VECTOR; /** * The layer type. * @protected * @type {ol.LayerType} */ - this.type = ol.LayerType.VECTOR; + this.type = _ol_LayerType_.VECTOR; }; -ol.inherits(ol.layer.Vector, ol.layer.Layer); + +_ol_.inherits(_ol_layer_Vector_, _ol_layer_Layer_); /** * @return {boolean} Declutter. */ -ol.layer.Vector.prototype.getDeclutter = function() { +_ol_layer_Vector_.prototype.getDeclutter = function() { return this.declutter_; }; @@ -104,7 +105,7 @@ ol.layer.Vector.prototype.getDeclutter = function() { /** * @param {boolean} declutter Declutter. */ -ol.layer.Vector.prototype.setDeclutter = function(declutter) { +_ol_layer_Vector_.prototype.setDeclutter = function(declutter) { this.declutter_ = declutter; }; @@ -112,7 +113,7 @@ ol.layer.Vector.prototype.setDeclutter = function(declutter) { /** * @return {number|undefined} Render buffer. */ -ol.layer.Vector.prototype.getRenderBuffer = function() { +_ol_layer_Vector_.prototype.getRenderBuffer = function() { return this.renderBuffer_; }; @@ -121,9 +122,10 @@ ol.layer.Vector.prototype.getRenderBuffer = function() { * @return {function(ol.Feature, ol.Feature): number|null|undefined} Render * order. */ -ol.layer.Vector.prototype.getRenderOrder = function() { - return /** @type {ol.RenderOrderFunction|null|undefined} */ ( - this.get(ol.layer.Vector.Property_.RENDER_ORDER)); +_ol_layer_Vector_.prototype.getRenderOrder = function() { + return ( + /** @type {ol.RenderOrderFunction|null|undefined} */ this.get(_ol_layer_Vector_.Property_.RENDER_ORDER) + ); }; @@ -133,7 +135,7 @@ ol.layer.Vector.prototype.getRenderOrder = function() { * @return {ol.source.Vector} Source. * @api */ -ol.layer.Vector.prototype.getSource; +_ol_layer_Vector_.prototype.getSource; /** @@ -143,7 +145,7 @@ ol.layer.Vector.prototype.getSource; * Layer style. * @api */ -ol.layer.Vector.prototype.getStyle = function() { +_ol_layer_Vector_.prototype.getStyle = function() { return this.style_; }; @@ -153,7 +155,7 @@ ol.layer.Vector.prototype.getStyle = function() { * @return {ol.StyleFunction|undefined} Layer style function. * @api */ -ol.layer.Vector.prototype.getStyleFunction = function() { +_ol_layer_Vector_.prototype.getStyleFunction = function() { return this.styleFunction_; }; @@ -162,7 +164,7 @@ ol.layer.Vector.prototype.getStyleFunction = function() { * @return {boolean} Whether the rendered layer should be updated while * animating. */ -ol.layer.Vector.prototype.getUpdateWhileAnimating = function() { +_ol_layer_Vector_.prototype.getUpdateWhileAnimating = function() { return this.updateWhileAnimating_; }; @@ -171,7 +173,7 @@ ol.layer.Vector.prototype.getUpdateWhileAnimating = function() { * @return {boolean} Whether the rendered layer should be updated while * interacting. */ -ol.layer.Vector.prototype.getUpdateWhileInteracting = function() { +_ol_layer_Vector_.prototype.getUpdateWhileInteracting = function() { return this.updateWhileInteracting_; }; @@ -180,8 +182,8 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() { * @param {ol.RenderOrderFunction|null|undefined} renderOrder * Render order. */ -ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { - this.set(ol.layer.Vector.Property_.RENDER_ORDER, renderOrder); +_ol_layer_Vector_.prototype.setRenderOrder = function(renderOrder) { + this.set(_ol_layer_Vector_.Property_.RENDER_ORDER, renderOrder); }; @@ -196,10 +198,10 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { * style Layer style. * @api */ -ol.layer.Vector.prototype.setStyle = function(style) { - this.style_ = style !== undefined ? style : ol.style.Style.defaultFunction; +_ol_layer_Vector_.prototype.setStyle = function(style) { + this.style_ = style !== undefined ? style : _ol_style_Style_.defaultFunction; this.styleFunction_ = style === null ? - undefined : ol.style.Style.createFunction(this.style_); + undefined : _ol_style_Style_.createFunction(this.style_); this.changed(); }; @@ -207,7 +209,7 @@ ol.layer.Vector.prototype.setStyle = function(style) { /** * @return {ol.layer.VectorRenderType|string} The render mode. */ -ol.layer.Vector.prototype.getRenderMode = function() { +_ol_layer_Vector_.prototype.getRenderMode = function() { return this.renderMode_; }; @@ -216,6 +218,7 @@ ol.layer.Vector.prototype.getRenderMode = function() { * @enum {string} * @private */ -ol.layer.Vector.Property_ = { +_ol_layer_Vector_.Property_ = { RENDER_ORDER: 'renderOrder' }; +export default _ol_layer_Vector_; diff --git a/src/ol/layer/VectorRenderType.js b/src/ol/layer/VectorRenderType.js index 4f8d79955c..4f17c4862a 100644 --- a/src/ol/layer/VectorRenderType.js +++ b/src/ol/layer/VectorRenderType.js @@ -1,5 +1,6 @@ -goog.provide('ol.layer.VectorRenderType'); - +/** + * @module ol/layer/VectorRenderType + */ /** * @enum {string} * Render mode for vector layers: @@ -10,7 +11,9 @@ goog.provide('ol.layer.VectorRenderType'); * even during animations, but slower performance. * @api */ -ol.layer.VectorRenderType = { +var _ol_layer_VectorRenderType_ = { IMAGE: 'image', VECTOR: 'vector' }; + +export default _ol_layer_VectorRenderType_; diff --git a/src/ol/layer/VectorTile.js b/src/ol/layer/VectorTile.js index 5fc5028689..edbe026e54 100644 --- a/src/ol/layer/VectorTile.js +++ b/src/ol/layer/VectorTile.js @@ -1,13 +1,13 @@ -goog.provide('ol.layer.VectorTile'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.asserts'); -goog.require('ol.layer.TileProperty'); -goog.require('ol.layer.Vector'); -goog.require('ol.layer.VectorTileRenderType'); -goog.require('ol.obj'); - +/** + * @module ol/layer/VectorTile + */ +import _ol_ from '../index.js'; +import _ol_LayerType_ from '../LayerType.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_layer_TileProperty_ from '../layer/TileProperty.js'; +import _ol_layer_Vector_ from '../layer/Vector.js'; +import _ol_layer_VectorTileRenderType_ from '../layer/VectorTileRenderType.js'; +import _ol_obj_ from '../obj.js'; /** * @classdesc @@ -21,25 +21,25 @@ goog.require('ol.obj'); * @param {olx.layer.VectorTileOptions=} opt_options Options. * @api */ -ol.layer.VectorTile = function(opt_options) { +var _ol_layer_VectorTile_ = function(opt_options) { var options = opt_options ? opt_options : {}; - var renderMode = options.renderMode || ol.layer.VectorTileRenderType.HYBRID; - ol.asserts.assert(renderMode == undefined || - renderMode == ol.layer.VectorTileRenderType.IMAGE || - renderMode == ol.layer.VectorTileRenderType.HYBRID || - renderMode == ol.layer.VectorTileRenderType.VECTOR, + var renderMode = options.renderMode || _ol_layer_VectorTileRenderType_.HYBRID; + _ol_asserts_.assert(renderMode == undefined || + renderMode == _ol_layer_VectorTileRenderType_.IMAGE || + renderMode == _ol_layer_VectorTileRenderType_.HYBRID || + renderMode == _ol_layer_VectorTileRenderType_.VECTOR, 28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'` - if (options.declutter && renderMode == ol.layer.VectorTileRenderType.IMAGE) { - renderMode = ol.layer.VectorTileRenderType.HYBRID; + if (options.declutter && renderMode == _ol_layer_VectorTileRenderType_.IMAGE) { + renderMode = _ol_layer_VectorTileRenderType_.HYBRID; } options.renderMode = renderMode; - var baseOptions = ol.obj.assign({}, options); + var baseOptions = _ol_obj_.assign({}, options); delete baseOptions.preload; delete baseOptions.useInterimTilesOnError; - ol.layer.Vector.call(this, /** @type {olx.layer.VectorOptions} */ (baseOptions)); + _ol_layer_Vector_.call(this, /** @type {olx.layer.VectorOptions} */ (baseOptions)); this.setPreload(options.preload ? options.preload : 0); this.setUseInterimTilesOnError(options.useInterimTilesOnError ? @@ -50,10 +50,11 @@ ol.layer.VectorTile = function(opt_options) { * @protected * @type {ol.LayerType} */ - this.type = ol.LayerType.VECTOR_TILE; + this.type = _ol_LayerType_.VECTOR_TILE; }; -ol.inherits(ol.layer.VectorTile, ol.layer.Vector); + +_ol_.inherits(_ol_layer_VectorTile_, _ol_layer_Vector_); /** @@ -62,8 +63,10 @@ ol.inherits(ol.layer.VectorTile, ol.layer.Vector); * @observable * @api */ -ol.layer.VectorTile.prototype.getPreload = function() { - return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD)); +_ol_layer_VectorTile_.prototype.getPreload = function() { + return ( + /** @type {number} */ this.get(_ol_layer_TileProperty_.PRELOAD) + ); }; @@ -73,9 +76,10 @@ ol.layer.VectorTile.prototype.getPreload = function() { * @observable * @api */ -ol.layer.VectorTile.prototype.getUseInterimTilesOnError = function() { - return /** @type {boolean} */ ( - this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR)); +_ol_layer_VectorTile_.prototype.getUseInterimTilesOnError = function() { + return ( + /** @type {boolean} */ this.get(_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR) + ); }; @@ -85,8 +89,8 @@ ol.layer.VectorTile.prototype.getUseInterimTilesOnError = function() { * @observable * @api */ -ol.layer.VectorTile.prototype.setPreload = function(preload) { - this.set(ol.layer.TileProperty.PRELOAD, preload); +_ol_layer_VectorTile_.prototype.setPreload = function(preload) { + this.set(_ol_layer_TileProperty_.PRELOAD, preload); }; @@ -96,9 +100,9 @@ ol.layer.VectorTile.prototype.setPreload = function(preload) { * @observable * @api */ -ol.layer.VectorTile.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { +_ol_layer_VectorTile_.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { this.set( - ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError); + _ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError); }; @@ -108,4 +112,5 @@ ol.layer.VectorTile.prototype.setUseInterimTilesOnError = function(useInterimTil * @return {ol.source.VectorTile} Source. * @api */ -ol.layer.VectorTile.prototype.getSource; +_ol_layer_VectorTile_.prototype.getSource; +export default _ol_layer_VectorTile_; diff --git a/src/ol/layer/VectorTileRenderType.js b/src/ol/layer/VectorTileRenderType.js index af95924c26..d8c96053a1 100644 --- a/src/ol/layer/VectorTileRenderType.js +++ b/src/ol/layer/VectorTileRenderType.js @@ -1,5 +1,6 @@ -goog.provide('ol.layer.VectorTileRenderType'); - +/** + * @module ol/layer/VectorTileRenderType + */ /** * @enum {string} * Render mode for vector tiles: @@ -13,8 +14,10 @@ goog.provide('ol.layer.VectorTileRenderType'); * even during animations, but slower performance than the other options. * @api */ -ol.layer.VectorTileRenderType = { +var _ol_layer_VectorTileRenderType_ = { IMAGE: 'image', HYBRID: 'hybrid', VECTOR: 'vector' }; + +export default _ol_layer_VectorTileRenderType_; diff --git a/src/ol/loadingstrategy.js b/src/ol/loadingstrategy.js index c545d791f7..5ff4dddef7 100644 --- a/src/ol/loadingstrategy.js +++ b/src/ol/loadingstrategy.js @@ -1,4 +1,7 @@ -goog.provide('ol.loadingstrategy'); +/** + * @module ol/loadingstrategy + */ +var _ol_loadingstrategy_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.loadingstrategy'); * @return {Array.} Extents. * @api */ -ol.loadingstrategy.all = function(extent, resolution) { +_ol_loadingstrategy_.all = function(extent, resolution) { return [[-Infinity, -Infinity, Infinity, Infinity]]; }; @@ -21,7 +24,7 @@ ol.loadingstrategy.all = function(extent, resolution) { * @return {Array.} Extents. * @api */ -ol.loadingstrategy.bbox = function(extent, resolution) { +_ol_loadingstrategy_.bbox = function(extent, resolution) { return [extent]; }; @@ -32,7 +35,7 @@ ol.loadingstrategy.bbox = function(extent, resolution) { * @return {function(ol.Extent, number): Array.} Loading strategy. * @api */ -ol.loadingstrategy.tile = function(tileGrid) { +_ol_loadingstrategy_.tile = function(tileGrid) { return ( /** * @param {ol.Extent} extent Extent. @@ -56,3 +59,4 @@ ol.loadingstrategy.tile = function(tileGrid) { return extents; }); }; +export default _ol_loadingstrategy_; diff --git a/src/ol/math.js b/src/ol/math.js index c844544cc0..a1aba72bb7 100644 --- a/src/ol/math.js +++ b/src/ol/math.js @@ -1,6 +1,8 @@ -goog.provide('ol.math'); - -goog.require('ol.asserts'); +/** + * @module ol/math + */ +import _ol_asserts_ from './asserts.js'; +var _ol_math_ = {}; /** @@ -11,7 +13,7 @@ goog.require('ol.asserts'); * @return {number} The input number if it is within bounds, or the nearest * number within the bounds. */ -ol.math.clamp = function(value, min, max) { +_ol_math_.clamp = function(value, min, max) { return Math.min(Math.max(value, min), max); }; @@ -25,7 +27,7 @@ ol.math.clamp = function(value, min, max) { * @param {number} x X. * @return {number} Hyperbolic cosine of x. */ -ol.math.cosh = (function() { +_ol_math_.cosh = (function() { // Wrapped in a iife, to save the overhead of checking for the native // implementation on every invocation. var cosh; @@ -47,8 +49,8 @@ ol.math.cosh = (function() { * @param {number} x X. * @return {number} The smallest power of two greater than or equal to x. */ -ol.math.roundUpToPowerOfTwo = function(x) { - ol.asserts.assert(0 < x, 29); // `x` must be greater than `0` +_ol_math_.roundUpToPowerOfTwo = function(x) { + _ol_asserts_.assert(0 < x, 29); // `x` must be greater than `0` return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2)); }; @@ -64,7 +66,7 @@ ol.math.roundUpToPowerOfTwo = function(x) { * @param {number} y2 Y2. * @return {number} Squared distance. */ -ol.math.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) { +_ol_math_.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; if (dx !== 0 || dy !== 0) { @@ -77,7 +79,7 @@ ol.math.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) { y1 += dy * t; } } - return ol.math.squaredDistance(x, y, x1, y1); + return _ol_math_.squaredDistance(x, y, x1, y1); }; @@ -89,7 +91,7 @@ ol.math.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) { * @param {number} y2 Y2. * @return {number} Squared distance. */ -ol.math.squaredDistance = function(x1, y1, x2, y2) { +_ol_math_.squaredDistance = function(x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; return dx * dx + dy * dy; @@ -103,7 +105,7 @@ ol.math.squaredDistance = function(x1, y1, x2, y2) { * in row-major order. * @return {Array.} The resulting vector. */ -ol.math.solveLinearSystem = function(mat) { +_ol_math_.solveLinearSystem = function(mat) { var n = mat.length; for (var i = 0; i < n; i++) { @@ -158,7 +160,7 @@ ol.math.solveLinearSystem = function(mat) { * @param {number} angleInRadians Angle in radians. * @return {number} Angle in degrees. */ -ol.math.toDegrees = function(angleInRadians) { +_ol_math_.toDegrees = function(angleInRadians) { return angleInRadians * 180 / Math.PI; }; @@ -169,7 +171,7 @@ ol.math.toDegrees = function(angleInRadians) { * @param {number} angleInDegrees Angle in degrees. * @return {number} Angle in radians. */ -ol.math.toRadians = function(angleInDegrees) { +_ol_math_.toRadians = function(angleInDegrees) { return angleInDegrees * Math.PI / 180; }; @@ -180,7 +182,7 @@ ol.math.toRadians = function(angleInDegrees) { * @param {number} b Divisor. * @return {number} Modulo. */ -ol.math.modulo = function(a, b) { +_ol_math_.modulo = function(a, b) { var r = a % b; return r * b < 0 ? r + b : r; }; @@ -193,6 +195,7 @@ ol.math.modulo = function(a, b) { * @param {number} x Value to be interpolated. * @return {number} Interpolated value. */ -ol.math.lerp = function(a, b, x) { +_ol_math_.lerp = function(a, b, x) { return a + x * (b - a); }; +export default _ol_math_; diff --git a/src/ol/net.js b/src/ol/net.js index 0fe398d97a..c1ba1812af 100644 --- a/src/ol/net.js +++ b/src/ol/net.js @@ -1,6 +1,8 @@ -goog.provide('ol.net'); - -goog.require('ol'); +/** + * @module ol/net + */ +import _ol_ from './index.js'; +var _ol_net_ = {}; /** @@ -14,9 +16,9 @@ goog.require('ol'); * @param {string=} opt_callbackParam Custom query parameter for the JSONP * callback. Default is 'callback'. */ -ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) { +_ol_net_.jsonp = function(url, callback, opt_errback, opt_callbackParam) { var script = document.createElement('script'); - var key = 'olc_' + ol.getUid(callback); + var key = 'olc_' + _ol_.getUid(callback); function cleanup() { delete window[key]; script.parentNode.removeChild(script); @@ -37,3 +39,4 @@ ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) { }; document.getElementsByTagName('head')[0].appendChild(script); }; +export default _ol_net_; diff --git a/src/ol/obj.js b/src/ol/obj.js index 5549b373dc..0099dfe816 100644 --- a/src/ol/obj.js +++ b/src/ol/obj.js @@ -1,4 +1,7 @@ -goog.provide('ol.obj'); +/** + * @module ol/obj + */ +var _ol_obj_ = {}; /** @@ -10,7 +13,7 @@ goog.provide('ol.obj'); * @param {...Object} var_sources The source object(s). * @return {!Object} The modified target object. */ -ol.obj.assign = (typeof Object.assign === 'function') ? Object.assign : function(target, var_sources) { +_ol_obj_.assign = (typeof Object.assign === 'function') ? Object.assign : function(target, var_sources) { if (target === undefined || target === null) { throw new TypeError('Cannot convert undefined or null to object'); } @@ -34,7 +37,7 @@ ol.obj.assign = (typeof Object.assign === 'function') ? Object.assign : function * Removes all properties from an object. * @param {Object} object The object to clear. */ -ol.obj.clear = function(object) { +_ol_obj_.clear = function(object) { for (var property in object) { delete object[property]; } @@ -47,7 +50,7 @@ ol.obj.clear = function(object) { * @return {!Array} The property values. * @template K,V */ -ol.obj.getValues = function(object) { +_ol_obj_.getValues = function(object) { var values = []; for (var property in object) { values.push(object[property]); @@ -61,10 +64,11 @@ ol.obj.getValues = function(object) { * @param {Object} object The object to check. * @return {boolean} The object is empty. */ -ol.obj.isEmpty = function(object) { +_ol_obj_.isEmpty = function(object) { var property; for (property in object) { return false; } return !property; }; +export default _ol_obj_; diff --git a/src/ol/plugins.js b/src/ol/plugins.js index 8ad12f1d42..c781d71041 100644 --- a/src/ol/plugins.js +++ b/src/ol/plugins.js @@ -1,21 +1,23 @@ -goog.provide('ol.plugins'); - -goog.require('ol.PluginType'); +/** + * @module ol/plugins + */ +import _ol_PluginType_ from './PluginType.js'; +var _ol_plugins_ = {}; /** * The registry of map renderer plugins. * @type {Array} * @private */ -ol.plugins.mapRendererPlugins_ = []; +_ol_plugins_.mapRendererPlugins_ = []; /** * Get all registered map renderer plugins. * @return {Array} The registered map renderer plugins. */ -ol.plugins.getMapRendererPlugins = function() { - return ol.plugins.mapRendererPlugins_; +_ol_plugins_.getMapRendererPlugins = function() { + return _ol_plugins_.mapRendererPlugins_; }; @@ -24,15 +26,15 @@ ol.plugins.getMapRendererPlugins = function() { * @type {Array} * @private */ -ol.plugins.layerRendererPlugins_ = []; +_ol_plugins_.layerRendererPlugins_ = []; /** * Get all registered layer renderer plugins. * @return {Array} The registered layer renderer plugins. */ -ol.plugins.getLayerRendererPlugins = function() { - return ol.plugins.layerRendererPlugins_; +_ol_plugins_.getLayerRendererPlugins = function() { + return _ol_plugins_.layerRendererPlugins_; }; @@ -41,16 +43,16 @@ ol.plugins.getLayerRendererPlugins = function() { * @param {ol.PluginType} type The plugin type. * @param {*} plugin The plugin. */ -ol.plugins.register = function(type, plugin) { +_ol_plugins_.register = function(type, plugin) { var plugins; switch (type) { - case ol.PluginType.MAP_RENDERER: { - plugins = ol.plugins.mapRendererPlugins_; + case _ol_PluginType_.MAP_RENDERER: { + plugins = _ol_plugins_.mapRendererPlugins_; plugins.push(/** @type {olx.MapRendererPlugin} */ (plugin)); break; } - case ol.PluginType.LAYER_RENDERER: { - plugins = ol.plugins.layerRendererPlugins_; + case _ol_PluginType_.LAYER_RENDERER: { + plugins = _ol_plugins_.layerRendererPlugins_; plugins.push(/** @type {olx.LayerRendererPlugin} */ (plugin)); break; } @@ -66,8 +68,9 @@ ol.plugins.register = function(type, plugin) { * @param {ol.PluginType} type The plugin type. * @param {Array} plugins The plugins. */ -ol.plugins.registerMultiple = function(type, plugins) { +_ol_plugins_.registerMultiple = function(type, plugins) { for (var i = 0, ii = plugins.length; i < ii; ++i) { - ol.plugins.register(type, plugins[i]); + _ol_plugins_.register(type, plugins[i]); } }; +export default _ol_plugins_; diff --git a/src/ol/pointer/EventSource.js b/src/ol/pointer/EventSource.js index 9eda993269..444b0c3d64 100644 --- a/src/ol/pointer/EventSource.js +++ b/src/ol/pointer/EventSource.js @@ -1,13 +1,13 @@ -goog.provide('ol.pointer.EventSource'); - - +/** + * @module ol/pointer/EventSource + */ /** * @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @param {!Object.} mapping Event * mapping. * @constructor */ -ol.pointer.EventSource = function(dispatcher, mapping) { +var _ol_pointer_EventSource_ = function(dispatcher, mapping) { /** * @type {ol.pointer.PointerEventHandler} */ @@ -26,7 +26,7 @@ ol.pointer.EventSource = function(dispatcher, mapping) { * List of events supported by this source. * @return {Array.} Event names */ -ol.pointer.EventSource.prototype.getEvents = function() { +_ol_pointer_EventSource_.prototype.getEvents = function() { return Object.keys(this.mapping_); }; @@ -36,6 +36,7 @@ ol.pointer.EventSource.prototype.getEvents = function() { * @param {string} eventType The event type. * @return {function(Event)} Handler */ -ol.pointer.EventSource.prototype.getHandlerForEvent = function(eventType) { +_ol_pointer_EventSource_.prototype.getHandlerForEvent = function(eventType) { return this.mapping_[eventType]; }; +export default _ol_pointer_EventSource_; diff --git a/src/ol/pointer/EventType.js b/src/ol/pointer/EventType.js index 1c25d1d27b..b25d211e35 100644 --- a/src/ol/pointer/EventType.js +++ b/src/ol/pointer/EventType.js @@ -1,11 +1,11 @@ -goog.provide('ol.pointer.EventType'); - - +/** + * @module ol/pointer/EventType + */ /** * Constants for event names. * @enum {string} */ -ol.pointer.EventType = { +var _ol_pointer_EventType_ = { POINTERMOVE: 'pointermove', POINTERDOWN: 'pointerdown', POINTERUP: 'pointerup', @@ -15,3 +15,5 @@ ol.pointer.EventType = { POINTERLEAVE: 'pointerleave', POINTERCANCEL: 'pointercancel' }; + +export default _ol_pointer_EventType_; diff --git a/src/ol/pointer/MouseSource.js b/src/ol/pointer/MouseSource.js index 2c10082dcc..22c02ced94 100644 --- a/src/ol/pointer/MouseSource.js +++ b/src/ol/pointer/MouseSource.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/MouseSource + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,18 +31,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.MouseSource'); - -goog.require('ol'); -goog.require('ol.pointer.EventSource'); - +import _ol_ from '../index.js'; +import _ol_pointer_EventSource_ from '../pointer/EventSource.js'; /** * @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @constructor * @extends {ol.pointer.EventSource} */ -ol.pointer.MouseSource = function(dispatcher) { +var _ol_pointer_MouseSource_ = function(dispatcher) { var mapping = { 'mousedown': this.mousedown, 'mousemove': this.mousemove, @@ -47,7 +47,7 @@ ol.pointer.MouseSource = function(dispatcher) { 'mouseover': this.mouseover, 'mouseout': this.mouseout }; - ol.pointer.EventSource.call(this, dispatcher, mapping); + _ol_pointer_EventSource_.call(this, dispatcher, mapping); /** * @const @@ -61,21 +61,22 @@ ol.pointer.MouseSource = function(dispatcher) { */ this.lastTouches = []; }; -ol.inherits(ol.pointer.MouseSource, ol.pointer.EventSource); + +_ol_.inherits(_ol_pointer_MouseSource_, _ol_pointer_EventSource_); /** * @const * @type {number} */ -ol.pointer.MouseSource.POINTER_ID = 1; +_ol_pointer_MouseSource_.POINTER_ID = 1; /** * @const * @type {string} */ -ol.pointer.MouseSource.POINTER_TYPE = 'mouse'; +_ol_pointer_MouseSource_.POINTER_TYPE = 'mouse'; /** @@ -84,7 +85,7 @@ ol.pointer.MouseSource.POINTER_TYPE = 'mouse'; * @const * @type {number} */ -ol.pointer.MouseSource.DEDUP_DIST = 25; +_ol_pointer_MouseSource_.DEDUP_DIST = 25; /** @@ -111,14 +112,14 @@ ol.pointer.MouseSource.DEDUP_DIST = 25; * @param {Event} inEvent The in event. * @return {boolean} True, if the event was generated by a touch. */ -ol.pointer.MouseSource.prototype.isEventSimulatedFromTouch_ = function(inEvent) { +_ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent) { var lts = this.lastTouches; var x = inEvent.clientX, y = inEvent.clientY; for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) { // simulated mouse events will be swallowed near a primary touchend var dx = Math.abs(x - t[0]), dy = Math.abs(y - t[1]); - if (dx <= ol.pointer.MouseSource.DEDUP_DIST && - dy <= ol.pointer.MouseSource.DEDUP_DIST) { + if (dx <= _ol_pointer_MouseSource_.DEDUP_DIST && + dy <= _ol_pointer_MouseSource_.DEDUP_DIST) { return true; } } @@ -134,7 +135,7 @@ ol.pointer.MouseSource.prototype.isEventSimulatedFromTouch_ = function(inEvent) * @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @return {Object} The copied event. */ -ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) { +_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) { var e = dispatcher.cloneEvent(inEvent, inEvent); // forward mouse preventDefault @@ -144,9 +145,9 @@ ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) { pd(); }; - e.pointerId = ol.pointer.MouseSource.POINTER_ID; + e.pointerId = _ol_pointer_MouseSource_.POINTER_ID; e.isPrimary = true; - e.pointerType = ol.pointer.MouseSource.POINTER_TYPE; + e.pointerType = _ol_pointer_MouseSource_.POINTER_TYPE; return e; }; @@ -157,15 +158,15 @@ ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.mousedown = function(inEvent) { +_ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { // TODO(dfreedman) workaround for some elements not sending mouseup // http://crbug/149091 - if (ol.pointer.MouseSource.POINTER_ID.toString() in this.pointerMap) { + if (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) { this.cancel(inEvent); } - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); - this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()] = inEvent; + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); + this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent; this.dispatcher.down(e, inEvent); } }; @@ -176,9 +177,9 @@ ol.pointer.MouseSource.prototype.mousedown = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.mousemove = function(inEvent) { +_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); this.dispatcher.move(e, inEvent); } }; @@ -189,12 +190,12 @@ ol.pointer.MouseSource.prototype.mousemove = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.mouseup = function(inEvent) { +_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { - var p = this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()]; + var p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()]; if (p && p.button === inEvent.button) { - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); this.dispatcher.up(e, inEvent); this.cleanupMouse(); } @@ -207,9 +208,9 @@ ol.pointer.MouseSource.prototype.mouseup = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.mouseover = function(inEvent) { +_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); this.dispatcher.enterOver(e, inEvent); } }; @@ -220,9 +221,9 @@ ol.pointer.MouseSource.prototype.mouseover = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.mouseout = function(inEvent) { +_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); this.dispatcher.leaveOut(e, inEvent); } }; @@ -233,8 +234,8 @@ ol.pointer.MouseSource.prototype.mouseout = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MouseSource.prototype.cancel = function(inEvent) { - var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher); +_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) { + var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); this.dispatcher.cancel(e, inEvent); this.cleanupMouse(); }; @@ -243,6 +244,7 @@ ol.pointer.MouseSource.prototype.cancel = function(inEvent) { /** * Remove the mouse from the list of active pointers. */ -ol.pointer.MouseSource.prototype.cleanupMouse = function() { - delete this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()]; +_ol_pointer_MouseSource_.prototype.cleanupMouse = function() { + delete this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()]; }; +export default _ol_pointer_MouseSource_; diff --git a/src/ol/pointer/MsSource.js b/src/ol/pointer/MsSource.js index d663c190cd..3988645498 100644 --- a/src/ol/pointer/MsSource.js +++ b/src/ol/pointer/MsSource.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/MsSource + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,18 +31,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.MsSource'); - -goog.require('ol'); -goog.require('ol.pointer.EventSource'); - +import _ol_ from '../index.js'; +import _ol_pointer_EventSource_ from '../pointer/EventSource.js'; /** * @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @constructor * @extends {ol.pointer.EventSource} */ -ol.pointer.MsSource = function(dispatcher) { +var _ol_pointer_MsSource_ = function(dispatcher) { var mapping = { 'MSPointerDown': this.msPointerDown, 'MSPointerMove': this.msPointerMove, @@ -50,7 +50,7 @@ ol.pointer.MsSource = function(dispatcher) { 'MSGotPointerCapture': this.msGotPointerCapture, 'MSLostPointerCapture': this.msLostPointerCapture }; - ol.pointer.EventSource.call(this, dispatcher, mapping); + _ol_pointer_EventSource_.call(this, dispatcher, mapping); /** * @const @@ -70,7 +70,8 @@ ol.pointer.MsSource = function(dispatcher) { 'mouse' ]; }; -ol.inherits(ol.pointer.MsSource, ol.pointer.EventSource); + +_ol_.inherits(_ol_pointer_MsSource_, _ol_pointer_EventSource_); /** @@ -81,7 +82,7 @@ ol.inherits(ol.pointer.MsSource, ol.pointer.EventSource); * @param {Event} inEvent The in event. * @return {Object} The copied event. */ -ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) { +_ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) { var e = inEvent; if (typeof inEvent.pointerType === 'number') { e = this.dispatcher.cloneEvent(inEvent, inEvent); @@ -96,7 +97,7 @@ ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) { * Remove this pointer from the list of active pointers. * @param {number} pointerId Pointer identifier. */ -ol.pointer.MsSource.prototype.cleanup = function(pointerId) { +_ol_pointer_MsSource_.prototype.cleanup = function(pointerId) { delete this.pointerMap[pointerId.toString()]; }; @@ -106,7 +107,7 @@ ol.pointer.MsSource.prototype.cleanup = function(pointerId) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) { this.pointerMap[inEvent.pointerId.toString()] = inEvent; var e = this.prepareEvent_(inEvent); this.dispatcher.down(e, inEvent); @@ -118,7 +119,7 @@ ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerMove = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) { var e = this.prepareEvent_(inEvent); this.dispatcher.move(e, inEvent); }; @@ -129,7 +130,7 @@ ol.pointer.MsSource.prototype.msPointerMove = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerUp = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) { var e = this.prepareEvent_(inEvent); this.dispatcher.up(e, inEvent); this.cleanup(inEvent.pointerId); @@ -141,7 +142,7 @@ ol.pointer.MsSource.prototype.msPointerUp = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerOut = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) { var e = this.prepareEvent_(inEvent); this.dispatcher.leaveOut(e, inEvent); }; @@ -152,7 +153,7 @@ ol.pointer.MsSource.prototype.msPointerOut = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerOver = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) { var e = this.prepareEvent_(inEvent); this.dispatcher.enterOver(e, inEvent); }; @@ -163,7 +164,7 @@ ol.pointer.MsSource.prototype.msPointerOver = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msPointerCancel = function(inEvent) { +_ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) { var e = this.prepareEvent_(inEvent); this.dispatcher.cancel(e, inEvent); this.cleanup(inEvent.pointerId); @@ -175,7 +176,7 @@ ol.pointer.MsSource.prototype.msPointerCancel = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msLostPointerCapture = function(inEvent) { +_ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) { var e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); @@ -187,8 +188,9 @@ ol.pointer.MsSource.prototype.msLostPointerCapture = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.MsSource.prototype.msGotPointerCapture = function(inEvent) { +_ol_pointer_MsSource_.prototype.msGotPointerCapture = function(inEvent) { var e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); }; +export default _ol_pointer_MsSource_; diff --git a/src/ol/pointer/NativeSource.js b/src/ol/pointer/NativeSource.js index 8abeabb325..7c5fd1193c 100644 --- a/src/ol/pointer/NativeSource.js +++ b/src/ol/pointer/NativeSource.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/NativeSource + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,18 +31,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.NativeSource'); - -goog.require('ol'); -goog.require('ol.pointer.EventSource'); - +import _ol_ from '../index.js'; +import _ol_pointer_EventSource_ from '../pointer/EventSource.js'; /** * @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @constructor * @extends {ol.pointer.EventSource} */ -ol.pointer.NativeSource = function(dispatcher) { +var _ol_pointer_NativeSource_ = function(dispatcher) { var mapping = { 'pointerdown': this.pointerDown, 'pointermove': this.pointerMove, @@ -50,9 +50,10 @@ ol.pointer.NativeSource = function(dispatcher) { 'gotpointercapture': this.gotPointerCapture, 'lostpointercapture': this.lostPointerCapture }; - ol.pointer.EventSource.call(this, dispatcher, mapping); + _ol_pointer_EventSource_.call(this, dispatcher, mapping); }; -ol.inherits(ol.pointer.NativeSource, ol.pointer.EventSource); + +_ol_.inherits(_ol_pointer_NativeSource_, _ol_pointer_EventSource_); /** @@ -60,7 +61,7 @@ ol.inherits(ol.pointer.NativeSource, ol.pointer.EventSource); * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerDown = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -70,7 +71,7 @@ ol.pointer.NativeSource.prototype.pointerDown = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerMove = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -80,7 +81,7 @@ ol.pointer.NativeSource.prototype.pointerMove = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerUp = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -90,7 +91,7 @@ ol.pointer.NativeSource.prototype.pointerUp = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerOut = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -100,7 +101,7 @@ ol.pointer.NativeSource.prototype.pointerOut = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerOver = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -110,7 +111,7 @@ ol.pointer.NativeSource.prototype.pointerOver = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.pointerCancel = function(inEvent) { +_ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -120,7 +121,7 @@ ol.pointer.NativeSource.prototype.pointerCancel = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.lostPointerCapture = function(inEvent) { +_ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; @@ -130,6 +131,7 @@ ol.pointer.NativeSource.prototype.lostPointerCapture = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.NativeSource.prototype.gotPointerCapture = function(inEvent) { +_ol_pointer_NativeSource_.prototype.gotPointerCapture = function(inEvent) { this.dispatcher.fireNativeEvent(inEvent); }; +export default _ol_pointer_NativeSource_; diff --git a/src/ol/pointer/PointerEvent.js b/src/ol/pointer/PointerEvent.js index d717b553eb..49d916bce3 100644 --- a/src/ol/pointer/PointerEvent.js +++ b/src/ol/pointer/PointerEvent.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/PointerEvent + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,12 +31,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.PointerEvent'); - - -goog.require('ol'); -goog.require('ol.events.Event'); - +import _ol_ from '../index.js'; +import _ol_events_Event_ from '../events/Event.js'; /** * A class for pointer events. @@ -48,8 +47,8 @@ goog.require('ol.events.Event'); * @param {Object.=} opt_eventDict An optional dictionary of * initial event properties. */ -ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) { - ol.events.Event.call(this, type); +var _ol_pointer_PointerEvent_ = function(type, originalEvent, opt_eventDict) { + _ol_events_Event_.call(this, type); /** * @const @@ -192,7 +191,8 @@ ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) { }; } }; -ol.inherits(ol.pointer.PointerEvent, ol.events.Event); + +_ol_.inherits(_ol_pointer_PointerEvent_, _ol_events_Event_); /** @@ -200,7 +200,7 @@ ol.inherits(ol.pointer.PointerEvent, ol.events.Event); * @param {Object.} eventDict The event dictionary. * @return {number} Button indicator. */ -ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) { +_ol_pointer_PointerEvent_.prototype.getButtons_ = function(eventDict) { // According to the w3c spec, // http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button // MouseEvent.button == 0 can mean either no mouse button depressed, or the @@ -223,7 +223,7 @@ ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) { // // This is fixed with DOM Level 4's use of buttons var buttons; - if (eventDict.buttons || ol.pointer.PointerEvent.HAS_BUTTONS) { + if (eventDict.buttons || _ol_pointer_PointerEvent_.HAS_BUTTONS) { buttons = eventDict.buttons; } else { switch (eventDict.which) { @@ -243,7 +243,7 @@ ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) { * @param {number} buttons Button indicator. * @return {number} The pressure. */ -ol.pointer.PointerEvent.prototype.getPressure_ = function(eventDict, buttons) { +_ol_pointer_PointerEvent_.prototype.getPressure_ = function(eventDict, buttons) { // Spec requires that pointers without pressure specified use 0.5 for down // state and 0 for up state. var pressure = 0; @@ -260,7 +260,7 @@ ol.pointer.PointerEvent.prototype.getPressure_ = function(eventDict, buttons) { * Is the `buttons` property supported? * @type {boolean} */ -ol.pointer.PointerEvent.HAS_BUTTONS = false; +_ol_pointer_PointerEvent_.HAS_BUTTONS = false; /** @@ -269,8 +269,9 @@ ol.pointer.PointerEvent.HAS_BUTTONS = false; (function() { try { var ev = new MouseEvent('click', {buttons: 1}); - ol.pointer.PointerEvent.HAS_BUTTONS = ev.buttons === 1; + _ol_pointer_PointerEvent_.HAS_BUTTONS = ev.buttons === 1; } catch (e) { // pass } })(); +export default _ol_pointer_PointerEvent_; diff --git a/src/ol/pointer/PointerEventHandler.js b/src/ol/pointer/PointerEventHandler.js index 607f30009d..cd7c426a7a 100644 --- a/src/ol/pointer/PointerEventHandler.js +++ b/src/ol/pointer/PointerEventHandler.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/PointerEventHandler + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,28 +31,24 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.PointerEventHandler'); - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); - -goog.require('ol.has'); -goog.require('ol.pointer.EventType'); -goog.require('ol.pointer.MouseSource'); -goog.require('ol.pointer.MsSource'); -goog.require('ol.pointer.NativeSource'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.pointer.TouchSource'); - +import _ol_ from '../index.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventTarget_ from '../events/EventTarget.js'; +import _ol_has_ from '../has.js'; +import _ol_pointer_EventType_ from '../pointer/EventType.js'; +import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js'; +import _ol_pointer_MsSource_ from '../pointer/MsSource.js'; +import _ol_pointer_NativeSource_ from '../pointer/NativeSource.js'; +import _ol_pointer_PointerEvent_ from '../pointer/PointerEvent.js'; +import _ol_pointer_TouchSource_ from '../pointer/TouchSource.js'; /** * @constructor * @extends {ol.events.EventTarget} * @param {Element|HTMLDocument} element Viewport element. */ -ol.pointer.PointerEventHandler = function(element) { - ol.events.EventTarget.call(this); +var _ol_pointer_PointerEventHandler_ = function(element) { + _ol_events_EventTarget_.call(this); /** * @const @@ -78,25 +77,26 @@ ol.pointer.PointerEventHandler = function(element) { this.registerSources(); }; -ol.inherits(ol.pointer.PointerEventHandler, ol.events.EventTarget); + +_ol_.inherits(_ol_pointer_PointerEventHandler_, _ol_events_EventTarget_); /** * Set up the event sources (mouse, touch and native pointers) * that generate pointer events. */ -ol.pointer.PointerEventHandler.prototype.registerSources = function() { - if (ol.has.POINTER) { - this.registerSource('native', new ol.pointer.NativeSource(this)); - } else if (ol.has.MSPOINTER) { - this.registerSource('ms', new ol.pointer.MsSource(this)); +_ol_pointer_PointerEventHandler_.prototype.registerSources = function() { + if (_ol_has_.POINTER) { + this.registerSource('native', new _ol_pointer_NativeSource_(this)); + } else if (_ol_has_.MSPOINTER) { + this.registerSource('ms', new _ol_pointer_MsSource_(this)); } else { - var mouseSource = new ol.pointer.MouseSource(this); + var mouseSource = new _ol_pointer_MouseSource_(this); this.registerSource('mouse', mouseSource); - if (ol.has.TOUCH) { + if (_ol_has_.TOUCH) { this.registerSource('touch', - new ol.pointer.TouchSource(this, mouseSource)); + new _ol_pointer_TouchSource_(this, mouseSource)); } } @@ -111,7 +111,7 @@ ol.pointer.PointerEventHandler.prototype.registerSources = function() { * @param {string} name A name for the event source * @param {ol.pointer.EventSource} source The source event. */ -ol.pointer.PointerEventHandler.prototype.registerSource = function(name, source) { +_ol_pointer_PointerEventHandler_.prototype.registerSource = function(name, source) { var s = source; var newEvents = s.getEvents(); @@ -132,7 +132,7 @@ ol.pointer.PointerEventHandler.prototype.registerSource = function(name, source) * Set up the events for all registered event sources. * @private */ -ol.pointer.PointerEventHandler.prototype.register_ = function() { +_ol_pointer_PointerEventHandler_.prototype.register_ = function() { var l = this.eventSourceList_.length; var eventSource; for (var i = 0; i < l; i++) { @@ -146,7 +146,7 @@ ol.pointer.PointerEventHandler.prototype.register_ = function() { * Remove all registered events. * @private */ -ol.pointer.PointerEventHandler.prototype.unregister_ = function() { +_ol_pointer_PointerEventHandler_.prototype.unregister_ = function() { var l = this.eventSourceList_.length; var eventSource; for (var i = 0; i < l; i++) { @@ -161,7 +161,7 @@ ol.pointer.PointerEventHandler.prototype.unregister_ = function() { * @private * @param {Event} inEvent Browser event. */ -ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) { +_ol_pointer_PointerEventHandler_.prototype.eventHandler_ = function(inEvent) { var type = inEvent.type; var handler = this.eventMap_[type]; if (handler) { @@ -175,9 +175,9 @@ ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) { * @private * @param {Array.} events List of events. */ -ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) { +_ol_pointer_PointerEventHandler_.prototype.addEvents_ = function(events) { events.forEach(function(eventName) { - ol.events.listen(this.element_, eventName, this.eventHandler_, this); + _ol_events_.listen(this.element_, eventName, this.eventHandler_, this); }, this); }; @@ -187,9 +187,9 @@ ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) { * @private * @param {Array.} events List of events. */ -ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) { +_ol_pointer_PointerEventHandler_.prototype.removeEvents_ = function(events) { events.forEach(function(e) { - ol.events.unlisten(this.element_, e, this.eventHandler_, this); + _ol_events_.unlisten(this.element_, e, this.eventHandler_, this); }, this); }; @@ -203,11 +203,11 @@ ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) { * @return {Object} An object containing shallow copies of * `inEvent`'s properties. */ -ol.pointer.PointerEventHandler.prototype.cloneEvent = function(event, inEvent) { +_ol_pointer_PointerEventHandler_.prototype.cloneEvent = function(event, inEvent) { var eventCopy = {}, p; - for (var i = 0, ii = ol.pointer.PointerEventHandler.CLONE_PROPS.length; i < ii; i++) { - p = ol.pointer.PointerEventHandler.CLONE_PROPS[i][0]; - eventCopy[p] = event[p] || inEvent[p] || ol.pointer.PointerEventHandler.CLONE_PROPS[i][1]; + for (var i = 0, ii = _ol_pointer_PointerEventHandler_.CLONE_PROPS.length; i < ii; i++) { + p = _ol_pointer_PointerEventHandler_.CLONE_PROPS[i][0]; + eventCopy[p] = event[p] || inEvent[p] || _ol_pointer_PointerEventHandler_.CLONE_PROPS[i][1]; } return eventCopy; @@ -222,8 +222,8 @@ ol.pointer.PointerEventHandler.prototype.cloneEvent = function(event, inEvent) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.down = function(data, event) { - this.fireEvent(ol.pointer.EventType.POINTERDOWN, data, event); +_ol_pointer_PointerEventHandler_.prototype.down = function(data, event) { + this.fireEvent(_ol_pointer_EventType_.POINTERDOWN, data, event); }; @@ -232,8 +232,8 @@ ol.pointer.PointerEventHandler.prototype.down = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.move = function(data, event) { - this.fireEvent(ol.pointer.EventType.POINTERMOVE, data, event); +_ol_pointer_PointerEventHandler_.prototype.move = function(data, event) { + this.fireEvent(_ol_pointer_EventType_.POINTERMOVE, data, event); }; @@ -242,8 +242,8 @@ ol.pointer.PointerEventHandler.prototype.move = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.up = function(data, event) { - this.fireEvent(ol.pointer.EventType.POINTERUP, data, event); +_ol_pointer_PointerEventHandler_.prototype.up = function(data, event) { + this.fireEvent(_ol_pointer_EventType_.POINTERUP, data, event); }; @@ -252,9 +252,9 @@ ol.pointer.PointerEventHandler.prototype.up = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.enter = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.enter = function(data, event) { data.bubbles = false; - this.fireEvent(ol.pointer.EventType.POINTERENTER, data, event); + this.fireEvent(_ol_pointer_EventType_.POINTERENTER, data, event); }; @@ -263,9 +263,9 @@ ol.pointer.PointerEventHandler.prototype.enter = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.leave = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.leave = function(data, event) { data.bubbles = false; - this.fireEvent(ol.pointer.EventType.POINTERLEAVE, data, event); + this.fireEvent(_ol_pointer_EventType_.POINTERLEAVE, data, event); }; @@ -274,9 +274,9 @@ ol.pointer.PointerEventHandler.prototype.leave = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.over = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.over = function(data, event) { data.bubbles = true; - this.fireEvent(ol.pointer.EventType.POINTEROVER, data, event); + this.fireEvent(_ol_pointer_EventType_.POINTEROVER, data, event); }; @@ -285,9 +285,9 @@ ol.pointer.PointerEventHandler.prototype.over = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.out = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.out = function(data, event) { data.bubbles = true; - this.fireEvent(ol.pointer.EventType.POINTEROUT, data, event); + this.fireEvent(_ol_pointer_EventType_.POINTEROUT, data, event); }; @@ -296,8 +296,8 @@ ol.pointer.PointerEventHandler.prototype.out = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.cancel = function(data, event) { - this.fireEvent(ol.pointer.EventType.POINTERCANCEL, data, event); +_ol_pointer_PointerEventHandler_.prototype.cancel = function(data, event) { + this.fireEvent(_ol_pointer_EventType_.POINTERCANCEL, data, event); }; @@ -306,7 +306,7 @@ ol.pointer.PointerEventHandler.prototype.cancel = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.leaveOut = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.leaveOut = function(data, event) { this.out(data, event); if (!this.contains_(data.target, data.relatedTarget)) { this.leave(data, event); @@ -319,7 +319,7 @@ ol.pointer.PointerEventHandler.prototype.leaveOut = function(data, event) { * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.enterOver = function(data, event) { +_ol_pointer_PointerEventHandler_.prototype.enterOver = function(data, event) { this.over(data, event); if (!this.contains_(data.target, data.relatedTarget)) { this.enter(data, event); @@ -334,7 +334,7 @@ ol.pointer.PointerEventHandler.prototype.enterOver = function(data, event) { * @return {boolean} Returns true if the container element * contains the other element. */ -ol.pointer.PointerEventHandler.prototype.contains_ = function(container, contained) { +_ol_pointer_PointerEventHandler_.prototype.contains_ = function(container, contained) { if (!container || !contained) { return false; } @@ -352,8 +352,8 @@ ol.pointer.PointerEventHandler.prototype.contains_ = function(container, contain * @param {Event} event The event. * @return {ol.pointer.PointerEvent} A PointerEvent of type `inType`. */ -ol.pointer.PointerEventHandler.prototype.makeEvent = function(inType, data, event) { - return new ol.pointer.PointerEvent(inType, event, data); +_ol_pointer_PointerEventHandler_.prototype.makeEvent = function(inType, data, event) { + return new _ol_pointer_PointerEvent_(inType, event, data); }; @@ -363,7 +363,7 @@ ol.pointer.PointerEventHandler.prototype.makeEvent = function(inType, data, even * @param {Object} data Pointer event data. * @param {Event} event The event. */ -ol.pointer.PointerEventHandler.prototype.fireEvent = function(inType, data, event) { +_ol_pointer_PointerEventHandler_.prototype.fireEvent = function(inType, data, event) { var e = this.makeEvent(inType, data, event); this.dispatchEvent(e); }; @@ -374,7 +374,7 @@ ol.pointer.PointerEventHandler.prototype.fireEvent = function(inType, data, even * and dispatches this event. * @param {Event} event A platform event with a target. */ -ol.pointer.PointerEventHandler.prototype.fireNativeEvent = function(event) { +_ol_pointer_PointerEventHandler_.prototype.fireNativeEvent = function(event) { var e = this.makeEvent(event.type, event, event); this.dispatchEvent(e); }; @@ -387,9 +387,9 @@ ol.pointer.PointerEventHandler.prototype.fireNativeEvent = function(event) { * @param {Event} event The event. * @return {ol.pointer.PointerEvent} The wrapped event. */ -ol.pointer.PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) { +_ol_pointer_PointerEventHandler_.prototype.wrapMouseEvent = function(eventType, event) { var pointerEvent = this.makeEvent( - eventType, ol.pointer.MouseSource.prepareEvent(event, this), event); + eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event); return pointerEvent; }; @@ -397,9 +397,9 @@ ol.pointer.PointerEventHandler.prototype.wrapMouseEvent = function(eventType, ev /** * @inheritDoc */ -ol.pointer.PointerEventHandler.prototype.disposeInternal = function() { +_ol_pointer_PointerEventHandler_.prototype.disposeInternal = function() { this.unregister_(); - ol.events.EventTarget.prototype.disposeInternal.call(this); + _ol_events_EventTarget_.prototype.disposeInternal.call(this); }; @@ -407,7 +407,7 @@ ol.pointer.PointerEventHandler.prototype.disposeInternal = function() { * Properties to copy when cloning an event, with default values. * @type {Array.} */ -ol.pointer.PointerEventHandler.CLONE_PROPS = [ +_ol_pointer_PointerEventHandler_.CLONE_PROPS = [ // MouseEvent ['bubbles', false], ['cancelable', false], @@ -441,3 +441,4 @@ ol.pointer.PointerEventHandler.CLONE_PROPS = [ ['currentTarget', null], ['which', 0] ]; +export default _ol_pointer_PointerEventHandler_; diff --git a/src/ol/pointer/TouchSource.js b/src/ol/pointer/TouchSource.js index 6653bd3aab..1a483be84e 100644 --- a/src/ol/pointer/TouchSource.js +++ b/src/ol/pointer/TouchSource.js @@ -1,3 +1,6 @@ +/** + * @module ol/pointer/TouchSource + */ // Based on https://github.com/Polymer/PointerEvents // Copyright (c) 2013 The Polymer Authors. All rights reserved. @@ -28,13 +31,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -goog.provide('ol.pointer.TouchSource'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.pointer.EventSource'); -goog.require('ol.pointer.MouseSource'); - +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_pointer_EventSource_ from '../pointer/EventSource.js'; +import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js'; /** * @constructor @@ -42,14 +42,14 @@ goog.require('ol.pointer.MouseSource'); * @param {ol.pointer.MouseSource} mouseSource Mouse source. * @extends {ol.pointer.EventSource} */ -ol.pointer.TouchSource = function(dispatcher, mouseSource) { +var _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) { var mapping = { 'touchstart': this.touchstart, 'touchmove': this.touchmove, 'touchend': this.touchend, 'touchcancel': this.touchcancel }; - ol.pointer.EventSource.call(this, dispatcher, mapping); + _ol_pointer_EventSource_.call(this, dispatcher, mapping); /** * @const @@ -81,7 +81,8 @@ ol.pointer.TouchSource = function(dispatcher, mouseSource) { */ this.resetId_ = undefined; }; -ol.inherits(ol.pointer.TouchSource, ol.pointer.EventSource); + +_ol_.inherits(_ol_pointer_TouchSource_, _ol_pointer_EventSource_); /** @@ -90,21 +91,21 @@ ol.inherits(ol.pointer.TouchSource, ol.pointer.EventSource); * @const * @type {number} */ -ol.pointer.TouchSource.DEDUP_TIMEOUT = 2500; +_ol_pointer_TouchSource_.DEDUP_TIMEOUT = 2500; /** * @const * @type {number} */ -ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT = 200; +_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT = 200; /** * @const * @type {string} */ -ol.pointer.TouchSource.POINTER_TYPE = 'touch'; +_ol_pointer_TouchSource_.POINTER_TYPE = 'touch'; /** @@ -112,7 +113,7 @@ ol.pointer.TouchSource.POINTER_TYPE = 'touch'; * @param {Touch} inTouch The in touch. * @return {boolean} True, if this is the primary touch. */ -ol.pointer.TouchSource.prototype.isPrimaryTouch_ = function(inTouch) { +_ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) { return this.firstTouchId_ === inTouch.identifier; }; @@ -122,10 +123,10 @@ ol.pointer.TouchSource.prototype.isPrimaryTouch_ = function(inTouch) { * @param {Touch} inTouch The in touch. * @private */ -ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) { +_ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) { var count = Object.keys(this.pointerMap).length; if (count === 0 || (count === 1 && - ol.pointer.MouseSource.POINTER_ID.toString() in this.pointerMap)) { + _ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap)) { this.firstTouchId_ = inTouch.identifier; this.cancelResetClickCount_(); } @@ -136,7 +137,7 @@ ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) { * @private * @param {Object} inPointer The in pointer object. */ -ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) { +_ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) { if (inPointer.isPrimary) { this.firstTouchId_ = undefined; this.resetClickCount_(); @@ -147,17 +148,17 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) { /** * @private */ -ol.pointer.TouchSource.prototype.resetClickCount_ = function() { +_ol_pointer_TouchSource_.prototype.resetClickCount_ = function() { this.resetId_ = setTimeout( this.resetClickCountHandler_.bind(this), - ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT); + _ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT); }; /** * @private */ -ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() { +_ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() { this.clickCount_ = 0; this.resetId_ = undefined; }; @@ -166,7 +167,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() { /** * @private */ -ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { +_ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() { if (this.resetId_ !== undefined) { clearTimeout(this.resetId_); } @@ -179,7 +180,7 @@ ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { * @param {Touch} inTouch Touch event * @return {Object} A pointer object. */ -ol.pointer.TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouch) { +_ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTouch) { var e = this.dispatcher.cloneEvent(browserEvent, inTouch); // Spec specifies that pointerId 1 is reserved for Mouse. // Touch identifiers can start at 0. @@ -196,7 +197,7 @@ ol.pointer.TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouc e.height = inTouch.webkitRadiusY || inTouch.radiusY || 0; e.pressure = inTouch.webkitForce || inTouch.force || 0.5; e.isPrimary = this.isPrimaryTouch_(inTouch); - e.pointerType = ol.pointer.TouchSource.POINTER_TYPE; + e.pointerType = _ol_pointer_TouchSource_.POINTER_TYPE; // make sure that the properties that are different for // each `Touch` object are not copied from the BrowserEvent object @@ -214,7 +215,7 @@ ol.pointer.TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouc * @param {Event} inEvent Touch event * @param {function(Event, Object)} inFunction In function. */ -ol.pointer.TouchSource.prototype.processTouches_ = function(inEvent, inFunction) { +_ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunction) { var touches = Array.prototype.slice.call( inEvent.changedTouches); var count = touches.length; @@ -237,7 +238,7 @@ ol.pointer.TouchSource.prototype.processTouches_ = function(inEvent, inFunction) * @param {number} searchId Search identifier. * @return {boolean} True, if the `Touch` with the given id is in the list. */ -ol.pointer.TouchSource.prototype.findTouch_ = function(touchList, searchId) { +_ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) { var l = touchList.length; var touch; for (var i = 0; i < l; i++) { @@ -261,7 +262,7 @@ ol.pointer.TouchSource.prototype.findTouch_ = function(touchList, searchId) { * @private * @param {Event} inEvent The in event. */ -ol.pointer.TouchSource.prototype.vacuumTouches_ = function(inEvent) { +_ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) { var touchList = inEvent.touches; // pointerMap.getCount() should be < touchList.length here, // as the touchstart has not been processed yet. @@ -276,7 +277,7 @@ ol.pointer.TouchSource.prototype.vacuumTouches_ = function(inEvent) { // Never remove pointerId == 1, which is mouse. // Touch identifiers are 2 smaller than their pointerId, which is the // index in pointermap. - if (key != ol.pointer.MouseSource.POINTER_ID && + if (key != _ol_pointer_MouseSource_.POINTER_ID && !this.findTouch_(touchList, key - 2)) { d.push(value.out); } @@ -294,7 +295,7 @@ ol.pointer.TouchSource.prototype.vacuumTouches_ = function(inEvent) { * * @param {Event} inEvent The in event. */ -ol.pointer.TouchSource.prototype.touchstart = function(inEvent) { +_ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) { this.vacuumTouches_(inEvent); this.setPrimaryTouch_(inEvent.changedTouches[0]); this.dedupSynthMouse_(inEvent); @@ -308,7 +309,7 @@ ol.pointer.TouchSource.prototype.touchstart = function(inEvent) { * @param {Event} browserEvent The event. * @param {Object} inPointer The in pointer object. */ -ol.pointer.TouchSource.prototype.overDown_ = function(browserEvent, inPointer) { +_ol_pointer_TouchSource_.prototype.overDown_ = function(browserEvent, inPointer) { this.pointerMap[inPointer.pointerId] = { target: inPointer.target, out: inPointer, @@ -325,7 +326,7 @@ ol.pointer.TouchSource.prototype.overDown_ = function(browserEvent, inPointer) { * * @param {Event} inEvent The in event. */ -ol.pointer.TouchSource.prototype.touchmove = function(inEvent) { +_ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) { inEvent.preventDefault(); this.processTouches_(inEvent, this.moveOverOut_); }; @@ -336,7 +337,7 @@ ol.pointer.TouchSource.prototype.touchmove = function(inEvent) { * @param {Event} browserEvent The event. * @param {Object} inPointer The in pointer. */ -ol.pointer.TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer) { +_ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPointer) { var event = inPointer; var pointer = this.pointerMap[event.pointerId]; // a finger drifted off the screen, ignore it @@ -372,7 +373,7 @@ ol.pointer.TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer * * @param {Event} inEvent The event. */ -ol.pointer.TouchSource.prototype.touchend = function(inEvent) { +_ol_pointer_TouchSource_.prototype.touchend = function(inEvent) { this.dedupSynthMouse_(inEvent); this.processTouches_(inEvent, this.upOut_); }; @@ -383,7 +384,7 @@ ol.pointer.TouchSource.prototype.touchend = function(inEvent) { * @param {Event} browserEvent An event. * @param {Object} inPointer The inPointer object. */ -ol.pointer.TouchSource.prototype.upOut_ = function(browserEvent, inPointer) { +_ol_pointer_TouchSource_.prototype.upOut_ = function(browserEvent, inPointer) { this.dispatcher.up(inPointer, browserEvent); this.dispatcher.out(inPointer, browserEvent); this.dispatcher.leave(inPointer, browserEvent); @@ -397,7 +398,7 @@ ol.pointer.TouchSource.prototype.upOut_ = function(browserEvent, inPointer) { * * @param {Event} inEvent The in event. */ -ol.pointer.TouchSource.prototype.touchcancel = function(inEvent) { +_ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) { this.processTouches_(inEvent, this.cancelOut_); }; @@ -407,7 +408,7 @@ ol.pointer.TouchSource.prototype.touchcancel = function(inEvent) { * @param {Event} browserEvent The event. * @param {Object} inPointer The in pointer. */ -ol.pointer.TouchSource.prototype.cancelOut_ = function(browserEvent, inPointer) { +_ol_pointer_TouchSource_.prototype.cancelOut_ = function(browserEvent, inPointer) { this.dispatcher.cancel(inPointer, browserEvent); this.dispatcher.out(inPointer, browserEvent); this.dispatcher.leave(inPointer, browserEvent); @@ -419,7 +420,7 @@ ol.pointer.TouchSource.prototype.cancelOut_ = function(browserEvent, inPointer) * @private * @param {Object} inPointer The inPointer object. */ -ol.pointer.TouchSource.prototype.cleanUpPointer_ = function(inPointer) { +_ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) { delete this.pointerMap[inPointer.pointerId]; this.removePrimaryPointer_(inPointer); }; @@ -431,7 +432,7 @@ ol.pointer.TouchSource.prototype.cleanUpPointer_ = function(inPointer) { * @private * @param {Event} inEvent The in event. */ -ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) { +_ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) { var lts = this.mouseSource.lastTouches; var t = inEvent.changedTouches[0]; // only the primary finger will synth mouse events @@ -442,7 +443,8 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) { setTimeout(function() { // remove touch after timeout - ol.array.remove(lts, lt); - }, ol.pointer.TouchSource.DEDUP_TIMEOUT); + _ol_array_.remove(lts, lt); + }, _ol_pointer_TouchSource_.DEDUP_TIMEOUT); } }; +export default _ol_pointer_TouchSource_; diff --git a/src/ol/proj.js b/src/ol/proj.js index bf5b0bb6ac..641b675228 100644 --- a/src/ol/proj.js +++ b/src/ol/proj.js @@ -1,16 +1,18 @@ -goog.provide('ol.proj'); - -goog.require('ol'); -goog.require('ol.Sphere'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.proj.EPSG3857'); -goog.require('ol.proj.EPSG4326'); -goog.require('ol.proj.Projection'); -goog.require('ol.proj.Units'); -goog.require('ol.proj.proj4'); -goog.require('ol.proj.projections'); -goog.require('ol.proj.transforms'); +/** + * @module ol/proj + */ +import _ol_ from './index.js'; +import _ol_Sphere_ from './Sphere.js'; +import _ol_extent_ from './extent.js'; +import _ol_math_ from './math.js'; +import _ol_proj_EPSG3857_ from './proj/EPSG3857.js'; +import _ol_proj_EPSG4326_ from './proj/EPSG4326.js'; +import _ol_proj_Projection_ from './proj/Projection.js'; +import _ol_proj_Units_ from './proj/Units.js'; +import _ol_proj_proj4_ from './proj/proj4.js'; +import _ol_proj_projections_ from './proj/projections.js'; +import _ol_proj_transforms_ from './proj/transforms.js'; +var _ol_proj_ = {}; /** @@ -19,7 +21,7 @@ goog.require('ol.proj.transforms'); * @type {Object.} * @api */ -ol.proj.METERS_PER_UNIT = ol.proj.Units.METERS_PER_UNIT; +_ol_proj_.METERS_PER_UNIT = _ol_proj_Units_.METERS_PER_UNIT; /** @@ -27,10 +29,10 @@ ol.proj.METERS_PER_UNIT = ol.proj.Units.METERS_PER_UNIT; * @private * @type {ol.Sphere} */ -ol.proj.SPHERE_ = new ol.Sphere(ol.Sphere.DEFAULT_RADIUS); +_ol_proj_.SPHERE_ = new _ol_Sphere_(_ol_Sphere_.DEFAULT_RADIUS); -if (ol.ENABLE_PROJ4JS) { +if (_ol_.ENABLE_PROJ4JS) { /** * Register proj4. If not explicitly registered, it will be assumed that * proj4js will be loaded in the global namespace. For example in a @@ -43,8 +45,8 @@ if (ol.ENABLE_PROJ4JS) { * @param {Proj4} proj4 Proj4. * @api */ - ol.proj.setProj4 = function(proj4) { - ol.proj.proj4.set(proj4); + _ol_proj_.setProj4 = function(proj4) { + _ol_proj_proj4_.set(proj4); }; } @@ -69,21 +71,21 @@ if (ol.ENABLE_PROJ4JS) { * @return {number} Point resolution. * @api */ -ol.proj.getPointResolution = function(projection, resolution, point, opt_units) { - projection = ol.proj.get(projection); +_ol_proj_.getPointResolution = function(projection, resolution, point, opt_units) { + projection = _ol_proj_.get(projection); var pointResolution; var getter = projection.getPointResolutionFunc(); if (getter) { pointResolution = getter(resolution, point); } else { var units = projection.getUnits(); - if (units == ol.proj.Units.DEGREES && !opt_units || opt_units == ol.proj.Units.DEGREES) { + if (units == _ol_proj_Units_.DEGREES && !opt_units || opt_units == _ol_proj_Units_.DEGREES) { pointResolution = resolution; } else { // Estimate point resolution by transforming the center pixel to EPSG:4326, // measuring its width and height on the normal sphere, and taking the // average of the width and height. - var toEPSG4326 = ol.proj.getTransformFromProjections(projection, ol.proj.get('EPSG:4326')); + var toEPSG4326 = _ol_proj_.getTransformFromProjections(projection, _ol_proj_.get('EPSG:4326')); var vertices = [ point[0] - resolution / 2, point[1], point[0] + resolution / 2, point[1], @@ -91,13 +93,13 @@ ol.proj.getPointResolution = function(projection, resolution, point, opt_units) point[0], point[1] + resolution / 2 ]; vertices = toEPSG4326(vertices, vertices, 2); - var width = ol.proj.SPHERE_.haversineDistance( + var width = _ol_proj_.SPHERE_.haversineDistance( vertices.slice(0, 2), vertices.slice(2, 4)); - var height = ol.proj.SPHERE_.haversineDistance( + var height = _ol_proj_.SPHERE_.haversineDistance( vertices.slice(4, 6), vertices.slice(6, 8)); pointResolution = (width + height) / 2; var metersPerUnit = opt_units ? - ol.proj.Units.METERS_PER_UNIT[opt_units] : + _ol_proj_Units_.METERS_PER_UNIT[opt_units] : projection.getMetersPerUnit(); if (metersPerUnit !== undefined) { pointResolution /= metersPerUnit; @@ -115,12 +117,12 @@ ol.proj.getPointResolution = function(projection, resolution, point, opt_units) * @param {Array.} projections Projections. * @api */ -ol.proj.addEquivalentProjections = function(projections) { - ol.proj.addProjections(projections); +_ol_proj_.addEquivalentProjections = function(projections) { + _ol_proj_.addProjections(projections); projections.forEach(function(source) { projections.forEach(function(destination) { if (source !== destination) { - ol.proj.transforms.add(source, destination, ol.proj.cloneTransform); + _ol_proj_transforms_.add(source, destination, _ol_proj_.cloneTransform); } }); }); @@ -140,11 +142,11 @@ ol.proj.addEquivalentProjections = function(projections) { * @param {ol.TransformFunction} inverseTransform Transform from any projection * in projection2 to any projection in projection1.. */ -ol.proj.addEquivalentTransforms = function(projections1, projections2, forwardTransform, inverseTransform) { +_ol_proj_.addEquivalentTransforms = function(projections1, projections2, forwardTransform, inverseTransform) { projections1.forEach(function(projection1) { projections2.forEach(function(projection2) { - ol.proj.transforms.add(projection1, projection2, forwardTransform); - ol.proj.transforms.add(projection2, projection1, inverseTransform); + _ol_proj_transforms_.add(projection1, projection2, forwardTransform); + _ol_proj_transforms_.add(projection2, projection1, inverseTransform); }); }); }; @@ -157,26 +159,26 @@ ol.proj.addEquivalentTransforms = function(projections1, projections2, forwardTr * @param {ol.proj.Projection} projection Projection instance. * @api */ -ol.proj.addProjection = function(projection) { - ol.proj.projections.add(projection.getCode(), projection); - ol.proj.transforms.add(projection, projection, ol.proj.cloneTransform); +_ol_proj_.addProjection = function(projection) { + _ol_proj_projections_.add(projection.getCode(), projection); + _ol_proj_transforms_.add(projection, projection, _ol_proj_.cloneTransform); }; /** * @param {Array.} projections Projections. */ -ol.proj.addProjections = function(projections) { - projections.forEach(ol.proj.addProjection); +_ol_proj_.addProjections = function(projections) { + projections.forEach(_ol_proj_.addProjection); }; /** * Clear all cached projections and transforms. */ -ol.proj.clearAllProjections = function() { - ol.proj.projections.clear(); - ol.proj.transforms.clear(); +_ol_proj_.clearAllProjections = function() { + _ol_proj_projections_.clear(); + _ol_proj_transforms_.clear(); }; @@ -185,11 +187,11 @@ ol.proj.clearAllProjections = function() { * @param {string} defaultCode Default code. * @return {ol.proj.Projection} Projection. */ -ol.proj.createProjection = function(projection, defaultCode) { +_ol_proj_.createProjection = function(projection, defaultCode) { if (!projection) { - return ol.proj.get(defaultCode); + return _ol_proj_.get(defaultCode); } else if (typeof projection === 'string') { - return ol.proj.get(projection); + return _ol_proj_.get(projection); } else { return /** @type {ol.proj.Projection} */ (projection); } @@ -215,13 +217,13 @@ ol.proj.createProjection = function(projection, defaultCode) { * the transformed {@link ol.Coordinate}. * @api */ -ol.proj.addCoordinateTransforms = function(source, destination, forward, inverse) { - var sourceProj = ol.proj.get(source); - var destProj = ol.proj.get(destination); - ol.proj.transforms.add(sourceProj, destProj, - ol.proj.createTransformFromCoordinateTransform(forward)); - ol.proj.transforms.add(destProj, sourceProj, - ol.proj.createTransformFromCoordinateTransform(inverse)); +_ol_proj_.addCoordinateTransforms = function(source, destination, forward, inverse) { + var sourceProj = _ol_proj_.get(source); + var destProj = _ol_proj_.get(destination); + _ol_proj_transforms_.add(sourceProj, destProj, + _ol_proj_.createTransformFromCoordinateTransform(forward)); + _ol_proj_transforms_.add(destProj, sourceProj, + _ol_proj_.createTransformFromCoordinateTransform(inverse)); }; @@ -232,7 +234,7 @@ ol.proj.addCoordinateTransforms = function(source, destination, forward, inverse * transform. * @return {ol.TransformFunction} Transform function. */ -ol.proj.createTransformFromCoordinateTransform = function(transform) { +_ol_proj_.createTransformFromCoordinateTransform = function(transform) { return ( /** * @param {Array.} input Input. @@ -267,8 +269,8 @@ ol.proj.createTransformFromCoordinateTransform = function(transform) { * @return {ol.Coordinate} Coordinate projected to the target projection. * @api */ -ol.proj.fromLonLat = function(coordinate, opt_projection) { - return ol.proj.transform(coordinate, 'EPSG:4326', +_ol_proj_.fromLonLat = function(coordinate, opt_projection) { + return _ol_proj_.transform(coordinate, 'EPSG:4326', opt_projection !== undefined ? opt_projection : 'EPSG:3857'); }; @@ -282,12 +284,12 @@ ol.proj.fromLonLat = function(coordinate, opt_projection) { * with longitude as 1st and latitude as 2nd element. * @api */ -ol.proj.toLonLat = function(coordinate, opt_projection) { - var lonLat = ol.proj.transform(coordinate, +_ol_proj_.toLonLat = function(coordinate, opt_projection) { + var lonLat = _ol_proj_.transform(coordinate, opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326'); var lon = lonLat[0]; if (lon < -180 || lon > 180) { - lonLat[0] = ol.math.modulo(lon + 180, 360) - 180; + lonLat[0] = _ol_math_.modulo(lon + 180, 360) - 180; } return lonLat; }; @@ -302,19 +304,19 @@ ol.proj.toLonLat = function(coordinate, opt_projection) { * @return {ol.proj.Projection} Projection object, or null if not in list. * @api */ -ol.proj.get = function(projectionLike) { +_ol_proj_.get = function(projectionLike) { var projection = null; - if (projectionLike instanceof ol.proj.Projection) { + if (projectionLike instanceof _ol_proj_Projection_) { projection = projectionLike; } else if (typeof projectionLike === 'string') { var code = projectionLike; - projection = ol.proj.projections.get(code); - if (ol.ENABLE_PROJ4JS && !projection) { - var proj4js = ol.proj.proj4.get(); + projection = _ol_proj_projections_.get(code); + if (_ol_.ENABLE_PROJ4JS && !projection) { + var proj4js = _ol_proj_proj4_.get(); if (typeof proj4js == 'function' && proj4js.defs(code) !== undefined) { - projection = new ol.proj.Projection({code: code}); - ol.proj.addProjection(projection); + projection = new _ol_proj_Projection_({code: code}); + _ol_proj_.addProjection(projection); } } } @@ -332,7 +334,7 @@ ol.proj.get = function(projectionLike) { * @return {boolean} Equivalent. * @api */ -ol.proj.equivalent = function(projection1, projection2) { +_ol_proj_.equivalent = function(projection1, projection2) { if (projection1 === projection2) { return true; } @@ -340,9 +342,9 @@ ol.proj.equivalent = function(projection1, projection2) { if (projection1.getCode() === projection2.getCode()) { return equalUnits; } else { - var transformFn = ol.proj.getTransformFromProjections( + var transformFn = _ol_proj_.getTransformFromProjections( projection1, projection2); - return transformFn === ol.proj.cloneTransform && equalUnits; + return transformFn === _ol_proj_.cloneTransform && equalUnits; } }; @@ -357,10 +359,10 @@ ol.proj.equivalent = function(projection1, projection2) { * @return {ol.TransformFunction} Transform function. * @api */ -ol.proj.getTransform = function(source, destination) { - var sourceProjection = ol.proj.get(source); - var destinationProjection = ol.proj.get(destination); - return ol.proj.getTransformFromProjections( +_ol_proj_.getTransform = function(source, destination) { + var sourceProjection = _ol_proj_.get(source); + var destinationProjection = _ol_proj_.get(destination); + return _ol_proj_.getTransformFromProjections( sourceProjection, destinationProjection); }; @@ -374,30 +376,30 @@ ol.proj.getTransform = function(source, destination) { * object. * @return {ol.TransformFunction} Transform function. */ -ol.proj.getTransformFromProjections = function(sourceProjection, destinationProjection) { +_ol_proj_.getTransformFromProjections = function(sourceProjection, destinationProjection) { var sourceCode = sourceProjection.getCode(); var destinationCode = destinationProjection.getCode(); - var transform = ol.proj.transforms.get(sourceCode, destinationCode); - if (ol.ENABLE_PROJ4JS && !transform) { - var proj4js = ol.proj.proj4.get(); + var transform = _ol_proj_transforms_.get(sourceCode, destinationCode); + if (_ol_.ENABLE_PROJ4JS && !transform) { + var proj4js = _ol_proj_proj4_.get(); if (typeof proj4js == 'function') { var sourceDef = proj4js.defs(sourceCode); var destinationDef = proj4js.defs(destinationCode); if (sourceDef !== undefined && destinationDef !== undefined) { if (sourceDef === destinationDef) { - ol.proj.addEquivalentProjections([destinationProjection, sourceProjection]); + _ol_proj_.addEquivalentProjections([destinationProjection, sourceProjection]); } else { var proj4Transform = proj4js(destinationCode, sourceCode); - ol.proj.addCoordinateTransforms(destinationProjection, sourceProjection, + _ol_proj_.addCoordinateTransforms(destinationProjection, sourceProjection, proj4Transform.forward, proj4Transform.inverse); } - transform = ol.proj.transforms.get(sourceCode, destinationCode); + transform = _ol_proj_transforms_.get(sourceCode, destinationCode); } } } if (!transform) { - transform = ol.proj.identityTransform; + transform = _ol_proj_.identityTransform; } return transform; }; @@ -409,7 +411,7 @@ ol.proj.getTransformFromProjections = function(sourceProjection, destinationProj * @param {number=} opt_dimension Dimension. * @return {Array.} Input coordinate array (same array as input). */ -ol.proj.identityTransform = function(input, opt_output, opt_dimension) { +_ol_proj_.identityTransform = function(input, opt_output, opt_dimension) { if (opt_output !== undefined && input !== opt_output) { for (var i = 0, ii = input.length; i < ii; ++i) { opt_output[i] = input[i]; @@ -427,7 +429,7 @@ ol.proj.identityTransform = function(input, opt_output, opt_dimension) { * @return {Array.} Output coordinate array (new array, same coordinate * values). */ -ol.proj.cloneTransform = function(input, opt_output, opt_dimension) { +_ol_proj_.cloneTransform = function(input, opt_output, opt_dimension) { var output; if (opt_output !== undefined) { for (var i = 0, ii = input.length; i < ii; ++i) { @@ -455,8 +457,8 @@ ol.proj.cloneTransform = function(input, opt_output, opt_dimension) { * @return {ol.Coordinate} Coordinate. * @api */ -ol.proj.transform = function(coordinate, source, destination) { - var transformFn = ol.proj.getTransform(source, destination); +_ol_proj_.transform = function(coordinate, source, destination) { + var transformFn = _ol_proj_.getTransform(source, destination); return transformFn(coordinate, undefined, coordinate.length); }; @@ -471,9 +473,9 @@ ol.proj.transform = function(coordinate, source, destination) { * @return {ol.Extent} The transformed extent. * @api */ -ol.proj.transformExtent = function(extent, source, destination) { - var transformFn = ol.proj.getTransform(source, destination); - return ol.extent.applyTransform(extent, transformFn); +_ol_proj_.transformExtent = function(extent, source, destination) { + var transformFn = _ol_proj_.getTransform(source, destination); + return _ol_extent_.applyTransform(extent, transformFn); }; @@ -485,8 +487,8 @@ ol.proj.transformExtent = function(extent, source, destination) { * @param {ol.proj.Projection} destinationProjection Destination projection. * @return {ol.Coordinate} Point. */ -ol.proj.transformWithProjections = function(point, sourceProjection, destinationProjection) { - var transformFn = ol.proj.getTransformFromProjections( +_ol_proj_.transformWithProjections = function(point, sourceProjection, destinationProjection) { + var transformFn = _ol_proj_.getTransformFromProjections( sourceProjection, destinationProjection); return transformFn(point); }; @@ -496,18 +498,19 @@ ol.proj.transformWithProjections = function(point, sourceProjection, destination * by when this module is executed and should only need to be called again after * `ol.proj.clearAllProjections()` is called (e.g. in tests). */ -ol.proj.addCommon = function() { +_ol_proj_.addCommon = function() { // Add transformations that don't alter coordinates to convert within set of // projections with equal meaning. - ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS); - ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS); + _ol_proj_.addEquivalentProjections(_ol_proj_EPSG3857_.PROJECTIONS); + _ol_proj_.addEquivalentProjections(_ol_proj_EPSG4326_.PROJECTIONS); // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like // coordinates and back. - ol.proj.addEquivalentTransforms( - ol.proj.EPSG4326.PROJECTIONS, - ol.proj.EPSG3857.PROJECTIONS, - ol.proj.EPSG3857.fromEPSG4326, - ol.proj.EPSG3857.toEPSG4326); + _ol_proj_.addEquivalentTransforms( + _ol_proj_EPSG4326_.PROJECTIONS, + _ol_proj_EPSG3857_.PROJECTIONS, + _ol_proj_EPSG3857_.fromEPSG4326, + _ol_proj_EPSG3857_.toEPSG4326); }; -ol.proj.addCommon(); +_ol_proj_.addCommon(); +export default _ol_proj_; diff --git a/src/ol/proj/EPSG3857.js b/src/ol/proj/EPSG3857.js index 7d0dbd119e..93b9fdeae6 100644 --- a/src/ol/proj/EPSG3857.js +++ b/src/ol/proj/EPSG3857.js @@ -1,9 +1,11 @@ -goog.provide('ol.proj.EPSG3857'); - -goog.require('ol'); -goog.require('ol.math'); -goog.require('ol.proj.Projection'); -goog.require('ol.proj.Units'); +/** + * @module ol/proj/EPSG3857 + */ +import _ol_ from '../index.js'; +import _ol_math_ from '../math.js'; +import _ol_proj_Projection_ from '../proj/Projection.js'; +import _ol_proj_Units_ from '../proj/Units.js'; +var _ol_proj_EPSG3857_ = {}; /** @@ -15,19 +17,19 @@ goog.require('ol.proj.Units'); * @param {string} code Code. * @private */ -ol.proj.EPSG3857.Projection_ = function(code) { - ol.proj.Projection.call(this, { +_ol_proj_EPSG3857_.Projection_ = function(code) { + _ol_proj_Projection_.call(this, { code: code, - units: ol.proj.Units.METERS, - extent: ol.proj.EPSG3857.EXTENT, + units: _ol_proj_Units_.METERS, + extent: _ol_proj_EPSG3857_.EXTENT, global: true, - worldExtent: ol.proj.EPSG3857.WORLD_EXTENT, + worldExtent: _ol_proj_EPSG3857_.WORLD_EXTENT, getPointResolution: function(resolution, point) { - return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS); + return resolution / _ol_math_.cosh(point[1] / _ol_proj_EPSG3857_.RADIUS); } }); }; -ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection); +_ol_.inherits(_ol_proj_EPSG3857_.Projection_, _ol_proj_Projection_); /** @@ -36,23 +38,23 @@ ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection); * @const * @type {number} */ -ol.proj.EPSG3857.RADIUS = 6378137; +_ol_proj_EPSG3857_.RADIUS = 6378137; /** * @const * @type {number} */ -ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS; +_ol_proj_EPSG3857_.HALF_SIZE = Math.PI * _ol_proj_EPSG3857_.RADIUS; /** * @const * @type {ol.Extent} */ -ol.proj.EPSG3857.EXTENT = [ - -ol.proj.EPSG3857.HALF_SIZE, -ol.proj.EPSG3857.HALF_SIZE, - ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE +_ol_proj_EPSG3857_.EXTENT = [ + -_ol_proj_EPSG3857_.HALF_SIZE, -_ol_proj_EPSG3857_.HALF_SIZE, + _ol_proj_EPSG3857_.HALF_SIZE, _ol_proj_EPSG3857_.HALF_SIZE ]; @@ -60,7 +62,7 @@ ol.proj.EPSG3857.EXTENT = [ * @const * @type {ol.Extent} */ -ol.proj.EPSG3857.WORLD_EXTENT = [-180, -85, 180, 85]; +_ol_proj_EPSG3857_.WORLD_EXTENT = [-180, -85, 180, 85]; /** @@ -69,14 +71,14 @@ ol.proj.EPSG3857.WORLD_EXTENT = [-180, -85, 180, 85]; * @const * @type {Array.} */ -ol.proj.EPSG3857.PROJECTIONS = [ - new ol.proj.EPSG3857.Projection_('EPSG:3857'), - new ol.proj.EPSG3857.Projection_('EPSG:102100'), - new ol.proj.EPSG3857.Projection_('EPSG:102113'), - new ol.proj.EPSG3857.Projection_('EPSG:900913'), - new ol.proj.EPSG3857.Projection_('urn:ogc:def:crs:EPSG:6.18:3:3857'), - new ol.proj.EPSG3857.Projection_('urn:ogc:def:crs:EPSG::3857'), - new ol.proj.EPSG3857.Projection_('http://www.opengis.net/gml/srs/epsg.xml#3857') +_ol_proj_EPSG3857_.PROJECTIONS = [ + new _ol_proj_EPSG3857_.Projection_('EPSG:3857'), + new _ol_proj_EPSG3857_.Projection_('EPSG:102100'), + new _ol_proj_EPSG3857_.Projection_('EPSG:102113'), + new _ol_proj_EPSG3857_.Projection_('EPSG:900913'), + new _ol_proj_EPSG3857_.Projection_('urn:ogc:def:crs:EPSG:6.18:3:3857'), + new _ol_proj_EPSG3857_.Projection_('urn:ogc:def:crs:EPSG::3857'), + new _ol_proj_EPSG3857_.Projection_('http://www.opengis.net/gml/srs/epsg.xml#3857') ]; @@ -88,7 +90,7 @@ ol.proj.EPSG3857.PROJECTIONS = [ * @param {number=} opt_dimension Dimension (default is `2`). * @return {Array.} Output array of coordinate values. */ -ol.proj.EPSG3857.fromEPSG4326 = function(input, opt_output, opt_dimension) { +_ol_proj_EPSG3857_.fromEPSG4326 = function(input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, output = opt_output; @@ -100,10 +102,10 @@ ol.proj.EPSG3857.fromEPSG4326 = function(input, opt_output, opt_dimension) { output = new Array(length); } } - var halfSize = ol.proj.EPSG3857.HALF_SIZE; + var halfSize = _ol_proj_EPSG3857_.HALF_SIZE; for (var i = 0; i < length; i += dimension) { output[i] = halfSize * input[i] / 180; - var y = ol.proj.EPSG3857.RADIUS * + var y = _ol_proj_EPSG3857_.RADIUS * Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360)); if (y > halfSize) { y = halfSize; @@ -124,7 +126,7 @@ ol.proj.EPSG3857.fromEPSG4326 = function(input, opt_output, opt_dimension) { * @param {number=} opt_dimension Dimension (default is `2`). * @return {Array.} Output array of coordinate values. */ -ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { +_ol_proj_EPSG3857_.toEPSG4326 = function(input, opt_output, opt_dimension) { var length = input.length, dimension = opt_dimension > 1 ? opt_dimension : 2, output = opt_output; @@ -137,9 +139,10 @@ ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { } } for (var i = 0; i < length; i += dimension) { - output[i] = 180 * input[i] / ol.proj.EPSG3857.HALF_SIZE; + output[i] = 180 * input[i] / _ol_proj_EPSG3857_.HALF_SIZE; output[i + 1] = 360 * Math.atan( - Math.exp(input[i + 1] / ol.proj.EPSG3857.RADIUS)) / Math.PI - 90; + Math.exp(input[i + 1] / _ol_proj_EPSG3857_.RADIUS)) / Math.PI - 90; } return output; }; +export default _ol_proj_EPSG3857_; diff --git a/src/ol/proj/EPSG4326.js b/src/ol/proj/EPSG4326.js index 373f1d44a4..be7a9e1389 100644 --- a/src/ol/proj/EPSG4326.js +++ b/src/ol/proj/EPSG4326.js @@ -1,8 +1,10 @@ -goog.provide('ol.proj.EPSG4326'); - -goog.require('ol'); -goog.require('ol.proj.Projection'); -goog.require('ol.proj.Units'); +/** + * @module ol/proj/EPSG4326 + */ +import _ol_ from '../index.js'; +import _ol_proj_Projection_ from '../proj/Projection.js'; +import _ol_proj_Units_ from '../proj/Units.js'; +var _ol_proj_EPSG4326_ = {}; /** @@ -19,18 +21,18 @@ goog.require('ol.proj.Units'); * @param {string=} opt_axisOrientation Axis orientation. * @private */ -ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) { - ol.proj.Projection.call(this, { +_ol_proj_EPSG4326_.Projection_ = function(code, opt_axisOrientation) { + _ol_proj_Projection_.call(this, { code: code, - units: ol.proj.Units.DEGREES, - extent: ol.proj.EPSG4326.EXTENT, + units: _ol_proj_Units_.DEGREES, + extent: _ol_proj_EPSG4326_.EXTENT, axisOrientation: opt_axisOrientation, global: true, - metersPerUnit: ol.proj.EPSG4326.METERS_PER_UNIT, - worldExtent: ol.proj.EPSG4326.EXTENT + metersPerUnit: _ol_proj_EPSG4326_.METERS_PER_UNIT, + worldExtent: _ol_proj_EPSG4326_.EXTENT }); }; -ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection); +_ol_.inherits(_ol_proj_EPSG4326_.Projection_, _ol_proj_Projection_); /** @@ -39,7 +41,7 @@ ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection); * @const * @type {number} */ -ol.proj.EPSG4326.RADIUS = 6378137; +_ol_proj_EPSG4326_.RADIUS = 6378137; /** @@ -48,14 +50,14 @@ ol.proj.EPSG4326.RADIUS = 6378137; * @const * @type {ol.Extent} */ -ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90]; +_ol_proj_EPSG4326_.EXTENT = [-180, -90, 180, 90]; /** * @const * @type {number} */ -ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.proj.EPSG4326.RADIUS / 180; +_ol_proj_EPSG4326_.METERS_PER_UNIT = Math.PI * _ol_proj_EPSG4326_.RADIUS / 180; /** @@ -64,13 +66,14 @@ ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.proj.EPSG4326.RADIUS / 180; * @const * @type {Array.} */ -ol.proj.EPSG4326.PROJECTIONS = [ - new ol.proj.EPSG4326.Projection_('CRS:84'), - new ol.proj.EPSG4326.Projection_('EPSG:4326', 'neu'), - new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG::4326', 'neu'), - new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'), - new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:1.3:CRS84'), - new ol.proj.EPSG4326.Projection_('urn:ogc:def:crs:OGC:2:84'), - new ol.proj.EPSG4326.Projection_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'), - new ol.proj.EPSG4326.Projection_('urn:x-ogc:def:crs:EPSG:4326', 'neu') +_ol_proj_EPSG4326_.PROJECTIONS = [ + new _ol_proj_EPSG4326_.Projection_('CRS:84'), + new _ol_proj_EPSG4326_.Projection_('EPSG:4326', 'neu'), + new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:EPSG::4326', 'neu'), + new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'), + new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:OGC:1.3:CRS84'), + new _ol_proj_EPSG4326_.Projection_('urn:ogc:def:crs:OGC:2:84'), + new _ol_proj_EPSG4326_.Projection_('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'), + new _ol_proj_EPSG4326_.Projection_('urn:x-ogc:def:crs:EPSG:4326', 'neu') ]; +export default _ol_proj_EPSG4326_; diff --git a/src/ol/proj/Projection.js b/src/ol/proj/Projection.js index 1faadb0df4..b1d9dfe595 100644 --- a/src/ol/proj/Projection.js +++ b/src/ol/proj/Projection.js @@ -1,9 +1,9 @@ -goog.provide('ol.proj.Projection'); - -goog.require('ol'); -goog.require('ol.proj.Units'); -goog.require('ol.proj.proj4'); - +/** + * @module ol/proj/Projection + */ +import _ol_ from '../index.js'; +import _ol_proj_Units_ from '../proj/Units.js'; +import _ol_proj_proj4_ from '../proj/proj4.js'; /** * @classdesc @@ -35,7 +35,7 @@ goog.require('ol.proj.proj4'); * @struct * @api */ -ol.proj.Projection = function(options) { +var _ol_proj_Projection_ = function(options) { /** * @private * @type {string} @@ -108,8 +108,8 @@ ol.proj.Projection = function(options) { this.metersPerUnit_ = options.metersPerUnit; var code = options.code; - if (ol.ENABLE_PROJ4JS) { - var proj4js = ol.proj.proj4.get(); + if (_ol_.ENABLE_PROJ4JS) { + var proj4js = _ol_proj_proj4_.get(); if (typeof proj4js == 'function') { var def = proj4js.defs(code); if (def !== undefined) { @@ -131,7 +131,7 @@ ol.proj.Projection = function(options) { /** * @return {boolean} The projection is suitable for wrapping the x-axis */ -ol.proj.Projection.prototype.canWrapX = function() { +_ol_proj_Projection_.prototype.canWrapX = function() { return this.canWrapX_; }; @@ -141,7 +141,7 @@ ol.proj.Projection.prototype.canWrapX = function() { * @return {string} Code. * @api */ -ol.proj.Projection.prototype.getCode = function() { +_ol_proj_Projection_.prototype.getCode = function() { return this.code_; }; @@ -151,7 +151,7 @@ ol.proj.Projection.prototype.getCode = function() { * @return {ol.Extent} Extent. * @api */ -ol.proj.Projection.prototype.getExtent = function() { +_ol_proj_Projection_.prototype.getExtent = function() { return this.extent_; }; @@ -161,7 +161,7 @@ ol.proj.Projection.prototype.getExtent = function() { * @return {ol.proj.Units} Units. * @api */ -ol.proj.Projection.prototype.getUnits = function() { +_ol_proj_Projection_.prototype.getUnits = function() { return this.units_; }; @@ -173,8 +173,8 @@ ol.proj.Projection.prototype.getUnits = function() { * @return {number|undefined} Meters. * @api */ -ol.proj.Projection.prototype.getMetersPerUnit = function() { - return this.metersPerUnit_ || ol.proj.Units.METERS_PER_UNIT[this.units_]; +_ol_proj_Projection_.prototype.getMetersPerUnit = function() { + return this.metersPerUnit_ || _ol_proj_Units_.METERS_PER_UNIT[this.units_]; }; @@ -183,7 +183,7 @@ ol.proj.Projection.prototype.getMetersPerUnit = function() { * @return {ol.Extent} Extent. * @api */ -ol.proj.Projection.prototype.getWorldExtent = function() { +_ol_proj_Projection_.prototype.getWorldExtent = function() { return this.worldExtent_; }; @@ -199,7 +199,7 @@ ol.proj.Projection.prototype.getWorldExtent = function() { * @return {string} Axis orientation. * @api */ -ol.proj.Projection.prototype.getAxisOrientation = function() { +_ol_proj_Projection_.prototype.getAxisOrientation = function() { return this.axisOrientation_; }; @@ -209,7 +209,7 @@ ol.proj.Projection.prototype.getAxisOrientation = function() { * @return {boolean} Whether the projection is global. * @api */ -ol.proj.Projection.prototype.isGlobal = function() { +_ol_proj_Projection_.prototype.isGlobal = function() { return this.global_; }; @@ -219,7 +219,7 @@ ol.proj.Projection.prototype.isGlobal = function() { * @param {boolean} global Whether the projection is global. * @api */ -ol.proj.Projection.prototype.setGlobal = function(global) { +_ol_proj_Projection_.prototype.setGlobal = function(global) { this.global_ = global; this.canWrapX_ = !!(global && this.extent_); }; @@ -228,7 +228,7 @@ ol.proj.Projection.prototype.setGlobal = function(global) { /** * @return {ol.tilegrid.TileGrid} The default tile grid. */ -ol.proj.Projection.prototype.getDefaultTileGrid = function() { +_ol_proj_Projection_.prototype.getDefaultTileGrid = function() { return this.defaultTileGrid_; }; @@ -236,7 +236,7 @@ ol.proj.Projection.prototype.getDefaultTileGrid = function() { /** * @param {ol.tilegrid.TileGrid} tileGrid The default tile grid. */ -ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) { +_ol_proj_Projection_.prototype.setDefaultTileGrid = function(tileGrid) { this.defaultTileGrid_ = tileGrid; }; @@ -246,7 +246,7 @@ ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) { * @param {ol.Extent} extent Extent. * @api */ -ol.proj.Projection.prototype.setExtent = function(extent) { +_ol_proj_Projection_.prototype.setExtent = function(extent) { this.extent_ = extent; this.canWrapX_ = !!(this.global_ && extent); }; @@ -258,7 +258,7 @@ ol.proj.Projection.prototype.setExtent = function(extent) { * [minlon, minlat, maxlon, maxlat]. * @api */ -ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) { +_ol_proj_Projection_.prototype.setWorldExtent = function(worldExtent) { this.worldExtent_ = worldExtent; }; @@ -269,7 +269,7 @@ ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) { * @param {function(number, ol.Coordinate):number} func Function * @api */ -ol.proj.Projection.prototype.setGetPointResolution = function(func) { +_ol_proj_Projection_.prototype.setGetPointResolution = function(func) { this.getPointResolutionFunc_ = func; }; @@ -279,6 +279,7 @@ ol.proj.Projection.prototype.setGetPointResolution = function(func) { * @return {function(number, ol.Coordinate):number|undefined} The custom point * resolution function (if set). */ -ol.proj.Projection.prototype.getPointResolutionFunc = function() { +_ol_proj_Projection_.prototype.getPointResolutionFunc = function() { return this.getPointResolutionFunc_; }; +export default _ol_proj_Projection_; diff --git a/src/ol/proj/Units.js b/src/ol/proj/Units.js index d122e82227..f1797aafb7 100644 --- a/src/ol/proj/Units.js +++ b/src/ol/proj/Units.js @@ -1,12 +1,12 @@ -goog.provide('ol.proj.Units'); - - +/** + * @module ol/proj/Units + */ /** * Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or * `'us-ft'`. * @enum {string} */ -ol.proj.Units = { +var _ol_proj_Units_ = { DEGREES: 'degrees', FEET: 'ft', METERS: 'm', @@ -22,10 +22,11 @@ ol.proj.Units = { * @type {Object.} * @api */ -ol.proj.Units.METERS_PER_UNIT = {}; +_ol_proj_Units_.METERS_PER_UNIT = {}; // use the radius of the Normal sphere -ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.DEGREES] = +_ol_proj_Units_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES] = 2 * Math.PI * 6370997 / 360; -ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048; -ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.METERS] = 1; -ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.USFEET] = 1200 / 3937; +_ol_proj_Units_.METERS_PER_UNIT[_ol_proj_Units_.FEET] = 0.3048; +_ol_proj_Units_.METERS_PER_UNIT[_ol_proj_Units_.METERS] = 1; +_ol_proj_Units_.METERS_PER_UNIT[_ol_proj_Units_.USFEET] = 1200 / 3937; +export default _ol_proj_Units_; diff --git a/src/ol/proj/common.js b/src/ol/proj/common.js index 7c27ff9477..906f91fd65 100644 --- a/src/ol/proj/common.js +++ b/src/ol/proj/common.js @@ -1,6 +1,8 @@ -goog.provide('ol.proj.common'); - -goog.require('ol.proj'); +/** + * @module ol/proj/common + */ +import _ol_proj_ from '../proj.js'; +var _ol_proj_common_ = {}; /** @@ -10,4 +12,5 @@ goog.require('ol.proj'); * @deprecated This function is no longer necessary. * @api */ -ol.proj.common.add = ol.proj.addCommon; +_ol_proj_common_.add = _ol_proj_.addCommon; +export default _ol_proj_common_; diff --git a/src/ol/proj/proj4.js b/src/ol/proj/proj4.js index 68920887e8..10a28aa2ce 100644 --- a/src/ol/proj/proj4.js +++ b/src/ol/proj/proj4.js @@ -1,19 +1,22 @@ -goog.provide('ol.proj.proj4'); +/** + * @module ol/proj/proj4 + */ +var _ol_proj_proj4_ = {}; /** * @private * @type {Proj4} */ -ol.proj.proj4.cache_ = null; +_ol_proj_proj4_.cache_ = null; /** * Store the proj4 function. * @param {Proj4} proj4 The proj4 function. */ -ol.proj.proj4.set = function(proj4) { - ol.proj.proj4.cache_ = proj4; +_ol_proj_proj4_.set = function(proj4) { + _ol_proj_proj4_.cache_ = proj4; }; @@ -21,6 +24,7 @@ ol.proj.proj4.set = function(proj4) { * Get proj4. * @return {Proj4} The proj4 function set above or available globally. */ -ol.proj.proj4.get = function() { - return ol.proj.proj4.cache_ || window['proj4']; +_ol_proj_proj4_.get = function() { + return _ol_proj_proj4_.cache_ || window['proj4']; }; +export default _ol_proj_proj4_; diff --git a/src/ol/proj/projections.js b/src/ol/proj/projections.js index a81092a5e2..b2148e95fb 100644 --- a/src/ol/proj/projections.js +++ b/src/ol/proj/projections.js @@ -1,18 +1,21 @@ -goog.provide('ol.proj.projections'); +/** + * @module ol/proj/projections + */ +var _ol_proj_projections_ = {}; /** * @private * @type {Object.} */ -ol.proj.projections.cache_ = {}; +_ol_proj_projections_.cache_ = {}; /** * Clear the projections cache. */ -ol.proj.projections.clear = function() { - ol.proj.projections.cache_ = {}; +_ol_proj_projections_.clear = function() { + _ol_proj_projections_.cache_ = {}; }; @@ -21,8 +24,8 @@ ol.proj.projections.clear = function() { * @param {string} code The code for the projection. * @return {ol.proj.Projection} The projection (if cached). */ -ol.proj.projections.get = function(code) { - var projections = ol.proj.projections.cache_; +_ol_proj_projections_.get = function(code) { + var projections = _ol_proj_projections_.cache_; return projections[code] || null; }; @@ -32,7 +35,8 @@ ol.proj.projections.get = function(code) { * @param {string} code The projection code. * @param {ol.proj.Projection} projection The projection to cache. */ -ol.proj.projections.add = function(code, projection) { - var projections = ol.proj.projections.cache_; +_ol_proj_projections_.add = function(code, projection) { + var projections = _ol_proj_projections_.cache_; projections[code] = projection; }; +export default _ol_proj_projections_; diff --git a/src/ol/proj/transforms.js b/src/ol/proj/transforms.js index d3f3e4e4f2..f7fc4068b7 100644 --- a/src/ol/proj/transforms.js +++ b/src/ol/proj/transforms.js @@ -1,20 +1,22 @@ -goog.provide('ol.proj.transforms'); - -goog.require('ol.obj'); +/** + * @module ol/proj/transforms + */ +import _ol_obj_ from '../obj.js'; +var _ol_proj_transforms_ = {}; /** * @private * @type {Object.>} */ -ol.proj.transforms.cache_ = {}; +_ol_proj_transforms_.cache_ = {}; /** * Clear the transform cache. */ -ol.proj.transforms.clear = function() { - ol.proj.transforms.cache_ = {}; +_ol_proj_transforms_.clear = function() { + _ol_proj_transforms_.cache_ = {}; }; @@ -26,10 +28,10 @@ ol.proj.transforms.clear = function() { * @param {ol.proj.Projection} destination Destination. * @param {ol.TransformFunction} transformFn Transform. */ -ol.proj.transforms.add = function(source, destination, transformFn) { +_ol_proj_transforms_.add = function(source, destination, transformFn) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.proj.transforms.cache_; + var transforms = _ol_proj_transforms_.cache_; if (!(sourceCode in transforms)) { transforms[sourceCode] = {}; } @@ -46,13 +48,13 @@ ol.proj.transforms.add = function(source, destination, transformFn) { * @param {ol.proj.Projection} destination Destination projection. * @return {ol.TransformFunction} transformFn The unregistered transform. */ -ol.proj.transforms.remove = function(source, destination) { +_ol_proj_transforms_.remove = function(source, destination) { var sourceCode = source.getCode(); var destinationCode = destination.getCode(); - var transforms = ol.proj.transforms.cache_; + var transforms = _ol_proj_transforms_.cache_; var transform = transforms[sourceCode][destinationCode]; delete transforms[sourceCode][destinationCode]; - if (ol.obj.isEmpty(transforms[sourceCode])) { + if (_ol_obj_.isEmpty(transforms[sourceCode])) { delete transforms[sourceCode]; } return transform; @@ -65,11 +67,12 @@ ol.proj.transforms.remove = function(source, destination) { * @param {string} destinationCode The code for the destination projection. * @return {ol.TransformFunction|undefined} The transform function (if found). */ -ol.proj.transforms.get = function(sourceCode, destinationCode) { +_ol_proj_transforms_.get = function(sourceCode, destinationCode) { var transform; - var transforms = ol.proj.transforms.cache_; + var transforms = _ol_proj_transforms_.cache_; if (sourceCode in transforms && destinationCode in transforms[sourceCode]) { transform = transforms[sourceCode][destinationCode]; } return transform; }; +export default _ol_proj_transforms_; diff --git a/src/ol/render.js b/src/ol/render.js index 12fd27216d..57819793b1 100644 --- a/src/ol/render.js +++ b/src/ol/render.js @@ -1,8 +1,10 @@ -goog.provide('ol.render'); - -goog.require('ol.has'); -goog.require('ol.transform'); -goog.require('ol.render.canvas.Immediate'); +/** + * @module ol/render + */ +import _ol_has_ from './has.js'; +import _ol_transform_ from './transform.js'; +import _ol_render_canvas_Immediate_ from './render/canvas/Immediate.js'; +var _ol_render_ = {}; /** @@ -25,10 +27,10 @@ goog.require('ol.render.canvas.Immediate'); * @return {ol.render.canvas.Immediate} Canvas Immediate. * @api */ -ol.render.toContext = function(context, opt_options) { +_ol_render_.toContext = function(context, opt_options) { var canvas = context.canvas; var options = opt_options ? opt_options : {}; - var pixelRatio = options.pixelRatio || ol.has.DEVICE_PIXEL_RATIO; + var pixelRatio = options.pixelRatio || _ol_has_.DEVICE_PIXEL_RATIO; var size = options.size; if (size) { canvas.width = size[0] * pixelRatio; @@ -37,7 +39,8 @@ ol.render.toContext = function(context, opt_options) { canvas.style.height = size[1] + 'px'; } var extent = [0, 0, canvas.width, canvas.height]; - var transform = ol.transform.scale(ol.transform.create(), pixelRatio, pixelRatio); - return new ol.render.canvas.Immediate(context, pixelRatio, extent, transform, + var transform = _ol_transform_.scale(_ol_transform_.create(), pixelRatio, pixelRatio); + return new _ol_render_canvas_Immediate_(context, pixelRatio, extent, transform, 0); }; +export default _ol_render_; diff --git a/src/ol/render/Box.js b/src/ol/render/Box.js index cd289c9281..d76727339b 100644 --- a/src/ol/render/Box.js +++ b/src/ol/render/Box.js @@ -1,18 +1,18 @@ +/** + * @module ol/render/Box + */ // FIXME add rotation -goog.provide('ol.render.Box'); - -goog.require('ol'); -goog.require('ol.Disposable'); -goog.require('ol.geom.Polygon'); - +import _ol_ from '../index.js'; +import _ol_Disposable_ from '../Disposable.js'; +import _ol_geom_Polygon_ from '../geom/Polygon.js'; /** * @constructor * @extends {ol.Disposable} * @param {string} className CSS class name. */ -ol.render.Box = function(className) { +var _ol_render_Box_ = function(className) { /** * @type {ol.geom.Polygon} @@ -47,13 +47,14 @@ ol.render.Box = function(className) { this.endPixel_ = null; }; -ol.inherits(ol.render.Box, ol.Disposable); + +_ol_.inherits(_ol_render_Box_, _ol_Disposable_); /** * @inheritDoc */ -ol.render.Box.prototype.disposeInternal = function() { +_ol_render_Box_.prototype.disposeInternal = function() { this.setMap(null); }; @@ -61,7 +62,7 @@ ol.render.Box.prototype.disposeInternal = function() { /** * @private */ -ol.render.Box.prototype.render_ = function() { +_ol_render_Box_.prototype.render_ = function() { var startPixel = this.startPixel_; var endPixel = this.endPixel_; var px = 'px'; @@ -76,7 +77,7 @@ ol.render.Box.prototype.render_ = function() { /** * @param {ol.PluggableMap} map Map. */ -ol.render.Box.prototype.setMap = function(map) { +_ol_render_Box_.prototype.setMap = function(map) { if (this.map_) { this.map_.getOverlayContainer().removeChild(this.element_); var style = this.element_.style; @@ -93,7 +94,7 @@ ol.render.Box.prototype.setMap = function(map) { * @param {ol.Pixel} startPixel Start pixel. * @param {ol.Pixel} endPixel End pixel. */ -ol.render.Box.prototype.setPixels = function(startPixel, endPixel) { +_ol_render_Box_.prototype.setPixels = function(startPixel, endPixel) { this.startPixel_ = startPixel; this.endPixel_ = endPixel; this.createOrUpdateGeometry(); @@ -104,7 +105,7 @@ ol.render.Box.prototype.setPixels = function(startPixel, endPixel) { /** * Creates or updates the cached geometry. */ -ol.render.Box.prototype.createOrUpdateGeometry = function() { +_ol_render_Box_.prototype.createOrUpdateGeometry = function() { var startPixel = this.startPixel_; var endPixel = this.endPixel_; var pixels = [ @@ -117,7 +118,7 @@ ol.render.Box.prototype.createOrUpdateGeometry = function() { // close the polygon coordinates[4] = coordinates[0].slice(); if (!this.geometry_) { - this.geometry_ = new ol.geom.Polygon([coordinates]); + this.geometry_ = new _ol_geom_Polygon_([coordinates]); } else { this.geometry_.setCoordinates([coordinates]); } @@ -127,6 +128,7 @@ ol.render.Box.prototype.createOrUpdateGeometry = function() { /** * @return {ol.geom.Polygon} Geometry. */ -ol.render.Box.prototype.getGeometry = function() { +_ol_render_Box_.prototype.getGeometry = function() { return this.geometry_; }; +export default _ol_render_Box_; diff --git a/src/ol/render/Event.js b/src/ol/render/Event.js index 4f55455aa0..da045347b1 100644 --- a/src/ol/render/Event.js +++ b/src/ol/render/Event.js @@ -1,8 +1,8 @@ -goog.provide('ol.render.Event'); - -goog.require('ol'); -goog.require('ol.events.Event'); - +/** + * @module ol/render/Event + */ +import _ol_ from '../index.js'; +import _ol_events_Event_ from '../events/Event.js'; /** * @constructor @@ -14,11 +14,11 @@ goog.require('ol.events.Event'); * @param {?CanvasRenderingContext2D=} opt_context Context. * @param {?ol.webgl.Context=} opt_glContext WebGL Context. */ -ol.render.Event = function( +var _ol_render_Event_ = function( type, opt_vectorContext, opt_frameState, opt_context, opt_glContext) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * For canvas, this is an instance of {@link ol.render.canvas.Immediate}. @@ -51,4 +51,6 @@ ol.render.Event = function( this.glContext = opt_glContext; }; -ol.inherits(ol.render.Event, ol.events.Event); + +_ol_.inherits(_ol_render_Event_, _ol_events_Event_); +export default _ol_render_Event_; diff --git a/src/ol/render/EventType.js b/src/ol/render/EventType.js index 098fc06c33..53f11e3a02 100644 --- a/src/ol/render/EventType.js +++ b/src/ol/render/EventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.render.EventType'); - +/** + * @module ol/render/EventType + */ /** * @enum {string} */ -ol.render.EventType = { +var _ol_render_EventType_ = { /** * @event ol.render.Event#postcompose * @api @@ -20,3 +21,5 @@ ol.render.EventType = { */ RENDER: 'render' }; + +export default _ol_render_EventType_; diff --git a/src/ol/render/Feature.js b/src/ol/render/Feature.js index a3d187fc1a..9c6a193be6 100644 --- a/src/ol/render/Feature.js +++ b/src/ol/render/Feature.js @@ -1,15 +1,15 @@ -goog.provide('ol.render.Feature'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.flat.center'); -goog.require('ol.geom.flat.interiorpoint'); -goog.require('ol.geom.flat.interpolate'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.transform'); - +/** + * @module ol/render/Feature + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_geom_flat_center_ from '../geom/flat/center.js'; +import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js'; +import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js'; +import _ol_geom_flat_transform_ from '../geom/flat/transform.js'; +import _ol_transform_ from '../transform.js'; /** * Lightweight, read-only, {@link ol.Feature} and {@link ol.geom.Geometry} like @@ -24,7 +24,7 @@ goog.require('ol.transform'); * @param {Object.} properties Properties. * @param {number|string|undefined} id Feature id. */ -ol.render.Feature = function(type, flatCoordinates, ends, properties, id) { +var _ol_render_Feature_ = function(type, flatCoordinates, ends, properties, id) { /** * @private * @type {ol.Extent|undefined} @@ -78,7 +78,7 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties, id) { * @private * @type {ol.Transform} */ - this.tmpTransform_ = ol.transform.create(); + this.tmpTransform_ = _ol_transform_.create(); }; @@ -88,7 +88,7 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties, id) { * @return {*} Value for the requested key. * @api */ -ol.render.Feature.prototype.get = function(key) { +_ol_render_Feature_.prototype.get = function(key) { return this.properties_[key]; }; @@ -96,8 +96,8 @@ ol.render.Feature.prototype.get = function(key) { /** * @return {Array.|Array.>} Ends or endss. */ -ol.render.Feature.prototype.getEnds = -ol.render.Feature.prototype.getEndss = function() { +_ol_render_Feature_.prototype.getEnds = +_ol_render_Feature_.prototype.getEndss = function() { return this.ends_; }; @@ -107,11 +107,11 @@ ol.render.Feature.prototype.getEndss = function() { * @return {ol.Extent} Extent. * @api */ -ol.render.Feature.prototype.getExtent = function() { +_ol_render_Feature_.prototype.getExtent = function() { if (!this.extent_) { - this.extent_ = this.type_ === ol.geom.GeometryType.POINT ? - ol.extent.createOrUpdateFromCoordinate(this.flatCoordinates_) : - ol.extent.createOrUpdateFromFlatCoordinates( + this.extent_ = this.type_ === _ol_geom_GeometryType_.POINT ? + _ol_extent_.createOrUpdateFromCoordinate(this.flatCoordinates_) : + _ol_extent_.createOrUpdateFromFlatCoordinates( this.flatCoordinates_, 0, this.flatCoordinates_.length, 2); } @@ -122,10 +122,10 @@ ol.render.Feature.prototype.getExtent = function() { /** * @return {Array.} Flat interior points. */ -ol.render.Feature.prototype.getFlatInteriorPoint = function() { +_ol_render_Feature_.prototype.getFlatInteriorPoint = function() { if (!this.flatInteriorPoints_) { - var flatCenter = ol.extent.getCenter(this.getExtent()); - this.flatInteriorPoints_ = ol.geom.flat.interiorpoint.linearRings( + var flatCenter = _ol_extent_.getCenter(this.getExtent()); + this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings( this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0); } return this.flatInteriorPoints_; @@ -135,11 +135,11 @@ ol.render.Feature.prototype.getFlatInteriorPoint = function() { /** * @return {Array.} Flat interior points. */ -ol.render.Feature.prototype.getFlatInteriorPoints = function() { +_ol_render_Feature_.prototype.getFlatInteriorPoints = function() { if (!this.flatInteriorPoints_) { - var flatCenters = ol.geom.flat.center.linearRingss( + var flatCenters = _ol_geom_flat_center_.linearRingss( this.flatCoordinates_, 0, this.ends_, 2); - this.flatInteriorPoints_ = ol.geom.flat.interiorpoint.linearRingss( + this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss( this.flatCoordinates_, 0, this.ends_, 2, flatCenters); } return this.flatInteriorPoints_; @@ -149,9 +149,9 @@ ol.render.Feature.prototype.getFlatInteriorPoints = function() { /** * @return {Array.} Flat midpoint. */ -ol.render.Feature.prototype.getFlatMidpoint = function() { +_ol_render_Feature_.prototype.getFlatMidpoint = function() { if (!this.flatMidpoints_) { - this.flatMidpoints_ = ol.geom.flat.interpolate.lineString( + this.flatMidpoints_ = _ol_geom_flat_interpolate_.lineString( this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5); } return this.flatMidpoints_; @@ -161,7 +161,7 @@ ol.render.Feature.prototype.getFlatMidpoint = function() { /** * @return {Array.} Flat midpoints. */ -ol.render.Feature.prototype.getFlatMidpoints = function() { +_ol_render_Feature_.prototype.getFlatMidpoints = function() { if (!this.flatMidpoints_) { this.flatMidpoints_ = []; var flatCoordinates = this.flatCoordinates_; @@ -169,9 +169,9 @@ ol.render.Feature.prototype.getFlatMidpoints = function() { var ends = this.ends_; for (var i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; - var midpoint = ol.geom.flat.interpolate.lineString( + var midpoint = _ol_geom_flat_interpolate_.lineString( flatCoordinates, offset, end, 2, 0.5); - ol.array.extend(this.flatMidpoints_, midpoint); + _ol_array_.extend(this.flatMidpoints_, midpoint); offset = end; } } @@ -184,7 +184,7 @@ ol.render.Feature.prototype.getFlatMidpoints = function() { * @return {number|string|undefined} Id. * @api */ -ol.render.Feature.prototype.getId = function() { +_ol_render_Feature_.prototype.getId = function() { return this.id_; }; @@ -192,7 +192,7 @@ ol.render.Feature.prototype.getId = function() { /** * @return {Array.} Flat coordinates. */ -ol.render.Feature.prototype.getOrientedFlatCoordinates = function() { +_ol_render_Feature_.prototype.getOrientedFlatCoordinates = function() { return this.flatCoordinates_; }; @@ -200,8 +200,8 @@ ol.render.Feature.prototype.getOrientedFlatCoordinates = function() { /** * @return {Array.} Flat coordinates. */ -ol.render.Feature.prototype.getFlatCoordinates = - ol.render.Feature.prototype.getOrientedFlatCoordinates; +_ol_render_Feature_.prototype.getFlatCoordinates = + _ol_render_Feature_.prototype.getOrientedFlatCoordinates; /** @@ -210,7 +210,7 @@ ol.render.Feature.prototype.getFlatCoordinates = * @return {ol.render.Feature} Feature. * @api */ -ol.render.Feature.prototype.getGeometry = function() { +_ol_render_Feature_.prototype.getGeometry = function() { return this; }; @@ -220,7 +220,7 @@ ol.render.Feature.prototype.getGeometry = function() { * @return {Object.} Feature properties. * @api */ -ol.render.Feature.prototype.getProperties = function() { +_ol_render_Feature_.prototype.getProperties = function() { return this.properties_; }; @@ -229,14 +229,14 @@ ol.render.Feature.prototype.getProperties = function() { * Get the feature for working with its geometry. * @return {ol.render.Feature} Feature. */ -ol.render.Feature.prototype.getSimplifiedGeometry = - ol.render.Feature.prototype.getGeometry; +_ol_render_Feature_.prototype.getSimplifiedGeometry = + _ol_render_Feature_.prototype.getGeometry; /** * @return {number} Stride. */ -ol.render.Feature.prototype.getStride = function() { +_ol_render_Feature_.prototype.getStride = function() { return 2; }; @@ -244,7 +244,7 @@ ol.render.Feature.prototype.getStride = function() { /** * @return {undefined} */ -ol.render.Feature.prototype.getStyleFunction = ol.nullFunction; +_ol_render_Feature_.prototype.getStyleFunction = _ol_.nullFunction; /** @@ -252,7 +252,7 @@ ol.render.Feature.prototype.getStyleFunction = ol.nullFunction; * @return {ol.geom.GeometryType} Geometry type. * @api */ -ol.render.Feature.prototype.getType = function() { +_ol_render_Feature_.prototype.getType = function() { return this.type_; }; @@ -263,15 +263,16 @@ ol.render.Feature.prototype.getType = function() { * @param {ol.ProjectionLike} source The current projection * @param {ol.ProjectionLike} destination The desired projection. */ -ol.render.Feature.prototype.transform = function(source, destination) { +_ol_render_Feature_.prototype.transform = function(source, destination) { var pixelExtent = source.getExtent(); var projectedExtent = source.getWorldExtent(); - var scale = ol.extent.getHeight(projectedExtent) / ol.extent.getHeight(pixelExtent); + var scale = _ol_extent_.getHeight(projectedExtent) / _ol_extent_.getHeight(pixelExtent); var transform = this.tmpTransform_; - ol.transform.compose(transform, + _ol_transform_.compose(transform, projectedExtent[0], projectedExtent[3], scale, -scale, 0, 0, 0); - ol.geom.flat.transform.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, + _ol_geom_flat_transform_.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, transform, this.flatCoordinates_); }; +export default _ol_render_Feature_; diff --git a/src/ol/render/ReplayGroup.js b/src/ol/render/ReplayGroup.js index 46a6a9b9a6..caf6e87350 100644 --- a/src/ol/render/ReplayGroup.js +++ b/src/ol/render/ReplayGroup.js @@ -1,12 +1,12 @@ -goog.provide('ol.render.ReplayGroup'); - - +/** + * @module ol/render/ReplayGroup + */ /** * Base class for replay groups. * @constructor * @abstract */ -ol.render.ReplayGroup = function() {}; +var _ol_render_ReplayGroup_ = function() {}; /** @@ -15,11 +15,12 @@ ol.render.ReplayGroup = function() {}; * @param {ol.render.ReplayType} replayType Replay type. * @return {ol.render.VectorContext} Replay. */ -ol.render.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {}; +_ol_render_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) {}; /** * @abstract * @return {boolean} Is empty. */ -ol.render.ReplayGroup.prototype.isEmpty = function() {}; +_ol_render_ReplayGroup_.prototype.isEmpty = function() {}; +export default _ol_render_ReplayGroup_; diff --git a/src/ol/render/ReplayType.js b/src/ol/render/ReplayType.js index 066bcef098..158178e924 100644 --- a/src/ol/render/ReplayType.js +++ b/src/ol/render/ReplayType.js @@ -1,10 +1,10 @@ -goog.provide('ol.render.ReplayType'); - - +/** + * @module ol/render/ReplayType + */ /** * @enum {string} */ -ol.render.ReplayType = { +var _ol_render_ReplayType_ = { CIRCLE: 'Circle', DEFAULT: 'Default', IMAGE: 'Image', @@ -12,3 +12,5 @@ ol.render.ReplayType = { POLYGON: 'Polygon', TEXT: 'Text' }; + +export default _ol_render_ReplayType_; diff --git a/src/ol/render/VectorContext.js b/src/ol/render/VectorContext.js index bfeab295e7..b3ed2a5f45 100644 --- a/src/ol/render/VectorContext.js +++ b/src/ol/render/VectorContext.js @@ -1,6 +1,6 @@ -goog.provide('ol.render.VectorContext'); - - +/** + * @module ol/render/VectorContext + */ /** * Context for drawing geometries. A vector context is available on render * events and does not need to be constructed directly. @@ -9,7 +9,7 @@ goog.provide('ol.render.VectorContext'); * @struct * @api */ -ol.render.VectorContext = function() { +var _ol_render_VectorContext_ = function() { }; @@ -20,7 +20,7 @@ ol.render.VectorContext = function() { * @param {ol.Feature|ol.render.Feature} feature Feature. * @param {Function} renderer Renderer. */ -ol.render.VectorContext.prototype.drawCustom = function(geometry, feature, renderer) {}; +_ol_render_VectorContext_.prototype.drawCustom = function(geometry, feature, renderer) {}; /** @@ -28,7 +28,7 @@ ol.render.VectorContext.prototype.drawCustom = function(geometry, feature, rende * * @param {ol.geom.Geometry} geometry The geometry to render. */ -ol.render.VectorContext.prototype.drawGeometry = function(geometry) {}; +_ol_render_VectorContext_.prototype.drawGeometry = function(geometry) {}; /** @@ -36,21 +36,21 @@ ol.render.VectorContext.prototype.drawGeometry = function(geometry) {}; * * @param {ol.style.Style} style The rendering style. */ -ol.render.VectorContext.prototype.setStyle = function(style) {}; +_ol_render_VectorContext_.prototype.setStyle = function(style) {}; /** * @param {ol.geom.Circle} circleGeometry Circle geometry. * @param {ol.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawCircle = function(circleGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawCircle = function(circleGeometry, feature) {}; /** * @param {ol.Feature} feature Feature. * @param {ol.style.Style} style Style. */ -ol.render.VectorContext.prototype.drawFeature = function(feature, style) {}; +_ol_render_VectorContext_.prototype.drawFeature = function(feature, style) {}; /** @@ -58,7 +58,7 @@ ol.render.VectorContext.prototype.drawFeature = function(feature, style) {}; * collection. * @param {ol.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawGeometryCollection = function(geometryCollectionGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawGeometryCollection = function(geometryCollectionGeometry, feature) {}; /** @@ -66,7 +66,7 @@ ol.render.VectorContext.prototype.drawGeometryCollection = function(geometryColl * string geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawLineString = function(lineStringGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawLineString = function(lineStringGeometry, feature) {}; /** @@ -74,7 +74,7 @@ ol.render.VectorContext.prototype.drawLineString = function(lineStringGeometry, * MultiLineString geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {}; /** @@ -82,21 +82,21 @@ ol.render.VectorContext.prototype.drawMultiLineString = function(multiLineString * geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawMultiPoint = function(multiPointGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawMultiPoint = function(multiPointGeometry, feature) {}; /** * @param {ol.geom.MultiPolygon} multiPolygonGeometry MultiPolygon geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {}; /** * @param {ol.geom.Point|ol.render.Feature} pointGeometry Point geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawPoint = function(pointGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawPoint = function(pointGeometry, feature) {}; /** @@ -104,32 +104,33 @@ ol.render.VectorContext.prototype.drawPoint = function(pointGeometry, feature) { * geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawPolygon = function(polygonGeometry, feature) {}; +_ol_render_VectorContext_.prototype.drawPolygon = function(polygonGeometry, feature) {}; /** * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.VectorContext.prototype.drawText = function(geometry, feature) {}; +_ol_render_VectorContext_.prototype.drawText = function(geometry, feature) {}; /** * @param {ol.style.Fill} fillStyle Fill style. * @param {ol.style.Stroke} strokeStyle Stroke style. */ -ol.render.VectorContext.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {}; +_ol_render_VectorContext_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {}; /** * @param {ol.style.Image} imageStyle Image style. * @param {ol.DeclutterGroup=} opt_declutterGroup Declutter. */ -ol.render.VectorContext.prototype.setImageStyle = function(imageStyle, opt_declutterGroup) {}; +_ol_render_VectorContext_.prototype.setImageStyle = function(imageStyle, opt_declutterGroup) {}; /** * @param {ol.style.Text} textStyle Text style. * @param {ol.DeclutterGroup=} opt_declutterGroup Declutter. */ -ol.render.VectorContext.prototype.setTextStyle = function(textStyle, opt_declutterGroup) {}; +_ol_render_VectorContext_.prototype.setTextStyle = function(textStyle, opt_declutterGroup) {}; +export default _ol_render_VectorContext_; diff --git a/src/ol/render/canvas.js b/src/ol/render/canvas.js index 8e5183f120..b06a7a0728 100644 --- a/src/ol/render/canvas.js +++ b/src/ol/render/canvas.js @@ -1,135 +1,136 @@ -goog.provide('ol.render.canvas'); - - -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.obj'); -goog.require('ol.structs.LRUCache'); -goog.require('ol.transform'); +/** + * @module ol/render/canvas + */ +import _ol_css_ from '../css.js'; +import _ol_dom_ from '../dom.js'; +import _ol_obj_ from '../obj.js'; +import _ol_structs_LRUCache_ from '../structs/LRUCache.js'; +import _ol_transform_ from '../transform.js'; +var _ol_render_canvas_ = {}; /** * @const * @type {string} */ -ol.render.canvas.defaultFont = '10px sans-serif'; +_ol_render_canvas_.defaultFont = '10px sans-serif'; /** * @const * @type {ol.Color} */ -ol.render.canvas.defaultFillStyle = [0, 0, 0, 1]; +_ol_render_canvas_.defaultFillStyle = [0, 0, 0, 1]; /** * @const * @type {string} */ -ol.render.canvas.defaultLineCap = 'round'; +_ol_render_canvas_.defaultLineCap = 'round'; /** * @const * @type {Array.} */ -ol.render.canvas.defaultLineDash = []; +_ol_render_canvas_.defaultLineDash = []; /** * @const * @type {number} */ -ol.render.canvas.defaultLineDashOffset = 0; +_ol_render_canvas_.defaultLineDashOffset = 0; /** * @const * @type {string} */ -ol.render.canvas.defaultLineJoin = 'round'; +_ol_render_canvas_.defaultLineJoin = 'round'; /** * @const * @type {number} */ -ol.render.canvas.defaultMiterLimit = 10; +_ol_render_canvas_.defaultMiterLimit = 10; /** * @const * @type {ol.Color} */ -ol.render.canvas.defaultStrokeStyle = [0, 0, 0, 1]; +_ol_render_canvas_.defaultStrokeStyle = [0, 0, 0, 1]; /** * @const * @type {string} */ -ol.render.canvas.defaultTextAlign = 'center'; +_ol_render_canvas_.defaultTextAlign = 'center'; /** * @const * @type {string} */ -ol.render.canvas.defaultTextBaseline = 'middle'; +_ol_render_canvas_.defaultTextBaseline = 'middle'; /** * @const * @type {Array.} */ -ol.render.canvas.defaultPadding = [0, 0, 0, 0]; +_ol_render_canvas_.defaultPadding = [0, 0, 0, 0]; /** * @const * @type {number} */ -ol.render.canvas.defaultLineWidth = 1; +_ol_render_canvas_.defaultLineWidth = 1; /** * @type {ol.structs.LRUCache.} */ -ol.render.canvas.labelCache = new ol.structs.LRUCache(); +_ol_render_canvas_.labelCache = new _ol_structs_LRUCache_(); /** * @type {!Object.} */ -ol.render.canvas.checkedFonts_ = {}; +_ol_render_canvas_.checkedFonts_ = {}; /** * @type {CanvasRenderingContext2D} */ -ol.render.canvas.measureContext_ = null; +_ol_render_canvas_.measureContext_ = null; /** * @type {!Object.} */ -ol.render.canvas.textHeights_ = {}; +_ol_render_canvas_.textHeights_ = {}; /** * Clears the label cache when a font becomes available. * @param {string} fontSpec CSS font spec. */ -ol.render.canvas.checkFont = (function() { +_ol_render_canvas_.checkFont = (function() { var retries = 60; - var checked = ol.render.canvas.checkedFonts_; - var labelCache = ol.render.canvas.labelCache; + var checked = _ol_render_canvas_.checkedFonts_; + var labelCache = _ol_render_canvas_.labelCache; var font = '32px monospace'; var text = 'wmytzilWMYTZIL@#/&?$%10'; var interval, referenceWidth; function isAvailable(fontFamily) { - var context = ol.render.canvas.getMeasureContext(); + var context = _ol_render_canvas_.getMeasureContext(); context.font = font; referenceWidth = context.measureText(text).width; var available = true; @@ -150,9 +151,9 @@ ol.render.canvas.checkFont = (function() { if (checked[font] < retries) { if (isAvailable(font)) { checked[font] = retries; - ol.obj.clear(ol.render.canvas.textHeights_); + _ol_obj_.clear(_ol_render_canvas_.textHeights_); // Make sure that loaded fonts are picked up by Safari - ol.render.canvas.measureContext_ = null; + _ol_render_canvas_.measureContext_ = null; labelCache.clear(); } else { ++checked[font]; @@ -167,7 +168,7 @@ ol.render.canvas.checkFont = (function() { } return function(fontSpec) { - var fontFamilies = ol.css.getFontFamilies(fontSpec); + var fontFamilies = _ol_css_.getFontFamilies(fontSpec); if (!fontFamilies) { return; } @@ -190,10 +191,10 @@ ol.render.canvas.checkFont = (function() { /** * @return {CanvasRenderingContext2D} Measure context. */ -ol.render.canvas.getMeasureContext = function() { - var context = ol.render.canvas.measureContext_; +_ol_render_canvas_.getMeasureContext = function() { + var context = _ol_render_canvas_.measureContext_; if (!context) { - context = ol.render.canvas.measureContext_ = ol.dom.createCanvasContext2D(1, 1); + context = _ol_render_canvas_.measureContext_ = _ol_dom_.createCanvasContext2D(1, 1); } return context; }; @@ -203,9 +204,9 @@ ol.render.canvas.getMeasureContext = function() { * @param {string} font Font to use for measuring. * @return {ol.Size} Measurement. */ -ol.render.canvas.measureTextHeight = (function() { +_ol_render_canvas_.measureTextHeight = (function() { var span; - var heights = ol.render.canvas.textHeights_; + var heights = _ol_render_canvas_.textHeights_; return function(font) { var height = heights[font]; if (height == undefined) { @@ -231,8 +232,8 @@ ol.render.canvas.measureTextHeight = (function() { * @param {string} text Text. * @return {number} Width. */ -ol.render.canvas.measureTextWidth = function(font, text) { - var measureContext = ol.render.canvas.getMeasureContext(); +_ol_render_canvas_.measureTextWidth = function(font, text) { + var measureContext = _ol_render_canvas_.getMeasureContext(); if (font != measureContext.font) { measureContext.font = font; } @@ -246,7 +247,7 @@ ol.render.canvas.measureTextWidth = function(font, text) { * @param {number} offsetX X offset. * @param {number} offsetY Y offset. */ -ol.render.canvas.rotateAtOffset = function(context, rotation, offsetX, offsetY) { +_ol_render_canvas_.rotateAtOffset = function(context, rotation, offsetX, offsetY) { if (rotation !== 0) { context.translate(offsetX, offsetY); context.rotate(rotation); @@ -255,7 +256,7 @@ ol.render.canvas.rotateAtOffset = function(context, rotation, offsetX, offsetY) }; -ol.render.canvas.resetTransform_ = ol.transform.create(); +_ol_render_canvas_.resetTransform_ = _ol_transform_.create(); /** @@ -271,7 +272,7 @@ ol.render.canvas.resetTransform_ = ol.transform.create(); * @param {number} y Y. * @param {number} scale Scale. */ -ol.render.canvas.drawImage = function(context, +_ol_render_canvas_.drawImage = function(context, transform, opacity, image, originX, originY, w, h, x, y, scale) { var alpha; if (opacity != 1) { @@ -288,6 +289,7 @@ ol.render.canvas.drawImage = function(context, context.globalAlpha = alpha; } if (transform) { - context.setTransform.apply(context, ol.render.canvas.resetTransform_); + context.setTransform.apply(context, _ol_render_canvas_.resetTransform_); } }; +export default _ol_render_canvas_; diff --git a/src/ol/render/canvas/ImageReplay.js b/src/ol/render/canvas/ImageReplay.js index fb021f27cc..6158c21a28 100644 --- a/src/ol/render/canvas/ImageReplay.js +++ b/src/ol/render/canvas/ImageReplay.js @@ -1,9 +1,9 @@ -goog.provide('ol.render.canvas.ImageReplay'); - -goog.require('ol'); -goog.require('ol.render.canvas.Instruction'); -goog.require('ol.render.canvas.Replay'); - +/** + * @module ol/render/canvas/ImageReplay + */ +import _ol_ from '../../index.js'; +import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; +import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; /** * @constructor @@ -16,9 +16,9 @@ goog.require('ol.render.canvas.Replay'); * @param {?} declutterTree Declutter tree. * @struct */ -ol.render.canvas.ImageReplay = function( +var _ol_render_canvas_ImageReplay_ = function( tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { - ol.render.canvas.Replay.call(this, + _ol_render_canvas_Replay_.call(this, tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree); /** @@ -106,7 +106,8 @@ ol.render.canvas.ImageReplay = function( this.width_ = undefined; }; -ol.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay); + +_ol_.inherits(_ol_render_canvas_ImageReplay_, _ol_render_canvas_Replay_); /** @@ -117,7 +118,7 @@ ol.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay); * @private * @return {number} My end. */ -ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { +_ol_render_canvas_ImageReplay_.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { return this.appendFlatCoordinates( flatCoordinates, offset, end, stride, false, false); }; @@ -126,7 +127,7 @@ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinat /** * @inheritDoc */ -ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) { +_ol_render_canvas_ImageReplay_.prototype.drawPoint = function(pointGeometry, feature) { if (!this.image_) { return; } @@ -137,14 +138,14 @@ ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, featu var myEnd = this.drawCoordinates_( flatCoordinates, 0, flatCoordinates.length, stride); this.instructions.push([ - ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_, + _ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_, this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_ ]); this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, + _ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, @@ -158,7 +159,7 @@ ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, featu /** * @inheritDoc */ -ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) { +_ol_render_canvas_ImageReplay_.prototype.drawMultiPoint = function(multiPointGeometry, feature) { if (!this.image_) { return; } @@ -169,14 +170,14 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeome var myEnd = this.drawCoordinates_( flatCoordinates, 0, flatCoordinates.length, stride); this.instructions.push([ - ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_, + _ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_, this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_ ]); this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, + _ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.hitDetectionImage_, // Remaining arguments to DRAW_IMAGE are in alphabetical order this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_, @@ -190,7 +191,7 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeome /** * @inheritDoc */ -ol.render.canvas.ImageReplay.prototype.finish = function() { +_ol_render_canvas_ImageReplay_.prototype.finish = function() { this.reverseHitDetectionInstructions(); // FIXME this doesn't really protect us against further calls to draw*Geometry this.anchorX_ = undefined; @@ -212,7 +213,7 @@ ol.render.canvas.ImageReplay.prototype.finish = function() { /** * @inheritDoc */ -ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle, declutterGroup) { +_ol_render_canvas_ImageReplay_.prototype.setImageStyle = function(imageStyle, declutterGroup) { var anchor = imageStyle.getAnchor(); var size = imageStyle.getSize(); var hitDetectionImage = imageStyle.getHitDetectionImage(1); @@ -233,3 +234,4 @@ ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle, decl this.snapToPixel_ = imageStyle.getSnapToPixel(); this.width_ = size[0]; }; +export default _ol_render_canvas_ImageReplay_; diff --git a/src/ol/render/canvas/Immediate.js b/src/ol/render/canvas/Immediate.js index b3cef08778..bb9c1dcb3b 100644 --- a/src/ol/render/canvas/Immediate.js +++ b/src/ol/render/canvas/Immediate.js @@ -1,21 +1,21 @@ +/** + * @module ol/render/canvas/Immediate + */ // FIXME test, especially polygons with holes and multipolygons // FIXME need to handle large thick features (where pixel size matters) // FIXME add offset and end to ol.geom.flat.transform.transform2D? -goog.provide('ol.render.canvas.Immediate'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.colorlike'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.has'); -goog.require('ol.render.VectorContext'); -goog.require('ol.render.canvas'); -goog.require('ol.transform'); - +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_colorlike_ from '../../colorlike.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_geom_GeometryType_ from '../../geom/GeometryType.js'; +import _ol_geom_SimpleGeometry_ from '../../geom/SimpleGeometry.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_has_ from '../../has.js'; +import _ol_render_VectorContext_ from '../VectorContext.js'; +import _ol_render_canvas_ from '../canvas.js'; +import _ol_transform_ from '../../transform.js'; /** * @classdesc @@ -35,8 +35,8 @@ goog.require('ol.transform'); * @param {number} viewRotation View rotation. * @struct */ -ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, viewRotation) { - ol.render.VectorContext.call(this); +var _ol_render_canvas_Immediate_ = function(context, pixelRatio, extent, transform, viewRotation) { + _ol_render_VectorContext_.call(this); /** * @private @@ -234,10 +234,11 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi * @private * @type {ol.Transform} */ - this.tmpLocalTransform_ = ol.transform.create(); + this.tmpLocalTransform_ = _ol_transform_.create(); }; -ol.inherits(ol.render.canvas.Immediate, ol.render.VectorContext); + +_ol_.inherits(_ol_render_canvas_Immediate_, _ol_render_VectorContext_); /** @@ -247,11 +248,11 @@ ol.inherits(ol.render.canvas.Immediate, ol.render.VectorContext); * @param {number} stride Stride. * @private */ -ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, offset, end, stride) { +_ol_render_canvas_Immediate_.prototype.drawImages_ = function(flatCoordinates, offset, end, stride) { if (!this.image_) { return; } - var pixelCoordinates = ol.geom.flat.transform.transform2D( + var pixelCoordinates = _ol_geom_flat_transform_.transform2D( flatCoordinates, offset, end, 2, this.transform_, this.pixelCoordinates_); var context = this.context_; @@ -275,7 +276,7 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off if (rotation !== 0 || this.imageScale_ != 1) { var centerX = x + this.imageAnchorX_; var centerY = y + this.imageAnchorY_; - ol.transform.compose(localTransform, + _ol_transform_.compose(localTransform, centerX, centerY, this.imageScale_, this.imageScale_, rotation, @@ -302,7 +303,7 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off * @param {number} stride Stride. * @private */ -ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offset, end, stride) { +_ol_render_canvas_Immediate_.prototype.drawText_ = function(flatCoordinates, offset, end, stride) { if (!this.textState_ || this.text_ === '') { return; } @@ -313,7 +314,7 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse this.setContextStrokeState_(this.textStrokeState_); } this.setContextTextState_(this.textState_); - var pixelCoordinates = ol.geom.flat.transform.transform2D( + var pixelCoordinates = _ol_geom_flat_transform_.transform2D( flatCoordinates, offset, end, stride, this.transform_, this.pixelCoordinates_); var context = this.context_; @@ -325,7 +326,7 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse var x = pixelCoordinates[offset] + this.textOffsetX_; var y = pixelCoordinates[offset + 1] + this.textOffsetY_; if (rotation !== 0 || this.textScale_ != 1) { - var localTransform = ol.transform.compose(this.tmpLocalTransform_, + var localTransform = _ol_transform_.compose(this.tmpLocalTransform_, x, y, this.textScale_, this.textScale_, rotation, @@ -354,9 +355,9 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse * @private * @return {number} end End. */ -ol.render.canvas.Immediate.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) { +_ol_render_canvas_Immediate_.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) { var context = this.context_; - var pixelCoordinates = ol.geom.flat.transform.transform2D( + var pixelCoordinates = _ol_geom_flat_transform_.transform2D( flatCoordinates, offset, end, stride, this.transform_, this.pixelCoordinates_); context.moveTo(pixelCoordinates[0], pixelCoordinates[1]); @@ -382,7 +383,7 @@ ol.render.canvas.Immediate.prototype.moveToLineTo_ = function(flatCoordinates, o * @private * @return {number} End. */ -ol.render.canvas.Immediate.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) { +_ol_render_canvas_Immediate_.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) { var i, ii; for (i = 0, ii = ends.length; i < ii; ++i) { offset = this.moveToLineTo_( @@ -400,8 +401,8 @@ ol.render.canvas.Immediate.prototype.drawRings_ = function(flatCoordinates, offs * @override * @api */ -ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) { - if (!ol.extent.intersects(this.extent_, geometry.getExtent())) { +_ol_render_canvas_Immediate_.prototype.drawCircle = function(geometry) { + if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } if (this.fillState_ || this.strokeState_) { @@ -411,7 +412,7 @@ ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) { if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); } - var pixelCoordinates = ol.geom.SimpleGeometry.transform2D( + var pixelCoordinates = _ol_geom_SimpleGeometry_.transform2D( geometry, this.transform_, this.pixelCoordinates_); var dx = pixelCoordinates[2] - pixelCoordinates[0]; var dy = pixelCoordinates[3] - pixelCoordinates[1]; @@ -441,7 +442,7 @@ ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) { * @override * @api */ -ol.render.canvas.Immediate.prototype.setStyle = function(style) { +_ol_render_canvas_Immediate_.prototype.setStyle = function(style) { this.setFillStrokeStyle(style.getFill(), style.getStroke()); this.setImageStyle(style.getImage()); this.setTextStyle(style.getText()); @@ -456,31 +457,31 @@ ol.render.canvas.Immediate.prototype.setStyle = function(style) { * @override * @api */ -ol.render.canvas.Immediate.prototype.drawGeometry = function(geometry) { +_ol_render_canvas_Immediate_.prototype.drawGeometry = function(geometry) { var type = geometry.getType(); switch (type) { - case ol.geom.GeometryType.POINT: + case _ol_geom_GeometryType_.POINT: this.drawPoint(/** @type {ol.geom.Point} */ (geometry)); break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: this.drawLineString(/** @type {ol.geom.LineString} */ (geometry)); break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: this.drawPolygon(/** @type {ol.geom.Polygon} */ (geometry)); break; - case ol.geom.GeometryType.MULTI_POINT: + case _ol_geom_GeometryType_.MULTI_POINT: this.drawMultiPoint(/** @type {ol.geom.MultiPoint} */ (geometry)); break; - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: this.drawMultiLineString(/** @type {ol.geom.MultiLineString} */ (geometry)); break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: this.drawMultiPolygon(/** @type {ol.geom.MultiPolygon} */ (geometry)); break; - case ol.geom.GeometryType.GEOMETRY_COLLECTION: + case _ol_geom_GeometryType_.GEOMETRY_COLLECTION: this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry)); break; - case ol.geom.GeometryType.CIRCLE: + case _ol_geom_GeometryType_.CIRCLE: this.drawCircle(/** @type {ol.geom.Circle} */ (geometry)); break; default: @@ -499,10 +500,10 @@ ol.render.canvas.Immediate.prototype.drawGeometry = function(geometry) { * @override * @api */ -ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) { +_ol_render_canvas_Immediate_.prototype.drawFeature = function(feature, style) { var geometry = style.getGeometryFunction()(feature); if (!geometry || - !ol.extent.intersects(this.extent_, geometry.getExtent())) { + !_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } this.setStyle(style); @@ -517,7 +518,7 @@ ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) { * @param {ol.geom.GeometryCollection} geometry Geometry collection. * @override */ -ol.render.canvas.Immediate.prototype.drawGeometryCollection = function(geometry) { +_ol_render_canvas_Immediate_.prototype.drawGeometryCollection = function(geometry) { var geometries = geometry.getGeometriesArray(); var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -533,7 +534,7 @@ ol.render.canvas.Immediate.prototype.drawGeometryCollection = function(geometry) * @param {ol.geom.Point|ol.render.Feature} geometry Point geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawPoint = function(geometry) { +_ol_render_canvas_Immediate_.prototype.drawPoint = function(geometry) { var flatCoordinates = geometry.getFlatCoordinates(); var stride = geometry.getStride(); if (this.image_) { @@ -552,7 +553,7 @@ ol.render.canvas.Immediate.prototype.drawPoint = function(geometry) { * @param {ol.geom.MultiPoint|ol.render.Feature} geometry MultiPoint geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawMultiPoint = function(geometry) { +_ol_render_canvas_Immediate_.prototype.drawMultiPoint = function(geometry) { var flatCoordinates = geometry.getFlatCoordinates(); var stride = geometry.getStride(); if (this.image_) { @@ -571,8 +572,8 @@ ol.render.canvas.Immediate.prototype.drawMultiPoint = function(geometry) { * @param {ol.geom.LineString|ol.render.Feature} geometry LineString geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawLineString = function(geometry) { - if (!ol.extent.intersects(this.extent_, geometry.getExtent())) { +_ol_render_canvas_Immediate_.prototype.drawLineString = function(geometry) { + if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } if (this.strokeState_) { @@ -599,9 +600,9 @@ ol.render.canvas.Immediate.prototype.drawLineString = function(geometry) { * geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawMultiLineString = function(geometry) { +_ol_render_canvas_Immediate_.prototype.drawMultiLineString = function(geometry) { var geometryExtent = geometry.getExtent(); - if (!ol.extent.intersects(this.extent_, geometryExtent)) { + if (!_ol_extent_.intersects(this.extent_, geometryExtent)) { return; } if (this.strokeState_) { @@ -633,8 +634,8 @@ ol.render.canvas.Immediate.prototype.drawMultiLineString = function(geometry) { * @param {ol.geom.Polygon|ol.render.Feature} geometry Polygon geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawPolygon = function(geometry) { - if (!ol.extent.intersects(this.extent_, geometry.getExtent())) { +_ol_render_canvas_Immediate_.prototype.drawPolygon = function(geometry) { + if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } if (this.strokeState_ || this.fillState_) { @@ -668,8 +669,8 @@ ol.render.canvas.Immediate.prototype.drawPolygon = function(geometry) { * @param {ol.geom.MultiPolygon} geometry MultiPolygon geometry. * @override */ -ol.render.canvas.Immediate.prototype.drawMultiPolygon = function(geometry) { - if (!ol.extent.intersects(this.extent_, geometry.getExtent())) { +_ol_render_canvas_Immediate_.prototype.drawMultiPolygon = function(geometry) { + if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } if (this.strokeState_ || this.fillState_) { @@ -708,7 +709,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygon = function(geometry) { * @param {ol.CanvasFillState} fillState Fill state. * @private */ -ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) { +_ol_render_canvas_Immediate_.prototype.setContextFillState_ = function(fillState) { var context = this.context_; var contextFillState = this.contextFillState_; if (!contextFillState) { @@ -728,12 +729,12 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) * @param {ol.CanvasStrokeState} strokeState Stroke state. * @private */ -ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeState) { +_ol_render_canvas_Immediate_.prototype.setContextStrokeState_ = function(strokeState) { var context = this.context_; var contextStrokeState = this.contextStrokeState_; if (!contextStrokeState) { context.lineCap = strokeState.lineCap; - if (ol.has.CANVAS_LINE_DASH) { + if (_ol_has_.CANVAS_LINE_DASH) { context.setLineDash(strokeState.lineDash); context.lineDashOffset = strokeState.lineDashOffset; } @@ -754,8 +755,8 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta if (contextStrokeState.lineCap != strokeState.lineCap) { contextStrokeState.lineCap = context.lineCap = strokeState.lineCap; } - if (ol.has.CANVAS_LINE_DASH) { - if (!ol.array.equals( + if (_ol_has_.CANVAS_LINE_DASH) { + if (!_ol_array_.equals( contextStrokeState.lineDash, strokeState.lineDash)) { context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash); } @@ -786,11 +787,11 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta * @param {ol.CanvasTextState} textState Text state. * @private */ -ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState) { +_ol_render_canvas_Immediate_.prototype.setContextTextState_ = function(textState) { var context = this.context_; var contextTextState = this.contextTextState_; var textAlign = textState.textAlign ? - textState.textAlign : ol.render.canvas.defaultTextAlign; + textState.textAlign : _ol_render_canvas_.defaultTextAlign; if (!contextTextState) { context.font = textState.font; context.textAlign = textAlign; @@ -823,14 +824,14 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState) * @param {ol.style.Stroke} strokeStyle Stroke style. * @override */ -ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_canvas_Immediate_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { if (!fillStyle) { this.fillState_ = null; } else { var fillStyleColor = fillStyle.getColor(); this.fillState_ = { - fillStyle: ol.colorlike.asColorLike(fillStyleColor ? - fillStyleColor : ol.render.canvas.defaultFillStyle) + fillStyle: _ol_colorlike_.asColorLike(fillStyleColor ? + fillStyleColor : _ol_render_canvas_.defaultFillStyle) }; } if (!strokeStyle) { @@ -845,19 +846,19 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, st var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); this.strokeState_ = { lineCap: strokeStyleLineCap !== undefined ? - strokeStyleLineCap : ol.render.canvas.defaultLineCap, + strokeStyleLineCap : _ol_render_canvas_.defaultLineCap, lineDash: strokeStyleLineDash ? - strokeStyleLineDash : ol.render.canvas.defaultLineDash, + strokeStyleLineDash : _ol_render_canvas_.defaultLineDash, lineDashOffset: strokeStyleLineDashOffset ? - strokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset, + strokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset, lineJoin: strokeStyleLineJoin !== undefined ? - strokeStyleLineJoin : ol.render.canvas.defaultLineJoin, + strokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin, lineWidth: this.pixelRatio_ * (strokeStyleWidth !== undefined ? - strokeStyleWidth : ol.render.canvas.defaultLineWidth), + strokeStyleWidth : _ol_render_canvas_.defaultLineWidth), miterLimit: strokeStyleMiterLimit !== undefined ? - strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, - strokeStyle: ol.colorlike.asColorLike(strokeStyleColor ? - strokeStyleColor : ol.render.canvas.defaultStrokeStyle) + strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit, + strokeStyle: _ol_colorlike_.asColorLike(strokeStyleColor ? + strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle) }; } }; @@ -870,7 +871,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, st * @param {ol.style.Image} imageStyle Image style. * @override */ -ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { +_ol_render_canvas_Immediate_.prototype.setImageStyle = function(imageStyle) { if (!imageStyle) { this.image_ = null; } else { @@ -902,7 +903,7 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { * @param {ol.style.Text} textStyle Text style. * @override */ -ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { +_ol_render_canvas_Immediate_.prototype.setTextStyle = function(textStyle) { if (!textStyle) { this.text_ = ''; } else { @@ -912,8 +913,8 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { } else { var textFillStyleColor = textFillStyle.getColor(); this.textFillState_ = { - fillStyle: ol.colorlike.asColorLike(textFillStyleColor ? - textFillStyleColor : ol.render.canvas.defaultFillStyle) + fillStyle: _ol_colorlike_.asColorLike(textFillStyleColor ? + textFillStyleColor : _ol_render_canvas_.defaultFillStyle) }; } var textStrokeStyle = textStyle.getStroke(); @@ -929,19 +930,19 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit(); this.textStrokeState_ = { lineCap: textStrokeStyleLineCap !== undefined ? - textStrokeStyleLineCap : ol.render.canvas.defaultLineCap, + textStrokeStyleLineCap : _ol_render_canvas_.defaultLineCap, lineDash: textStrokeStyleLineDash ? - textStrokeStyleLineDash : ol.render.canvas.defaultLineDash, + textStrokeStyleLineDash : _ol_render_canvas_.defaultLineDash, lineDashOffset: textStrokeStyleLineDashOffset ? - textStrokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset, + textStrokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset, lineJoin: textStrokeStyleLineJoin !== undefined ? - textStrokeStyleLineJoin : ol.render.canvas.defaultLineJoin, + textStrokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin, lineWidth: textStrokeStyleWidth !== undefined ? - textStrokeStyleWidth : ol.render.canvas.defaultLineWidth, + textStrokeStyleWidth : _ol_render_canvas_.defaultLineWidth, miterLimit: textStrokeStyleMiterLimit !== undefined ? - textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, - strokeStyle: ol.colorlike.asColorLike(textStrokeStyleColor ? - textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle) + textStrokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit, + strokeStyle: _ol_colorlike_.asColorLike(textStrokeStyleColor ? + textStrokeStyleColor : _ol_render_canvas_.defaultStrokeStyle) }; } var textFont = textStyle.getFont(); @@ -955,11 +956,11 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { var textTextBaseline = textStyle.getTextBaseline(); this.textState_ = { font: textFont !== undefined ? - textFont : ol.render.canvas.defaultFont, + textFont : _ol_render_canvas_.defaultFont, textAlign: textTextAlign !== undefined ? - textTextAlign : ol.render.canvas.defaultTextAlign, + textTextAlign : _ol_render_canvas_.defaultTextAlign, textBaseline: textTextBaseline !== undefined ? - textTextBaseline : ol.render.canvas.defaultTextBaseline + textTextBaseline : _ol_render_canvas_.defaultTextBaseline }; this.text_ = textText !== undefined ? textText : ''; this.textOffsetX_ = @@ -972,3 +973,4 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { textScale : 1); } }; +export default _ol_render_canvas_Immediate_; diff --git a/src/ol/render/canvas/Instruction.js b/src/ol/render/canvas/Instruction.js index 205e6381f6..43f6dfb8c0 100644 --- a/src/ol/render/canvas/Instruction.js +++ b/src/ol/render/canvas/Instruction.js @@ -1,9 +1,10 @@ -goog.provide('ol.render.canvas.Instruction'); - +/** + * @module ol/render/canvas/Instruction + */ /** * @enum {number} */ -ol.render.canvas.Instruction = { +var _ol_render_canvas_Instruction_ = { BEGIN_GEOMETRY: 0, BEGIN_PATH: 1, CIRCLE: 2, @@ -18,3 +19,5 @@ ol.render.canvas.Instruction = { SET_STROKE_STYLE: 11, STROKE: 12 }; + +export default _ol_render_canvas_Instruction_; diff --git a/src/ol/render/canvas/LineStringReplay.js b/src/ol/render/canvas/LineStringReplay.js index 04035b33d9..09ccc10adb 100644 --- a/src/ol/render/canvas/LineStringReplay.js +++ b/src/ol/render/canvas/LineStringReplay.js @@ -1,9 +1,9 @@ -goog.provide('ol.render.canvas.LineStringReplay'); - -goog.require('ol'); -goog.require('ol.render.canvas.Instruction'); -goog.require('ol.render.canvas.Replay'); - +/** + * @module ol/render/canvas/LineStringReplay + */ +import _ol_ from '../../index.js'; +import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; +import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; /** * @constructor @@ -16,12 +16,13 @@ goog.require('ol.render.canvas.Replay'); * @param {?} declutterTree Declutter tree. * @struct */ -ol.render.canvas.LineStringReplay = function( +var _ol_render_canvas_LineStringReplay_ = function( tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { - ol.render.canvas.Replay.call(this, + _ol_render_canvas_Replay_.call(this, tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree); }; -ol.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay); + +_ol_.inherits(_ol_render_canvas_LineStringReplay_, _ol_render_canvas_Replay_); /** @@ -32,12 +33,12 @@ ol.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay); * @private * @return {number} end. */ -ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) { +_ol_render_canvas_LineStringReplay_.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) { var myBegin = this.coordinates.length; var myEnd = this.appendFlatCoordinates( flatCoordinates, offset, end, stride, false, false); var moveToLineToInstruction = - [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd]; + [_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd]; this.instructions.push(moveToLineToInstruction); this.hitDetectionInstructions.push(moveToLineToInstruction); return end; @@ -47,7 +48,7 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = function(flat /** * @inheritDoc */ -ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) { +_ol_render_canvas_LineStringReplay_.prototype.drawLineString = function(lineStringGeometry, feature) { var state = this.state; var strokeStyle = state.strokeStyle; var lineWidth = state.lineWidth; @@ -57,16 +58,16 @@ ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineString this.updateStrokeStyle(state, this.applyStroke); this.beginGeometry(lineStringGeometry, feature); this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.miterLimit, state.lineDash, state.lineDashOffset ], [ - ol.render.canvas.Instruction.BEGIN_PATH + _ol_render_canvas_Instruction_.BEGIN_PATH ]); var flatCoordinates = lineStringGeometry.getFlatCoordinates(); var stride = lineStringGeometry.getStride(); this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride); - this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]); + this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]); this.endGeometry(lineStringGeometry, feature); }; @@ -74,7 +75,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineString /** * @inheritDoc */ -ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) { +_ol_render_canvas_LineStringReplay_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) { var state = this.state; var strokeStyle = state.strokeStyle; var lineWidth = state.lineWidth; @@ -84,11 +85,11 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi this.updateStrokeStyle(state, this.applyStroke); this.beginGeometry(multiLineStringGeometry, feature); this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.miterLimit, state.lineDash, state.lineDashOffset ], [ - ol.render.canvas.Instruction.BEGIN_PATH + _ol_render_canvas_Instruction_.BEGIN_PATH ]); var ends = multiLineStringGeometry.getEnds(); var flatCoordinates = multiLineStringGeometry.getFlatCoordinates(); @@ -99,7 +100,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi offset = this.drawFlatCoordinates_( flatCoordinates, offset, ends[i], stride); } - this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]); + this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]); this.endGeometry(multiLineStringGeometry, feature); }; @@ -107,10 +108,10 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi /** * @inheritDoc */ -ol.render.canvas.LineStringReplay.prototype.finish = function() { +_ol_render_canvas_LineStringReplay_.prototype.finish = function() { var state = this.state; if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) { - this.instructions.push([ol.render.canvas.Instruction.STROKE]); + this.instructions.push([_ol_render_canvas_Instruction_.STROKE]); } this.reverseHitDetectionInstructions(); this.state = null; @@ -120,12 +121,13 @@ ol.render.canvas.LineStringReplay.prototype.finish = function() { /** * @inheritDoc. */ -ol.render.canvas.LineStringReplay.prototype.applyStroke = function(state) { +_ol_render_canvas_LineStringReplay_.prototype.applyStroke = function(state) { if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) { - this.instructions.push([ol.render.canvas.Instruction.STROKE]); + this.instructions.push([_ol_render_canvas_Instruction_.STROKE]); state.lastStroke = this.coordinates.length; } state.lastStroke = 0; - ol.render.canvas.Replay.prototype.applyStroke.call(this, state); - this.instructions.push([ol.render.canvas.Instruction.BEGIN_PATH]); + _ol_render_canvas_Replay_.prototype.applyStroke.call(this, state); + this.instructions.push([_ol_render_canvas_Instruction_.BEGIN_PATH]); }; +export default _ol_render_canvas_LineStringReplay_; diff --git a/src/ol/render/canvas/PolygonReplay.js b/src/ol/render/canvas/PolygonReplay.js index 8589850203..20079cf0ba 100644 --- a/src/ol/render/canvas/PolygonReplay.js +++ b/src/ol/render/canvas/PolygonReplay.js @@ -1,12 +1,12 @@ -goog.provide('ol.render.canvas.PolygonReplay'); - -goog.require('ol'); -goog.require('ol.color'); -goog.require('ol.geom.flat.simplify'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.Instruction'); -goog.require('ol.render.canvas.Replay'); - +/** + * @module ol/render/canvas/PolygonReplay + */ +import _ol_ from '../../index.js'; +import _ol_color_ from '../../color.js'; +import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js'; +import _ol_render_canvas_ from '../canvas.js'; +import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; +import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; /** * @constructor @@ -19,12 +19,13 @@ goog.require('ol.render.canvas.Replay'); * @param {?} declutterTree Declutter tree. * @struct */ -ol.render.canvas.PolygonReplay = function( +var _ol_render_canvas_PolygonReplay_ = function( tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { - ol.render.canvas.Replay.call(this, + _ol_render_canvas_Replay_.call(this, tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree); }; -ol.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay); + +_ol_.inherits(_ol_render_canvas_PolygonReplay_, _ol_render_canvas_Replay_); /** @@ -35,12 +36,12 @@ ol.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay); * @private * @return {number} End. */ -ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates, offset, ends, stride) { +_ol_render_canvas_PolygonReplay_.prototype.drawFlatCoordinatess_ = function(flatCoordinates, offset, ends, stride) { var state = this.state; var fill = state.fillStyle !== undefined; var stroke = state.strokeStyle != undefined; var numEnds = ends.length; - var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH]; + var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH]; this.instructions.push(beginPathInstruction); this.hitDetectionInstructions.push(beginPathInstruction); for (var i = 0; i < numEnds; ++i) { @@ -49,25 +50,25 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo var myEnd = this.appendFlatCoordinates( flatCoordinates, offset, end, stride, true, !stroke); var moveToLineToInstruction = - [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd]; + [_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd]; this.instructions.push(moveToLineToInstruction); this.hitDetectionInstructions.push(moveToLineToInstruction); if (stroke) { // Performance optimization: only call closePath() when we have a stroke. // Otherwise the ring is closed already (see appendFlatCoordinates above). - var closePathInstruction = [ol.render.canvas.Instruction.CLOSE_PATH]; + var closePathInstruction = [_ol_render_canvas_Instruction_.CLOSE_PATH]; this.instructions.push(closePathInstruction); this.hitDetectionInstructions.push(closePathInstruction); } offset = end; } - var fillInstruction = [ol.render.canvas.Instruction.FILL]; + var fillInstruction = [_ol_render_canvas_Instruction_.FILL]; this.hitDetectionInstructions.push(fillInstruction); if (fill) { this.instructions.push(fillInstruction); } if (stroke) { - var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; + var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE]; this.instructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction); } @@ -78,7 +79,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo /** * @inheritDoc */ -ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, feature) { +_ol_render_canvas_PolygonReplay_.prototype.drawCircle = function(circleGeometry, feature) { var state = this.state; var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; @@ -89,12 +90,12 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f this.beginGeometry(circleGeometry, feature); // always fill the circle for hit detection this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_FILL_STYLE, - ol.color.asString(ol.render.canvas.defaultFillStyle) + _ol_render_canvas_Instruction_.SET_FILL_STYLE, + _ol_color_.asString(_ol_render_canvas_.defaultFillStyle) ]); if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.miterLimit, state.lineDash, state.lineDashOffset ]); @@ -104,17 +105,17 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f var myBegin = this.coordinates.length; this.appendFlatCoordinates( flatCoordinates, 0, flatCoordinates.length, stride, false, false); - var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH]; - var circleInstruction = [ol.render.canvas.Instruction.CIRCLE, myBegin]; + var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH]; + var circleInstruction = [_ol_render_canvas_Instruction_.CIRCLE, myBegin]; this.instructions.push(beginPathInstruction, circleInstruction); this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction); - var fillInstruction = [ol.render.canvas.Instruction.FILL]; + var fillInstruction = [_ol_render_canvas_Instruction_.FILL]; this.hitDetectionInstructions.push(fillInstruction); if (state.fillStyle !== undefined) { this.instructions.push(fillInstruction); } if (state.strokeStyle !== undefined) { - var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; + var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE]; this.instructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction); } @@ -125,18 +126,18 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f /** * @inheritDoc */ -ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) { +_ol_render_canvas_PolygonReplay_.prototype.drawPolygon = function(polygonGeometry, feature) { var state = this.state; this.setFillStrokeStyles_(polygonGeometry); this.beginGeometry(polygonGeometry, feature); // always fill the polygon for hit detection this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_FILL_STYLE, - ol.color.asString(ol.render.canvas.defaultFillStyle)] + _ol_render_canvas_Instruction_.SET_FILL_STYLE, + _ol_color_.asString(_ol_render_canvas_.defaultFillStyle)] ); if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.miterLimit, state.lineDash, state.lineDashOffset ]); @@ -152,7 +153,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, /** * @inheritDoc */ -ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) { +_ol_render_canvas_PolygonReplay_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) { var state = this.state; var fillStyle = state.fillStyle; var strokeStyle = state.strokeStyle; @@ -163,12 +164,12 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygo this.beginGeometry(multiPolygonGeometry, feature); // always fill the multi-polygon for hit detection this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_FILL_STYLE, - ol.color.asString(ol.render.canvas.defaultFillStyle) + _ol_render_canvas_Instruction_.SET_FILL_STYLE, + _ol_color_.asString(_ol_render_canvas_.defaultFillStyle) ]); if (state.strokeStyle !== undefined) { this.hitDetectionInstructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.miterLimit, state.lineDash, state.lineDashOffset ]); @@ -189,7 +190,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygo /** * @inheritDoc */ -ol.render.canvas.PolygonReplay.prototype.finish = function() { +_ol_render_canvas_PolygonReplay_.prototype.finish = function() { this.reverseHitDetectionInstructions(); this.state = null; // We want to preserve topology when drawing polygons. Polygons are @@ -201,7 +202,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() { var coordinates = this.coordinates; var i, ii; for (i = 0, ii = coordinates.length; i < ii; ++i) { - coordinates[i] = ol.geom.flat.simplify.snap(coordinates[i], tolerance); + coordinates[i] = _ol_geom_flat_simplify_.snap(coordinates[i], tolerance); } } }; @@ -211,7 +212,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() { * @private * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. */ -ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometry) { +_ol_render_canvas_PolygonReplay_.prototype.setFillStrokeStyles_ = function(geometry) { var state = this.state; var fillStyle = state.fillStyle; if (fillStyle !== undefined) { @@ -221,3 +222,4 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometr this.updateStrokeStyle(state, this.applyStroke); } }; +export default _ol_render_canvas_PolygonReplay_; diff --git a/src/ol/render/canvas/Replay.js b/src/ol/render/canvas/Replay.js index ef6abf3511..59c3f42915 100644 --- a/src/ol/render/canvas/Replay.js +++ b/src/ol/render/canvas/Replay.js @@ -1,23 +1,23 @@ -goog.provide('ol.render.canvas.Replay'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.colorlike'); -goog.require('ol.extent'); -goog.require('ol.extent.Relationship'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.geom.flat.inflate'); -goog.require('ol.geom.flat.length'); -goog.require('ol.geom.flat.textpath'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.has'); -goog.require('ol.obj'); -goog.require('ol.render.VectorContext'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.Instruction'); -goog.require('ol.render.replay'); -goog.require('ol.transform'); - +/** + * @module ol/render/canvas/Replay + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_colorlike_ from '../../colorlike.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_extent_Relationship_ from '../../extent/Relationship.js'; +import _ol_geom_GeometryType_ from '../../geom/GeometryType.js'; +import _ol_geom_flat_inflate_ from '../../geom/flat/inflate.js'; +import _ol_geom_flat_length_ from '../../geom/flat/length.js'; +import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_has_ from '../../has.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_render_VectorContext_ from '../VectorContext.js'; +import _ol_render_canvas_ from '../canvas.js'; +import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; +import _ol_render_replay_ from '../replay.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -30,8 +30,8 @@ goog.require('ol.transform'); * @param {?} declutterTree Declutter tree. * @struct */ -ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { - ol.render.VectorContext.call(this); +var _ol_render_canvas_Replay_ = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { + _ol_render_VectorContext_.call(this); /** * @type {?} @@ -42,7 +42,7 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio, * @private * @type {ol.Extent} */ - this.tmpExtent_ = ol.extent.createEmpty(); + this.tmpExtent_ = _ol_extent_.createEmpty(); /** * @protected @@ -128,7 +128,7 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio, * @private * @type {!ol.Transform} */ - this.renderedTransform_ = ol.transform.create(); + this.renderedTransform_ = _ol_transform_.create(); /** * @protected @@ -158,15 +158,16 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio, * @private * @type {!ol.Transform} */ - this.tmpLocalTransform_ = ol.transform.create(); + this.tmpLocalTransform_ = _ol_transform_.create(); /** * @private * @type {!ol.Transform} */ - this.resetTransform_ = ol.transform.create(); + this.resetTransform_ = _ol_transform_.create(); }; -ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext); + +_ol_.inherits(_ol_render_canvas_Replay_, _ol_render_VectorContext_); /** @@ -178,7 +179,7 @@ ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext); * @param {Array.<*>} fillInstruction Fill instruction. * @param {Array.<*>} strokeInstruction Stroke instruction. */ -ol.render.canvas.Replay.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4, +_ol_render_canvas_Replay_.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4, fillInstruction, strokeInstruction) { context.beginPath(); context.moveTo.apply(context, p1); @@ -217,7 +218,7 @@ ol.render.canvas.Replay.prototype.replayTextBackground_ = function(context, p1, * @param {Array.<*>} fillInstruction Fill instruction. * @param {Array.<*>} strokeInstruction Stroke instruction. */ -ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image, +_ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image, anchorX, anchorY, declutterGroup, height, opacity, originX, originY, rotation, scale, snapToPixel, width, padding, fillInstruction, strokeInstruction) { var fillStroke = fillInstruction || strokeInstruction; @@ -254,16 +255,16 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image, if (rotation !== 0) { var centerX = x + anchorX; var centerY = y + anchorY; - transform = ol.transform.compose(localTransform, + transform = _ol_transform_.compose(localTransform, centerX, centerY, 1, 1, rotation, -centerX, -centerY); - ol.extent.createOrUpdateEmpty(box); - ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p1)); - ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p2)); - ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p3)); - ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p4)); + _ol_extent_.createOrUpdateEmpty(box); + _ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p1)); + _ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p2)); + _ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p3)); + _ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p4)); } else { - ol.extent.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box); + _ol_extent_.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box); } var canvas = context.canvas; var intersects = box[0] <= canvas.width && box[2] >= 0 && box[1] <= canvas.height && box[3] >= 0; @@ -277,7 +278,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image, if (!intersects && declutterGroup[4] == 1) { return; } - ol.extent.extend(declutterGroup, box); + _ol_extent_.extend(declutterGroup, box); var declutterArgs = intersects ? [context, transform ? transform.slice(0) : null, opacity, image, originX, originY, w, h, x, y, scale] : null; @@ -291,7 +292,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image, /** @type {Array.<*>} */ (fillInstruction), /** @type {Array.<*>} */ (strokeInstruction)); } - ol.render.canvas.drawImage(context, transform, opacity, image, originX, originY, w, h, x, y, scale); + _ol_render_canvas_.drawImage(context, transform, opacity, image, originX, originY, w, h, x, y, scale); } }; @@ -301,7 +302,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image, * @param {Array.} dashArray Dash array. * @return {Array.} Dash array with pixel ratio applied */ -ol.render.canvas.Replay.prototype.applyPixelRatio = function(dashArray) { +_ol_render_canvas_Replay_.prototype.applyPixelRatio = function(dashArray) { var pixelRatio = this.pixelRatio; return pixelRatio == 1 ? dashArray : dashArray.map(function(dash) { return dash * pixelRatio; @@ -319,7 +320,7 @@ ol.render.canvas.Replay.prototype.applyPixelRatio = function(dashArray) { * @protected * @return {number} My end. */ -ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) { +_ol_render_canvas_Replay_.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) { var myEnd = this.coordinates.length; var extent = this.getBufferedMaxExtent(); @@ -334,7 +335,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat for (i = offset + stride; i < end; i += stride) { nextCoord[0] = flatCoordinates[i]; nextCoord[1] = flatCoordinates[i + 1]; - nextRel = ol.extent.coordinateRelationship(extent, nextCoord); + nextRel = _ol_extent_.coordinateRelationship(extent, nextCoord); if (nextRel !== lastRel) { if (skipped) { this.coordinates[myEnd++] = lastCoord[0]; @@ -343,7 +344,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat this.coordinates[myEnd++] = nextCoord[0]; this.coordinates[myEnd++] = nextCoord[1]; skipped = false; - } else if (nextRel === ol.extent.Relationship.INTERSECTING) { + } else if (nextRel === _ol_extent_Relationship_.INTERSECTING) { this.coordinates[myEnd++] = nextCoord[0]; this.coordinates[myEnd++] = nextCoord[1]; skipped = false; @@ -372,7 +373,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat * @param {Array.} replayEnds Replay ends. * @return {number} Offset. */ -ol.render.canvas.Replay.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) { +_ol_render_canvas_Replay_.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) { for (var i = 0, ii = ends.length; i < ii; ++i) { var end = ends[i]; var replayEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false); @@ -386,14 +387,14 @@ ol.render.canvas.Replay.prototype.drawCustomCoordinates_ = function(flatCoordina /** * @inheritDoc. */ -ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, renderer) { +_ol_render_canvas_Replay_.prototype.drawCustom = function(geometry, feature, renderer) { this.beginGeometry(geometry, feature); var type = geometry.getType(); var stride = geometry.getStride(); var replayBegin = this.coordinates.length; var flatCoordinates, replayEnd, replayEnds, replayEndss; var offset; - if (type == ol.geom.GeometryType.MULTI_POLYGON) { + if (type == _ol_geom_GeometryType_.MULTI_POLYGON) { geometry = /** @type {ol.geom.MultiPolygon} */ (geometry); flatCoordinates = geometry.getOrientedFlatCoordinates(); replayEndss = []; @@ -404,29 +405,29 @@ ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, rende offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds); replayEndss.push(myEnds); } - this.instructions.push([ol.render.canvas.Instruction.CUSTOM, - replayBegin, replayEndss, geometry, renderer, ol.geom.flat.inflate.coordinatesss]); - } else if (type == ol.geom.GeometryType.POLYGON || type == ol.geom.GeometryType.MULTI_LINE_STRING) { + this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM, + replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]); + } else if (type == _ol_geom_GeometryType_.POLYGON || type == _ol_geom_GeometryType_.MULTI_LINE_STRING) { replayEnds = []; - flatCoordinates = (type == ol.geom.GeometryType.POLYGON) ? + flatCoordinates = (type == _ol_geom_GeometryType_.POLYGON) ? /** @type {ol.geom.Polygon} */ (geometry).getOrientedFlatCoordinates() : geometry.getFlatCoordinates(); offset = this.drawCustomCoordinates_(flatCoordinates, 0, /** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(), stride, replayEnds); - this.instructions.push([ol.render.canvas.Instruction.CUSTOM, - replayBegin, replayEnds, geometry, renderer, ol.geom.flat.inflate.coordinatess]); - } else if (type == ol.geom.GeometryType.LINE_STRING || type == ol.geom.GeometryType.MULTI_POINT) { + this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM, + replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]); + } else if (type == _ol_geom_GeometryType_.LINE_STRING || type == _ol_geom_GeometryType_.MULTI_POINT) { flatCoordinates = geometry.getFlatCoordinates(); replayEnd = this.appendFlatCoordinates( flatCoordinates, 0, flatCoordinates.length, stride, false, false); - this.instructions.push([ol.render.canvas.Instruction.CUSTOM, - replayBegin, replayEnd, geometry, renderer, ol.geom.flat.inflate.coordinates]); - } else if (type == ol.geom.GeometryType.POINT) { + this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM, + replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]); + } else if (type == _ol_geom_GeometryType_.POINT) { flatCoordinates = geometry.getFlatCoordinates(); this.coordinates.push(flatCoordinates[0], flatCoordinates[1]); replayEnd = this.coordinates.length; - this.instructions.push([ol.render.canvas.Instruction.CUSTOM, + this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM, replayBegin, replayEnd, geometry, renderer]); } this.endGeometry(geometry, feature); @@ -438,12 +439,12 @@ ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, rende * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) { +_ol_render_canvas_Replay_.prototype.beginGeometry = function(geometry, feature) { this.beginGeometryInstruction1_ = - [ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0]; + [_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0]; this.instructions.push(this.beginGeometryInstruction1_); this.beginGeometryInstruction2_ = - [ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0]; + [_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0]; this.hitDetectionInstructions.push(this.beginGeometryInstruction2_); }; @@ -452,15 +453,15 @@ ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) { * @private * @param {CanvasRenderingContext2D} context Context. */ -ol.render.canvas.Replay.prototype.fill_ = function(context) { +_ol_render_canvas_Replay_.prototype.fill_ = function(context) { if (this.fillOrigin_) { - var origin = ol.transform.apply(this.renderedTransform_, this.fillOrigin_.slice()); + var origin = _ol_transform_.apply(this.renderedTransform_, this.fillOrigin_.slice()); context.translate(origin[0], origin[1]); context.rotate(this.viewRotation_); } context.fill(); if (this.fillOrigin_) { - context.setTransform.apply(context, ol.render.canvas.resetTransform_); + context.setTransform.apply(context, _ol_render_canvas_.resetTransform_); } }; @@ -470,13 +471,13 @@ ol.render.canvas.Replay.prototype.fill_ = function(context) { * @param {CanvasRenderingContext2D} context Context. * @param {Array.<*>} instruction Instruction. */ -ol.render.canvas.Replay.prototype.setStrokeStyle_ = function(context, instruction) { +_ol_render_canvas_Replay_.prototype.setStrokeStyle_ = function(context, instruction) { context.strokeStyle = /** @type {ol.ColorLike} */ (instruction[1]); context.lineWidth = /** @type {number} */ (instruction[2]); context.lineCap = /** @type {string} */ (instruction[3]); context.lineJoin = /** @type {string} */ (instruction[4]); context.miterLimit = /** @type {number} */ (instruction[5]); - if (ol.has.CANVAS_LINE_DASH) { + if (_ol_has_.CANVAS_LINE_DASH) { context.lineDashOffset = /** @type {number} */ (instruction[7]); context.setLineDash(/** @type {Array.} */ (instruction[6])); } @@ -487,7 +488,7 @@ ol.render.canvas.Replay.prototype.setStrokeStyle_ = function(context, instructio * @param {ol.DeclutterGroup} declutterGroup Declutter group. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, feature) { +_ol_render_canvas_Replay_.prototype.renderDeclutter_ = function(declutterGroup, feature) { if (declutterGroup && declutterGroup.length > 5) { var groupCount = declutterGroup[4]; if (groupCount == 1 || groupCount == declutterGroup.length - 5) { @@ -501,7 +502,7 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe }; if (!this.declutterTree.collides(box)) { this.declutterTree.insert(box); - var drawImage = ol.render.canvas.drawImage; + var drawImage = _ol_render_canvas_.drawImage; for (var j = 5, jj = declutterGroup.length; j < jj; ++j) { var declutterData = /** @type {Array} */ (declutterGroup[j]); if (declutterData) { @@ -515,7 +516,7 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe } } declutterGroup.length = 5; - ol.extent.createOrUpdateEmpty(declutterGroup); + _ol_extent_.createOrUpdateEmpty(declutterGroup); } } }; @@ -535,23 +536,23 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe * @return {T|undefined} Callback result. * @template T */ -ol.render.canvas.Replay.prototype.replay_ = function( +_ol_render_canvas_Replay_.prototype.replay_ = function( context, transform, skippedFeaturesHash, instructions, featureCallback, opt_hitExtent) { /** @type {Array.} */ var pixelCoordinates; - if (this.pixelCoordinates_ && ol.array.equals(transform, this.renderedTransform_)) { + if (this.pixelCoordinates_ && _ol_array_.equals(transform, this.renderedTransform_)) { pixelCoordinates = this.pixelCoordinates_; } else { if (!this.pixelCoordinates_) { this.pixelCoordinates_ = []; } - pixelCoordinates = ol.geom.flat.transform.transform2D( + pixelCoordinates = _ol_geom_flat_transform_.transform2D( this.coordinates, 0, this.coordinates.length, 2, transform, this.pixelCoordinates_); - ol.transform.setFromArray(this.renderedTransform_, transform); + _ol_transform_.setFromArray(this.renderedTransform_, transform); } - var skipFeatures = !ol.obj.isEmpty(skippedFeaturesHash); + var skipFeatures = !_ol_obj_.isEmpty(skippedFeaturesHash); var i = 0; // instruction index var ii = instructions.length; // end of instructions var d = 0; // data index @@ -580,20 +581,20 @@ ol.render.canvas.Replay.prototype.replay_ = function( var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]); var /** @type {ol.Feature|ol.render.Feature} */ feature, x, y; switch (type) { - case ol.render.canvas.Instruction.BEGIN_GEOMETRY: + case _ol_render_canvas_Instruction_.BEGIN_GEOMETRY: feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]); if ((skipFeatures && - skippedFeaturesHash[ol.getUid(feature).toString()]) || + skippedFeaturesHash[_ol_.getUid(feature).toString()]) || !feature.getGeometry()) { i = /** @type {number} */ (instruction[2]); - } else if (opt_hitExtent !== undefined && !ol.extent.intersects( + } else if (opt_hitExtent !== undefined && !_ol_extent_.intersects( opt_hitExtent, feature.getGeometry().getExtent())) { i = /** @type {number} */ (instruction[2]) + 1; } else { ++i; } break; - case ol.render.canvas.Instruction.BEGIN_PATH: + case _ol_render_canvas_Instruction_.BEGIN_PATH: if (pendingFill > batchSize) { this.fill_(context); pendingFill = 0; @@ -608,7 +609,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( } ++i; break; - case ol.render.canvas.Instruction.CIRCLE: + case _ol_render_canvas_Instruction_.CIRCLE: d = /** @type {number} */ (instruction[1]); var x1 = pixelCoordinates[d]; var y1 = pixelCoordinates[d + 1]; @@ -621,11 +622,11 @@ ol.render.canvas.Replay.prototype.replay_ = function( context.arc(x1, y1, r, 0, 2 * Math.PI, true); ++i; break; - case ol.render.canvas.Instruction.CLOSE_PATH: + case _ol_render_canvas_Instruction_.CLOSE_PATH: context.closePath(); ++i; break; - case ol.render.canvas.Instruction.CUSTOM: + case _ol_render_canvas_Instruction_.CUSTOM: d = /** @type {number} */ (instruction[1]); dd = instruction[2]; var geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]); @@ -647,7 +648,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( renderer(coords, state); ++i; break; - case ol.render.canvas.Instruction.DRAW_IMAGE: + case _ol_render_canvas_Instruction_.DRAW_IMAGE: d = /** @type {number} */ (instruction[1]); dd = /** @type {number} */ (instruction[2]); image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */ @@ -672,7 +673,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( backgroundFill = /** @type {boolean} */ (instruction[17]); backgroundStroke = /** @type {boolean} */ (instruction[18]); } else { - padding = ol.render.canvas.defaultPadding; + padding = _ol_render_canvas_.defaultPadding; backgroundFill = backgroundStroke = false; } @@ -690,7 +691,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( this.renderDeclutter_(declutterGroup, feature); ++i; break; - case ol.render.canvas.Instruction.DRAW_CHARS: + case _ol_render_canvas_Instruction_.DRAW_CHARS: var begin = /** @type {number} */ (instruction[1]); var end = /** @type {number} */ (instruction[2]); var baseline = /** @type {number} */ (instruction[3]); @@ -706,12 +707,12 @@ ol.render.canvas.Replay.prototype.replay_ = function( var textKey = /** @type {string} */ (instruction[13]); var textScale = /** @type {number} */ (instruction[14]); - var pathLength = ol.geom.flat.length.lineString(pixelCoordinates, begin, end, 2); + var pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2); var textLength = measure(text); if (overflow || textLength <= pathLength) { var textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign; - var startM = (pathLength - textLength) * ol.render.replay.TEXT_ALIGN[textAlign]; - var parts = ol.geom.flat.textpath.lineString( + var startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign]; + var parts = _ol_geom_flat_textpath_.lineString( pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle); if (parts) { var c, cc, chars, label, part; @@ -726,7 +727,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( /** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label, anchorX, anchorY, declutterGroup, label.height, 1, 0, 0, /** @type {number} */ (part[3]), textScale, false, label.width, - ol.render.canvas.defaultPadding, null, null); + _ol_render_canvas_.defaultPadding, null, null); } } if (fillKey) { @@ -740,7 +741,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( /** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label, anchorX, anchorY, declutterGroup, label.height, 1, 0, 0, /** @type {number} */ (part[3]), textScale, false, label.width, - ol.render.canvas.defaultPadding, null, null); + _ol_render_canvas_.defaultPadding, null, null); } } } @@ -748,7 +749,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( this.renderDeclutter_(declutterGroup, feature); ++i; break; - case ol.render.canvas.Instruction.END_GEOMETRY: + case _ol_render_canvas_Instruction_.END_GEOMETRY: if (featureCallback !== undefined) { feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]); var result = featureCallback(feature); @@ -758,7 +759,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( } ++i; break; - case ol.render.canvas.Instruction.FILL: + case _ol_render_canvas_Instruction_.FILL: if (batchSize) { pendingFill++; } else { @@ -766,7 +767,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( } ++i; break; - case ol.render.canvas.Instruction.MOVE_TO_LINE_TO: + case _ol_render_canvas_Instruction_.MOVE_TO_LINE_TO: d = /** @type {number} */ (instruction[1]); dd = /** @type {number} */ (instruction[2]); x = pixelCoordinates[d]; @@ -791,7 +792,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( } ++i; break; - case ol.render.canvas.Instruction.SET_FILL_STYLE: + case _ol_render_canvas_Instruction_.SET_FILL_STYLE: lastFillInstruction = instruction; this.fillOrigin_ = instruction[2]; @@ -807,7 +808,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( context.fillStyle = /** @type {ol.ColorLike} */ (instruction[1]); ++i; break; - case ol.render.canvas.Instruction.SET_STROKE_STYLE: + case _ol_render_canvas_Instruction_.SET_STROKE_STYLE: lastStrokeInstruction = instruction; if (pendingStroke) { context.stroke(); @@ -816,7 +817,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( this.setStrokeStyle_(context, /** @type {Array.<*>} */ (instruction)); ++i; break; - case ol.render.canvas.Instruction.STROKE: + case _ol_render_canvas_Instruction_.STROKE: if (batchSize) { pendingStroke++; } else { @@ -846,7 +847,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( * @param {Object.} skippedFeaturesHash Ids of features * to skip. */ -ol.render.canvas.Replay.prototype.replay = function( +_ol_render_canvas_Replay_.prototype.replay = function( context, transform, viewRotation, skippedFeaturesHash) { this.viewRotation_ = viewRotation; this.replay_(context, transform, @@ -867,7 +868,7 @@ ol.render.canvas.Replay.prototype.replay = function( * @return {T|undefined} Callback result. * @template T */ -ol.render.canvas.Replay.prototype.replayHitDetection = function( +_ol_render_canvas_Replay_.prototype.replayHitDetection = function( context, transform, viewRotation, skippedFeaturesHash, opt_featureCallback, opt_hitExtent) { this.viewRotation_ = viewRotation; @@ -879,7 +880,7 @@ ol.render.canvas.Replay.prototype.replayHitDetection = function( /** * Reverse the hit detection instructions. */ -ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() { +_ol_render_canvas_Replay_.prototype.reverseHitDetectionInstructions = function() { var hitDetectionInstructions = this.hitDetectionInstructions; // step 1 - reverse array hitDetectionInstructions.reverse(); @@ -892,11 +893,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() { for (i = 0; i < n; ++i) { instruction = hitDetectionInstructions[i]; type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]); - if (type == ol.render.canvas.Instruction.END_GEOMETRY) { + if (type == _ol_render_canvas_Instruction_.END_GEOMETRY) { begin = i; - } else if (type == ol.render.canvas.Instruction.BEGIN_GEOMETRY) { + } else if (type == _ol_render_canvas_Instruction_.BEGIN_GEOMETRY) { instruction[2] = i; - ol.array.reverseSubArray(this.hitDetectionInstructions, begin, i); + _ol_array_.reverseSubArray(this.hitDetectionInstructions, begin, i); begin = -1; } } @@ -906,37 +907,37 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() { /** * @inheritDoc */ -ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_canvas_Replay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { var state = this.state; if (fillStyle) { var fillStyleColor = fillStyle.getColor(); - state.fillStyle = ol.colorlike.asColorLike(fillStyleColor ? - fillStyleColor : ol.render.canvas.defaultFillStyle); + state.fillStyle = _ol_colorlike_.asColorLike(fillStyleColor ? + fillStyleColor : _ol_render_canvas_.defaultFillStyle); } else { state.fillStyle = undefined; } if (strokeStyle) { var strokeStyleColor = strokeStyle.getColor(); - state.strokeStyle = ol.colorlike.asColorLike(strokeStyleColor ? - strokeStyleColor : ol.render.canvas.defaultStrokeStyle); + state.strokeStyle = _ol_colorlike_.asColorLike(strokeStyleColor ? + strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle); var strokeStyleLineCap = strokeStyle.getLineCap(); state.lineCap = strokeStyleLineCap !== undefined ? - strokeStyleLineCap : ol.render.canvas.defaultLineCap; + strokeStyleLineCap : _ol_render_canvas_.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); state.lineDash = strokeStyleLineDash ? - strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; + strokeStyleLineDash.slice() : _ol_render_canvas_.defaultLineDash; var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset(); state.lineDashOffset = strokeStyleLineDashOffset ? - strokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset; + strokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset; var strokeStyleLineJoin = strokeStyle.getLineJoin(); state.lineJoin = strokeStyleLineJoin !== undefined ? - strokeStyleLineJoin : ol.render.canvas.defaultLineJoin; + strokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin; var strokeStyleWidth = strokeStyle.getWidth(); state.lineWidth = strokeStyleWidth !== undefined ? - strokeStyleWidth : ol.render.canvas.defaultLineWidth; + strokeStyleWidth : _ol_render_canvas_.defaultLineWidth; var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); state.miterLimit = strokeStyleMiterLimit !== undefined ? - strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; + strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit; if (state.lineWidth > this.maxLineWidth) { this.maxLineWidth = state.lineWidth; @@ -959,9 +960,9 @@ ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strok * @param {ol.CanvasFillStrokeState} state State. * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. */ -ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) { +_ol_render_canvas_Replay_.prototype.applyFill = function(state, geometry) { var fillStyle = state.fillStyle; - var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle]; + var fillInstruction = [_ol_render_canvas_Instruction_.SET_FILL_STYLE, fillStyle]; if (typeof fillStyle !== 'string') { var fillExtent = geometry.getExtent(); fillInstruction.push([fillExtent[0], fillExtent[3]]); @@ -973,9 +974,9 @@ ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) { /** * @param {ol.CanvasFillStrokeState} state State. */ -ol.render.canvas.Replay.prototype.applyStroke = function(state) { +_ol_render_canvas_Replay_.prototype.applyStroke = function(state) { this.instructions.push([ - ol.render.canvas.Instruction.SET_STROKE_STYLE, + _ol_render_canvas_Instruction_.SET_STROKE_STYLE, state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap, state.lineJoin, state.miterLimit, this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio @@ -988,7 +989,7 @@ ol.render.canvas.Replay.prototype.applyStroke = function(state) { * @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState, (ol.geom.Geometry|ol.render.Feature))} applyFill Apply fill. * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. */ -ol.render.canvas.Replay.prototype.updateFillStyle = function(state, applyFill, geometry) { +_ol_render_canvas_Replay_.prototype.updateFillStyle = function(state, applyFill, geometry) { var fillStyle = state.fillStyle; if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) { applyFill.call(this, state, geometry); @@ -1001,7 +1002,7 @@ ol.render.canvas.Replay.prototype.updateFillStyle = function(state, applyFill, g * @param {ol.CanvasFillStrokeState} state State. * @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState)} applyStroke Apply stroke. */ -ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStroke) { +_ol_render_canvas_Replay_.prototype.updateStrokeStyle = function(state, applyStroke) { var strokeStyle = state.strokeStyle; var lineCap = state.lineCap; var lineDash = state.lineDash; @@ -1011,7 +1012,7 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok var miterLimit = state.miterLimit; if (state.currentStrokeStyle != strokeStyle || state.currentLineCap != lineCap || - (lineDash != state.currentLineDash && !ol.array.equals(state.currentLineDash, lineDash)) || + (lineDash != state.currentLineDash && !_ol_array_.equals(state.currentLineDash, lineDash)) || state.currentLineDashOffset != lineDashOffset || state.currentLineJoin != lineJoin || state.currentLineWidth != lineWidth || @@ -1032,13 +1033,13 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @param {ol.Feature|ol.render.Feature} feature Feature. */ -ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) { +_ol_render_canvas_Replay_.prototype.endGeometry = function(geometry, feature) { this.beginGeometryInstruction1_[2] = this.instructions.length; this.beginGeometryInstruction1_ = null; this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length; this.beginGeometryInstruction2_ = null; var endGeometryInstruction = - [ol.render.canvas.Instruction.END_GEOMETRY, feature]; + [_ol_render_canvas_Instruction_.END_GEOMETRY, feature]; this.instructions.push(endGeometryInstruction); this.hitDetectionInstructions.push(endGeometryInstruction); }; @@ -1047,7 +1048,7 @@ ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) { /** * FIXME empty description for jsdoc */ -ol.render.canvas.Replay.prototype.finish = ol.nullFunction; +_ol_render_canvas_Replay_.prototype.finish = _ol_.nullFunction; /** @@ -1057,13 +1058,14 @@ ol.render.canvas.Replay.prototype.finish = ol.nullFunction; * @return {ol.Extent} The buffered rendering extent. * @protected */ -ol.render.canvas.Replay.prototype.getBufferedMaxExtent = function() { +_ol_render_canvas_Replay_.prototype.getBufferedMaxExtent = function() { if (!this.bufferedMaxExtent_) { - this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); + this.bufferedMaxExtent_ = _ol_extent_.clone(this.maxExtent); if (this.maxLineWidth > 0) { var width = this.resolution * (this.maxLineWidth + 1) / 2; - ol.extent.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_); + _ol_extent_.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_); } } return this.bufferedMaxExtent_; }; +export default _ol_render_canvas_Replay_; diff --git a/src/ol/render/canvas/ReplayGroup.js b/src/ol/render/canvas/ReplayGroup.js index f37e7a3851..3c5b45fcd2 100644 --- a/src/ol/render/canvas/ReplayGroup.js +++ b/src/ol/render/canvas/ReplayGroup.js @@ -1,21 +1,21 @@ -goog.provide('ol.render.canvas.ReplayGroup'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.obj'); -goog.require('ol.render.ReplayGroup'); -goog.require('ol.render.ReplayType'); -goog.require('ol.render.canvas.Replay'); -goog.require('ol.render.canvas.ImageReplay'); -goog.require('ol.render.canvas.LineStringReplay'); -goog.require('ol.render.canvas.PolygonReplay'); -goog.require('ol.render.canvas.TextReplay'); -goog.require('ol.render.replay'); -goog.require('ol.transform'); - +/** + * @module ol/render/canvas/ReplayGroup + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_render_ReplayGroup_ from '../ReplayGroup.js'; +import _ol_render_ReplayType_ from '../ReplayType.js'; +import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; +import _ol_render_canvas_ImageReplay_ from '../canvas/ImageReplay.js'; +import _ol_render_canvas_LineStringReplay_ from '../canvas/LineStringReplay.js'; +import _ol_render_canvas_PolygonReplay_ from '../canvas/PolygonReplay.js'; +import _ol_render_canvas_TextReplay_ from '../canvas/TextReplay.js'; +import _ol_render_replay_ from '../replay.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -30,9 +30,9 @@ goog.require('ol.transform'); * @param {number=} opt_renderBuffer Optional rendering buffer. * @struct */ -ol.render.canvas.ReplayGroup = function( +var _ol_render_canvas_ReplayGroup_ = function( tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree, opt_renderBuffer) { - ol.render.ReplayGroup.call(this); + _ol_render_ReplayGroup_.call(this); /** * Declutter tree. @@ -93,15 +93,16 @@ ol.render.canvas.ReplayGroup = function( * @private * @type {CanvasRenderingContext2D} */ - this.hitDetectionContext_ = ol.dom.createCanvasContext2D(1, 1); + this.hitDetectionContext_ = _ol_dom_.createCanvasContext2D(1, 1); /** * @private * @type {ol.Transform} */ - this.hitDetectionTransform_ = ol.transform.create(); + this.hitDetectionTransform_ = _ol_transform_.create(); }; -ol.inherits(ol.render.canvas.ReplayGroup, ol.render.ReplayGroup); + +_ol_.inherits(_ol_render_canvas_ReplayGroup_, _ol_render_ReplayGroup_); /** @@ -110,7 +111,7 @@ ol.inherits(ol.render.canvas.ReplayGroup, ol.render.ReplayGroup); * @type {Object.>>} * @private */ -ol.render.canvas.ReplayGroup.circleArrayCache_ = { +_ol_render_canvas_ReplayGroup_.circleArrayCache_ = { 0: [[true]] }; @@ -123,7 +124,7 @@ ol.render.canvas.ReplayGroup.circleArrayCache_ = { * @param {number} y Y coordinate. * @private */ -ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) { +_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_ = function(array, x, y) { var i; var radius = Math.floor(array.length / 2); if (x >= radius) { @@ -147,9 +148,9 @@ ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) * @returns {Array.>} An array with marked circle points. * @private */ -ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) { - if (ol.render.canvas.ReplayGroup.circleArrayCache_[radius] !== undefined) { - return ol.render.canvas.ReplayGroup.circleArrayCache_[radius]; +_ol_render_canvas_ReplayGroup_.getCircleArray_ = function(radius) { + if (_ol_render_canvas_ReplayGroup_.circleArrayCache_[radius] !== undefined) { + return _ol_render_canvas_ReplayGroup_.circleArrayCache_[radius]; } var arraySize = radius * 2 + 1; @@ -163,14 +164,14 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) { var error = 0; while (x >= y) { - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius + x); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius + x); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius + y); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius - y); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius - x); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius - x); - ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius - y); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + y, radius + x); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - y, radius + x); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - x, radius + y); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - x, radius - y); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - y, radius - x); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + y, radius - x); + _ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + x, radius - y); y++; error += 1 + 2 * y; @@ -180,7 +181,7 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) { } } - ol.render.canvas.ReplayGroup.circleArrayCache_[radius] = arr; + _ol_render_canvas_ReplayGroup_.circleArrayCache_[radius] = arr; return arr; }; @@ -190,8 +191,8 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) { * @param {CanvasRenderingContext2D} context Context. * @param {number} rotation Rotation. */ -ol.render.canvas.ReplayGroup.replayDeclutter = function(declutterReplays, context, rotation) { - var zs = Object.keys(declutterReplays).map(Number).sort(ol.array.numberSafeCompareFunction); +_ol_render_canvas_ReplayGroup_.replayDeclutter = function(declutterReplays, context, rotation) { + var zs = Object.keys(declutterReplays).map(Number).sort(_ol_array_.numberSafeCompareFunction); var skippedFeatureUids = {}; for (var z = 0, zz = zs.length; z < zz; ++z) { var replayData = declutterReplays[zs[z].toString()]; @@ -208,14 +209,14 @@ ol.render.canvas.ReplayGroup.replayDeclutter = function(declutterReplays, contex * @param {boolean} group Group with previous replay. * @return {ol.DeclutterGroup} Declutter instruction group. */ -ol.render.canvas.ReplayGroup.prototype.addDeclutter = function(group) { +_ol_render_canvas_ReplayGroup_.prototype.addDeclutter = function(group) { var declutter = null; if (this.declutterTree_) { if (group) { declutter = this.declutterGroup_; /** @type {number} */ (declutter[4])++; } else { - declutter = this.declutterGroup_ = ol.extent.createEmpty(); + declutter = this.declutterGroup_ = _ol_extent_.createEmpty(); declutter.push(1); } } @@ -227,7 +228,7 @@ ol.render.canvas.ReplayGroup.prototype.addDeclutter = function(group) { * @param {CanvasRenderingContext2D} context Context. * @param {ol.Transform} transform Transform. */ -ol.render.canvas.ReplayGroup.prototype.clip = function(context, transform) { +_ol_render_canvas_ReplayGroup_.prototype.clip = function(context, transform) { var flatClipCoords = this.getClipCoords(transform); context.beginPath(); context.moveTo(flatClipCoords[0], flatClipCoords[1]); @@ -242,7 +243,7 @@ ol.render.canvas.ReplayGroup.prototype.clip = function(context, transform) { * @param {Array.} replays Replays. * @return {boolean} Has replays of the provided types. */ -ol.render.canvas.ReplayGroup.prototype.hasReplays = function(replays) { +_ol_render_canvas_ReplayGroup_.prototype.hasReplays = function(replays) { for (var zIndex in this.replaysByZIndex_) { var candidates = this.replaysByZIndex_[zIndex]; for (var i = 0, ii = replays.length; i < ii; ++i) { @@ -258,7 +259,7 @@ ol.render.canvas.ReplayGroup.prototype.hasReplays = function(replays) { /** * FIXME empty description for jsdoc */ -ol.render.canvas.ReplayGroup.prototype.finish = function() { +_ol_render_canvas_ReplayGroup_.prototype.finish = function() { var zKey; for (zKey in this.replaysByZIndex_) { var replays = this.replaysByZIndex_[zKey]; @@ -284,12 +285,12 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() { * @return {T|undefined} Callback result. * @template T */ -ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( +_ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function( coordinate, resolution, rotation, hitTolerance, skippedFeaturesHash, callback, declutterReplays) { hitTolerance = Math.round(hitTolerance); var contextSize = hitTolerance * 2 + 1; - var transform = ol.transform.compose(this.hitDetectionTransform_, + var transform = _ol_transform_.compose(this.hitDetectionTransform_, hitTolerance + 0.5, hitTolerance + 0.5, 1 / resolution, -1 / resolution, -rotation, @@ -308,12 +309,12 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( */ var hitExtent; if (this.renderBuffer_ !== undefined) { - hitExtent = ol.extent.createEmpty(); - ol.extent.extendCoordinate(hitExtent, coordinate); - ol.extent.buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent); + hitExtent = _ol_extent_.createEmpty(); + _ol_extent_.extendCoordinate(hitExtent, coordinate); + _ol_extent_.buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent); } - var mask = ol.render.canvas.ReplayGroup.getCircleArray_(hitTolerance); + var mask = _ol_render_canvas_ReplayGroup_.getCircleArray_(hitTolerance); var declutteredFeatures; if (this.declutterTree_) { declutteredFeatures = this.declutterTree_.all().map(function(entry) { @@ -356,14 +357,14 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( * @param {ol.Transform} transform Transform. * @return {Array.} Clip coordinates. */ -ol.render.canvas.ReplayGroup.prototype.getClipCoords = function(transform) { +_ol_render_canvas_ReplayGroup_.prototype.getClipCoords = function(transform) { var maxExtent = this.maxExtent_; var minX = maxExtent[0]; var minY = maxExtent[1]; var maxX = maxExtent[2]; var maxY = maxExtent[3]; var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY]; - ol.geom.flat.transform.transform2D( + _ol_geom_flat_transform_.transform2D( flatClipCoords, 0, 8, 2, transform, flatClipCoords); return flatClipCoords; }; @@ -372,7 +373,7 @@ ol.render.canvas.ReplayGroup.prototype.getClipCoords = function(transform) { /** * @inheritDoc */ -ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { +_ol_render_canvas_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) { var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0'; var replays = this.replaysByZIndex_[zIndexKey]; if (replays === undefined) { @@ -381,7 +382,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) } var replay = replays[replayType]; if (replay === undefined) { - var Constructor = ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_[replayType]; + var Constructor = _ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType]; replay = new Constructor(this.tolerance_, this.maxExtent_, this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_); replays[replayType] = replay; @@ -393,7 +394,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) /** * @return {Object.>} Replays. */ -ol.render.canvas.ReplayGroup.prototype.getReplays = function() { +_ol_render_canvas_ReplayGroup_.prototype.getReplays = function() { return this.replaysByZIndex_; }; @@ -401,8 +402,8 @@ ol.render.canvas.ReplayGroup.prototype.getReplays = function() { /** * @inheritDoc */ -ol.render.canvas.ReplayGroup.prototype.isEmpty = function() { - return ol.obj.isEmpty(this.replaysByZIndex_); +_ol_render_canvas_ReplayGroup_.prototype.isEmpty = function() { + return _ol_obj_.isEmpty(this.replaysByZIndex_); }; @@ -417,19 +418,19 @@ ol.render.canvas.ReplayGroup.prototype.isEmpty = function() { * @param {Object.=} opt_declutterReplays Declutter * replays. */ -ol.render.canvas.ReplayGroup.prototype.replay = function(context, +_ol_render_canvas_ReplayGroup_.prototype.replay = function(context, transform, viewRotation, skippedFeaturesHash, opt_replayTypes, opt_declutterReplays) { /** @type {Array.} */ var zs = Object.keys(this.replaysByZIndex_).map(Number); - zs.sort(ol.array.numberSafeCompareFunction); + zs.sort(_ol_array_.numberSafeCompareFunction); // setup clipping so that the parts of over-simplified geometries are not // visible outside the current extent when panning context.save(); this.clip(context, transform); - var replayTypes = opt_replayTypes ? opt_replayTypes : ol.render.replay.ORDER; + var replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER; var i, ii, j, jj, replays, replay; for (i = 0, ii = zs.length; i < ii; ++i) { var zIndexKey = zs[i].toString(); @@ -439,7 +440,7 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context, replay = replays[replayType]; if (replay !== undefined) { if (opt_declutterReplays && - (replayType == ol.render.ReplayType.IMAGE || replayType == ol.render.ReplayType.TEXT)) { + (replayType == _ol_render_ReplayType_.IMAGE || replayType == _ol_render_ReplayType_.TEXT)) { var declutter = opt_declutterReplays[zIndexKey]; if (!declutter) { opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)]; @@ -473,23 +474,23 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context, * @return {T|undefined} Callback result. * @template T */ -ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function( +_ol_render_canvas_ReplayGroup_.prototype.replayHitDetection_ = function( context, transform, viewRotation, skippedFeaturesHash, featureCallback, opt_hitExtent, opt_declutterReplays) { /** @type {Array.} */ var zs = Object.keys(this.replaysByZIndex_).map(Number); - zs.sort(ol.array.numberSafeCompareFunction); + zs.sort(_ol_array_.numberSafeCompareFunction); var i, j, replays, replay, result; for (i = zs.length - 1; i >= 0; --i) { var zIndexKey = zs[i].toString(); replays = this.replaysByZIndex_[zIndexKey]; - for (j = ol.render.replay.ORDER.length - 1; j >= 0; --j) { - var replayType = ol.render.replay.ORDER[j]; + for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) { + var replayType = _ol_render_replay_.ORDER[j]; replay = replays[replayType]; if (replay !== undefined) { if (opt_declutterReplays && - (replayType == ol.render.ReplayType.IMAGE || replayType == ol.render.ReplayType.TEXT)) { + (replayType == _ol_render_ReplayType_.IMAGE || replayType == _ol_render_ReplayType_.TEXT)) { var declutter = opt_declutterReplays[zIndexKey]; if (!declutter) { opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)]; @@ -517,11 +518,12 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function( * function(new: ol.render.canvas.Replay, number, ol.Extent, * number, number, boolean, Array.)>} */ -ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_ = { - 'Circle': ol.render.canvas.PolygonReplay, - 'Default': ol.render.canvas.Replay, - 'Image': ol.render.canvas.ImageReplay, - 'LineString': ol.render.canvas.LineStringReplay, - 'Polygon': ol.render.canvas.PolygonReplay, - 'Text': ol.render.canvas.TextReplay +_ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_ = { + 'Circle': _ol_render_canvas_PolygonReplay_, + 'Default': _ol_render_canvas_Replay_, + 'Image': _ol_render_canvas_ImageReplay_, + 'LineString': _ol_render_canvas_LineStringReplay_, + 'Polygon': _ol_render_canvas_PolygonReplay_, + 'Text': _ol_render_canvas_TextReplay_ }; +export default _ol_render_canvas_ReplayGroup_; diff --git a/src/ol/render/canvas/TextReplay.js b/src/ol/render/canvas/TextReplay.js index 48f09bcbe1..2d17eb790f 100644 --- a/src/ol/render/canvas/TextReplay.js +++ b/src/ol/render/canvas/TextReplay.js @@ -1,18 +1,18 @@ -goog.provide('ol.render.canvas.TextReplay'); - -goog.require('ol'); -goog.require('ol.colorlike'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.geom.flat.straightchunk'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.has'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.Instruction'); -goog.require('ol.render.canvas.Replay'); -goog.require('ol.render.replay'); -goog.require('ol.style.TextPlacement'); - +/** + * @module ol/render/canvas/TextReplay + */ +import _ol_ from '../../index.js'; +import _ol_colorlike_ from '../../colorlike.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js'; +import _ol_geom_GeometryType_ from '../../geom/GeometryType.js'; +import _ol_has_ from '../../has.js'; +import _ol_render_canvas_ from '../canvas.js'; +import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; +import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; +import _ol_render_replay_ from '../replay.js'; +import _ol_style_TextPlacement_ from '../../style/TextPlacement.js'; /** * @constructor @@ -25,9 +25,9 @@ goog.require('ol.style.TextPlacement'); * @param {?} declutterTree Declutter tree. * @struct */ -ol.render.canvas.TextReplay = function( +var _ol_render_canvas_TextReplay_ = function( tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) { - ol.render.canvas.Replay.call(this, + _ol_render_canvas_Replay_.call(this, tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree); /** @@ -129,11 +129,12 @@ ol.render.canvas.TextReplay = function( */ this.widths_ = {}; - var labelCache = ol.render.canvas.labelCache; + var labelCache = _ol_render_canvas_.labelCache; labelCache.prune(); }; -ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay); + +_ol_.inherits(_ol_render_canvas_TextReplay_, _ol_render_canvas_Replay_); /** @@ -143,12 +144,12 @@ ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay); * each line. * @return {number} Width of the whole text. */ -ol.render.canvas.TextReplay.measureTextWidths = function(font, lines, widths) { +_ol_render_canvas_TextReplay_.measureTextWidths = function(font, lines, widths) { var numLines = lines.length; var width = 0; var currentWidth, i; for (i = 0; i < numLines; ++i) { - currentWidth = ol.render.canvas.measureTextWidth(font, lines[i]); + currentWidth = _ol_render_canvas_.measureTextWidth(font, lines[i]); width = Math.max(width, currentWidth); widths.push(currentWidth); } @@ -159,7 +160,7 @@ ol.render.canvas.TextReplay.measureTextWidths = function(font, lines, widths) { /** * @inheritDoc */ -ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) { +_ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) { var fillState = this.textFillState_; var strokeState = this.textStrokeState_; var textState = this.textState_; @@ -175,20 +176,20 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) { var stride = 2; var i, ii; - if (textState.placement === ol.style.TextPlacement.LINE) { - if (!ol.extent.intersects(this.getBufferedMaxExtent(), geometry.getExtent())) { + if (textState.placement === _ol_style_TextPlacement_.LINE) { + if (!_ol_extent_.intersects(this.getBufferedMaxExtent(), geometry.getExtent())) { return; } var ends; flatCoordinates = geometry.getFlatCoordinates(); stride = geometry.getStride(); - if (geometryType == ol.geom.GeometryType.LINE_STRING) { + if (geometryType == _ol_geom_GeometryType_.LINE_STRING) { ends = [flatCoordinates.length]; - } else if (geometryType == ol.geom.GeometryType.MULTI_LINE_STRING) { + } else if (geometryType == _ol_geom_GeometryType_.MULTI_LINE_STRING) { ends = geometry.getEnds(); - } else if (geometryType == ol.geom.GeometryType.POLYGON) { + } else if (geometryType == _ol_geom_GeometryType_.POLYGON) { ends = geometry.getEnds().slice(0, 1); - } else if (geometryType == ol.geom.GeometryType.MULTI_POLYGON) { + } else if (geometryType == _ol_geom_GeometryType_.MULTI_POLYGON) { var endss = geometry.getEndss(); ends = []; for (i = 0, ii = endss.length; i < ii; ++i) { @@ -201,7 +202,7 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) { var flatEnd; for (var o = 0, oo = ends.length; o < oo; ++o) { if (textAlign == undefined) { - var range = ol.geom.flat.straightchunk.lineString( + var range = _ol_geom_flat_straightchunk_.lineString( textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride); flatOffset = range[0]; flatEnd = range[1]; @@ -222,29 +223,29 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) { var label = this.getImage(this.text_, this.textKey_, this.fillKey_, this.strokeKey_); var width = label.width / this.pixelRatio; switch (geometryType) { - case ol.geom.GeometryType.POINT: - case ol.geom.GeometryType.MULTI_POINT: + case _ol_geom_GeometryType_.POINT: + case _ol_geom_GeometryType_.MULTI_POINT: flatCoordinates = geometry.getFlatCoordinates(); end = flatCoordinates.length; break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: flatCoordinates = /** @type {ol.geom.LineString} */ (geometry).getFlatMidpoint(); break; - case ol.geom.GeometryType.CIRCLE: + case _ol_geom_GeometryType_.CIRCLE: flatCoordinates = /** @type {ol.geom.Circle} */ (geometry).getCenter(); break; - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: flatCoordinates = /** @type {ol.geom.MultiLineString} */ (geometry).getFlatMidpoints(); end = flatCoordinates.length; break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: flatCoordinates = /** @type {ol.geom.Polygon} */ (geometry).getFlatInteriorPoint(); if (!textState.overflow && flatCoordinates[2] / this.resolution < width) { return; } stride = 3; break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: var interiorPoints = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints(); flatCoordinates = []; for (i = 0, ii = interiorPoints.length; i < ii; i += 3) { @@ -279,28 +280,28 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) { * @param {string} strokeKey Stroke style key. * @return {HTMLCanvasElement} Image. */ -ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey) { +_ol_render_canvas_TextReplay_.prototype.getImage = function(text, textKey, fillKey, strokeKey) { var label; var key = strokeKey + textKey + text + fillKey + this.pixelRatio; - var labelCache = ol.render.canvas.labelCache; + var labelCache = _ol_render_canvas_.labelCache; if (!labelCache.containsKey(key)) { var strokeState = strokeKey ? this.strokeStates[strokeKey] || this.textStrokeState_ : null; var fillState = fillKey ? this.fillStates[fillKey] || this.textFillState_ : null; var textState = this.textStates[textKey] || this.textState_; var pixelRatio = this.pixelRatio; var scale = textState.scale * pixelRatio; - var align = ol.render.replay.TEXT_ALIGN[textState.textAlign || ol.render.canvas.defaultTextAlign]; + var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign]; var strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0; var lines = text.split('\n'); var numLines = lines.length; var widths = []; - var width = ol.render.canvas.TextReplay.measureTextWidths(textState.font, lines, widths); - var lineHeight = ol.render.canvas.measureTextHeight(textState.font); + var width = _ol_render_canvas_TextReplay_.measureTextWidths(textState.font, lines, widths); + var lineHeight = _ol_render_canvas_.measureTextHeight(textState.font); var height = lineHeight * numLines; var renderWidth = (width + strokeWidth); - var context = ol.dom.createCanvasContext2D( + var context = _ol_dom_.createCanvasContext2D( Math.ceil(renderWidth * scale), Math.ceil((height + strokeWidth) * scale)); label = context.canvas; @@ -311,11 +312,11 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey context.font = textState.font; if (strokeKey) { context.strokeStyle = strokeState.strokeStyle; - context.lineWidth = strokeWidth * (ol.has.SAFARI ? scale : 1); + context.lineWidth = strokeWidth * (_ol_has_.SAFARI ? scale : 1); context.lineCap = strokeState.lineCap; context.lineJoin = strokeState.lineJoin; context.miterLimit = strokeState.miterLimit; - if (ol.has.CANVAS_LINE_DASH && strokeState.lineDash.length) { + if (_ol_has_.CANVAS_LINE_DASH && strokeState.lineDash.length) { context.setLineDash(strokeState.lineDash); context.lineDashOffset = strokeState.lineDashOffset; } @@ -349,27 +350,27 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey * @param {number} begin Begin. * @param {number} end End. */ -ol.render.canvas.TextReplay.prototype.drawTextImage_ = function(label, begin, end) { +_ol_render_canvas_TextReplay_.prototype.drawTextImage_ = function(label, begin, end) { var textState = this.textState_; var strokeState = this.textStrokeState_; var pixelRatio = this.pixelRatio; - var align = ol.render.replay.TEXT_ALIGN[textState.textAlign || ol.render.canvas.defaultTextAlign]; - var baseline = ol.render.replay.TEXT_ALIGN[textState.textBaseline]; + var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign]; + var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline]; var strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0; var anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth; var anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth; - this.instructions.push([ol.render.canvas.Instruction.DRAW_IMAGE, begin, end, + this.instructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end, label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio, this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_, 1, true, label.width, - textState.padding == ol.render.canvas.defaultPadding ? - ol.render.canvas.defaultPadding : textState.padding.map(function(p) { + textState.padding == _ol_render_canvas_.defaultPadding ? + _ol_render_canvas_.defaultPadding : textState.padding.map(function(p) { return p * pixelRatio; }), !!textState.backgroundFill, !!textState.backgroundStroke ]); - this.hitDetectionInstructions.push([ol.render.canvas.Instruction.DRAW_IMAGE, begin, end, + this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end, label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio, this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_, 1 / pixelRatio, true, label.width, textState.padding, @@ -384,7 +385,7 @@ ol.render.canvas.TextReplay.prototype.drawTextImage_ = function(label, begin, en * @param {number} end End. * @param {ol.DeclutterGroup} declutterGroup Declutter group. */ -ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) { +_ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declutterGroup) { var strokeState = this.textStrokeState_; var textState = this.textState_; var fillState = this.textFillState_; @@ -407,7 +408,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte if (!(this.textKey_ in this.textStates)) { this.textStates[this.textKey_] = /** @type {ol.CanvasTextState} */ ({ font: textState.font, - textAlign: textState.textAlign || ol.render.canvas.defaultTextAlign, + textAlign: textState.textAlign || _ol_render_canvas_.defaultTextAlign, scale: textState.scale }); } @@ -421,7 +422,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte } var pixelRatio = this.pixelRatio; - var baseline = ol.render.replay.TEXT_ALIGN[textState.textBaseline]; + var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline]; var offsetY = this.textOffsetY_ * pixelRatio; var text = this.text_; @@ -432,25 +433,25 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte if (!widths) { this.widths_[font] = widths = {}; } - this.instructions.push([ol.render.canvas.Instruction.DRAW_CHARS, + this.instructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS, begin, end, baseline, declutterGroup, textState.overflow, fillKey, textState.maxAngle, function(text) { var width = widths[text]; if (!width) { - width = widths[text] = ol.render.canvas.measureTextWidth(font, text); + width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text); } return width * textScale * pixelRatio; }, offsetY, strokeKey, strokeWidth * pixelRatio, text, textKey, 1 ]); - this.hitDetectionInstructions.push([ol.render.canvas.Instruction.DRAW_CHARS, + this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS, begin, end, baseline, declutterGroup, textState.overflow, fillKey, textState.maxAngle, function(text) { var width = widths[text]; if (!width) { - width = widths[text] = ol.render.canvas.measureTextWidth(font, text); + width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text); } return width * textScale; }, @@ -462,7 +463,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte /** * @inheritDoc */ -ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutterGroup) { +_ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declutterGroup) { var textState, fillState, strokeState; if (!textStyle) { this.text_ = ''; @@ -477,8 +478,8 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt if (!fillState) { fillState = this.textFillState_ = /** @type {ol.CanvasFillState} */ ({}); } - fillState.fillStyle = ol.colorlike.asColorLike( - textFillStyle.getColor() || ol.render.canvas.defaultFillStyle); + fillState.fillStyle = _ol_colorlike_.asColorLike( + textFillStyle.getColor() || _ol_render_canvas_.defaultFillStyle); } var textStrokeStyle = textStyle.getStroke(); @@ -493,32 +494,32 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt var lineDashOffset = textStrokeStyle.getLineDashOffset(); var lineWidth = textStrokeStyle.getWidth(); var miterLimit = textStrokeStyle.getMiterLimit(); - strokeState.lineCap = textStrokeStyle.getLineCap() || ol.render.canvas.defaultLineCap; - strokeState.lineDash = lineDash ? lineDash.slice() : ol.render.canvas.defaultLineDash; + strokeState.lineCap = textStrokeStyle.getLineCap() || _ol_render_canvas_.defaultLineCap; + strokeState.lineDash = lineDash ? lineDash.slice() : _ol_render_canvas_.defaultLineDash; strokeState.lineDashOffset = - lineDashOffset === undefined ? ol.render.canvas.defaultLineDashOffset : lineDashOffset; - strokeState.lineJoin = textStrokeStyle.getLineJoin() || ol.render.canvas.defaultLineJoin; + lineDashOffset === undefined ? _ol_render_canvas_.defaultLineDashOffset : lineDashOffset; + strokeState.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_canvas_.defaultLineJoin; strokeState.lineWidth = - lineWidth === undefined ? ol.render.canvas.defaultLineWidth : lineWidth; + lineWidth === undefined ? _ol_render_canvas_.defaultLineWidth : lineWidth; strokeState.miterLimit = - miterLimit === undefined ? ol.render.canvas.defaultMiterLimit : miterLimit; - strokeState.strokeStyle = ol.colorlike.asColorLike( - textStrokeStyle.getColor() || ol.render.canvas.defaultStrokeStyle); + miterLimit === undefined ? _ol_render_canvas_.defaultMiterLimit : miterLimit; + strokeState.strokeStyle = _ol_colorlike_.asColorLike( + textStrokeStyle.getColor() || _ol_render_canvas_.defaultStrokeStyle); } textState = this.textState_; - var font = textStyle.getFont() || ol.render.canvas.defaultFont; - ol.render.canvas.checkFont(font); + var font = textStyle.getFont() || _ol_render_canvas_.defaultFont; + _ol_render_canvas_.checkFont(font); var textScale = textStyle.getScale(); textState.overflow = textStyle.getOverflow(); textState.font = font; textState.maxAngle = textStyle.getMaxAngle(); textState.placement = textStyle.getPlacement(); textState.textAlign = textStyle.getTextAlign(); - textState.textBaseline = textStyle.getTextBaseline() || ol.render.canvas.defaultTextBaseline; + textState.textBaseline = textStyle.getTextBaseline() || _ol_render_canvas_.defaultTextBaseline; textState.backgroundFill = textStyle.getBackgroundFill(); textState.backgroundStroke = textStyle.getBackgroundStroke(); - textState.padding = textStyle.getPadding() || ol.render.canvas.defaultPadding; + textState.padding = textStyle.getPadding() || _ol_render_canvas_.defaultPadding; textState.scale = textScale === undefined ? 1 : textScale; var textOffsetX = textStyle.getOffsetX(); @@ -532,13 +533,14 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt this.textRotation_ = textRotation === undefined ? 0 : textRotation; this.strokeKey_ = strokeState ? - (typeof strokeState.strokeStyle == 'string' ? strokeState.strokeStyle : ol.getUid(strokeState.strokeStyle)) + + (typeof strokeState.strokeStyle == 'string' ? strokeState.strokeStyle : _ol_.getUid(strokeState.strokeStyle)) + strokeState.lineCap + strokeState.lineDashOffset + '|' + strokeState.lineWidth + strokeState.lineJoin + strokeState.miterLimit + '[' + strokeState.lineDash.join() + ']' : ''; this.textKey_ = textState.font + textState.scale + (textState.textAlign || '?'); this.fillKey_ = fillState ? - (typeof fillState.fillStyle == 'string' ? fillState.fillStyle : ('|' + ol.getUid(fillState.fillStyle))) : + (typeof fillState.fillStyle == 'string' ? fillState.fillStyle : ('|' + _ol_.getUid(fillState.fillStyle))) : ''; } }; +export default _ol_render_canvas_TextReplay_; diff --git a/src/ol/render/replay.js b/src/ol/render/replay.js index 3827508289..648b759a04 100644 --- a/src/ol/render/replay.js +++ b/src/ol/render/replay.js @@ -1,34 +1,37 @@ -goog.provide('ol.render.replay'); - -goog.require('ol.render.ReplayType'); +/** + * @module ol/render/replay + */ +import _ol_render_ReplayType_ from '../render/ReplayType.js'; +var _ol_render_replay_ = {}; /** * @const * @type {Array.} */ -ol.render.replay.ORDER = [ - ol.render.ReplayType.POLYGON, - ol.render.ReplayType.CIRCLE, - ol.render.ReplayType.LINE_STRING, - ol.render.ReplayType.IMAGE, - ol.render.ReplayType.TEXT, - ol.render.ReplayType.DEFAULT +_ol_render_replay_.ORDER = [ + _ol_render_ReplayType_.POLYGON, + _ol_render_ReplayType_.CIRCLE, + _ol_render_ReplayType_.LINE_STRING, + _ol_render_ReplayType_.IMAGE, + _ol_render_ReplayType_.TEXT, + _ol_render_ReplayType_.DEFAULT ]; /** * @const * @enum {number} */ -ol.render.replay.TEXT_ALIGN = {}; -ol.render.replay.TEXT_ALIGN['left'] = 0; -ol.render.replay.TEXT_ALIGN['end'] = 0; -ol.render.replay.TEXT_ALIGN['center'] = 0.5; -ol.render.replay.TEXT_ALIGN['right'] = 1; -ol.render.replay.TEXT_ALIGN['start'] = 1; -ol.render.replay.TEXT_ALIGN['top'] = 0; -ol.render.replay.TEXT_ALIGN['middle'] = 0.5; -ol.render.replay.TEXT_ALIGN['hanging'] = 0.2; -ol.render.replay.TEXT_ALIGN['alphabetic'] = 0.8; -ol.render.replay.TEXT_ALIGN['ideographic'] = 0.8; -ol.render.replay.TEXT_ALIGN['bottom'] = 1; +_ol_render_replay_.TEXT_ALIGN = {}; +_ol_render_replay_.TEXT_ALIGN['left'] = 0; +_ol_render_replay_.TEXT_ALIGN['end'] = 0; +_ol_render_replay_.TEXT_ALIGN['center'] = 0.5; +_ol_render_replay_.TEXT_ALIGN['right'] = 1; +_ol_render_replay_.TEXT_ALIGN['start'] = 1; +_ol_render_replay_.TEXT_ALIGN['top'] = 0; +_ol_render_replay_.TEXT_ALIGN['middle'] = 0.5; +_ol_render_replay_.TEXT_ALIGN['hanging'] = 0.2; +_ol_render_replay_.TEXT_ALIGN['alphabetic'] = 0.8; +_ol_render_replay_.TEXT_ALIGN['ideographic'] = 0.8; +_ol_render_replay_.TEXT_ALIGN['bottom'] = 1; +export default _ol_render_replay_; diff --git a/src/ol/render/webgl.js b/src/ol/render/webgl.js index 0794d51559..fbb0b61ef0 100644 --- a/src/ol/render/webgl.js +++ b/src/ol/render/webgl.js @@ -1,80 +1,83 @@ -goog.provide('ol.render.webgl'); +/** + * @module ol/render/webgl + */ +var _ol_render_webgl_ = {}; /** * @const * @type {string} */ -ol.render.webgl.defaultFont = '10px sans-serif'; +_ol_render_webgl_.defaultFont = '10px sans-serif'; /** * @const * @type {ol.Color} */ -ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0]; +_ol_render_webgl_.defaultFillStyle = [0.0, 0.0, 0.0, 1.0]; /** * @const * @type {string} */ -ol.render.webgl.defaultLineCap = 'round'; +_ol_render_webgl_.defaultLineCap = 'round'; /** * @const * @type {Array.} */ -ol.render.webgl.defaultLineDash = []; +_ol_render_webgl_.defaultLineDash = []; /** * @const * @type {number} */ -ol.render.webgl.defaultLineDashOffset = 0; +_ol_render_webgl_.defaultLineDashOffset = 0; /** * @const * @type {string} */ -ol.render.webgl.defaultLineJoin = 'round'; +_ol_render_webgl_.defaultLineJoin = 'round'; /** * @const * @type {number} */ -ol.render.webgl.defaultMiterLimit = 10; +_ol_render_webgl_.defaultMiterLimit = 10; /** * @const * @type {ol.Color} */ -ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0]; +_ol_render_webgl_.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0]; /** * @const * @type {number} */ -ol.render.webgl.defaultTextAlign = 0.5; +_ol_render_webgl_.defaultTextAlign = 0.5; /** * @const * @type {number} */ -ol.render.webgl.defaultTextBaseline = 0.5; +_ol_render_webgl_.defaultTextBaseline = 0.5; /** * @const * @type {number} */ -ol.render.webgl.defaultLineWidth = 1; +_ol_render_webgl_.defaultLineWidth = 1; /** * Calculates the orientation of a triangle based on the determinant method. @@ -86,9 +89,9 @@ ol.render.webgl.defaultLineWidth = 1; * @param {number} y3 Third Y coordinate. * @return {boolean|undefined} Triangle is clockwise. */ -ol.render.webgl.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) { +_ol_render_webgl_.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) { var area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1); - return (area <= ol.render.webgl.EPSILON && area >= -ol.render.webgl.EPSILON) ? + return (area <= _ol_render_webgl_.EPSILON && area >= -_ol_render_webgl_.EPSILON) ? undefined : area > 0; }; @@ -96,4 +99,5 @@ ol.render.webgl.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) { * @const * @type {number} */ -ol.render.webgl.EPSILON = Number.EPSILON || 2.220446049250313e-16; +_ol_render_webgl_.EPSILON = Number.EPSILON || 2.220446049250313e-16; +export default _ol_render_webgl_; diff --git a/src/ol/render/webgl/CircleReplay.js b/src/ol/render/webgl/CircleReplay.js index 198f0a2d0e..145022157b 100644 --- a/src/ol/render/webgl/CircleReplay.js +++ b/src/ol/render/webgl/CircleReplay.js @@ -1,18 +1,18 @@ -goog.provide('ol.render.webgl.CircleReplay'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.color'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.render.webgl.circlereplay.defaultshader'); -goog.require('ol.render.webgl.circlereplay.defaultshader.Locations'); -goog.require('ol.render.webgl.Replay'); -goog.require('ol.render.webgl'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Buffer'); - +/** + * @module ol/render/webgl/CircleReplay + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_color_ from '../../color.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_render_webgl_circlereplay_defaultshader_ from '../webgl/circlereplay/defaultshader.js'; +import _ol_render_webgl_circlereplay_defaultshader_Locations_ from '../webgl/circlereplay/defaultshader/Locations.js'; +import _ol_render_webgl_Replay_ from '../webgl/Replay.js'; +import _ol_render_webgl_ from '../webgl.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -21,8 +21,8 @@ goog.require('ol.webgl.Buffer'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.CircleReplay = function(tolerance, maxExtent) { - ol.render.webgl.Replay.call(this, tolerance, maxExtent); +var _ol_render_webgl_CircleReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_Replay_.call(this, tolerance, maxExtent); /** * @private @@ -67,7 +67,8 @@ ol.render.webgl.CircleReplay = function(tolerance, maxExtent) { }; }; -ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay); + +_ol_.inherits(_ol_render_webgl_CircleReplay_, _ol_render_webgl_Replay_); /** @@ -77,7 +78,7 @@ ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay); * @param {number} end End. * @param {number} stride Stride. */ -ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function( +_ol_render_webgl_CircleReplay_.prototype.drawCoordinates_ = function( flatCoordinates, offset, end, stride) { var numVertices = this.vertices.length; var numIndices = this.indices.length; @@ -120,7 +121,7 @@ ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function( /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, feature) { +_ol_render_webgl_CircleReplay_.prototype.drawCircle = function(circleGeometry, feature) { var radius = circleGeometry.getRadius(); var stride = circleGeometry.getStride(); if (radius) { @@ -133,7 +134,7 @@ ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, fea this.radius_ = radius; var flatCoordinates = circleGeometry.getFlatCoordinates(); - flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, 2, + flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, 2, stride, -this.origin[0], -this.origin[1]); this.drawCoordinates_(flatCoordinates, 0, 2, stride); } else { @@ -154,12 +155,12 @@ ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, fea /** * @inheritDoc **/ -ol.render.webgl.CircleReplay.prototype.finish = function(context) { +_ol_render_webgl_CircleReplay_.prototype.finish = function(context) { // create, bind, and populate the vertices buffer - this.verticesBuffer = new ol.webgl.Buffer(this.vertices); + this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices); // create, bind, and populate the indices buffer - this.indicesBuffer = new ol.webgl.Buffer(this.indices); + this.indicesBuffer = new _ol_webgl_Buffer_(this.indices); this.startIndices.push(this.indices.length); @@ -176,7 +177,7 @@ ol.render.webgl.CircleReplay.prototype.finish = function(context) { /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(context) { +_ol_render_webgl_CircleReplay_.prototype.getDeleteResourcesFunction = function(context) { // We only delete our stuff here. The shaders and the program may // be used by other CircleReplay instances (for other layers). And // they will be deleted when disposing of the ol.webgl.Context @@ -193,17 +194,17 @@ ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(con /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) { +_ol_render_webgl_CircleReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) { // get the program var fragmentShader, vertexShader; - fragmentShader = ol.render.webgl.circlereplay.defaultshader.fragment; - vertexShader = ol.render.webgl.circlereplay.defaultshader.vertex; + fragmentShader = _ol_render_webgl_circlereplay_defaultshader_.fragment; + vertexShader = _ol_render_webgl_circlereplay_defaultshader_.vertex; var program = context.getProgram(fragmentShader, vertexShader); // get the locations var locations; if (!this.defaultLocations_) { - locations = new ol.render.webgl.circlereplay.defaultshader.Locations(gl, program); + locations = new _ol_render_webgl_circlereplay_defaultshader_Locations_(gl, program); this.defaultLocations_ = locations; } else { locations = this.defaultLocations_; @@ -213,15 +214,15 @@ ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size // enable the vertex attrib arrays gl.enableVertexAttribArray(locations.a_position); - gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0); gl.enableVertexAttribArray(locations.a_instruction); - gl.vertexAttribPointer(locations.a_instruction, 1, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_instruction, 1, _ol_webgl_.FLOAT, false, 16, 8); gl.enableVertexAttribArray(locations.a_radius); - gl.vertexAttribPointer(locations.a_radius, 1, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_radius, 1, _ol_webgl_.FLOAT, false, 16, 12); // Enable renderer specific uniforms. @@ -235,7 +236,7 @@ ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations) { +_ol_render_webgl_CircleReplay_.prototype.shutDownProgram = function(gl, locations) { gl.disableVertexAttribArray(locations.a_position); gl.disableVertexAttribArray(locations.a_instruction); gl.disableVertexAttribArray(locations.a_radius); @@ -245,8 +246,8 @@ ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations) /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { - if (!ol.obj.isEmpty(skippedFeaturesHash)) { +_ol_render_webgl_CircleReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { + if (!_ol_obj_.isEmpty(skippedFeaturesHash)) { this.drawReplaySkipping_(gl, context, skippedFeaturesHash); } else { //Draw by style groups to minimize drawElements() calls. @@ -268,7 +269,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippe /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_CircleReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex; featureIndex = this.startIndices.length - 2; @@ -284,11 +285,11 @@ ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function this.startIndices[featureIndex] >= groupStart) { start = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid] === undefined && feature.getGeometry() && - (opt_hitExtent === undefined || ol.extent.intersects( + (opt_hitExtent === undefined || _ol_extent_.intersects( /** @type {Array} */ (opt_hitExtent), feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); @@ -315,7 +316,7 @@ ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function * @param {ol.webgl.Context} context Context. * @param {Object} skippedFeaturesHash Ids of features to skip. */ -ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { +_ol_render_webgl_CircleReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart; featureIndex = this.startIndices.length - 2; end = start = this.startIndices[featureIndex + 1]; @@ -330,7 +331,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, contex this.startIndices[featureIndex] >= groupStart) { featureStart = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid]) { if (start !== end) { @@ -354,7 +355,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, contex * @param {WebGLRenderingContext} gl gl. * @param {Array.} color Color. */ -ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) { +_ol_render_webgl_CircleReplay_.prototype.setFillStyle_ = function(gl, color) { gl.uniform4fv(this.defaultLocations_.u_fillColor, color); }; @@ -365,7 +366,7 @@ ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) { * @param {Array.} color Color. * @param {number} lineWidth Line width. */ -ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth) { +_ol_render_webgl_CircleReplay_.prototype.setStrokeStyle_ = function(gl, color, lineWidth) { gl.uniform4fv(this.defaultLocations_.u_strokeColor, color); gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth); }; @@ -374,27 +375,27 @@ ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lin /** * @inheritDoc */ -ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_webgl_CircleReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { var strokeStyleColor, strokeStyleWidth; if (strokeStyle) { var strokeStyleLineDash = strokeStyle.getLineDash(); this.state_.lineDash = strokeStyleLineDash ? - strokeStyleLineDash : ol.render.webgl.defaultLineDash; + strokeStyleLineDash : _ol_render_webgl_.defaultLineDash; var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset(); this.state_.lineDashOffset = strokeStyleLineDashOffset ? - strokeStyleLineDashOffset : ol.render.webgl.defaultLineDashOffset; + strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset; strokeStyleColor = strokeStyle.getColor(); if (!(strokeStyleColor instanceof CanvasGradient) && !(strokeStyleColor instanceof CanvasPattern)) { - strokeStyleColor = ol.color.asArray(strokeStyleColor).map(function(c, i) { + strokeStyleColor = _ol_color_.asArray(strokeStyleColor).map(function(c, i) { return i != 3 ? c / 255 : c; - }) || ol.render.webgl.defaultStrokeStyle; + }) || _ol_render_webgl_.defaultStrokeStyle; } else { - strokeStyleColor = ol.render.webgl.defaultStrokeStyle; + strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle; } strokeStyleWidth = strokeStyle.getWidth(); strokeStyleWidth = strokeStyleWidth !== undefined ? - strokeStyleWidth : ol.render.webgl.defaultLineWidth; + strokeStyleWidth : _ol_render_webgl_.defaultLineWidth; } else { strokeStyleColor = [0, 0, 0, 0]; strokeStyleWidth = 0; @@ -402,14 +403,14 @@ ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0]; if (!(fillStyleColor instanceof CanvasGradient) && !(fillStyleColor instanceof CanvasPattern)) { - fillStyleColor = ol.color.asArray(fillStyleColor).map(function(c, i) { + fillStyleColor = _ol_color_.asArray(fillStyleColor).map(function(c, i) { return i != 3 ? c / 255 : c; - }) || ol.render.webgl.defaultFillStyle; + }) || _ol_render_webgl_.defaultFillStyle; } else { - fillStyleColor = ol.render.webgl.defaultFillStyle; + fillStyleColor = _ol_render_webgl_.defaultFillStyle; } - if (!this.state_.strokeColor || !ol.array.equals(this.state_.strokeColor, strokeStyleColor) || - !this.state_.fillColor || !ol.array.equals(this.state_.fillColor, fillStyleColor) || + if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) || + !this.state_.fillColor || !_ol_array_.equals(this.state_.fillColor, fillStyleColor) || this.state_.lineWidth !== strokeStyleWidth) { this.state_.changed = true; this.state_.fillColor = fillStyleColor; @@ -418,3 +419,4 @@ ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, this.styles_.push([fillStyleColor, strokeStyleColor, strokeStyleWidth]); } }; +export default _ol_render_webgl_CircleReplay_; diff --git a/src/ol/render/webgl/ImageReplay.js b/src/ol/render/webgl/ImageReplay.js index 8d8341cd09..44f6ed0b6c 100644 --- a/src/ol/render/webgl/ImageReplay.js +++ b/src/ol/render/webgl/ImageReplay.js @@ -1,9 +1,9 @@ -goog.provide('ol.render.webgl.ImageReplay'); - -goog.require('ol'); -goog.require('ol.render.webgl.TextureReplay'); -goog.require('ol.webgl.Buffer'); - +/** + * @module ol/render/webgl/ImageReplay + */ +import _ol_ from '../../index.js'; +import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -12,8 +12,8 @@ goog.require('ol.webgl.Buffer'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.ImageReplay = function(tolerance, maxExtent) { - ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent); +var _ol_render_webgl_ImageReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_TextureReplay_.call(this, tolerance, maxExtent); /** * @type {Array.} @@ -40,13 +40,14 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) { this.hitDetectionTextures_ = []; }; -ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.TextureReplay); + +_ol_.inherits(_ol_render_webgl_ImageReplay_, _ol_render_webgl_TextureReplay_); /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) { +_ol_render_webgl_ImageReplay_.prototype.drawMultiPoint = function(multiPointGeometry, feature) { this.startIndices.push(this.indices.length); this.startIndicesFeature.push(feature); var flatCoordinates = multiPointGeometry.getFlatCoordinates(); @@ -59,7 +60,7 @@ ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeomet /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) { +_ol_render_webgl_ImageReplay_.prototype.drawPoint = function(pointGeometry, feature) { this.startIndices.push(this.indices.length); this.startIndicesFeature.push(feature); var flatCoordinates = pointGeometry.getFlatCoordinates(); @@ -72,19 +73,19 @@ ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, featur /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.finish = function(context) { +_ol_render_webgl_ImageReplay_.prototype.finish = function(context) { var gl = context.getGL(); this.groupIndices.push(this.indices.length); this.hitDetectionGroupIndices.push(this.indices.length); // create, bind, and populate the vertices buffer - this.verticesBuffer = new ol.webgl.Buffer(this.vertices); + this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices); var indices = this.indices; // create, bind, and populate the indices buffer - this.indicesBuffer = new ol.webgl.Buffer(indices); + this.indicesBuffer = new _ol_webgl_Buffer_(indices); // create textures /** @type {Object.} */ @@ -97,14 +98,14 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) { this.images_ = null; this.hitDetectionImages_ = null; - ol.render.webgl.TextureReplay.prototype.finish.call(this, context); + _ol_render_webgl_TextureReplay_.prototype.finish.call(this, context); }; /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { +_ol_render_webgl_ImageReplay_.prototype.setImageStyle = function(imageStyle) { var anchor = imageStyle.getAnchor(); var image = imageStyle.getImage(1); var imageSize = imageStyle.getImageSize(); @@ -121,7 +122,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { this.images_.push(image); } else { currentImage = this.images_[this.images_.length - 1]; - if (ol.getUid(currentImage) != ol.getUid(image)) { + if (_ol_.getUid(currentImage) != _ol_.getUid(image)) { this.groupIndices.push(this.indices.length); this.images_.push(image); } @@ -132,7 +133,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { } else { currentImage = this.hitDetectionImages_[this.hitDetectionImages_.length - 1]; - if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) { + if (_ol_.getUid(currentImage) != _ol_.getUid(hitDetectionImage)) { this.hitDetectionGroupIndices.push(this.indices.length); this.hitDetectionImages_.push(hitDetectionImage); } @@ -156,7 +157,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) { +_ol_render_webgl_ImageReplay_.prototype.getTextures = function(opt_all) { return opt_all ? this.textures_.concat(this.hitDetectionTextures_) : this.textures_; }; @@ -164,6 +165,7 @@ ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) { /** * @inheritDoc */ -ol.render.webgl.ImageReplay.prototype.getHitDetectionTextures = function() { +_ol_render_webgl_ImageReplay_.prototype.getHitDetectionTextures = function() { return this.hitDetectionTextures_; }; +export default _ol_render_webgl_ImageReplay_; diff --git a/src/ol/render/webgl/Immediate.js b/src/ol/render/webgl/Immediate.js index 84908b1340..be2fea1a73 100644 --- a/src/ol/render/webgl/Immediate.js +++ b/src/ol/render/webgl/Immediate.js @@ -1,12 +1,12 @@ -goog.provide('ol.render.webgl.Immediate'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.render.ReplayType'); -goog.require('ol.render.VectorContext'); -goog.require('ol.render.webgl.ReplayGroup'); - +/** + * @module ol/render/webgl/Immediate + */ +import _ol_ from '../../index.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_geom_GeometryType_ from '../../geom/GeometryType.js'; +import _ol_render_ReplayType_ from '../ReplayType.js'; +import _ol_render_VectorContext_ from '../VectorContext.js'; +import _ol_render_webgl_ReplayGroup_ from '../webgl/ReplayGroup.js'; /** * @constructor @@ -20,8 +20,8 @@ goog.require('ol.render.webgl.ReplayGroup'); * @param {number} pixelRatio Pixel ratio. * @struct */ -ol.render.webgl.Immediate = function(context, center, resolution, rotation, size, extent, pixelRatio) { - ol.render.VectorContext.call(this); +var _ol_render_webgl_Immediate_ = function(context, center, resolution, rotation, size, extent, pixelRatio) { + _ol_render_VectorContext_.call(this); /** * @private @@ -83,7 +83,8 @@ ol.render.webgl.Immediate = function(context, center, resolution, rotation, size this.textStyle_ = null; }; -ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext); + +_ol_.inherits(_ol_render_webgl_Immediate_, _ol_render_VectorContext_); /** @@ -91,10 +92,10 @@ ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext); * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @private */ -ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup, geometry) { +_ol_render_webgl_Immediate_.prototype.drawText_ = function(replayGroup, geometry) { var context = this.context_; var replay = /** @type {ol.render.webgl.TextReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.TEXT)); + replayGroup.getReplay(0, _ol_render_ReplayType_.TEXT)); replay.setTextStyle(this.textStyle_); replay.drawText(geometry, null); replay.finish(context); @@ -118,7 +119,7 @@ ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup, geometry) * @override * @api */ -ol.render.webgl.Immediate.prototype.setStyle = function(style) { +_ol_render_webgl_Immediate_.prototype.setStyle = function(style) { this.setFillStrokeStyle(style.getFill(), style.getStroke()); this.setImageStyle(style.getImage()); this.setTextStyle(style.getText()); @@ -133,31 +134,31 @@ ol.render.webgl.Immediate.prototype.setStyle = function(style) { * @override * @api */ -ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) { +_ol_render_webgl_Immediate_.prototype.drawGeometry = function(geometry) { var type = geometry.getType(); switch (type) { - case ol.geom.GeometryType.POINT: + case _ol_geom_GeometryType_.POINT: this.drawPoint(/** @type {ol.geom.Point} */ (geometry), null); break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: this.drawLineString(/** @type {ol.geom.LineString} */ (geometry), null); break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: this.drawPolygon(/** @type {ol.geom.Polygon} */ (geometry), null); break; - case ol.geom.GeometryType.MULTI_POINT: + case _ol_geom_GeometryType_.MULTI_POINT: this.drawMultiPoint(/** @type {ol.geom.MultiPoint} */ (geometry), null); break; - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: this.drawMultiLineString(/** @type {ol.geom.MultiLineString} */ (geometry), null); break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: this.drawMultiPolygon(/** @type {ol.geom.MultiPolygon} */ (geometry), null); break; - case ol.geom.GeometryType.GEOMETRY_COLLECTION: + case _ol_geom_GeometryType_.GEOMETRY_COLLECTION: this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry), null); break; - case ol.geom.GeometryType.CIRCLE: + case _ol_geom_GeometryType_.CIRCLE: this.drawCircle(/** @type {ol.geom.Circle} */ (geometry), null); break; default: @@ -170,10 +171,10 @@ ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) { * @inheritDoc * @api */ -ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) { +_ol_render_webgl_Immediate_.prototype.drawFeature = function(feature, style) { var geometry = style.getGeometryFunction()(feature); if (!geometry || - !ol.extent.intersects(this.extent_, geometry.getExtent())) { + !_ol_extent_.intersects(this.extent_, geometry.getExtent())) { return; } this.setStyle(style); @@ -184,7 +185,7 @@ ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawGeometryCollection = function(geometry, data) { var geometries = geometry.getGeometriesArray(); var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { @@ -196,11 +197,11 @@ ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry, /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawPoint = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.ImageReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.IMAGE)); + replayGroup.getReplay(0, _ol_render_ReplayType_.IMAGE)); replay.setImageStyle(this.imageStyle_); replay.drawPoint(geometry, data); replay.finish(context); @@ -223,11 +224,11 @@ ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawMultiPoint = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.ImageReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.IMAGE)); + replayGroup.getReplay(0, _ol_render_ReplayType_.IMAGE)); replay.setImageStyle(this.imageStyle_); replay.drawMultiPoint(geometry, data); replay.finish(context); @@ -249,11 +250,11 @@ ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawLineString = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.LineStringReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.LINE_STRING)); + replayGroup.getReplay(0, _ol_render_ReplayType_.LINE_STRING)); replay.setFillStrokeStyle(null, this.strokeStyle_); replay.drawLineString(geometry, data); replay.finish(context); @@ -275,11 +276,11 @@ ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawMultiLineString = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.LineStringReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.LINE_STRING)); + replayGroup.getReplay(0, _ol_render_ReplayType_.LINE_STRING)); replay.setFillStrokeStyle(null, this.strokeStyle_); replay.drawMultiLineString(geometry, data); replay.finish(context); @@ -301,11 +302,11 @@ ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, dat /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawPolygon = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.PolygonReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.POLYGON)); + replayGroup.getReplay(0, _ol_render_ReplayType_.POLYGON)); replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_); replay.drawPolygon(geometry, data); replay.finish(context); @@ -327,11 +328,11 @@ ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawMultiPolygon = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.PolygonReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.POLYGON)); + replayGroup.getReplay(0, _ol_render_ReplayType_.POLYGON)); replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_); replay.drawMultiPolygon(geometry, data); replay.finish(context); @@ -353,11 +354,11 @@ ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data) /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) { +_ol_render_webgl_Immediate_.prototype.drawCircle = function(geometry, data) { var context = this.context_; - var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_); + var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_); var replay = /** @type {ol.render.webgl.CircleReplay} */ ( - replayGroup.getReplay(0, ol.render.ReplayType.CIRCLE)); + replayGroup.getReplay(0, _ol_render_ReplayType_.CIRCLE)); replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_); replay.drawCircle(geometry, data); replay.finish(context); @@ -379,7 +380,7 @@ ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) { +_ol_render_webgl_Immediate_.prototype.setImageStyle = function(imageStyle) { this.imageStyle_ = imageStyle; }; @@ -387,7 +388,7 @@ ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) { /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_webgl_Immediate_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { this.fillStyle_ = fillStyle; this.strokeStyle_ = strokeStyle; }; @@ -396,6 +397,7 @@ ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, str /** * @inheritDoc */ -ol.render.webgl.Immediate.prototype.setTextStyle = function(textStyle) { +_ol_render_webgl_Immediate_.prototype.setTextStyle = function(textStyle) { this.textStyle_ = textStyle; }; +export default _ol_render_webgl_Immediate_; diff --git a/src/ol/render/webgl/LineStringReplay.js b/src/ol/render/webgl/LineStringReplay.js index 5817cec8e5..3e8203007f 100644 --- a/src/ol/render/webgl/LineStringReplay.js +++ b/src/ol/render/webgl/LineStringReplay.js @@ -1,20 +1,20 @@ -goog.provide('ol.render.webgl.LineStringReplay'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.color'); -goog.require('ol.extent'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.geom.flat.topology'); -goog.require('ol.obj'); -goog.require('ol.render.webgl'); -goog.require('ol.render.webgl.Replay'); -goog.require('ol.render.webgl.linestringreplay.defaultshader'); -goog.require('ol.render.webgl.linestringreplay.defaultshader.Locations'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Buffer'); - +/** + * @module ol/render/webgl/LineStringReplay + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_color_ from '../../color.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_geom_flat_orient_ from '../../geom/flat/orient.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_geom_flat_topology_ from '../../geom/flat/topology.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_render_webgl_ from '../webgl.js'; +import _ol_render_webgl_Replay_ from '../webgl/Replay.js'; +import _ol_render_webgl_linestringreplay_defaultshader_ from '../webgl/linestringreplay/defaultshader.js'; +import _ol_render_webgl_linestringreplay_defaultshader_Locations_ from '../webgl/linestringreplay/defaultshader/Locations.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -23,8 +23,8 @@ goog.require('ol.webgl.Buffer'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) { - ol.render.webgl.Replay.call(this, tolerance, maxExtent); +var _ol_render_webgl_LineStringReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_Replay_.call(this, tolerance, maxExtent); /** * @private @@ -67,7 +67,8 @@ ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) { }; }; -ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay); + +_ol_.inherits(_ol_render_webgl_LineStringReplay_, _ol_render_webgl_Replay_); /** @@ -78,7 +79,7 @@ ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay); * @param {number} end End. * @param {number} stride Stride. */ -ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { +_ol_render_webgl_LineStringReplay_.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) { var i, ii; var numVertices = this.vertices.length; @@ -90,7 +91,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord this.state_.lineJoin === 'miter' ? 1 : 2; var lineCap = this.state_.lineCap === 'butt' ? 0 : this.state_.lineCap === 'square' ? 1 : 2; - var closed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, offset, end, stride); + var closed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, offset, end, stride); var startCoords, sign, n; var lastIndex = numIndices; var lastSign = 1; @@ -106,7 +107,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord //First vertex. if (i === offset) { p2 = [flatCoordinates[i + stride], flatCoordinates[i + stride + 1]]; - if (end - offset === stride * 2 && ol.array.equals(p1, p2)) { + if (end - offset === stride * 2 && _ol_array_.equals(p1, p2)) { break; } if (closed) { @@ -120,10 +121,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord if (lineCap) { numVertices = this.addVertices_([0, 0], p1, p2, - lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices); + lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices); numVertices = this.addVertices_([0, 0], p1, p2, - -lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices); + -lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices); this.indices[numIndices++] = n + 2; this.indices[numIndices++] = n; @@ -136,10 +137,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord } numVertices = this.addVertices_([0, 0], p1, p2, - lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices); + lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices); numVertices = this.addVertices_([0, 0], p1, p2, - -lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices); + -lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices); lastIndex = numVertices / 7 - 1; @@ -155,10 +156,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord p0 = p0 || [0, 0]; numVertices = this.addVertices_(p0, p1, [0, 0], - lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices); + lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE * (lineCap || 1), numVertices); numVertices = this.addVertices_(p0, p1, [0, 0], - -lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices); + -lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE * (lineCap || 1), numVertices); this.indices[numIndices++] = n; this.indices[numIndices++] = lastIndex - 1; @@ -170,10 +171,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord if (lineCap) { numVertices = this.addVertices_(p0, p1, [0, 0], - lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices); + lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE_CAP * lineCap, numVertices); numVertices = this.addVertices_(p0, p1, [0, 0], - -lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices); + -lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE_CAP * lineCap, numVertices); this.indices[numIndices++] = n + 2; this.indices[numIndices++] = n; @@ -192,17 +193,17 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord } // We group CW and straight lines, thus the not so inituitive CCW checking function. - sign = ol.render.webgl.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]) + sign = _ol_render_webgl_.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]) ? -1 : 1; numVertices = this.addVertices_(p0, p1, p2, - sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices); + sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices); numVertices = this.addVertices_(p0, p1, p2, - sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_SECOND * (lineJoin || 1), numVertices); + sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_SECOND * (lineJoin || 1), numVertices); numVertices = this.addVertices_(p0, p1, p2, - -sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices); + -sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices); if (i > offset) { this.indices[numIndices++] = n; @@ -224,7 +225,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord //Add miter if (lineJoin) { numVertices = this.addVertices_(p0, p1, p2, - sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_TOP * lineJoin, numVertices); + sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_TOP * lineJoin, numVertices); this.indices[numIndices++] = n + 1; this.indices[numIndices++] = n + 3; @@ -234,14 +235,14 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord if (closed) { n = n || numVertices / 7; - sign = ol.geom.flat.orient.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2) + sign = _ol_geom_flat_orient_.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2) ? 1 : -1; numVertices = this.addVertices_(p0, p1, p2, - sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices); + sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices); numVertices = this.addVertices_(p0, p1, p2, - -sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices); + -sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices); this.indices[numIndices++] = n; this.indices[numIndices++] = lastIndex - 1; @@ -262,7 +263,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord * @return {number} Vertex counter. * @private */ -ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) { +_ol_render_webgl_LineStringReplay_.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) { this.vertices[numVertices++] = p0[0]; this.vertices[numVertices++] = p0[1]; this.vertices[numVertices++] = p1[0]; @@ -283,14 +284,14 @@ ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, p * @return {boolean} The linestring can be drawn. * @private */ -ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates, offset, end, stride) { +_ol_render_webgl_LineStringReplay_.prototype.isValid_ = function(flatCoordinates, offset, end, stride) { var range = end - offset; if (range < stride * 2) { return false; } else if (range === stride * 2) { var firstP = [flatCoordinates[offset], flatCoordinates[offset + 1]]; var lastP = [flatCoordinates[offset + stride], flatCoordinates[offset + stride + 1]]; - return !ol.array.equals(firstP, lastP); + return !_ol_array_.equals(firstP, lastP); } return true; @@ -300,11 +301,11 @@ ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates, /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) { +_ol_render_webgl_LineStringReplay_.prototype.drawLineString = function(lineStringGeometry, feature) { var flatCoordinates = lineStringGeometry.getFlatCoordinates(); var stride = lineStringGeometry.getStride(); if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) { - flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, flatCoordinates.length, + flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, flatCoordinates.length, stride, -this.origin[0], -this.origin[1]); if (this.state_.changed) { this.styleIndices_.push(this.indices.length); @@ -321,7 +322,7 @@ ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringG /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) { +_ol_render_webgl_LineStringReplay_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) { var indexCount = this.indices.length; var ends = multiLineStringGeometry.getEnds(); ends.unshift(0); @@ -331,7 +332,7 @@ ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiL if (ends.length > 1) { for (i = 1, ii = ends.length; i < ii; ++i) { if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) { - var lineString = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1], ends[i], + var lineString = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1], ends[i], stride, -this.origin[0], -this.origin[1]); this.drawCoordinates_( lineString, 0, lineString.length, stride); @@ -354,9 +355,9 @@ ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiL * @param {Array.>} holeFlatCoordinates Hole flat coordinates. * @param {number} stride Stride. */ -ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function( +_ol_render_webgl_LineStringReplay_.prototype.drawPolygonCoordinates = function( flatCoordinates, holeFlatCoordinates, stride) { - if (!ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, + if (!_ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, stride)) { flatCoordinates.push(flatCoordinates[0]); flatCoordinates.push(flatCoordinates[1]); @@ -365,7 +366,7 @@ ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function( if (holeFlatCoordinates.length) { var i, ii; for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) { - if (!ol.geom.flat.topology.lineStringIsClosed(holeFlatCoordinates[i], 0, + if (!_ol_geom_flat_topology_.lineStringIsClosed(holeFlatCoordinates[i], 0, holeFlatCoordinates[i].length, stride)) { holeFlatCoordinates[i].push(holeFlatCoordinates[i][0]); holeFlatCoordinates[i].push(holeFlatCoordinates[i][1]); @@ -381,7 +382,7 @@ ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function( * @param {ol.Feature|ol.render.Feature} feature Feature. * @param {number=} opt_index Index count. */ -ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, opt_index) { +_ol_render_webgl_LineStringReplay_.prototype.setPolygonStyle = function(feature, opt_index) { var index = opt_index === undefined ? this.indices.length : opt_index; this.startIndices.push(index); this.startIndicesFeature.push(feature); @@ -395,7 +396,7 @@ ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, o /** * @return {number} Current index. */ -ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() { +_ol_render_webgl_LineStringReplay_.prototype.getCurrentIndex = function() { return this.indices.length; }; @@ -403,12 +404,12 @@ ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() { /** * @inheritDoc **/ -ol.render.webgl.LineStringReplay.prototype.finish = function(context) { +_ol_render_webgl_LineStringReplay_.prototype.finish = function(context) { // create, bind, and populate the vertices buffer - this.verticesBuffer = new ol.webgl.Buffer(this.vertices); + this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices); // create, bind, and populate the indices buffer - this.indicesBuffer = new ol.webgl.Buffer(this.indices); + this.indicesBuffer = new _ol_webgl_Buffer_(this.indices); this.startIndices.push(this.indices.length); @@ -425,7 +426,7 @@ ol.render.webgl.LineStringReplay.prototype.finish = function(context) { /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function(context) { +_ol_render_webgl_LineStringReplay_.prototype.getDeleteResourcesFunction = function(context) { var verticesBuffer = this.verticesBuffer; var indicesBuffer = this.indicesBuffer; return function() { @@ -438,17 +439,17 @@ ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) { +_ol_render_webgl_LineStringReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) { // get the program var fragmentShader, vertexShader; - fragmentShader = ol.render.webgl.linestringreplay.defaultshader.fragment; - vertexShader = ol.render.webgl.linestringreplay.defaultshader.vertex; + fragmentShader = _ol_render_webgl_linestringreplay_defaultshader_.fragment; + vertexShader = _ol_render_webgl_linestringreplay_defaultshader_.vertex; var program = context.getProgram(fragmentShader, vertexShader); // get the locations var locations; if (!this.defaultLocations_) { - locations = new ol.render.webgl.linestringreplay.defaultshader.Locations(gl, program); + locations = new _ol_render_webgl_linestringreplay_defaultshader_Locations_(gl, program); this.defaultLocations_ = locations; } else { locations = this.defaultLocations_; @@ -458,19 +459,19 @@ ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, // enable the vertex attrib arrays gl.enableVertexAttribArray(locations.a_lastPos); - gl.vertexAttribPointer(locations.a_lastPos, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_lastPos, 2, _ol_webgl_.FLOAT, false, 28, 0); gl.enableVertexAttribArray(locations.a_position); - gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT, false, 28, 8); gl.enableVertexAttribArray(locations.a_nextPos); - gl.vertexAttribPointer(locations.a_nextPos, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_nextPos, 2, _ol_webgl_.FLOAT, false, 28, 16); gl.enableVertexAttribArray(locations.a_direction); - gl.vertexAttribPointer(locations.a_direction, 1, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_direction, 1, _ol_webgl_.FLOAT, false, 28, 24); // Enable renderer specific uniforms. @@ -484,7 +485,7 @@ ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locations) { +_ol_render_webgl_LineStringReplay_.prototype.shutDownProgram = function(gl, locations) { gl.disableVertexAttribArray(locations.a_lastPos); gl.disableVertexAttribArray(locations.a_position); gl.disableVertexAttribArray(locations.a_nextPos); @@ -495,7 +496,7 @@ ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locati /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { +_ol_render_webgl_LineStringReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { //Save GL parameters. var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC)); var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK)); @@ -506,7 +507,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, sk gl.depthFunc(gl.NOTEQUAL); } - if (!ol.obj.isEmpty(skippedFeaturesHash)) { + if (!_ol_obj_.isEmpty(skippedFeaturesHash)) { this.drawReplaySkipping_(gl, context, skippedFeaturesHash); } else { //Draw by style groups to minimize drawElements() calls. @@ -537,7 +538,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, sk * @param {ol.webgl.Context} context Context. * @param {Object} skippedFeaturesHash Ids of features to skip. */ -ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { +_ol_render_webgl_LineStringReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart; featureIndex = this.startIndices.length - 2; end = start = this.startIndices[featureIndex + 1]; @@ -550,7 +551,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, co this.startIndices[featureIndex] >= groupStart) { featureStart = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid]) { if (start !== end) { @@ -574,7 +575,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, co /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_LineStringReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex; featureIndex = this.startIndices.length - 2; @@ -588,11 +589,11 @@ ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = func this.startIndices[featureIndex] >= groupStart) { start = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid] === undefined && feature.getGeometry() && - (opt_hitExtent === undefined || ol.extent.intersects( + (opt_hitExtent === undefined || _ol_extent_.intersects( /** @type {Array} */ (opt_hitExtent), feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); @@ -620,7 +621,7 @@ ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = func * @param {number} lineWidth Line width. * @param {number} miterLimit Miter limit. */ -ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) { +_ol_render_webgl_LineStringReplay_.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) { gl.uniform4fv(this.defaultLocations_.u_color, color); gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth); gl.uniform1f(this.defaultLocations_.u_miterLimit, miterLimit); @@ -630,35 +631,35 @@ ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color, /** * @inheritDoc */ -ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_webgl_LineStringReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { var strokeStyleLineCap = strokeStyle.getLineCap(); this.state_.lineCap = strokeStyleLineCap !== undefined ? - strokeStyleLineCap : ol.render.webgl.defaultLineCap; + strokeStyleLineCap : _ol_render_webgl_.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); this.state_.lineDash = strokeStyleLineDash ? - strokeStyleLineDash : ol.render.webgl.defaultLineDash; + strokeStyleLineDash : _ol_render_webgl_.defaultLineDash; var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset(); this.state_.lineDashOffset = strokeStyleLineDashOffset ? - strokeStyleLineDashOffset : ol.render.webgl.defaultLineDashOffset; + strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset; var strokeStyleLineJoin = strokeStyle.getLineJoin(); this.state_.lineJoin = strokeStyleLineJoin !== undefined ? - strokeStyleLineJoin : ol.render.webgl.defaultLineJoin; + strokeStyleLineJoin : _ol_render_webgl_.defaultLineJoin; var strokeStyleColor = strokeStyle.getColor(); if (!(strokeStyleColor instanceof CanvasGradient) && !(strokeStyleColor instanceof CanvasPattern)) { - strokeStyleColor = ol.color.asArray(strokeStyleColor).map(function(c, i) { + strokeStyleColor = _ol_color_.asArray(strokeStyleColor).map(function(c, i) { return i != 3 ? c / 255 : c; - }) || ol.render.webgl.defaultStrokeStyle; + }) || _ol_render_webgl_.defaultStrokeStyle; } else { - strokeStyleColor = ol.render.webgl.defaultStrokeStyle; + strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle; } var strokeStyleWidth = strokeStyle.getWidth(); strokeStyleWidth = strokeStyleWidth !== undefined ? - strokeStyleWidth : ol.render.webgl.defaultLineWidth; + strokeStyleWidth : _ol_render_webgl_.defaultLineWidth; var strokeStyleMiterLimit = strokeStyle.getMiterLimit(); strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ? - strokeStyleMiterLimit : ol.render.webgl.defaultMiterLimit; - if (!this.state_.strokeColor || !ol.array.equals(this.state_.strokeColor, strokeStyleColor) || + strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit; + if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) || this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) { this.state_.changed = true; this.state_.strokeColor = strokeStyleColor; @@ -672,7 +673,7 @@ ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillSty * @enum {number} * @private */ -ol.render.webgl.LineStringReplay.Instruction_ = { +_ol_render_webgl_LineStringReplay_.Instruction_ = { ROUND: 2, BEGIN_LINE: 3, END_LINE: 5, @@ -683,3 +684,4 @@ ol.render.webgl.LineStringReplay.Instruction_ = { MITER_BOTTOM: 19, MITER_TOP: 23 }; +export default _ol_render_webgl_LineStringReplay_; diff --git a/src/ol/render/webgl/PolygonReplay.js b/src/ol/render/webgl/PolygonReplay.js index 0899b87cd5..bde72d54c6 100644 --- a/src/ol/render/webgl/PolygonReplay.js +++ b/src/ol/render/webgl/PolygonReplay.js @@ -1,24 +1,24 @@ -goog.provide('ol.render.webgl.PolygonReplay'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.color'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.geom.flat.contains'); -goog.require('ol.geom.flat.orient'); -goog.require('ol.geom.flat.transform'); -goog.require('ol.render.webgl.polygonreplay.defaultshader'); -goog.require('ol.render.webgl.polygonreplay.defaultshader.Locations'); -goog.require('ol.render.webgl.LineStringReplay'); -goog.require('ol.render.webgl.Replay'); -goog.require('ol.render.webgl'); -goog.require('ol.style.Stroke'); -goog.require('ol.structs.LinkedList'); -goog.require('ol.structs.RBush'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Buffer'); - +/** + * @module ol/render/webgl/PolygonReplay + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_color_ from '../../color.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_geom_flat_contains_ from '../../geom/flat/contains.js'; +import _ol_geom_flat_orient_ from '../../geom/flat/orient.js'; +import _ol_geom_flat_transform_ from '../../geom/flat/transform.js'; +import _ol_render_webgl_polygonreplay_defaultshader_ from '../webgl/polygonreplay/defaultshader.js'; +import _ol_render_webgl_polygonreplay_defaultshader_Locations_ from '../webgl/polygonreplay/defaultshader/Locations.js'; +import _ol_render_webgl_LineStringReplay_ from '../webgl/LineStringReplay.js'; +import _ol_render_webgl_Replay_ from '../webgl/Replay.js'; +import _ol_render_webgl_ from '../webgl.js'; +import _ol_style_Stroke_ from '../../style/Stroke.js'; +import _ol_structs_LinkedList_ from '../../structs/LinkedList.js'; +import _ol_structs_RBush_ from '../../structs/RBush.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -27,10 +27,10 @@ goog.require('ol.webgl.Buffer'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) { - ol.render.webgl.Replay.call(this, tolerance, maxExtent); +var _ol_render_webgl_PolygonReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_Replay_.call(this, tolerance, maxExtent); - this.lineStringReplay = new ol.render.webgl.LineStringReplay( + this.lineStringReplay = new _ol_render_webgl_LineStringReplay_( tolerance, maxExtent); /** @@ -62,7 +62,8 @@ ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) { }; }; -ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay); + +_ol_.inherits(_ol_render_webgl_PolygonReplay_, _ol_render_webgl_Replay_); /** @@ -72,11 +73,11 @@ ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay); * @param {number} stride Stride. * @private */ -ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function( +_ol_render_webgl_PolygonReplay_.prototype.drawCoordinates_ = function( flatCoordinates, holeFlatCoordinates, stride) { // Triangulate the polygon - var outerRing = new ol.structs.LinkedList(); - var rtree = new ol.structs.RBush(); + var outerRing = new _ol_structs_LinkedList_(); + var rtree = new _ol_structs_RBush_(); // Initialize the outer ring this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true); var maxCoords = this.getMaxCoords_(outerRing); @@ -87,9 +88,9 @@ ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function( var holeLists = []; for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) { var holeList = { - list: new ol.structs.LinkedList(), + list: new _ol_structs_LinkedList_(), maxCoords: undefined, - rtree: new ol.structs.RBush() + rtree: new _ol_structs_RBush_() }; holeLists.push(holeList); this.processFlatCoordinates_(holeFlatCoordinates[i], @@ -137,9 +138,9 @@ ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function( * @param {ol.structs.RBush} rtree R-Tree of the polygon. * @param {boolean} clockwise Coordinate order should be clockwise. */ -ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function( +_ol_render_webgl_PolygonReplay_.prototype.processFlatCoordinates_ = function( flatCoordinates, stride, list, rtree, clockwise) { - var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, + var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, 0, flatCoordinates.length, stride); var i, ii; var n = this.vertices.length / 2; @@ -189,7 +190,7 @@ ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function( * @param {ol.structs.LinkedList} list Polygons ring. * @return {Array.} Max X coordinates. */ -ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) { +_ol_render_webgl_PolygonReplay_.prototype.getMaxCoords_ = function(list) { var start = list.firstItem(); var seg = start; var maxCoords = [seg.p0.x, seg.p0.y]; @@ -213,15 +214,15 @@ ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) { * @param {boolean} ccw The orientation of the polygon is counter-clockwise. * @return {boolean} There were reclassified points. */ -ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) { +_ol_render_webgl_PolygonReplay_.prototype.classifyPoints_ = function(list, rtree, ccw) { var start = list.firstItem(); var s0 = start; var s1 = list.nextItem(); var pointsReclassified = false; do { - var reflex = ccw ? ol.render.webgl.triangleIsCounterClockwise(s1.p1.x, + var reflex = ccw ? _ol_render_webgl_.triangleIsCounterClockwise(s1.p1.x, s1.p1.y, s0.p1.x, s0.p1.y, s0.p0.x, s0.p0.y) : - ol.render.webgl.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x, + _ol_render_webgl_.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x, s0.p1.y, s1.p1.x, s1.p1.y); if (reflex === undefined) { this.removeItem_(s0, s1, list, rtree); @@ -251,7 +252,7 @@ ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree, * @param {ol.structs.RBush} rtree R-Tree of the polygon. * @return {boolean} Bridging was successful. */ -ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX, +_ol_render_webgl_PolygonReplay_.prototype.bridgeHole_ = function(hole, holeMaxX, list, listMaxX, rtree) { var seg = hole.firstItem(); while (seg.p1.x !== holeMaxX) { @@ -272,7 +273,7 @@ ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX, var intersection = this.calculateIntersection_(p1, p2, currSeg.p0, currSeg.p1, true); var dist = Math.abs(p1.x - intersection[0]); - if (dist < minDist && ol.render.webgl.triangleIsCounterClockwise(p1.x, p1.y, + if (dist < minDist && _ol_render_webgl_.triangleIsCounterClockwise(p1.x, p1.y, currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) { minDist = dist; p5 = {x: intersection[0], y: intersection[1], i: -1}; @@ -324,7 +325,7 @@ ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX, * @param {ol.structs.LinkedList} list Linked list of the polygon. * @param {ol.structs.RBush} rtree R-Tree of the polygon. */ -ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) { +_ol_render_webgl_PolygonReplay_.prototype.triangulate_ = function(list, rtree) { var ccw = false; var simple = this.isSimple_(list, rtree); @@ -377,7 +378,7 @@ ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) { * @param {boolean} ccw Orientation of the polygon is counter-clockwise. * @return {boolean} There were processed ears. */ -ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) { +_ol_render_webgl_PolygonReplay_.prototype.clipEars_ = function(list, rtree, simple, ccw) { var numIndices = this.indices.length; var start = list.firstItem(); var s0 = list.getPrevItem(); @@ -403,7 +404,7 @@ ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple variableCriterion) { //The diagonal is completely inside the polygon if (simple || p0.reflex === false || p2.reflex === false || - ol.geom.flat.orient.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x, + _ol_geom_flat_orient_.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, s3.p1.x, s3.p1.y], 0, 10, 2) === !ccw) { //The diagonal is persumably valid, we have an ear this.indices[numIndices++] = p0.i; @@ -435,7 +436,7 @@ ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple * @param {boolean=} opt_touch Resolve touching segments. * @return {boolean} There were resolved intersections. */ -ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function( +_ol_render_webgl_PolygonReplay_.prototype.resolveSelfIntersections_ = function( list, rtree, opt_touch) { var start = list.firstItem(); list.nextItem(); @@ -503,7 +504,7 @@ ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function( * @param {ol.structs.RBush} rtree R-Tree of the polygon. * @return {boolean} The polygon is simple. */ -ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) { +_ol_render_webgl_PolygonReplay_.prototype.isSimple_ = function(list, rtree) { var start = list.firstItem(); var seg = start; do { @@ -521,7 +522,7 @@ ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) { * @param {ol.structs.LinkedList} list Linked list of the polygon. * @return {boolean} Orientation is clockwise. */ -ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) { +_ol_render_webgl_PolygonReplay_.prototype.isClockwise_ = function(list) { var length = list.getLength() * 2; var flatCoordinates = new Array(length); var start = list.firstItem(); @@ -532,7 +533,7 @@ ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) { flatCoordinates[i++] = seg.p0.y; seg = list.nextItem(); } while (seg !== start); - return ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, 0, length, 2); + return _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, 0, length, 2); }; @@ -541,7 +542,7 @@ ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) { * @param {ol.structs.LinkedList} list Linked list of the polygon. * @param {ol.structs.RBush} rtree R-Tree of the polygon. */ -ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) { +_ol_render_webgl_PolygonReplay_.prototype.splitPolygon_ = function(list, rtree) { var start = list.firstItem(); var s0 = start; do { @@ -552,8 +553,8 @@ ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) { var intersection = this.calculateIntersection_(s0.p0, s0.p1, s1.p0, s1.p1); var p = this.createPoint_(intersection[0], intersection[1], n); - var newPolygon = new ol.structs.LinkedList(); - var newRtree = new ol.structs.RBush(); + var newPolygon = new _ol_structs_LinkedList_(); + var newRtree = new _ol_structs_RBush_(); this.insertItem_(p, s0.p1, newPolygon, newRtree); s0.p1 = p; rtree.update([Math.min(s0.p0.x, p.x), Math.min(s0.p0.y, p.y), @@ -587,7 +588,7 @@ ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) { * @param {number} i Index. * @return {ol.WebglPolygonVertex} List item. */ -ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) { +_ol_render_webgl_PolygonReplay_.prototype.createPoint_ = function(x, y, i) { var numVertices = this.vertices.length; this.vertices[numVertices++] = x; this.vertices[numVertices++] = y; @@ -610,7 +611,7 @@ ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) { * @param {ol.structs.RBush=} opt_rtree Insert the segment into the R-Tree. * @return {ol.WebglPolygonSegment} segment. */ -ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) { +_ol_render_webgl_PolygonReplay_.prototype.insertItem_ = function(p0, p1, list, opt_rtree) { var seg = { p0: p0, p1: p1 @@ -631,7 +632,7 @@ ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt * @param {ol.structs.LinkedList} list Polygon ring. * @param {ol.structs.RBush} rtree R-Tree of the polygon. */ -ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtree) { +_ol_render_webgl_PolygonReplay_.prototype.removeItem_ = function(s0, s1, list, rtree) { if (list.getCurrItem() === s1) { list.removeItem(); s0.p1 = s1.p1; @@ -651,7 +652,7 @@ ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtr * @param {boolean=} opt_reflex Only include reflex points. * @return {Array.} Points in the triangle. */ -ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, +_ol_render_webgl_PolygonReplay_.prototype.getPointsInTriangle_ = function(p0, p1, p2, rtree, opt_reflex) { var i, ii, j, p; var result = []; @@ -664,7 +665,7 @@ ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, if (typeof p === 'object' && (!opt_reflex || p.reflex)) { if ((p.x !== p0.x || p.y !== p0.y) && (p.x !== p1.x || p.y !== p1.y) && (p.x !== p2.x || p.y !== p2.y) && result.indexOf(p) === -1 && - ol.geom.flat.contains.linearRingContainsXY([p0.x, p0.y, p1.x, p1.y, + _ol_geom_flat_contains_.linearRingContainsXY([p0.x, p0.y, p1.x, p1.y, p2.x, p2.y], 0, 6, 2, p.x, p.y)) { result.push(p); } @@ -682,7 +683,7 @@ ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, * @param {boolean=} opt_touch Touching segments should be considered an intersection. * @return {Array.} Intersecting segments. */ -ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) { +_ol_render_webgl_PolygonReplay_.prototype.getIntersections_ = function(segment, rtree, opt_touch) { var p0 = segment.p0; var p1 = segment.p1; var segmentsInExtent = rtree.getInExtent([Math.min(p0.x, p1.x), @@ -712,14 +713,14 @@ ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rt * @param {boolean=} opt_touch Touching segments should be considered an intersection. * @return {Array.|undefined} Intersection coordinates. */ -ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0, +_ol_render_webgl_PolygonReplay_.prototype.calculateIntersection_ = function(p0, p1, p2, p3, opt_touch) { var denom = (p3.y - p2.y) * (p1.x - p0.x) - (p3.x - p2.x) * (p1.y - p0.y); if (denom !== 0) { var ua = ((p3.x - p2.x) * (p0.y - p2.y) - (p3.y - p2.y) * (p0.x - p2.x)) / denom; var ub = ((p1.x - p0.x) * (p0.y - p2.y) - (p1.y - p0.y) * (p0.x - p2.x)) / denom; - if ((!opt_touch && ua > ol.render.webgl.EPSILON && ua < 1 - ol.render.webgl.EPSILON && - ub > ol.render.webgl.EPSILON && ub < 1 - ol.render.webgl.EPSILON) || (opt_touch && + if ((!opt_touch && ua > _ol_render_webgl_.EPSILON && ua < 1 - _ol_render_webgl_.EPSILON && + ub > _ol_render_webgl_.EPSILON && ub < 1 - _ol_render_webgl_.EPSILON) || (opt_touch && ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) { return [p0.x + ua * (p1.x - p0.x), p0.y + ua * (p1.y - p0.y)]; } @@ -737,7 +738,7 @@ ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0, * @param {ol.WebglPolygonVertex} p4 Point after the end of the diagonal. * @return {boolean} Diagonal is inside the polygon. */ -ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) { +_ol_render_webgl_PolygonReplay_.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) { if (p1.reflex === undefined || p3.reflex === undefined) { return false; } @@ -754,7 +755,7 @@ ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) { +_ol_render_webgl_PolygonReplay_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) { var endss = multiPolygonGeometry.getEndss(); var stride = multiPolygonGeometry.getStride(); var currIndex = this.indices.length; @@ -765,14 +766,14 @@ ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygon for (i = 0, ii = endss.length; i < ii; ++i) { var ends = endss[i]; if (ends.length > 0) { - var outerRing = ol.geom.flat.transform.translate(flatCoordinates, start, ends[0], + var outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, start, ends[0], stride, -this.origin[0], -this.origin[1]); if (outerRing.length) { var holes = []; var holeFlatCoords; for (j = 1, jj = ends.length; j < jj; ++j) { if (ends[j] !== ends[j - 1]) { - holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[j - 1], + holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[j - 1], ends[j], stride, -this.origin[0], -this.origin[1]); holes.push(holeFlatCoords); } @@ -800,19 +801,19 @@ ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygon /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) { +_ol_render_webgl_PolygonReplay_.prototype.drawPolygon = function(polygonGeometry, feature) { var ends = polygonGeometry.getEnds(); var stride = polygonGeometry.getStride(); if (ends.length > 0) { var flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number); - var outerRing = ol.geom.flat.transform.translate(flatCoordinates, 0, ends[0], + var outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, 0, ends[0], stride, -this.origin[0], -this.origin[1]); if (outerRing.length) { var holes = []; var i, ii, holeFlatCoords; for (i = 1, ii = ends.length; i < ii; ++i) { if (ends[i] !== ends[i - 1]) { - holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1], + holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1], ends[i], stride, -this.origin[0], -this.origin[1]); holes.push(holeFlatCoords); } @@ -836,12 +837,12 @@ ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, /** * @inheritDoc **/ -ol.render.webgl.PolygonReplay.prototype.finish = function(context) { +_ol_render_webgl_PolygonReplay_.prototype.finish = function(context) { // create, bind, and populate the vertices buffer - this.verticesBuffer = new ol.webgl.Buffer(this.vertices); + this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices); // create, bind, and populate the indices buffer - this.indicesBuffer = new ol.webgl.Buffer(this.indices); + this.indicesBuffer = new _ol_webgl_Buffer_(this.indices); this.startIndices.push(this.indices.length); @@ -860,7 +861,7 @@ ol.render.webgl.PolygonReplay.prototype.finish = function(context) { /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(context) { +_ol_render_webgl_PolygonReplay_.prototype.getDeleteResourcesFunction = function(context) { var verticesBuffer = this.verticesBuffer; var indicesBuffer = this.indicesBuffer; var lineDeleter = this.lineStringReplay.getDeleteResourcesFunction(context); @@ -875,17 +876,17 @@ ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(co /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) { +_ol_render_webgl_PolygonReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) { // get the program var fragmentShader, vertexShader; - fragmentShader = ol.render.webgl.polygonreplay.defaultshader.fragment; - vertexShader = ol.render.webgl.polygonreplay.defaultshader.vertex; + fragmentShader = _ol_render_webgl_polygonreplay_defaultshader_.fragment; + vertexShader = _ol_render_webgl_polygonreplay_defaultshader_.vertex; var program = context.getProgram(fragmentShader, vertexShader); // get the locations var locations; if (!this.defaultLocations_) { - locations = new ol.render.webgl.polygonreplay.defaultshader.Locations(gl, program); + locations = new _ol_render_webgl_polygonreplay_defaultshader_Locations_(gl, program); this.defaultLocations_ = locations; } else { locations = this.defaultLocations_; @@ -895,7 +896,7 @@ ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, siz // enable the vertex attrib arrays gl.enableVertexAttribArray(locations.a_position); - gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT, false, 8, 0); return locations; @@ -905,7 +906,7 @@ ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, siz /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations) { +_ol_render_webgl_PolygonReplay_.prototype.shutDownProgram = function(gl, locations) { gl.disableVertexAttribArray(locations.a_position); }; @@ -913,7 +914,7 @@ ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { +_ol_render_webgl_PolygonReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { //Save GL parameters. var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC)); var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK)); @@ -924,7 +925,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skipp gl.depthFunc(gl.NOTEQUAL); } - if (!ol.obj.isEmpty(skippedFeaturesHash)) { + if (!_ol_obj_.isEmpty(skippedFeaturesHash)) { this.drawReplaySkipping_(gl, context, skippedFeaturesHash); } else { //Draw by style groups to minimize drawElements() calls. @@ -951,7 +952,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skipp /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_PolygonReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex; featureIndex = this.startIndices.length - 2; @@ -965,11 +966,11 @@ ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = functio this.startIndices[featureIndex] >= groupStart) { start = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid] === undefined && feature.getGeometry() && - (opt_hitExtent === undefined || ol.extent.intersects( + (opt_hitExtent === undefined || _ol_extent_.intersects( /** @type {Array} */ (opt_hitExtent), feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); @@ -996,7 +997,7 @@ ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = functio * @param {ol.webgl.Context} context Context. * @param {Object} skippedFeaturesHash Ids of features to skip. */ -ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { +_ol_render_webgl_PolygonReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) { var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart; featureIndex = this.startIndices.length - 2; end = start = this.startIndices[featureIndex + 1]; @@ -1009,7 +1010,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte this.startIndices[featureIndex] >= groupStart) { featureStart = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid]) { if (start !== end) { @@ -1035,7 +1036,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte * @param {WebGLRenderingContext} gl gl. * @param {Array.} color Color. */ -ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) { +_ol_render_webgl_PolygonReplay_.prototype.setFillStyle_ = function(gl, color) { gl.uniform4fv(this.defaultLocations_.u_color, color); }; @@ -1043,17 +1044,17 @@ ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) { /** * @inheritDoc */ -ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { +_ol_render_webgl_PolygonReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0]; if (!(fillStyleColor instanceof CanvasGradient) && !(fillStyleColor instanceof CanvasPattern)) { - fillStyleColor = ol.color.asArray(fillStyleColor).map(function(c, i) { + fillStyleColor = _ol_color_.asArray(fillStyleColor).map(function(c, i) { return i != 3 ? c / 255 : c; - }) || ol.render.webgl.defaultFillStyle; + }) || _ol_render_webgl_.defaultFillStyle; } else { - fillStyleColor = ol.render.webgl.defaultFillStyle; + fillStyleColor = _ol_render_webgl_.defaultFillStyle; } - if (!this.state_.fillColor || !ol.array.equals(fillStyleColor, this.state_.fillColor)) { + if (!this.state_.fillColor || !_ol_array_.equals(fillStyleColor, this.state_.fillColor)) { this.state_.fillColor = fillStyleColor; this.state_.changed = true; this.styles_.push(fillStyleColor); @@ -1062,10 +1063,11 @@ ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, if (strokeStyle) { this.lineStringReplay.setFillStrokeStyle(null, strokeStyle); } else { - var nullStrokeStyle = new ol.style.Stroke({ + var nullStrokeStyle = new _ol_style_Stroke_({ color: [0, 0, 0, 0], lineWidth: 0 }); this.lineStringReplay.setFillStrokeStyle(null, nullStrokeStyle); } }; +export default _ol_render_webgl_PolygonReplay_; diff --git a/src/ol/render/webgl/Replay.js b/src/ol/render/webgl/Replay.js index 21b728388e..06994ac66c 100644 --- a/src/ol/render/webgl/Replay.js +++ b/src/ol/render/webgl/Replay.js @@ -1,12 +1,12 @@ -goog.provide('ol.render.webgl.Replay'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.render.VectorContext'); -goog.require('ol.transform'); -goog.require('ol.vec.Mat4'); -goog.require('ol.webgl'); - +/** + * @module ol/render/webgl/Replay + */ +import _ol_ from '../../index.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_render_VectorContext_ from '../VectorContext.js'; +import _ol_transform_ from '../../transform.js'; +import _ol_vec_Mat4_ from '../../vec/Mat4.js'; +import _ol_webgl_ from '../../webgl.js'; /** * @constructor @@ -16,8 +16,8 @@ goog.require('ol.webgl'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.Replay = function(tolerance, maxExtent) { - ol.render.VectorContext.call(this); +var _ol_render_webgl_Replay_ = function(tolerance, maxExtent) { + _ol_render_VectorContext_.call(this); /** * @protected @@ -40,31 +40,31 @@ ol.render.webgl.Replay = function(tolerance, maxExtent) { * @protected * @type {ol.Coordinate} */ - this.origin = ol.extent.getCenter(maxExtent); + this.origin = _ol_extent_.getCenter(maxExtent); /** * @private * @type {ol.Transform} */ - this.projectionMatrix_ = ol.transform.create(); + this.projectionMatrix_ = _ol_transform_.create(); /** * @private * @type {ol.Transform} */ - this.offsetRotateMatrix_ = ol.transform.create(); + this.offsetRotateMatrix_ = _ol_transform_.create(); /** * @private * @type {ol.Transform} */ - this.offsetScaleMatrix_ = ol.transform.create(); + this.offsetScaleMatrix_ = _ol_transform_.create(); /** * @private * @type {Array.} */ - this.tmpMat4_ = ol.vec.Mat4.create(); + this.tmpMat4_ = _ol_vec_Mat4_.create(); /** * @protected @@ -112,7 +112,8 @@ ol.render.webgl.Replay = function(tolerance, maxExtent) { this.lineStringReplay = undefined; }; -ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext); + +_ol_.inherits(_ol_render_webgl_Replay_, _ol_render_VectorContext_); /** @@ -120,14 +121,14 @@ ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext); * @param {ol.webgl.Context} context WebGL context. * @return {function()} Delete resources function. */ -ol.render.webgl.Replay.prototype.getDeleteResourcesFunction = function(context) {}; +_ol_render_webgl_Replay_.prototype.getDeleteResourcesFunction = function(context) {}; /** * @abstract * @param {ol.webgl.Context} context Context. */ -ol.render.webgl.Replay.prototype.finish = function(context) {}; +_ol_render_webgl_Replay_.prototype.finish = function(context) {}; /** @@ -142,7 +143,7 @@ ol.render.webgl.Replay.prototype.finish = function(context) {}; ol.render.webgl.polygonreplay.defaultshader.Locations| ol.render.webgl.texturereplay.defaultshader.Locations} Locations. */ -ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {}; +_ol_render_webgl_Replay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {}; /** @@ -154,7 +155,7 @@ ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixe ol.render.webgl.polygonreplay.defaultshader.Locations| ol.render.webgl.texturereplay.defaultshader.Locations} locations Locations. */ -ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {}; +_ol_render_webgl_Replay_.prototype.shutDownProgram = function(gl, locations) {}; /** @@ -166,7 +167,7 @@ ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {}; * to skip. * @param {boolean} hitDetection Hit detection mode. */ -ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {}; +_ol_render_webgl_Replay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {}; /** @@ -182,7 +183,7 @@ ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeatu * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {}; +_ol_render_webgl_Replay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {}; /** @@ -198,7 +199,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, c * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_Replay_.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) { if (!oneByOne) { // draw all hit-detection features in "once" (by texture group) @@ -222,7 +223,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context, * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_Replay_.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash, featureCallback) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); this.drawReplay(gl, context, skippedFeaturesHash, true); @@ -253,7 +254,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, contex * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.Replay.prototype.replay = function(context, +_ol_render_webgl_Replay_.prototype.replay = function(context, center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) { @@ -286,32 +287,32 @@ ol.render.webgl.Replay.prototype.replay = function(context, gl.stencilFunc(gl.NOTEQUAL, 1, 255); } - context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.verticesBuffer); + context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.verticesBuffer); - context.bindBuffer(ol.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); + context.bindBuffer(_ol_webgl_.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); var locations = this.setUpProgram(gl, context, size, pixelRatio); // set the "uniform" values - var projectionMatrix = ol.transform.reset(this.projectionMatrix_); - ol.transform.scale(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1])); - ol.transform.rotate(projectionMatrix, -rotation); - ol.transform.translate(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1])); + var projectionMatrix = _ol_transform_.reset(this.projectionMatrix_); + _ol_transform_.scale(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1])); + _ol_transform_.rotate(projectionMatrix, -rotation); + _ol_transform_.translate(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1])); - var offsetScaleMatrix = ol.transform.reset(this.offsetScaleMatrix_); - ol.transform.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]); + var offsetScaleMatrix = _ol_transform_.reset(this.offsetScaleMatrix_); + _ol_transform_.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]); - var offsetRotateMatrix = ol.transform.reset(this.offsetRotateMatrix_); + var offsetRotateMatrix = _ol_transform_.reset(this.offsetRotateMatrix_); if (rotation !== 0) { - ol.transform.rotate(offsetRotateMatrix, -rotation); + _ol_transform_.rotate(offsetRotateMatrix, -rotation); } gl.uniformMatrix4fv(locations.u_projectionMatrix, false, - ol.vec.Mat4.fromTransform(this.tmpMat4_, projectionMatrix)); + _ol_vec_Mat4_.fromTransform(this.tmpMat4_, projectionMatrix)); gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false, - ol.vec.Mat4.fromTransform(this.tmpMat4_, offsetScaleMatrix)); + _ol_vec_Mat4_.fromTransform(this.tmpMat4_, offsetScaleMatrix)); gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false, - ol.vec.Mat4.fromTransform(this.tmpMat4_, offsetRotateMatrix)); + _ol_vec_Mat4_.fromTransform(this.tmpMat4_, offsetRotateMatrix)); gl.uniform1f(locations.u_opacity, opacity); // draw! @@ -349,13 +350,14 @@ ol.render.webgl.Replay.prototype.replay = function(context, * @param {number} start Start index. * @param {number} end End index. */ -ol.render.webgl.Replay.prototype.drawElements = function( +_ol_render_webgl_Replay_.prototype.drawElements = function( gl, context, start, end) { var elementType = context.hasOESElementIndexUint ? - ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT; + _ol_webgl_.UNSIGNED_INT : _ol_webgl_.UNSIGNED_SHORT; var elementSize = context.hasOESElementIndexUint ? 4 : 2; var numItems = end - start; var offsetInBytes = start * elementSize; - gl.drawElements(ol.webgl.TRIANGLES, numItems, elementType, offsetInBytes); + gl.drawElements(_ol_webgl_.TRIANGLES, numItems, elementType, offsetInBytes); }; +export default _ol_render_webgl_Replay_; diff --git a/src/ol/render/webgl/ReplayGroup.js b/src/ol/render/webgl/ReplayGroup.js index 0d29d5dcb1..71384bbc34 100644 --- a/src/ol/render/webgl/ReplayGroup.js +++ b/src/ol/render/webgl/ReplayGroup.js @@ -1,17 +1,17 @@ -goog.provide('ol.render.webgl.ReplayGroup'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.render.replay'); -goog.require('ol.render.ReplayGroup'); -goog.require('ol.render.webgl.CircleReplay'); -goog.require('ol.render.webgl.ImageReplay'); -goog.require('ol.render.webgl.LineStringReplay'); -goog.require('ol.render.webgl.PolygonReplay'); -goog.require('ol.render.webgl.TextReplay'); - +/** + * @module ol/render/webgl/ReplayGroup + */ +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_render_replay_ from '../replay.js'; +import _ol_render_ReplayGroup_ from '../ReplayGroup.js'; +import _ol_render_webgl_CircleReplay_ from '../webgl/CircleReplay.js'; +import _ol_render_webgl_ImageReplay_ from '../webgl/ImageReplay.js'; +import _ol_render_webgl_LineStringReplay_ from '../webgl/LineStringReplay.js'; +import _ol_render_webgl_PolygonReplay_ from '../webgl/PolygonReplay.js'; +import _ol_render_webgl_TextReplay_ from '../webgl/TextReplay.js'; /** * @constructor @@ -21,8 +21,8 @@ goog.require('ol.render.webgl.TextReplay'); * @param {number=} opt_renderBuffer Render buffer. * @struct */ -ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) { - ol.render.ReplayGroup.call(this); +var _ol_render_webgl_ReplayGroup_ = function(tolerance, maxExtent, opt_renderBuffer) { + _ol_render_ReplayGroup_.call(this); /** * @type {ol.Extent} @@ -50,21 +50,22 @@ ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) { this.replaysByZIndex_ = {}; }; -ol.inherits(ol.render.webgl.ReplayGroup, ol.render.ReplayGroup); + +_ol_.inherits(_ol_render_webgl_ReplayGroup_, _ol_render_ReplayGroup_); /** * @param {ol.style.Style} style Style. * @param {boolean} group Group with previous replay. */ -ol.render.webgl.ReplayGroup.prototype.addDeclutter = function(style, group) {}; +_ol_render_webgl_ReplayGroup_.prototype.addDeclutter = function(style, group) {}; /** * @param {ol.webgl.Context} context WebGL context. * @return {function()} Delete resources function. */ -ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(context) { +_ol_render_webgl_ReplayGroup_.prototype.getDeleteResourcesFunction = function(context) { var functions = []; var zKey; for (zKey in this.replaysByZIndex_) { @@ -89,7 +90,7 @@ ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(cont /** * @param {ol.webgl.Context} context Context. */ -ol.render.webgl.ReplayGroup.prototype.finish = function(context) { +_ol_render_webgl_ReplayGroup_.prototype.finish = function(context) { var zKey; for (zKey in this.replaysByZIndex_) { var replays = this.replaysByZIndex_[zKey]; @@ -104,7 +105,7 @@ ol.render.webgl.ReplayGroup.prototype.finish = function(context) { /** * @inheritDoc */ -ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { +_ol_render_webgl_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) { var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0'; var replays = this.replaysByZIndex_[zIndexKey]; if (replays === undefined) { @@ -116,7 +117,7 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { /** * @type {Function} */ - var Constructor = ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_[replayType]; + var Constructor = _ol_render_webgl_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType]; replay = new Constructor(this.tolerance_, this.maxExtent_); replays[replayType] = replay; } @@ -127,8 +128,8 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) { /** * @inheritDoc */ -ol.render.webgl.ReplayGroup.prototype.isEmpty = function() { - return ol.obj.isEmpty(this.replaysByZIndex_); +_ol_render_webgl_ReplayGroup_.prototype.isEmpty = function() { + return _ol_obj_.isEmpty(this.replaysByZIndex_); }; @@ -143,18 +144,18 @@ ol.render.webgl.ReplayGroup.prototype.isEmpty = function() { * @param {Object.} skippedFeaturesHash Ids of features * to skip. */ -ol.render.webgl.ReplayGroup.prototype.replay = function(context, +_ol_render_webgl_ReplayGroup_.prototype.replay = function(context, center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash) { /** @type {Array.} */ var zs = Object.keys(this.replaysByZIndex_).map(Number); - zs.sort(ol.array.numberSafeCompareFunction); + zs.sort(_ol_array_.numberSafeCompareFunction); var i, ii, j, jj, replays, replay; for (i = 0, ii = zs.length; i < ii; ++i) { replays = this.replaysByZIndex_[zs[i].toString()]; - for (j = 0, jj = ol.render.replay.ORDER.length; j < jj; ++j) { - replay = replays[ol.render.replay.ORDER[j]]; + for (j = 0, jj = _ol_render_replay_.ORDER.length; j < jj; ++j) { + replay = replays[_ol_render_replay_.ORDER[j]]; if (replay !== undefined) { replay.replay(context, center, resolution, rotation, size, pixelRatio, @@ -184,7 +185,7 @@ ol.render.webgl.ReplayGroup.prototype.replay = function(context, * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, +_ol_render_webgl_ReplayGroup_.prototype.replayHitDetection_ = function(context, center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) { /** @type {Array.} */ @@ -196,8 +197,8 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, var i, ii, j, replays, replay, result; for (i = 0, ii = zs.length; i < ii; ++i) { replays = this.replaysByZIndex_[zs[i].toString()]; - for (j = ol.render.replay.ORDER.length - 1; j >= 0; --j) { - replay = replays[ol.render.replay.ORDER[j]]; + for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) { + replay = replays[_ol_render_replay_.ORDER[j]]; if (replay !== undefined) { result = replay.replay(context, center, resolution, rotation, size, pixelRatio, opacity, @@ -227,7 +228,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context, * @return {T|undefined} Callback result. * @template T */ -ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( +_ol_render_webgl_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function( coordinate, context, center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash, callback) { @@ -243,13 +244,13 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( if (this.renderBuffer_ !== undefined) { // build an extent around the coordinate, so that only features that // intersect this extent are checked - hitExtent = ol.extent.buffer( - ol.extent.createOrUpdateFromCoordinate(coordinate), + hitExtent = _ol_extent_.buffer( + _ol_extent_.createOrUpdateFromCoordinate(coordinate), resolution * this.renderBuffer_); } return this.replayHitDetection_(context, - coordinate, resolution, rotation, ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_, + coordinate, resolution, rotation, _ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_, pixelRatio, opacity, skippedFeaturesHash, /** * @param {ol.Feature|ol.render.Feature} feature Feature. @@ -282,7 +283,7 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( * to skip. * @return {boolean} Is there a feature at the given coordinate? */ -ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function( +_ol_render_webgl_ReplayGroup_.prototype.hasFeatureAtCoordinate = function( coordinate, context, center, resolution, rotation, size, pixelRatio, opacity, skippedFeaturesHash) { var gl = context.getGL(); @@ -290,7 +291,7 @@ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function( gl.FRAMEBUFFER, context.getHitDetectionFramebuffer()); var hasFeature = this.replayHitDetection_(context, - coordinate, resolution, rotation, ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_, + coordinate, resolution, rotation, _ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_, pixelRatio, opacity, skippedFeaturesHash, /** * @param {ol.Feature|ol.render.Feature} feature Feature. @@ -310,7 +311,7 @@ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function( * @private * @type {Array.} */ -ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1]; +_ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_ = [1, 1]; /** * @const @@ -319,10 +320,11 @@ ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1]; * function(new: ol.render.webgl.Replay, number, * ol.Extent)>} */ -ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_ = { - 'Circle': ol.render.webgl.CircleReplay, - 'Image': ol.render.webgl.ImageReplay, - 'LineString': ol.render.webgl.LineStringReplay, - 'Polygon': ol.render.webgl.PolygonReplay, - 'Text': ol.render.webgl.TextReplay +_ol_render_webgl_ReplayGroup_.BATCH_CONSTRUCTORS_ = { + 'Circle': _ol_render_webgl_CircleReplay_, + 'Image': _ol_render_webgl_ImageReplay_, + 'LineString': _ol_render_webgl_LineStringReplay_, + 'Polygon': _ol_render_webgl_PolygonReplay_, + 'Text': _ol_render_webgl_TextReplay_ }; +export default _ol_render_webgl_ReplayGroup_; diff --git a/src/ol/render/webgl/TextReplay.js b/src/ol/render/webgl/TextReplay.js index 98a60bc4b8..a79573f2d9 100644 --- a/src/ol/render/webgl/TextReplay.js +++ b/src/ol/render/webgl/TextReplay.js @@ -1,16 +1,16 @@ -goog.provide('ol.render.webgl.TextReplay'); - -goog.require('ol'); -goog.require('ol.colorlike'); -goog.require('ol.dom'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.has'); -goog.require('ol.render.replay'); -goog.require('ol.render.webgl'); -goog.require('ol.render.webgl.TextureReplay'); -goog.require('ol.style.AtlasManager'); -goog.require('ol.webgl.Buffer'); - +/** + * @module ol/render/webgl/TextReplay + */ +import _ol_ from '../../index.js'; +import _ol_colorlike_ from '../../colorlike.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_geom_GeometryType_ from '../../geom/GeometryType.js'; +import _ol_has_ from '../../has.js'; +import _ol_render_replay_ from '../replay.js'; +import _ol_render_webgl_ from '../webgl.js'; +import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js'; +import _ol_style_AtlasManager_ from '../../style/AtlasManager.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -19,8 +19,8 @@ goog.require('ol.webgl.Buffer'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.TextReplay = function(tolerance, maxExtent) { - ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent); +var _ol_render_webgl_TextReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_TextureReplay_.call(this, tolerance, maxExtent); /** * @private @@ -38,7 +38,7 @@ ol.render.webgl.TextReplay = function(tolerance, maxExtent) { * @private * @type {HTMLCanvasElement} */ - this.measureCanvas_ = ol.dom.createCanvasContext2D(0, 0).canvas; + this.measureCanvas_ = _ol_dom_.createCanvasContext2D(0, 0).canvas; /** * @private @@ -113,39 +113,40 @@ ol.render.webgl.TextReplay = function(tolerance, maxExtent) { this.opacity = 1; }; -ol.inherits(ol.render.webgl.TextReplay, ol.render.webgl.TextureReplay); + +_ol_.inherits(_ol_render_webgl_TextReplay_, _ol_render_webgl_TextureReplay_); /** * @inheritDoc */ -ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) { +_ol_render_webgl_TextReplay_.prototype.drawText = function(geometry, feature) { if (this.text_) { var flatCoordinates = null; var offset = 0; var end = 2; var stride = 2; switch (geometry.getType()) { - case ol.geom.GeometryType.POINT: - case ol.geom.GeometryType.MULTI_POINT: + case _ol_geom_GeometryType_.POINT: + case _ol_geom_GeometryType_.MULTI_POINT: flatCoordinates = geometry.getFlatCoordinates(); end = flatCoordinates.length; stride = geometry.getStride(); break; - case ol.geom.GeometryType.CIRCLE: + case _ol_geom_GeometryType_.CIRCLE: flatCoordinates = /** @type {ol.geom.Circle} */ (geometry).getCenter(); break; - case ol.geom.GeometryType.LINE_STRING: + case _ol_geom_GeometryType_.LINE_STRING: flatCoordinates = /** @type {ol.geom.LineString} */ (geometry).getFlatMidpoint(); break; - case ol.geom.GeometryType.MULTI_LINE_STRING: + case _ol_geom_GeometryType_.MULTI_LINE_STRING: flatCoordinates = /** @type {ol.geom.MultiLineString} */ (geometry).getFlatMidpoints(); end = flatCoordinates.length; break; - case ol.geom.GeometryType.POLYGON: + case _ol_geom_GeometryType_.POLYGON: flatCoordinates = /** @type {ol.geom.Polygon} */ (geometry).getFlatInteriorPoint(); break; - case ol.geom.GeometryType.MULTI_POLYGON: + case _ol_geom_GeometryType_.MULTI_POLYGON: flatCoordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints(); end = flatCoordinates.length; break; @@ -188,7 +189,7 @@ ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) { this.images_.push(image); } else { currentImage = this.images_[this.images_.length - 1]; - if (ol.getUid(currentImage) != ol.getUid(image)) { + if (_ol_.getUid(currentImage) != _ol_.getUid(image)) { this.groupIndices.push(this.indices.length); this.images_.push(image); } @@ -208,7 +209,7 @@ ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) { * @param {Array.} lines Label to draw split to lines. * @return {Array.} Size of the label in pixels. */ -ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) { +_ol_render_webgl_TextReplay_.prototype.getTextSize_ = function(lines) { var self = this; var glyphAtlas = this.currAtlas_; var textHeight = lines.length * glyphAtlas.height; @@ -239,7 +240,7 @@ ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) { * @param {number} end End. * @param {number} stride Stride. */ -ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offset, +_ol_render_webgl_TextReplay_.prototype.drawText_ = function(flatCoordinates, offset, end, stride) { var i, ii; for (i = offset, ii = end; i < ii; i += stride) { @@ -252,7 +253,7 @@ ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offse * @private * @param {string} char Character. */ -ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) { +_ol_render_webgl_TextReplay_.prototype.addCharToAtlas_ = function(char) { if (char.length === 1) { var glyphAtlas = this.currAtlas_; var state = this.state_; @@ -272,7 +273,7 @@ ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) { ctx.miterLimit = /** @type {number} */ (state.miterLimit); ctx.textAlign = 'left'; ctx.textBaseline = 'top'; - if (ol.has.CANVAS_LINE_DASH && state.lineDash) { + if (_ol_has_.CANVAS_LINE_DASH && state.lineDash) { //FIXME: use pixelRatio ctx.setLineDash(state.lineDash); ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset); @@ -302,17 +303,17 @@ ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) { /** * @inheritDoc */ -ol.render.webgl.TextReplay.prototype.finish = function(context) { +_ol_render_webgl_TextReplay_.prototype.finish = function(context) { var gl = context.getGL(); this.groupIndices.push(this.indices.length); this.hitDetectionGroupIndices = this.groupIndices; // create, bind, and populate the vertices buffer - this.verticesBuffer = new ol.webgl.Buffer(this.vertices); + this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices); // create, bind, and populate the indices buffer - this.indicesBuffer = new ol.webgl.Buffer(this.indices); + this.indicesBuffer = new _ol_webgl_Buffer_(this.indices); // create textures /** @type {Object.} */ @@ -340,14 +341,14 @@ ol.render.webgl.TextReplay.prototype.finish = function(context) { this.images_ = null; this.atlases_ = {}; this.currAtlas_ = undefined; - ol.render.webgl.TextureReplay.prototype.finish.call(this, context); + _ol_render_webgl_TextureReplay_.prototype.finish.call(this, context); }; /** * @inheritDoc */ -ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) { +_ol_render_webgl_TextReplay_.prototype.setTextStyle = function(textStyle) { var state = this.state_; var textFillStyle = textStyle.getFill(); var textStrokeStyle = textStyle.getStroke(); @@ -358,33 +359,33 @@ ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) { state.fillColor = null; } else { var textFillStyleColor = textFillStyle.getColor(); - state.fillColor = ol.colorlike.asColorLike(textFillStyleColor ? - textFillStyleColor : ol.render.webgl.defaultFillStyle); + state.fillColor = _ol_colorlike_.asColorLike(textFillStyleColor ? + textFillStyleColor : _ol_render_webgl_.defaultFillStyle); } if (!textStrokeStyle) { state.strokeColor = null; state.lineWidth = 0; } else { var textStrokeStyleColor = textStrokeStyle.getColor(); - state.strokeColor = ol.colorlike.asColorLike(textStrokeStyleColor ? - textStrokeStyleColor : ol.render.webgl.defaultStrokeStyle); - state.lineWidth = textStrokeStyle.getWidth() || ol.render.webgl.defaultLineWidth; - state.lineCap = textStrokeStyle.getLineCap() || ol.render.webgl.defaultLineCap; - state.lineDashOffset = textStrokeStyle.getLineDashOffset() || ol.render.webgl.defaultLineDashOffset; - state.lineJoin = textStrokeStyle.getLineJoin() || ol.render.webgl.defaultLineJoin; - state.miterLimit = textStrokeStyle.getMiterLimit() || ol.render.webgl.defaultMiterLimit; + state.strokeColor = _ol_colorlike_.asColorLike(textStrokeStyleColor ? + textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle); + state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth; + state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap; + state.lineDashOffset = textStrokeStyle.getLineDashOffset() || _ol_render_webgl_.defaultLineDashOffset; + state.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_webgl_.defaultLineJoin; + state.miterLimit = textStrokeStyle.getMiterLimit() || _ol_render_webgl_.defaultMiterLimit; var lineDash = textStrokeStyle.getLineDash(); - state.lineDash = lineDash ? lineDash.slice() : ol.render.webgl.defaultLineDash; + state.lineDash = lineDash ? lineDash.slice() : _ol_render_webgl_.defaultLineDash; } - state.font = textStyle.getFont() || ol.render.webgl.defaultFont; + state.font = textStyle.getFont() || _ol_render_webgl_.defaultFont; state.scale = textStyle.getScale() || 1; this.text_ = /** @type {string} */ (textStyle.getText()); - var textAlign = ol.render.replay.TEXT_ALIGN[textStyle.getTextAlign()]; - var textBaseline = ol.render.replay.TEXT_ALIGN[textStyle.getTextBaseline()]; + var textAlign = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextAlign()]; + var textBaseline = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextBaseline()]; this.textAlign_ = textAlign === undefined ? - ol.render.webgl.defaultTextAlign : textAlign; + _ol_render_webgl_.defaultTextAlign : textAlign; this.textBaseline_ = textBaseline === undefined ? - ol.render.webgl.defaultTextBaseline : textBaseline; + _ol_render_webgl_.defaultTextBaseline : textBaseline; this.offsetX_ = textStyle.getOffsetX() || 0; this.offsetY_ = textStyle.getOffsetY() || 0; this.rotateWithView = !!textStyle.getRotateWithView(); @@ -400,7 +401,7 @@ ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) { * @param {Object} state Font attributes. * @return {ol.WebglGlyphAtlas} Glyph atlas. */ -ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) { +_ol_render_webgl_TextReplay_.prototype.getAtlas_ = function(state) { var params = []; var i; for (i in state) { @@ -420,7 +421,7 @@ ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) { state.lineWidth / 2) * state.scale); this.atlases_[hash] = { - atlas: new ol.style.AtlasManager({ + atlas: new _ol_style_AtlasManager_({ space: state.lineWidth + 1 }), width: {}, @@ -436,7 +437,7 @@ ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) { * @param {Array.} params Array of parameters. * @return {string} Hash string. */ -ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) { +_ol_render_webgl_TextReplay_.prototype.calculateHash_ = function(params) { //TODO: Create a more performant, reliable, general hash function. var i, ii; var hash = ''; @@ -450,7 +451,7 @@ ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) { /** * @inheritDoc */ -ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) { +_ol_render_webgl_TextReplay_.prototype.getTextures = function(opt_all) { return this.textures_; }; @@ -458,6 +459,7 @@ ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) { /** * @inheritDoc */ -ol.render.webgl.TextReplay.prototype.getHitDetectionTextures = function() { +_ol_render_webgl_TextReplay_.prototype.getHitDetectionTextures = function() { return this.textures_; }; +export default _ol_render_webgl_TextReplay_; diff --git a/src/ol/render/webgl/TextureReplay.js b/src/ol/render/webgl/TextureReplay.js index 6247095d1e..b7021fee9e 100644 --- a/src/ol/render/webgl/TextureReplay.js +++ b/src/ol/render/webgl/TextureReplay.js @@ -1,13 +1,14 @@ -goog.provide('ol.render.webgl.TextureReplay'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.render.webgl.texturereplay.defaultshader'); -goog.require('ol.render.webgl.texturereplay.defaultshader.Locations'); -goog.require('ol.render.webgl.Replay'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Context'); +/** + * @module ol/render/webgl/TextureReplay + */ +import _ol_ from '../../index.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_render_webgl_texturereplay_defaultshader_ from '../webgl/texturereplay/defaultshader.js'; +import _ol_render_webgl_texturereplay_defaultshader_Locations_ from '../webgl/texturereplay/defaultshader/Locations.js'; +import _ol_render_webgl_Replay_ from '../webgl/Replay.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Context_ from '../../webgl/Context.js'; /** * @constructor @@ -17,8 +18,8 @@ goog.require('ol.webgl.Context'); * @param {ol.Extent} maxExtent Max extent. * @struct */ -ol.render.webgl.TextureReplay = function(tolerance, maxExtent) { - ol.render.webgl.Replay.call(this, tolerance, maxExtent); +var _ol_render_webgl_TextureReplay_ = function(tolerance, maxExtent) { + _ol_render_webgl_Replay_.call(this, tolerance, maxExtent); /** * @type {number|undefined} @@ -110,13 +111,14 @@ ol.render.webgl.TextureReplay = function(tolerance, maxExtent) { */ this.width = undefined; }; -ol.inherits(ol.render.webgl.TextureReplay, ol.render.webgl.Replay); + +_ol_.inherits(_ol_render_webgl_TextureReplay_, _ol_render_webgl_Replay_); /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(context) { +_ol_render_webgl_TextureReplay_.prototype.getDeleteResourcesFunction = function(context) { var verticesBuffer = this.verticesBuffer; var indicesBuffer = this.indicesBuffer; var textures = this.getTextures(true); @@ -142,7 +144,7 @@ ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(co * @return {number} My end. * @protected */ -ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) { +_ol_render_webgl_TextureReplay_.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) { var anchorX = /** @type {number} */ (this.anchorX); var anchorY = /** @type {number} */ (this.anchorY); var height = /** @type {number} */ (this.height); @@ -245,18 +247,18 @@ ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinat * @param {Object.} texturePerImage Texture cache. * @param {WebGLRenderingContext} gl Gl. */ -ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) { +_ol_render_webgl_TextureReplay_.prototype.createTextures = function(textures, images, texturePerImage, gl) { var texture, image, uid, i; var ii = images.length; for (i = 0; i < ii; ++i) { image = images[i]; - uid = ol.getUid(image).toString(); + uid = _ol_.getUid(image).toString(); if (uid in texturePerImage) { texture = texturePerImage[uid]; } else { - texture = ol.webgl.Context.createTexture( - gl, image, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE); + texture = _ol_webgl_Context_.createTexture( + gl, image, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE); texturePerImage[uid] = texture; } textures[i] = texture; @@ -267,16 +269,16 @@ ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, imag /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) { +_ol_render_webgl_TextureReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) { // get the program - var fragmentShader = ol.render.webgl.texturereplay.defaultshader.fragment; - var vertexShader = ol.render.webgl.texturereplay.defaultshader.vertex; + var fragmentShader = _ol_render_webgl_texturereplay_defaultshader_.fragment; + var vertexShader = _ol_render_webgl_texturereplay_defaultshader_.vertex; var program = context.getProgram(fragmentShader, vertexShader); // get the locations var locations; if (!this.defaultLocations) { - locations = new ol.render.webgl.texturereplay.defaultshader.Locations(gl, program); + locations = new _ol_render_webgl_texturereplay_defaultshader_Locations_(gl, program); this.defaultLocations = locations; } else { locations = this.defaultLocations; @@ -287,23 +289,23 @@ ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, siz // enable the vertex attrib arrays gl.enableVertexAttribArray(locations.a_position); - gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT, false, 32, 0); gl.enableVertexAttribArray(locations.a_offsets); - gl.vertexAttribPointer(locations.a_offsets, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_offsets, 2, _ol_webgl_.FLOAT, false, 32, 8); gl.enableVertexAttribArray(locations.a_texCoord); - gl.vertexAttribPointer(locations.a_texCoord, 2, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 32, 16); gl.enableVertexAttribArray(locations.a_opacity); - gl.vertexAttribPointer(locations.a_opacity, 1, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_opacity, 1, _ol_webgl_.FLOAT, false, 32, 24); gl.enableVertexAttribArray(locations.a_rotateWithView); - gl.vertexAttribPointer(locations.a_rotateWithView, 1, ol.webgl.FLOAT, + gl.vertexAttribPointer(locations.a_rotateWithView, 1, _ol_webgl_.FLOAT, false, 32, 28); return locations; @@ -313,7 +315,7 @@ ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, siz /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations) { +_ol_render_webgl_TextureReplay_.prototype.shutDownProgram = function(gl, locations) { gl.disableVertexAttribArray(locations.a_position); gl.disableVertexAttribArray(locations.a_offsets); gl.disableVertexAttribArray(locations.a_texCoord); @@ -325,17 +327,17 @@ ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { +_ol_render_webgl_TextureReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) { var textures = hitDetection ? this.getHitDetectionTextures() : this.getTextures(); var groupIndices = hitDetection ? this.hitDetectionGroupIndices : this.groupIndices; - if (!ol.obj.isEmpty(skippedFeaturesHash)) { + if (!_ol_obj_.isEmpty(skippedFeaturesHash)) { this.drawReplaySkipping( gl, context, skippedFeaturesHash, textures, groupIndices); } else { var i, ii, start; for (i = 0, ii = textures.length, start = 0; i < ii; ++i) { - gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]); var end = groupIndices[i]; this.drawElements(gl, context, start, end); start = end; @@ -370,13 +372,13 @@ ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skipp * @param {Array.} textures Textures. * @param {Array.} groupIndices Texture group indices. */ -ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures, +_ol_render_webgl_TextureReplay_.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures, groupIndices) { var featureIndex = 0; var i, ii; for (i = 0, ii = textures.length; i < ii; ++i) { - gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]); var groupStart = (i > 0) ? groupIndices[i - 1] : 0; var groupEnd = groupIndices[i]; @@ -386,7 +388,7 @@ ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, contex this.startIndices[featureIndex] <= groupEnd) { var feature = this.startIndicesFeature[featureIndex]; - var featureUid = ol.getUid(feature).toString(); + var featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid] !== undefined) { // feature should be skipped if (start !== end) { @@ -417,13 +419,13 @@ ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, contex /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, +_ol_render_webgl_TextureReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) { var i, groupStart, start, end, feature, featureUid; var featureIndex = this.startIndices.length - 1; var hitDetectionTextures = this.getHitDetectionTextures(); for (i = hitDetectionTextures.length - 1; i >= 0; --i) { - gl.bindTexture(ol.webgl.TEXTURE_2D, hitDetectionTextures[i]); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, hitDetectionTextures[i]); groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0; end = this.hitDetectionGroupIndices[i]; @@ -432,11 +434,11 @@ ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = functio this.startIndices[featureIndex] >= groupStart) { start = this.startIndices[featureIndex]; feature = this.startIndicesFeature[featureIndex]; - featureUid = ol.getUid(feature).toString(); + featureUid = _ol_.getUid(feature).toString(); if (skippedFeaturesHash[featureUid] === undefined && feature.getGeometry() && - (opt_hitExtent === undefined || ol.extent.intersects( + (opt_hitExtent === undefined || _ol_extent_.intersects( /** @type {Array} */ (opt_hitExtent), feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); @@ -459,7 +461,7 @@ ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = functio /** * @inheritDoc */ -ol.render.webgl.TextureReplay.prototype.finish = function(context) { +_ol_render_webgl_TextureReplay_.prototype.finish = function(context) { this.anchorX = undefined; this.anchorY = undefined; this.height = undefined; @@ -483,7 +485,7 @@ ol.render.webgl.TextureReplay.prototype.finish = function(context) { * @param {boolean=} opt_all Return hit detection textures with regular ones. * @returns {Array.} Textures. */ -ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {}; +_ol_render_webgl_TextureReplay_.prototype.getTextures = function(opt_all) {}; /** @@ -491,4 +493,5 @@ ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {}; * @protected * @returns {Array.} Textures. */ -ol.render.webgl.TextureReplay.prototype.getHitDetectionTextures = function() {}; +_ol_render_webgl_TextureReplay_.prototype.getHitDetectionTextures = function() {}; +export default _ol_render_webgl_TextureReplay_; diff --git a/src/ol/render/webgl/circlereplay/defaultshader.js b/src/ol/render/webgl/circlereplay/defaultshader.js index 66d4a4831c..4b51035a82 100644 --- a/src/ol/render/webgl/circlereplay/defaultshader.js +++ b/src/ol/render/webgl/circlereplay/defaultshader.js @@ -1,15 +1,18 @@ +/** + * @module ol/render/webgl/circlereplay/defaultshader + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.circlereplay.defaultshader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../../index.js'; +import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js'; +var _ol_render_webgl_circlereplay_defaultshader_ = {}; -ol.render.webgl.circlereplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_render_webgl_circlereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n float radius = length(windowCenter - windowOffset);\n float dist = length(windowCenter - gl_FragCoord.xy);\n if (dist > radius + v_halfWidth) {\n if (u_strokeColor.a == 0.0) {\n gl_FragColor = u_fillColor;\n } else {\n gl_FragColor = u_strokeColor;\n }\n gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n } else if (u_fillColor.a == 0.0) {\n // Hooray, no fill, just stroke. We can use real antialiasing.\n gl_FragColor = u_strokeColor;\n if (dist < radius - v_halfWidth) {\n gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n }\n } else {\n gl_FragColor = u_fillColor;\n float strokeDist = radius - v_halfWidth;\n float antialias = 2.0 * v_pixelRatio;\n if (dist > strokeDist) {\n gl_FragColor = u_strokeColor;\n } else if (dist >= strokeDist - antialias) {\n float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n }\n }\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n if (gl_FragColor.a <= 0.0) {\n discard;\n }\n}\n' : 'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(diststrokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}'); -ol.render.webgl.circlereplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_render_webgl_circlereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n' : 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;//Until we get gl_VertexID in WebGL,we store an instruction.if(f==0.0){//Offsetting the edges of the triangle by lineWidth/2 is necessary,however//we should also leave some space for the antialiasing,thus we offset by lineWidth.offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}'); +export default _ol_render_webgl_circlereplay_defaultshader_; diff --git a/src/ol/render/webgl/circlereplay/defaultshader/Locations.js b/src/ol/render/webgl/circlereplay/defaultshader/Locations.js index b9d585e8fa..1039a7d58e 100644 --- a/src/ol/render/webgl/circlereplay/defaultshader/Locations.js +++ b/src/ol/render/webgl/circlereplay/defaultshader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/render/webgl/circlereplay/defaultshader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.circlereplay.defaultshader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../../index.js'; /** * @constructor @@ -10,77 +10,79 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.render.webgl.circlereplay.defaultshader.Locations = function(gl, program) { +var _ol_render_webgl_circlereplay_defaultshader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_projectionMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); + program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); /** * @type {WebGLUniformLocation} */ this.u_offsetScaleMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); /** * @type {WebGLUniformLocation} */ this.u_offsetRotateMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); /** * @type {WebGLUniformLocation} */ this.u_lineWidth = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_lineWidth' : 'k'); + program, _ol_.DEBUG_WEBGL ? 'u_lineWidth' : 'k'); /** * @type {WebGLUniformLocation} */ this.u_pixelRatio = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_pixelRatio' : 'l'); + program, _ol_.DEBUG_WEBGL ? 'u_pixelRatio' : 'l'); /** * @type {WebGLUniformLocation} */ this.u_opacity = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_opacity' : 'm'); + program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'm'); /** * @type {WebGLUniformLocation} */ this.u_fillColor = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_fillColor' : 'n'); + program, _ol_.DEBUG_WEBGL ? 'u_fillColor' : 'n'); /** * @type {WebGLUniformLocation} */ this.u_strokeColor = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_strokeColor' : 'o'); + program, _ol_.DEBUG_WEBGL ? 'u_strokeColor' : 'o'); /** * @type {WebGLUniformLocation} */ this.u_size = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_size' : 'p'); + program, _ol_.DEBUG_WEBGL ? 'u_size' : 'p'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'e'); /** * @type {number} */ this.a_instruction = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_instruction' : 'f'); + program, _ol_.DEBUG_WEBGL ? 'a_instruction' : 'f'); /** * @type {number} */ this.a_radius = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_radius' : 'g'); + program, _ol_.DEBUG_WEBGL ? 'a_radius' : 'g'); }; + +export default _ol_render_webgl_circlereplay_defaultshader_Locations_; diff --git a/src/ol/render/webgl/linestringreplay/defaultshader.js b/src/ol/render/webgl/linestringreplay/defaultshader.js index 20577285ba..c03bbf3d7a 100644 --- a/src/ol/render/webgl/linestringreplay/defaultshader.js +++ b/src/ol/render/webgl/linestringreplay/defaultshader.js @@ -1,15 +1,18 @@ +/** + * @module ol/render/webgl/linestringreplay/defaultshader + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.linestringreplay.defaultshader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../../index.js'; +import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js'; +var _ol_render_webgl_linestringreplay_defaultshader_ = {}; -ol.render.webgl.linestringreplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_render_webgl_linestringreplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\nvarying float v_round;\nvarying vec2 v_roundVertex;\nvarying float v_halfWidth;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_color;\nuniform vec2 u_size;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n if (v_round > 0.0) {\n vec2 windowCoords = vec2((v_roundVertex.x + 1.0) / 2.0 * u_size.x * u_pixelRatio,\n (v_roundVertex.y + 1.0) / 2.0 * u_size.y * u_pixelRatio);\n if (length(windowCoords - gl_FragCoord.xy) > v_halfWidth * u_pixelRatio) {\n discard;\n }\n }\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' : 'precision mediump float;varying float a;varying vec2 aVertex;varying float c;uniform float m;uniform vec4 n;uniform vec2 o;uniform float p;void main(void){if(a>0.0){vec2 windowCoords=vec2((aVertex.x+1.0)/2.0*o.x*p,(aVertex.y+1.0)/2.0*o.y*p);if(length(windowCoords-gl_FragCoord.xy)>c*p){discard;}} gl_FragColor=n;float alpha=n.a*m;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}'); -ol.render.webgl.linestringreplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_render_webgl_linestringreplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? 'varying float v_round;\nvarying vec2 v_roundVertex;\nvarying float v_halfWidth;\n\n\nattribute vec2 a_lastPos;\nattribute vec2 a_position;\nattribute vec2 a_nextPos;\nattribute float a_direction;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_miterLimit;\n\nbool nearlyEquals(in float value, in float ref) {\n float epsilon = 0.000000000001;\n return value >= ref - epsilon && value <= ref + epsilon;\n}\n\nvoid alongNormal(out vec2 offset, in vec2 nextP, in float turnDir, in float direction) {\n vec2 dirVect = nextP - a_position;\n vec2 normal = normalize(vec2(-turnDir * dirVect.y, turnDir * dirVect.x));\n offset = u_lineWidth / 2.0 * normal * direction;\n}\n\nvoid miterUp(out vec2 offset, out float round, in bool isRound, in float direction) {\n float halfWidth = u_lineWidth / 2.0;\n vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 dirVect = a_nextPos - a_position;\n vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));\n float miterLength = abs(halfWidth / dot(normal, tmpNormal));\n offset = normal * direction * miterLength;\n round = 0.0;\n if (isRound) {\n round = 1.0;\n } else if (miterLength > u_miterLimit + u_lineWidth) {\n offset = halfWidth * tmpNormal * direction;\n }\n}\n\nbool miterDown(out vec2 offset, in vec4 projPos, in mat4 offsetMatrix, in float direction) {\n bool degenerate = false;\n vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 dirVect = a_lastPos - a_position;\n vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));\n vec2 longOffset, shortOffset, longVertex;\n vec4 shortProjVertex;\n float halfWidth = u_lineWidth / 2.0;\n if (length(a_nextPos - a_position) > length(a_lastPos - a_position)) {\n longOffset = tmpNormal * direction * halfWidth;\n shortOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;\n longVertex = a_nextPos;\n shortProjVertex = u_projectionMatrix * vec4(a_lastPos, 0.0, 1.0);\n } else {\n shortOffset = tmpNormal * direction * halfWidth;\n longOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;\n longVertex = a_lastPos;\n shortProjVertex = u_projectionMatrix * vec4(a_nextPos, 0.0, 1.0);\n }\n //Intersection algorithm based on theory by Paul Bourke (http://paulbourke.net/geometry/pointlineplane/).\n vec4 p1 = u_projectionMatrix * vec4(longVertex, 0.0, 1.0) + offsetMatrix * vec4(longOffset, 0.0, 0.0);\n vec4 p2 = projPos + offsetMatrix * vec4(longOffset, 0.0, 0.0);\n vec4 p3 = shortProjVertex + offsetMatrix * vec4(-shortOffset, 0.0, 0.0);\n vec4 p4 = shortProjVertex + offsetMatrix * vec4(shortOffset, 0.0, 0.0);\n float denom = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);\n float firstU = ((p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x)) / denom;\n float secondU = ((p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x)) / denom;\n float epsilon = 0.000000000001;\n if (firstU > epsilon && firstU < 1.0 - epsilon && secondU > epsilon && secondU < 1.0 - epsilon) {\n shortProjVertex.x = p1.x + firstU * (p2.x - p1.x);\n shortProjVertex.y = p1.y + firstU * (p2.y - p1.y);\n offset = shortProjVertex.xy;\n degenerate = true;\n } else {\n float miterLength = abs(halfWidth / dot(normal, tmpNormal));\n offset = normal * direction * miterLength;\n }\n return degenerate;\n}\n\nvoid squareCap(out vec2 offset, out float round, in bool isRound, in vec2 nextP,\n in float turnDir, in float direction) {\n round = 0.0;\n vec2 dirVect = a_position - nextP;\n vec2 firstNormal = normalize(dirVect);\n vec2 secondNormal = vec2(turnDir * firstNormal.y * direction, -turnDir * firstNormal.x * direction);\n vec2 hypotenuse = normalize(firstNormal - secondNormal);\n vec2 normal = vec2(turnDir * hypotenuse.y * direction, -turnDir * hypotenuse.x * direction);\n float length = sqrt(v_halfWidth * v_halfWidth * 2.0);\n offset = normal * length;\n if (isRound) {\n round = 1.0;\n }\n}\n\nvoid main(void) {\n bool degenerate = false;\n float direction = float(sign(a_direction));\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n vec2 offset;\n vec4 projPos = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n bool round = nearlyEquals(mod(a_direction, 2.0), 0.0);\n\n v_round = 0.0;\n v_halfWidth = u_lineWidth / 2.0;\n v_roundVertex = projPos.xy;\n\n if (nearlyEquals(mod(a_direction, 3.0), 0.0) || nearlyEquals(mod(a_direction, 17.0), 0.0)) {\n alongNormal(offset, a_nextPos, 1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 5.0), 0.0) || nearlyEquals(mod(a_direction, 13.0), 0.0)) {\n alongNormal(offset, a_lastPos, -1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 23.0), 0.0)) {\n miterUp(offset, v_round, round, direction);\n } else if (nearlyEquals(mod(a_direction, 19.0), 0.0)) {\n degenerate = miterDown(offset, projPos, offsetMatrix, direction);\n } else if (nearlyEquals(mod(a_direction, 7.0), 0.0)) {\n squareCap(offset, v_round, round, a_nextPos, 1.0, direction);\n } else if (nearlyEquals(mod(a_direction, 11.0), 0.0)) {\n squareCap(offset, v_round, round, a_lastPos, -1.0, direction);\n }\n if (!degenerate) {\n vec4 offsets = offsetMatrix * vec4(offset, 0.0, 0.0);\n gl_Position = projPos + offsets;\n } else {\n gl_Position = vec4(offset, 0.0, 1.0);\n }\n}\n\n\n' : 'varying float a;varying vec2 aVertex;varying float c;attribute vec2 d;attribute vec2 e;attribute vec2 f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;bool nearlyEquals(in float value,in float ref){float epsilon=0.000000000001;return value>=ref-epsilon&&value<=ref+epsilon;}void alongNormal(out vec2 offset,in vec2 nextP,in float turnDir,in float direction){vec2 dirVect=nextP-e;vec2 normal=normalize(vec2(-turnDir*dirVect.y,turnDir*dirVect.x));offset=k/2.0*normal*direction;}void miterUp(out vec2 offset,out float round,in bool isRound,in float direction){float halfWidth=k/2.0;vec2 tangent=normalize(normalize(f-e)+normalize(e-d));vec2 normal=vec2(-tangent.y,tangent.x);vec2 dirVect=f-e;vec2 tmpNormal=normalize(vec2(-dirVect.y,dirVect.x));float miterLength=abs(halfWidth/dot(normal,tmpNormal));offset=normal*direction*miterLength;round=0.0;if(isRound){round=1.0;}else if(miterLength>l+k){offset=halfWidth*tmpNormal*direction;}} bool miterDown(out vec2 offset,in vec4 projPos,in mat4 offsetMatrix,in float direction){bool degenerate=false;vec2 tangent=normalize(normalize(f-e)+normalize(e-d));vec2 normal=vec2(-tangent.y,tangent.x);vec2 dirVect=d-e;vec2 tmpNormal=normalize(vec2(-dirVect.y,dirVect.x));vec2 longOffset,shortOffset,longVertex;vec4 shortProjVertex;float halfWidth=k/2.0;if(length(f-e)>length(d-e)){longOffset=tmpNormal*direction*halfWidth;shortOffset=normalize(vec2(dirVect.y,-dirVect.x))*direction*halfWidth;longVertex=f;shortProjVertex=h*vec4(d,0.0,1.0);}else{shortOffset=tmpNormal*direction*halfWidth;longOffset=normalize(vec2(dirVect.y,-dirVect.x))*direction*halfWidth;longVertex=d;shortProjVertex=h*vec4(f,0.0,1.0);}vec4 p1=h*vec4(longVertex,0.0,1.0)+offsetMatrix*vec4(longOffset,0.0,0.0);vec4 p2=projPos+offsetMatrix*vec4(longOffset,0.0,0.0);vec4 p3=shortProjVertex+offsetMatrix*vec4(-shortOffset,0.0,0.0);vec4 p4=shortProjVertex+offsetMatrix*vec4(shortOffset,0.0,0.0);float denom=(p4.y-p3.y)*(p2.x-p1.x)-(p4.x-p3.x)*(p2.y-p1.y);float firstU=((p4.x-p3.x)*(p1.y-p3.y)-(p4.y-p3.y)*(p1.x-p3.x))/denom;float secondU=((p2.x-p1.x)*(p1.y-p3.y)-(p2.y-p1.y)*(p1.x-p3.x))/denom;float epsilon=0.000000000001;if(firstU>epsilon&&firstU<1.0-epsilon&&secondU>epsilon&&secondU<1.0-epsilon){shortProjVertex.x=p1.x+firstU*(p2.x-p1.x);shortProjVertex.y=p1.y+firstU*(p2.y-p1.y);offset=shortProjVertex.xy;degenerate=true;}else{float miterLength=abs(halfWidth/dot(normal,tmpNormal));offset=normal*direction*miterLength;}return degenerate;}void squareCap(out vec2 offset,out float round,in bool isRound,in vec2 nextP,in float turnDir,in float direction){round=0.0;vec2 dirVect=e-nextP;vec2 firstNormal=normalize(dirVect);vec2 secondNormal=vec2(turnDir*firstNormal.y*direction,-turnDir*firstNormal.x*direction);vec2 hypotenuse=normalize(firstNormal-secondNormal);vec2 normal=vec2(turnDir*hypotenuse.y*direction,-turnDir*hypotenuse.x*direction);float length=sqrt(c*c*2.0);offset=normal*length;if(isRound){round=1.0;}} void main(void){bool degenerate=false;float direction=float(sign(g));mat4 offsetMatrix=i*j;vec2 offset;vec4 projPos=h*vec4(e,0.0,1.0);bool round=nearlyEquals(mod(g,2.0),0.0);a=0.0;c=k/2.0;aVertex=projPos.xy;if(nearlyEquals(mod(g,3.0),0.0)||nearlyEquals(mod(g,17.0),0.0)){alongNormal(offset,f,1.0,direction);}else if(nearlyEquals(mod(g,5.0),0.0)||nearlyEquals(mod(g,13.0),0.0)){alongNormal(offset,d,-1.0,direction);}else if(nearlyEquals(mod(g,23.0),0.0)){miterUp(offset,a,round,direction);}else if(nearlyEquals(mod(g,19.0),0.0)){degenerate=miterDown(offset,projPos,offsetMatrix,direction);}else if(nearlyEquals(mod(g,7.0),0.0)){squareCap(offset,a,round,f,1.0,direction);}else if(nearlyEquals(mod(g,11.0),0.0)){squareCap(offset,a,round,d,-1.0,direction);}if(!degenerate){vec4 offsets=offsetMatrix*vec4(offset,0.0,0.0);gl_Position=projPos+offsets;}else{gl_Position=vec4(offset,0.0,1.0);}}'); +export default _ol_render_webgl_linestringreplay_defaultshader_; diff --git a/src/ol/render/webgl/linestringreplay/defaultshader/Locations.js b/src/ol/render/webgl/linestringreplay/defaultshader/Locations.js index 44fc1d01bd..d7e270e11f 100644 --- a/src/ol/render/webgl/linestringreplay/defaultshader/Locations.js +++ b/src/ol/render/webgl/linestringreplay/defaultshader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/render/webgl/linestringreplay/defaultshader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.linestringreplay.defaultshader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../../index.js'; /** * @constructor @@ -10,83 +10,85 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.render.webgl.linestringreplay.defaultshader.Locations = function(gl, program) { +var _ol_render_webgl_linestringreplay_defaultshader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_projectionMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); + program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); /** * @type {WebGLUniformLocation} */ this.u_offsetScaleMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); /** * @type {WebGLUniformLocation} */ this.u_offsetRotateMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); /** * @type {WebGLUniformLocation} */ this.u_lineWidth = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_lineWidth' : 'k'); + program, _ol_.DEBUG_WEBGL ? 'u_lineWidth' : 'k'); /** * @type {WebGLUniformLocation} */ this.u_miterLimit = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_miterLimit' : 'l'); + program, _ol_.DEBUG_WEBGL ? 'u_miterLimit' : 'l'); /** * @type {WebGLUniformLocation} */ this.u_opacity = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_opacity' : 'm'); + program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'm'); /** * @type {WebGLUniformLocation} */ this.u_color = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_color' : 'n'); + program, _ol_.DEBUG_WEBGL ? 'u_color' : 'n'); /** * @type {WebGLUniformLocation} */ this.u_size = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_size' : 'o'); + program, _ol_.DEBUG_WEBGL ? 'u_size' : 'o'); /** * @type {WebGLUniformLocation} */ this.u_pixelRatio = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_pixelRatio' : 'p'); + program, _ol_.DEBUG_WEBGL ? 'u_pixelRatio' : 'p'); /** * @type {number} */ this.a_lastPos = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_lastPos' : 'd'); + program, _ol_.DEBUG_WEBGL ? 'a_lastPos' : 'd'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'e'); /** * @type {number} */ this.a_nextPos = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_nextPos' : 'f'); + program, _ol_.DEBUG_WEBGL ? 'a_nextPos' : 'f'); /** * @type {number} */ this.a_direction = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_direction' : 'g'); + program, _ol_.DEBUG_WEBGL ? 'a_direction' : 'g'); }; + +export default _ol_render_webgl_linestringreplay_defaultshader_Locations_; diff --git a/src/ol/render/webgl/polygonreplay/defaultshader.js b/src/ol/render/webgl/polygonreplay/defaultshader.js index 17cf0524f8..564af702ec 100644 --- a/src/ol/render/webgl/polygonreplay/defaultshader.js +++ b/src/ol/render/webgl/polygonreplay/defaultshader.js @@ -1,15 +1,18 @@ +/** + * @module ol/render/webgl/polygonreplay/defaultshader + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.polygonreplay.defaultshader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../../index.js'; +import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js'; +var _ol_render_webgl_polygonreplay_defaultshader_ = {}; -ol.render.webgl.polygonreplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_render_webgl_polygonreplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\n\n\n\nuniform vec4 u_color;\nuniform float u_opacity;\n\nvoid main(void) {\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' : 'precision mediump float;uniform vec4 e;uniform float f;void main(void){gl_FragColor=e;float alpha=e.a*f;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}'); -ol.render.webgl.polygonreplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_render_webgl_polygonreplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? '\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n' : 'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}'); +export default _ol_render_webgl_polygonreplay_defaultshader_; diff --git a/src/ol/render/webgl/polygonreplay/defaultshader/Locations.js b/src/ol/render/webgl/polygonreplay/defaultshader/Locations.js index 600724511b..57b8c1ecd4 100644 --- a/src/ol/render/webgl/polygonreplay/defaultshader/Locations.js +++ b/src/ol/render/webgl/polygonreplay/defaultshader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/render/webgl/polygonreplay/defaultshader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.polygonreplay.defaultshader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../../index.js'; /** * @constructor @@ -10,41 +10,43 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.render.webgl.polygonreplay.defaultshader.Locations = function(gl, program) { +var _ol_render_webgl_polygonreplay_defaultshader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_projectionMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'b'); + program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'b'); /** * @type {WebGLUniformLocation} */ this.u_offsetScaleMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'c'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'c'); /** * @type {WebGLUniformLocation} */ this.u_offsetRotateMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'd'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'd'); /** * @type {WebGLUniformLocation} */ this.u_color = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_color' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'u_color' : 'e'); /** * @type {WebGLUniformLocation} */ this.u_opacity = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_opacity' : 'f'); + program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'f'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'a'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'a'); }; + +export default _ol_render_webgl_polygonreplay_defaultshader_Locations_; diff --git a/src/ol/render/webgl/texturereplay/defaultshader.js b/src/ol/render/webgl/texturereplay/defaultshader.js index 473c9e2e82..aa4de3dfb1 100644 --- a/src/ol/render/webgl/texturereplay/defaultshader.js +++ b/src/ol/render/webgl/texturereplay/defaultshader.js @@ -1,15 +1,18 @@ +/** + * @module ol/render/webgl/texturereplay/defaultshader + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.texturereplay.defaultshader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../../index.js'; +import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js'; +var _ol_render_webgl_texturereplay_defaultshader_ = {}; -ol.render.webgl.texturereplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_render_webgl_texturereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' : 'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}'); -ol.render.webgl.texturereplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_render_webgl_texturereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n' : 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}'); +export default _ol_render_webgl_texturereplay_defaultshader_; diff --git a/src/ol/render/webgl/texturereplay/defaultshader/Locations.js b/src/ol/render/webgl/texturereplay/defaultshader/Locations.js index 59e7f54ff2..2bdd2389bc 100644 --- a/src/ol/render/webgl/texturereplay/defaultshader/Locations.js +++ b/src/ol/render/webgl/texturereplay/defaultshader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/render/webgl/texturereplay/defaultshader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.render.webgl.texturereplay.defaultshader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../../index.js'; /** * @constructor @@ -10,65 +10,67 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.render.webgl.texturereplay.defaultshader.Locations = function(gl, program) { +var _ol_render_webgl_texturereplay_defaultshader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_projectionMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); + program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h'); /** * @type {WebGLUniformLocation} */ this.u_offsetScaleMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i'); /** * @type {WebGLUniformLocation} */ this.u_offsetRotateMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); + program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j'); /** * @type {WebGLUniformLocation} */ this.u_opacity = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_opacity' : 'k'); + program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'k'); /** * @type {WebGLUniformLocation} */ this.u_image = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_image' : 'l'); + program, _ol_.DEBUG_WEBGL ? 'u_image' : 'l'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'c'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'c'); /** * @type {number} */ this.a_texCoord = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd'); + program, _ol_.DEBUG_WEBGL ? 'a_texCoord' : 'd'); /** * @type {number} */ this.a_offsets = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_offsets' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'a_offsets' : 'e'); /** * @type {number} */ this.a_opacity = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_opacity' : 'f'); + program, _ol_.DEBUG_WEBGL ? 'a_opacity' : 'f'); /** * @type {number} */ this.a_rotateWithView = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_rotateWithView' : 'g'); + program, _ol_.DEBUG_WEBGL ? 'a_rotateWithView' : 'g'); }; + +export default _ol_render_webgl_texturereplay_defaultshader_Locations_; diff --git a/src/ol/renderer/Layer.js b/src/ol/renderer/Layer.js index 276b1ebaf4..568f901fd8 100644 --- a/src/ol/renderer/Layer.js +++ b/src/ol/renderer/Layer.js @@ -1,15 +1,15 @@ -goog.provide('ol.renderer.Layer'); - -goog.require('ol'); -goog.require('ol.ImageState'); -goog.require('ol.Observable'); -goog.require('ol.TileState'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.functions'); -goog.require('ol.source.State'); - +/** + * @module ol/renderer/Layer + */ +import _ol_ from '../index.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_Observable_ from '../Observable.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_functions_ from '../functions.js'; +import _ol_source_State_ from '../source/State.js'; /** * @constructor @@ -17,9 +17,9 @@ goog.require('ol.source.State'); * @param {ol.layer.Layer} layer Layer. * @struct */ -ol.renderer.Layer = function(layer) { +var _ol_renderer_Layer_ = function(layer) { - ol.Observable.call(this); + _ol_Observable_.call(this); /** * @private @@ -29,7 +29,8 @@ ol.renderer.Layer = function(layer) { }; -ol.inherits(ol.renderer.Layer, ol.Observable); + +_ol_.inherits(_ol_renderer_Layer_, _ol_Observable_); /** @@ -42,7 +43,7 @@ ol.inherits(ol.renderer.Layer, ol.Observable); * @return {T|undefined} Callback result. * @template S,T */ -ol.renderer.Layer.prototype.forEachFeatureAtCoordinate = ol.nullFunction; +_ol_renderer_Layer_.prototype.forEachFeatureAtCoordinate = _ol_.nullFunction; /** @@ -50,7 +51,7 @@ ol.renderer.Layer.prototype.forEachFeatureAtCoordinate = ol.nullFunction; * @param {olx.FrameState} frameState Frame state. * @return {boolean} Is there a feature at the given coordinate? */ -ol.renderer.Layer.prototype.hasFeatureAtCoordinate = ol.functions.FALSE; +_ol_renderer_Layer_.prototype.hasFeatureAtCoordinate = _ol_functions_.FALSE; /** @@ -64,7 +65,7 @@ ol.renderer.Layer.prototype.hasFeatureAtCoordinate = ol.functions.FALSE; * lookup. * @protected */ -ol.renderer.Layer.prototype.createLoadedTileFinder = function(source, projection, tiles) { +_ol_renderer_Layer_.prototype.createLoadedTileFinder = function(source, projection, tiles) { return ( /** * @param {number} zoom Zoom level. @@ -86,7 +87,7 @@ ol.renderer.Layer.prototype.createLoadedTileFinder = function(source, projection /** * @return {ol.layer.Layer} Layer. */ -ol.renderer.Layer.prototype.getLayer = function() { +_ol_renderer_Layer_.prototype.getLayer = function() { return this.layer_; }; @@ -96,9 +97,9 @@ ol.renderer.Layer.prototype.getLayer = function() { * @param {ol.events.Event} event Image change event. * @private */ -ol.renderer.Layer.prototype.handleImageChange_ = function(event) { +_ol_renderer_Layer_.prototype.handleImageChange_ = function(event) { var image = /** @type {ol.Image} */ (event.target); - if (image.getState() === ol.ImageState.LOADED) { + if (image.getState() === _ol_ImageState_.LOADED) { this.renderIfReadyAndVisible(); } }; @@ -112,27 +113,27 @@ ol.renderer.Layer.prototype.handleImageChange_ = function(event) { * otherwise. * @protected */ -ol.renderer.Layer.prototype.loadImage = function(image) { +_ol_renderer_Layer_.prototype.loadImage = function(image) { var imageState = image.getState(); - if (imageState != ol.ImageState.LOADED && - imageState != ol.ImageState.ERROR) { - ol.events.listen(image, ol.events.EventType.CHANGE, + if (imageState != _ol_ImageState_.LOADED && + imageState != _ol_ImageState_.ERROR) { + _ol_events_.listen(image, _ol_events_EventType_.CHANGE, this.handleImageChange_, this); } - if (imageState == ol.ImageState.IDLE) { + if (imageState == _ol_ImageState_.IDLE) { image.load(); imageState = image.getState(); } - return imageState == ol.ImageState.LOADED; + return imageState == _ol_ImageState_.LOADED; }; /** * @protected */ -ol.renderer.Layer.prototype.renderIfReadyAndVisible = function() { +_ol_renderer_Layer_.prototype.renderIfReadyAndVisible = function() { var layer = this.getLayer(); - if (layer.getVisible() && layer.getSourceState() == ol.source.State.READY) { + if (layer.getVisible() && layer.getSourceState() == _ol_source_State_.READY) { this.changed(); } }; @@ -143,7 +144,7 @@ ol.renderer.Layer.prototype.renderIfReadyAndVisible = function() { * @param {ol.source.Tile} tileSource Tile source. * @protected */ -ol.renderer.Layer.prototype.scheduleExpireCache = function(frameState, tileSource) { +_ol_renderer_Layer_.prototype.scheduleExpireCache = function(frameState, tileSource) { if (tileSource.canExpireCache()) { /** * @param {ol.source.Tile} tileSource Tile source. @@ -151,7 +152,7 @@ ol.renderer.Layer.prototype.scheduleExpireCache = function(frameState, tileSourc * @param {olx.FrameState} frameState Frame state. */ var postRenderFunction = function(tileSource, map, frameState) { - var tileSourceKey = ol.getUid(tileSource).toString(); + var tileSourceKey = _ol_.getUid(tileSource).toString(); if (tileSourceKey in frameState.usedTiles) { tileSource.expireCache(frameState.viewState.projection, frameState.usedTiles[tileSourceKey]); @@ -170,14 +171,14 @@ ol.renderer.Layer.prototype.scheduleExpireCache = function(frameState, tileSourc * @param {ol.source.Source} source Source. * @protected */ -ol.renderer.Layer.prototype.updateLogos = function(frameState, source) { +_ol_renderer_Layer_.prototype.updateLogos = function(frameState, source) { var logo = source.getLogo(); if (logo !== undefined) { if (typeof logo === 'string') { frameState.logos[logo] = ''; } else if (logo) { - ol.asserts.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string. - ol.asserts.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string. + _ol_asserts_.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string. + _ol_asserts_.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string. frameState.logos[logo.src] = logo.href; } } @@ -191,9 +192,9 @@ ol.renderer.Layer.prototype.updateLogos = function(frameState, source) { * @param {ol.TileRange} tileRange Tile range. * @protected */ -ol.renderer.Layer.prototype.updateUsedTiles = function(usedTiles, tileSource, z, tileRange) { +_ol_renderer_Layer_.prototype.updateUsedTiles = function(usedTiles, tileSource, z, tileRange) { // FIXME should we use tilesToDrawByZ instead? - var tileSourceKey = ol.getUid(tileSource).toString(); + var tileSourceKey = _ol_.getUid(tileSource).toString(); var zKey = z.toString(); if (tileSourceKey in usedTiles) { if (zKey in usedTiles[tileSourceKey]) { @@ -228,10 +229,10 @@ ol.renderer.Layer.prototype.updateUsedTiles = function(usedTiles, tileSource, z, * @protected * @template T */ -ol.renderer.Layer.prototype.manageTilePyramid = function( +_ol_renderer_Layer_.prototype.manageTilePyramid = function( frameState, tileSource, tileGrid, pixelRatio, projection, extent, currentZ, preload, opt_tileCallback, opt_this) { - var tileSourceKey = ol.getUid(tileSource).toString(); + var tileSourceKey = _ol_.getUid(tileSource).toString(); if (!(tileSourceKey in frameState.wantedTiles)) { frameState.wantedTiles[tileSourceKey] = {}; } @@ -246,7 +247,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function( for (y = tileRange.minY; y <= tileRange.maxY; ++y) { if (currentZ - z <= preload) { tile = tileSource.getTile(z, x, y, pixelRatio, projection); - if (tile.getState() == ol.TileState.IDLE) { + if (tile.getState() == _ol_TileState_.IDLE) { wantedTiles[tile.getKey()] = true; if (!tileQueue.isKeyQueued(tile.getKey())) { tileQueue.enqueue([tile, tileSourceKey, @@ -263,3 +264,4 @@ ol.renderer.Layer.prototype.manageTilePyramid = function( } } }; +export default _ol_renderer_Layer_; diff --git a/src/ol/renderer/Map.js b/src/ol/renderer/Map.js index 64b38a466e..8fe5658882 100644 --- a/src/ol/renderer/Map.js +++ b/src/ol/renderer/Map.js @@ -1,16 +1,16 @@ -goog.provide('ol.renderer.Map'); - -goog.require('ol'); -goog.require('ol.Disposable'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.layer.Layer'); -goog.require('ol.plugins'); -goog.require('ol.style'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/Map + */ +import _ol_ from '../index.js'; +import _ol_Disposable_ from '../Disposable.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_functions_ from '../functions.js'; +import _ol_layer_Layer_ from '../layer/Layer.js'; +import _ol_plugins_ from '../plugins.js'; +import _ol_style_ from '../style.js'; +import _ol_transform_ from '../transform.js'; /** * @constructor @@ -20,9 +20,9 @@ goog.require('ol.transform'); * @param {ol.PluggableMap} map Map. * @struct */ -ol.renderer.Map = function(container, map) { +var _ol_renderer_Map_ = function(container, map) { - ol.Disposable.call(this); + _ol_Disposable_.call(this); /** @@ -44,33 +44,34 @@ ol.renderer.Map = function(container, map) { this.layerRendererListeners_ = {}; }; -ol.inherits(ol.renderer.Map, ol.Disposable); + +_ol_.inherits(_ol_renderer_Map_, _ol_Disposable_); /** * @param {olx.FrameState} frameState FrameState. * @protected */ -ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) { +_ol_renderer_Map_.prototype.calculateMatrices2D = function(frameState) { var viewState = frameState.viewState; var coordinateToPixelTransform = frameState.coordinateToPixelTransform; var pixelToCoordinateTransform = frameState.pixelToCoordinateTransform; - ol.transform.compose(coordinateToPixelTransform, + _ol_transform_.compose(coordinateToPixelTransform, frameState.size[0] / 2, frameState.size[1] / 2, 1 / viewState.resolution, -1 / viewState.resolution, -viewState.rotation, -viewState.center[0], -viewState.center[1]); - ol.transform.invert( - ol.transform.setFromArray(pixelToCoordinateTransform, coordinateToPixelTransform)); + _ol_transform_.invert( + _ol_transform_.setFromArray(pixelToCoordinateTransform, coordinateToPixelTransform)); }; /** * Removes all layer renderers. */ -ol.renderer.Map.prototype.removeLayerRenderers = function() { +_ol_renderer_Map_.prototype.removeLayerRenderers = function() { for (var key in this.layerRenderers_) { this.removeLayerRendererByKey_(key).dispose(); } @@ -82,8 +83,8 @@ ol.renderer.Map.prototype.removeLayerRenderers = function() { * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.Map.expireIconCache_ = function(map, frameState) { - var cache = ol.style.iconImageCache; +_ol_renderer_Map_.expireIconCache_ = function(map, frameState) { + var cache = _ol_style_.iconImageCache; cache.expire(); }; @@ -103,7 +104,7 @@ ol.renderer.Map.expireIconCache_ = function(map, frameState) { * @return {T|undefined} Callback result. * @template S,T,U */ -ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, +_ol_renderer_Map_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) { var result; var viewState = frameState.viewState; @@ -115,8 +116,8 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram * @return {?} Callback result. */ function forEachFeatureAtCoordinate(feature, layer) { - var key = ol.getUid(feature).toString(); - var managed = frameState.layerStates[ol.getUid(layer)].managed; + var key = _ol_.getUid(feature).toString(); + var managed = frameState.layerStates[_ol_.getUid(layer)].managed; if (!(key in frameState.skippedFeatureUids && !managed)) { return callback.call(thisArg, feature, managed ? layer : null); } @@ -127,7 +128,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram var translatedCoordinate = coordinate; if (projection.canWrapX()) { var projectionExtent = projection.getExtent(); - var worldWidth = ol.extent.getWidth(projectionExtent); + var worldWidth = _ol_extent_.getWidth(projectionExtent); var x = coordinate[0]; if (x < projectionExtent[0] || x > projectionExtent[2]) { var worldsAway = Math.ceil((projectionExtent[0] - x) / worldWidth); @@ -141,7 +142,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram for (i = numLayers - 1; i >= 0; --i) { var layerState = layerStates[i]; var layer = layerState.layer; - if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewResolution) && layerFilter.call(thisArg2, layer)) { var layerRenderer = this.getLayerRenderer(layer); if (layer.getSource()) { @@ -173,7 +174,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram * @return {T|undefined} Callback result. * @template S,T,U */ -ol.renderer.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, +_ol_renderer_Map_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, layerFilter, thisArg2) {}; @@ -189,9 +190,9 @@ ol.renderer.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, call * @return {boolean} Is there a feature at the given coordinate? * @template U */ -ol.renderer.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) { +_ol_renderer_Map_.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) { var hasFeature = this.forEachFeatureAtCoordinate( - coordinate, frameState, hitTolerance, ol.functions.TRUE, this, layerFilter, thisArg); + coordinate, frameState, hitTolerance, _ol_functions_.TRUE, this, layerFilter, thisArg); return hasFeature !== undefined; }; @@ -202,12 +203,12 @@ ol.renderer.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameSta * @protected * @return {ol.renderer.Layer} Layer renderer. */ -ol.renderer.Map.prototype.getLayerRenderer = function(layer) { - var layerKey = ol.getUid(layer).toString(); +_ol_renderer_Map_.prototype.getLayerRenderer = function(layer) { + var layerKey = _ol_.getUid(layer).toString(); if (layerKey in this.layerRenderers_) { return this.layerRenderers_[layerKey]; } else { - var layerRendererPlugins = ol.plugins.getLayerRendererPlugins(); + var layerRendererPlugins = _ol_plugins_.getLayerRendererPlugins(); var renderer; var type = this.getType(); for (var i = 0, ii = layerRendererPlugins.length; i < ii; ++i) { @@ -219,8 +220,8 @@ ol.renderer.Map.prototype.getLayerRenderer = function(layer) { } if (renderer) { this.layerRenderers_[layerKey] = renderer; - this.layerRendererListeners_[layerKey] = ol.events.listen(renderer, - ol.events.EventType.CHANGE, this.handleLayerRendererChange_, this); + this.layerRendererListeners_[layerKey] = _ol_events_.listen(renderer, + _ol_events_EventType_.CHANGE, this.handleLayerRendererChange_, this); } else { throw new Error('Unable to create renderer for layer: ' + layer.getType()); } @@ -234,7 +235,7 @@ ol.renderer.Map.prototype.getLayerRenderer = function(layer) { * @protected * @return {ol.renderer.Layer} Layer renderer. */ -ol.renderer.Map.prototype.getLayerRendererByKey = function(layerKey) { +_ol_renderer_Map_.prototype.getLayerRendererByKey = function(layerKey) { return this.layerRenderers_[layerKey]; }; @@ -243,7 +244,7 @@ ol.renderer.Map.prototype.getLayerRendererByKey = function(layerKey) { * @protected * @return {Object.} Layer renderers. */ -ol.renderer.Map.prototype.getLayerRenderers = function() { +_ol_renderer_Map_.prototype.getLayerRenderers = function() { return this.layerRenderers_; }; @@ -251,7 +252,7 @@ ol.renderer.Map.prototype.getLayerRenderers = function() { /** * @return {ol.PluggableMap} Map. */ -ol.renderer.Map.prototype.getMap = function() { +_ol_renderer_Map_.prototype.getMap = function() { return this.map_; }; @@ -260,14 +261,14 @@ ol.renderer.Map.prototype.getMap = function() { * @abstract * @return {ol.renderer.Type} Type */ -ol.renderer.Map.prototype.getType = function() {}; +_ol_renderer_Map_.prototype.getType = function() {}; /** * Handle changes in a layer renderer. * @private */ -ol.renderer.Map.prototype.handleLayerRendererChange_ = function() { +_ol_renderer_Map_.prototype.handleLayerRendererChange_ = function() { this.map_.render(); }; @@ -277,11 +278,11 @@ ol.renderer.Map.prototype.handleLayerRendererChange_ = function() { * @return {ol.renderer.Layer} Layer renderer. * @private */ -ol.renderer.Map.prototype.removeLayerRendererByKey_ = function(layerKey) { +_ol_renderer_Map_.prototype.removeLayerRendererByKey_ = function(layerKey) { var layerRenderer = this.layerRenderers_[layerKey]; delete this.layerRenderers_[layerKey]; - ol.events.unlistenByKey(this.layerRendererListeners_[layerKey]); + _ol_events_.unlistenByKey(this.layerRendererListeners_[layerKey]); delete this.layerRendererListeners_[layerKey]; return layerRenderer; @@ -292,7 +293,7 @@ ol.renderer.Map.prototype.removeLayerRendererByKey_ = function(layerKey) { * Render. * @param {?olx.FrameState} frameState Frame state. */ -ol.renderer.Map.prototype.renderFrame = ol.nullFunction; +_ol_renderer_Map_.prototype.renderFrame = _ol_.nullFunction; /** @@ -300,7 +301,7 @@ ol.renderer.Map.prototype.renderFrame = ol.nullFunction; * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.Map.prototype.removeUnusedLayerRenderers_ = function(map, frameState) { +_ol_renderer_Map_.prototype.removeUnusedLayerRenderers_ = function(map, frameState) { var layerKey; for (layerKey in this.layerRenderers_) { if (!frameState || !(layerKey in frameState.layerStates)) { @@ -314,9 +315,9 @@ ol.renderer.Map.prototype.removeUnusedLayerRenderers_ = function(map, frameState * @param {olx.FrameState} frameState Frame state. * @protected */ -ol.renderer.Map.prototype.scheduleExpireIconCache = function(frameState) { +_ol_renderer_Map_.prototype.scheduleExpireIconCache = function(frameState) { frameState.postRenderFunctions.push( - /** @type {ol.PostRenderFunction} */ (ol.renderer.Map.expireIconCache_) + /** @type {ol.PostRenderFunction} */ (_ol_renderer_Map_.expireIconCache_) ); }; @@ -325,7 +326,7 @@ ol.renderer.Map.prototype.scheduleExpireIconCache = function(frameState) { * @param {!olx.FrameState} frameState Frame state. * @protected */ -ol.renderer.Map.prototype.scheduleRemoveUnusedLayerRenderers = function(frameState) { +_ol_renderer_Map_.prototype.scheduleRemoveUnusedLayerRenderers = function(frameState) { var layerKey; for (layerKey in this.layerRenderers_) { if (!(layerKey in frameState.layerStates)) { @@ -343,6 +344,7 @@ ol.renderer.Map.prototype.scheduleRemoveUnusedLayerRenderers = function(frameSta * @param {ol.LayerState} state2 Second layer state. * @return {number} The zIndex difference. */ -ol.renderer.Map.sortByZIndex = function(state1, state2) { +_ol_renderer_Map_.sortByZIndex = function(state1, state2) { return state1.zIndex - state2.zIndex; }; +export default _ol_renderer_Map_; diff --git a/src/ol/renderer/Type.js b/src/ol/renderer/Type.js index 7851b64eae..e02c1da7c8 100644 --- a/src/ol/renderer/Type.js +++ b/src/ol/renderer/Type.js @@ -1,11 +1,13 @@ -goog.provide('ol.renderer.Type'); - - +/** + * @module ol/renderer/Type + */ /** * Available renderers: `'canvas'` or `'webgl'`. * @enum {string} */ -ol.renderer.Type = { +var _ol_renderer_Type_ = { CANVAS: 'canvas', WEBGL: 'webgl' }; + +export default _ol_renderer_Type_; diff --git a/src/ol/renderer/canvas/ImageLayer.js b/src/ol/renderer/canvas/ImageLayer.js index dd4043ba44..957a644301 100644 --- a/src/ol/renderer/canvas/ImageLayer.js +++ b/src/ol/renderer/canvas/ImageLayer.js @@ -1,18 +1,18 @@ -goog.provide('ol.renderer.canvas.ImageLayer'); - -goog.require('ol'); -goog.require('ol.ImageCanvas'); -goog.require('ol.LayerType'); -goog.require('ol.ViewHint'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.layer.VectorRenderType'); -goog.require('ol.obj'); -goog.require('ol.plugins'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.canvas.IntermediateCanvas'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/canvas/ImageLayer + */ +import _ol_ from '../../index.js'; +import _ol_ImageCanvas_ from '../../ImageCanvas.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_ViewHint_ from '../../ViewHint.js'; +import _ol_array_ from '../../array.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_layer_VectorRenderType_ from '../../layer/VectorRenderType.js'; +import _ol_obj_ from '../../obj.js'; +import _ol_plugins_ from '../../plugins.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_canvas_IntermediateCanvas_ from '../canvas/IntermediateCanvas.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -20,9 +20,9 @@ goog.require('ol.transform'); * @param {ol.layer.Image} imageLayer Single image layer. * @api */ -ol.renderer.canvas.ImageLayer = function(imageLayer) { +var _ol_renderer_canvas_ImageLayer_ = function(imageLayer) { - ol.renderer.canvas.IntermediateCanvas.call(this, imageLayer); + _ol_renderer_canvas_IntermediateCanvas_.call(this, imageLayer); /** * @private @@ -34,7 +34,7 @@ ol.renderer.canvas.ImageLayer = function(imageLayer) { * @private * @type {ol.Transform} */ - this.imageTransform_ = ol.transform.create(); + this.imageTransform_ = _ol_transform_.create(); /** * @type {!Array.} @@ -48,7 +48,8 @@ ol.renderer.canvas.ImageLayer = function(imageLayer) { this.vectorRenderer_ = null; }; -ol.inherits(ol.renderer.canvas.ImageLayer, ol.renderer.canvas.IntermediateCanvas); + +_ol_.inherits(_ol_renderer_canvas_ImageLayer_, _ol_renderer_canvas_IntermediateCanvas_); /** @@ -57,10 +58,10 @@ ol.inherits(ol.renderer.canvas.ImageLayer, ol.renderer.canvas.IntermediateCanvas * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.canvas.ImageLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.CANVAS && (layer.getType() === ol.LayerType.IMAGE || - layer.getType() === ol.LayerType.VECTOR && - /** @type {ol.layer.Vector} */ (layer).getRenderMode() === ol.layer.VectorRenderType.IMAGE); +_ol_renderer_canvas_ImageLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.CANVAS && (layer.getType() === _ol_LayerType_.IMAGE || + layer.getType() === _ol_LayerType_.VECTOR && + /** @type {ol.layer.Vector} */ (layer).getRenderMode() === _ol_layer_VectorRenderType_.IMAGE); }; @@ -70,13 +71,13 @@ ol.renderer.canvas.ImageLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.canvas.ImageLayer} The layer renderer. */ -ol.renderer.canvas.ImageLayer['create'] = function(mapRenderer, layer) { - var renderer = new ol.renderer.canvas.ImageLayer(/** @type {ol.layer.Image} */ (layer)); - if (layer.getType() === ol.LayerType.VECTOR) { - var candidates = ol.plugins.getLayerRendererPlugins(); +_ol_renderer_canvas_ImageLayer_['create'] = function(mapRenderer, layer) { + var renderer = new _ol_renderer_canvas_ImageLayer_(/** @type {ol.layer.Image} */ (layer)); + if (layer.getType() === _ol_LayerType_.VECTOR) { + var candidates = _ol_plugins_.getLayerRendererPlugins(); for (var i = 0, ii = candidates.length; i < ii; ++i) { var candidate = /** @type {Object.} */ (candidates[i]); - if (candidate !== ol.renderer.canvas.ImageLayer && candidate['handles'](ol.renderer.Type.CANVAS, layer)) { + if (candidate !== _ol_renderer_canvas_ImageLayer_ && candidate['handles'](_ol_renderer_Type_.CANVAS, layer)) { renderer.setVectorRenderer(candidate['create'](mapRenderer, layer)); } } @@ -88,7 +89,7 @@ ol.renderer.canvas.ImageLayer['create'] = function(mapRenderer, layer) { /** * @inheritDoc */ -ol.renderer.canvas.ImageLayer.prototype.getImage = function() { +_ol_renderer_canvas_ImageLayer_.prototype.getImage = function() { return !this.image_ ? null : this.image_.getImage(); }; @@ -96,7 +97,7 @@ ol.renderer.canvas.ImageLayer.prototype.getImage = function() { /** * @inheritDoc */ -ol.renderer.canvas.ImageLayer.prototype.getImageTransform = function() { +_ol_renderer_canvas_ImageLayer_.prototype.getImageTransform = function() { return this.imageTransform_; }; @@ -104,7 +105,7 @@ ol.renderer.canvas.ImageLayer.prototype.getImageTransform = function() { /** * @inheritDoc */ -ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, layerState) { +_ol_renderer_canvas_ImageLayer_.prototype.prepareFrame = function(frameState, layerState) { var pixelRatio = frameState.pixelRatio; var size = frameState.size; @@ -120,14 +121,14 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye var renderedExtent = frameState.extent; if (layerState.extent !== undefined) { - renderedExtent = ol.extent.getIntersection( + renderedExtent = _ol_extent_.getIntersection( renderedExtent, layerState.extent); } - if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] && - !ol.extent.isEmpty(renderedExtent)) { + if (!hints[_ol_ViewHint_.ANIMATING] && !hints[_ol_ViewHint_.INTERACTING] && + !_ol_extent_.isEmpty(renderedExtent)) { var projection = viewState.projection; - if (!ol.ENABLE_RASTER_REPROJECTION) { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { var sourceProjection = imageSource.getProjection(); if (sourceProjection) { projection = sourceProjection; @@ -136,23 +137,23 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye var vectorRenderer = this.vectorRenderer_; if (vectorRenderer) { var context = vectorRenderer.context; - var imageFrameState = /** @type {olx.FrameState} */ (ol.obj.assign({}, frameState, { + var imageFrameState = /** @type {olx.FrameState} */ (_ol_obj_.assign({}, frameState, { size: [ - ol.extent.getWidth(renderedExtent) / viewResolution, - ol.extent.getHeight(renderedExtent) / viewResolution + _ol_extent_.getWidth(renderedExtent) / viewResolution, + _ol_extent_.getHeight(renderedExtent) / viewResolution ], - viewState: /** @type {olx.ViewState} */ (ol.obj.assign({}, frameState.viewState, { + viewState: /** @type {olx.ViewState} */ (_ol_obj_.assign({}, frameState.viewState, { rotation: 0 })) })); var skippedFeatures = Object.keys(imageFrameState.skippedFeatureUids).sort(); if (vectorRenderer.prepareFrame(imageFrameState, layerState) && (vectorRenderer.replayGroupChanged || - !ol.array.equals(skippedFeatures, this.skippedFeatures_))) { + !_ol_array_.equals(skippedFeatures, this.skippedFeatures_))) { context.canvas.width = imageFrameState.size[0] * pixelRatio; context.canvas.height = imageFrameState.size[1] * pixelRatio; vectorRenderer.composeFrame(imageFrameState, layerState, context); - this.image_ = new ol.ImageCanvas(renderedExtent, viewResolution, pixelRatio, context.canvas); + this.image_ = new _ol_ImageCanvas_(renderedExtent, viewResolution, pixelRatio, context.canvas); this.skippedFeatures_ = skippedFeatures; } } else { @@ -174,13 +175,13 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye var imagePixelRatio = image.getPixelRatio(); var scale = pixelRatio * imageResolution / (viewResolution * imagePixelRatio); - var transform = ol.transform.compose(this.imageTransform_, + var transform = _ol_transform_.compose(this.imageTransform_, pixelRatio * size[0] / 2, pixelRatio * size[1] / 2, scale, scale, 0, imagePixelRatio * (imageExtent[0] - viewCenter[0]) / imageResolution, imagePixelRatio * (viewCenter[1] - imageExtent[3]) / imageResolution); - ol.transform.compose(this.coordinateToCanvasPixelTransform, + _ol_transform_.compose(this.coordinateToCanvasPixelTransform, pixelRatio * size[0] / 2 - transform[4], pixelRatio * size[1] / 2 - transform[5], pixelRatio / viewResolution, -pixelRatio / viewResolution, 0, @@ -197,11 +198,11 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye /** * @inheritDoc */ -ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_canvas_ImageLayer_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { if (this.vectorRenderer_) { return this.vectorRenderer_.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback, thisArg); } else { - return ol.renderer.canvas.IntermediateCanvas.prototype.forEachFeatureAtCoordinate.call(this, coordinate, frameState, hitTolerance, callback, thisArg); + return _ol_renderer_canvas_IntermediateCanvas_.prototype.forEachFeatureAtCoordinate.call(this, coordinate, frameState, hitTolerance, callback, thisArg); } }; @@ -209,6 +210,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate = function(co /** * @param {ol.renderer.canvas.VectorLayer} renderer Vector renderer. */ -ol.renderer.canvas.ImageLayer.prototype.setVectorRenderer = function(renderer) { +_ol_renderer_canvas_ImageLayer_.prototype.setVectorRenderer = function(renderer) { this.vectorRenderer_ = renderer; }; +export default _ol_renderer_canvas_ImageLayer_; diff --git a/src/ol/renderer/canvas/IntermediateCanvas.js b/src/ol/renderer/canvas/IntermediateCanvas.js index f8573ddcbe..e4241cd82b 100644 --- a/src/ol/renderer/canvas/IntermediateCanvas.js +++ b/src/ol/renderer/canvas/IntermediateCanvas.js @@ -1,12 +1,12 @@ -goog.provide('ol.renderer.canvas.IntermediateCanvas'); - -goog.require('ol'); -goog.require('ol.coordinate'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.renderer.canvas.Layer'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/canvas/IntermediateCanvas + */ +import _ol_ from '../../index.js'; +import _ol_coordinate_ from '../../coordinate.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_renderer_canvas_Layer_ from '../canvas/Layer.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -14,15 +14,15 @@ goog.require('ol.transform'); * @extends {ol.renderer.canvas.Layer} * @param {ol.layer.Layer} layer Layer. */ -ol.renderer.canvas.IntermediateCanvas = function(layer) { +var _ol_renderer_canvas_IntermediateCanvas_ = function(layer) { - ol.renderer.canvas.Layer.call(this, layer); + _ol_renderer_canvas_Layer_.call(this, layer); /** * @protected * @type {ol.Transform} */ - this.coordinateToCanvasPixelTransform = ol.transform.create(); + this.coordinateToCanvasPixelTransform = _ol_transform_.create(); /** * @private @@ -31,13 +31,14 @@ ol.renderer.canvas.IntermediateCanvas = function(layer) { this.hitCanvasContext_ = null; }; -ol.inherits(ol.renderer.canvas.IntermediateCanvas, ol.renderer.canvas.Layer); + +_ol_.inherits(_ol_renderer_canvas_IntermediateCanvas_, _ol_renderer_canvas_Layer_); /** * @inheritDoc */ -ol.renderer.canvas.IntermediateCanvas.prototype.composeFrame = function(frameState, layerState, context) { +_ol_renderer_canvas_IntermediateCanvas_.prototype.composeFrame = function(frameState, layerState, context) { this.preCompose(context, frameState); @@ -47,8 +48,8 @@ ol.renderer.canvas.IntermediateCanvas.prototype.composeFrame = function(frameSta // clipped rendering if layer extent is set var extent = layerState.extent; var clipped = extent !== undefined && - !ol.extent.containsExtent(extent, frameState.extent) && - ol.extent.intersects(extent, frameState.extent); + !_ol_extent_.containsExtent(extent, frameState.extent) && + _ol_extent_.intersects(extent, frameState.extent); if (clipped) { this.clip(context, frameState, /** @type {ol.Extent} */ (extent)); } @@ -83,20 +84,20 @@ ol.renderer.canvas.IntermediateCanvas.prototype.composeFrame = function(frameSta * @abstract * @return {HTMLCanvasElement|HTMLVideoElement|Image} Canvas. */ -ol.renderer.canvas.IntermediateCanvas.prototype.getImage = function() {}; +_ol_renderer_canvas_IntermediateCanvas_.prototype.getImage = function() {}; /** * @abstract * @return {!ol.Transform} Image transform. */ -ol.renderer.canvas.IntermediateCanvas.prototype.getImageTransform = function() {}; +_ol_renderer_canvas_IntermediateCanvas_.prototype.getImageTransform = function() {}; /** * @inheritDoc */ -ol.renderer.canvas.IntermediateCanvas.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_canvas_IntermediateCanvas_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { var layer = this.getLayer(); var source = layer.getSource(); var resolution = frameState.viewState.resolution; @@ -117,21 +118,21 @@ ol.renderer.canvas.IntermediateCanvas.prototype.forEachFeatureAtCoordinate = fun /** * @inheritDoc */ -ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) { +_ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) { if (!this.getImage()) { return undefined; } - if (this.getLayer().getSource().forEachFeatureAtCoordinate !== ol.nullFunction) { + if (this.getLayer().getSource().forEachFeatureAtCoordinate !== _ol_.nullFunction) { // for ImageCanvas sources use the original hit-detection logic, // so that for example also transparent polygons are detected - return ol.renderer.canvas.Layer.prototype.forEachLayerAtCoordinate.apply(this, arguments); + return _ol_renderer_canvas_Layer_.prototype.forEachLayerAtCoordinate.apply(this, arguments); } else { - var pixel = ol.transform.apply(this.coordinateToCanvasPixelTransform, coordinate.slice()); - ol.coordinate.scale(pixel, frameState.viewState.resolution / this.renderedResolution); + var pixel = _ol_transform_.apply(this.coordinateToCanvasPixelTransform, coordinate.slice()); + _ol_coordinate_.scale(pixel, frameState.viewState.resolution / this.renderedResolution); if (!this.hitCanvasContext_) { - this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1); + this.hitCanvasContext_ = _ol_dom_.createCanvasContext2D(1, 1); } this.hitCanvasContext_.clearRect(0, 0, 1, 1); @@ -145,3 +146,4 @@ ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = funct } } }; +export default _ol_renderer_canvas_IntermediateCanvas_; diff --git a/src/ol/renderer/canvas/Layer.js b/src/ol/renderer/canvas/Layer.js index 8ddd277ce5..0556a3194f 100644 --- a/src/ol/renderer/canvas/Layer.js +++ b/src/ol/renderer/canvas/Layer.js @@ -1,15 +1,15 @@ -goog.provide('ol.renderer.canvas.Layer'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.render.Event'); -goog.require('ol.render.EventType'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.Immediate'); -goog.require('ol.renderer.Layer'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/canvas/Layer + */ +import _ol_ from '../../index.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_functions_ from '../../functions.js'; +import _ol_render_Event_ from '../../render/Event.js'; +import _ol_render_EventType_ from '../../render/EventType.js'; +import _ol_render_canvas_ from '../../render/canvas.js'; +import _ol_render_canvas_Immediate_ from '../../render/canvas/Immediate.js'; +import _ol_renderer_Layer_ from '../Layer.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -17,9 +17,9 @@ goog.require('ol.transform'); * @extends {ol.renderer.Layer} * @param {ol.layer.Layer} layer Layer. */ -ol.renderer.canvas.Layer = function(layer) { +var _ol_renderer_canvas_Layer_ = function(layer) { - ol.renderer.Layer.call(this, layer); + _ol_renderer_Layer_.call(this, layer); /** * @protected @@ -31,10 +31,11 @@ ol.renderer.canvas.Layer = function(layer) { * @private * @type {ol.Transform} */ - this.transform_ = ol.transform.create(); + this.transform_ = _ol_transform_.create(); }; -ol.inherits(ol.renderer.canvas.Layer, ol.renderer.Layer); + +_ol_.inherits(_ol_renderer_canvas_Layer_, _ol_renderer_Layer_); /** @@ -43,30 +44,30 @@ ol.inherits(ol.renderer.canvas.Layer, ol.renderer.Layer); * @param {ol.Extent} extent Clip extent. * @protected */ -ol.renderer.canvas.Layer.prototype.clip = function(context, frameState, extent) { +_ol_renderer_canvas_Layer_.prototype.clip = function(context, frameState, extent) { var pixelRatio = frameState.pixelRatio; var width = frameState.size[0] * pixelRatio; var height = frameState.size[1] * pixelRatio; var rotation = frameState.viewState.rotation; - var topLeft = ol.extent.getTopLeft(/** @type {ol.Extent} */ (extent)); - var topRight = ol.extent.getTopRight(/** @type {ol.Extent} */ (extent)); - var bottomRight = ol.extent.getBottomRight(/** @type {ol.Extent} */ (extent)); - var bottomLeft = ol.extent.getBottomLeft(/** @type {ol.Extent} */ (extent)); + var topLeft = _ol_extent_.getTopLeft(/** @type {ol.Extent} */ (extent)); + var topRight = _ol_extent_.getTopRight(/** @type {ol.Extent} */ (extent)); + var bottomRight = _ol_extent_.getBottomRight(/** @type {ol.Extent} */ (extent)); + var bottomLeft = _ol_extent_.getBottomLeft(/** @type {ol.Extent} */ (extent)); - ol.transform.apply(frameState.coordinateToPixelTransform, topLeft); - ol.transform.apply(frameState.coordinateToPixelTransform, topRight); - ol.transform.apply(frameState.coordinateToPixelTransform, bottomRight); - ol.transform.apply(frameState.coordinateToPixelTransform, bottomLeft); + _ol_transform_.apply(frameState.coordinateToPixelTransform, topLeft); + _ol_transform_.apply(frameState.coordinateToPixelTransform, topRight); + _ol_transform_.apply(frameState.coordinateToPixelTransform, bottomRight); + _ol_transform_.apply(frameState.coordinateToPixelTransform, bottomLeft); context.save(); - ol.render.canvas.rotateAtOffset(context, -rotation, width / 2, height / 2); + _ol_render_canvas_.rotateAtOffset(context, -rotation, width / 2, height / 2); context.beginPath(); context.moveTo(topLeft[0] * pixelRatio, topLeft[1] * pixelRatio); context.lineTo(topRight[0] * pixelRatio, topRight[1] * pixelRatio); context.lineTo(bottomRight[0] * pixelRatio, bottomRight[1] * pixelRatio); context.lineTo(bottomLeft[0] * pixelRatio, bottomLeft[1] * pixelRatio); context.clip(); - ol.render.canvas.rotateAtOffset(context, rotation, width / 2, height / 2); + _ol_render_canvas_.rotateAtOffset(context, rotation, width / 2, height / 2); }; @@ -77,22 +78,22 @@ ol.renderer.canvas.Layer.prototype.clip = function(context, frameState, extent) * @param {ol.Transform=} opt_transform Transform. * @private */ -ol.renderer.canvas.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState, opt_transform) { +_ol_renderer_canvas_Layer_.prototype.dispatchComposeEvent_ = function(type, context, frameState, opt_transform) { var layer = this.getLayer(); if (layer.hasListener(type)) { var width = frameState.size[0] * frameState.pixelRatio; var height = frameState.size[1] * frameState.pixelRatio; var rotation = frameState.viewState.rotation; - ol.render.canvas.rotateAtOffset(context, -rotation, width / 2, height / 2); + _ol_render_canvas_.rotateAtOffset(context, -rotation, width / 2, height / 2); var transform = opt_transform !== undefined ? opt_transform : this.getTransform(frameState, 0); - var render = new ol.render.canvas.Immediate( + var render = new _ol_render_canvas_Immediate_( context, frameState.pixelRatio, frameState.extent, transform, frameState.viewState.rotation); - var composeEvent = new ol.render.Event(type, render, frameState, + var composeEvent = new _ol_render_Event_(type, render, frameState, context, null); layer.dispatchEvent(composeEvent); - ol.render.canvas.rotateAtOffset(context, rotation, width / 2, height / 2); + _ol_render_canvas_.rotateAtOffset(context, rotation, width / 2, height / 2); } }; @@ -106,9 +107,9 @@ ol.renderer.canvas.Layer.prototype.dispatchComposeEvent_ = function(type, contex * @return {T|undefined} Callback result. * @template S,T,U */ -ol.renderer.canvas.Layer.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) { +_ol_renderer_canvas_Layer_.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) { var hasFeature = this.forEachFeatureAtCoordinate( - coordinate, frameState, 0, ol.functions.TRUE, this); + coordinate, frameState, 0, _ol_functions_.TRUE, this); if (hasFeature) { return callback.call(thisArg, this.getLayer(), null); @@ -125,8 +126,8 @@ ol.renderer.canvas.Layer.prototype.forEachLayerAtCoordinate = function(coordinat * @param {ol.Transform=} opt_transform Transform. * @protected */ -ol.renderer.canvas.Layer.prototype.postCompose = function(context, frameState, layerState, opt_transform) { - this.dispatchComposeEvent_(ol.render.EventType.POSTCOMPOSE, context, +_ol_renderer_canvas_Layer_.prototype.postCompose = function(context, frameState, layerState, opt_transform) { + this.dispatchComposeEvent_(_ol_render_EventType_.POSTCOMPOSE, context, frameState, opt_transform); }; @@ -137,8 +138,8 @@ ol.renderer.canvas.Layer.prototype.postCompose = function(context, frameState, l * @param {ol.Transform=} opt_transform Transform. * @protected */ -ol.renderer.canvas.Layer.prototype.preCompose = function(context, frameState, opt_transform) { - this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, context, +_ol_renderer_canvas_Layer_.prototype.preCompose = function(context, frameState, opt_transform) { + this.dispatchComposeEvent_(_ol_render_EventType_.PRECOMPOSE, context, frameState, opt_transform); }; @@ -149,8 +150,8 @@ ol.renderer.canvas.Layer.prototype.preCompose = function(context, frameState, op * @param {ol.Transform=} opt_transform Transform. * @protected */ -ol.renderer.canvas.Layer.prototype.dispatchRenderEvent = function(context, frameState, opt_transform) { - this.dispatchComposeEvent_(ol.render.EventType.RENDER, context, +_ol_renderer_canvas_Layer_.prototype.dispatchRenderEvent = function(context, frameState, opt_transform) { + this.dispatchComposeEvent_(_ol_render_EventType_.RENDER, context, frameState, opt_transform); }; @@ -161,7 +162,7 @@ ol.renderer.canvas.Layer.prototype.dispatchRenderEvent = function(context, frame * @protected * @return {!ol.Transform} Transform. */ -ol.renderer.canvas.Layer.prototype.getTransform = function(frameState, offsetX) { +_ol_renderer_canvas_Layer_.prototype.getTransform = function(frameState, offsetX) { var viewState = frameState.viewState; var pixelRatio = frameState.pixelRatio; var dx1 = pixelRatio * frameState.size[0] / 2; @@ -171,7 +172,7 @@ ol.renderer.canvas.Layer.prototype.getTransform = function(frameState, offsetX) var angle = -viewState.rotation; var dx2 = -viewState.center[0] + offsetX; var dy2 = -viewState.center[1]; - return ol.transform.compose(this.transform_, dx1, dy1, sx, sy, angle, dx2, dy2); + return _ol_transform_.compose(this.transform_, dx1, dy1, sx, sy, angle, dx2, dy2); }; @@ -181,7 +182,7 @@ ol.renderer.canvas.Layer.prototype.getTransform = function(frameState, offsetX) * @param {ol.LayerState} layerState Layer state. * @param {CanvasRenderingContext2D} context Context. */ -ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerState, context) {}; +_ol_renderer_canvas_Layer_.prototype.composeFrame = function(frameState, layerState, context) {}; /** * @abstract @@ -189,4 +190,5 @@ ol.renderer.canvas.Layer.prototype.composeFrame = function(frameState, layerStat * @param {ol.LayerState} layerState Layer state. * @return {boolean} whether composeFrame should be called. */ -ol.renderer.canvas.Layer.prototype.prepareFrame = function(frameState, layerState) {}; +_ol_renderer_canvas_Layer_.prototype.prepareFrame = function(frameState, layerState) {}; +export default _ol_renderer_canvas_Layer_; diff --git a/src/ol/renderer/canvas/Map.js b/src/ol/renderer/canvas/Map.js index 65f9b8c643..b612d0fafa 100644 --- a/src/ol/renderer/canvas/Map.js +++ b/src/ol/renderer/canvas/Map.js @@ -1,21 +1,21 @@ +/** + * @module ol/renderer/canvas/Map + */ // FIXME offset panning -goog.provide('ol.renderer.canvas.Map'); - -goog.require('ol.transform'); -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.layer.Layer'); -goog.require('ol.render.Event'); -goog.require('ol.render.EventType'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.Immediate'); -goog.require('ol.renderer.Map'); -goog.require('ol.renderer.Type'); -goog.require('ol.source.State'); - +import _ol_transform_ from '../../transform.js'; +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_css_ from '../../css.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_layer_Layer_ from '../../layer/Layer.js'; +import _ol_render_Event_ from '../../render/Event.js'; +import _ol_render_EventType_ from '../../render/EventType.js'; +import _ol_render_canvas_ from '../../render/canvas.js'; +import _ol_render_canvas_Immediate_ from '../../render/canvas/Immediate.js'; +import _ol_renderer_Map_ from '../Map.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_source_State_ from '../../source/State.js'; /** * @constructor @@ -24,15 +24,15 @@ goog.require('ol.source.State'); * @param {ol.PluggableMap} map Map. * @api */ -ol.renderer.canvas.Map = function(container, map) { +var _ol_renderer_canvas_Map_ = function(container, map) { - ol.renderer.Map.call(this, container, map); + _ol_renderer_Map_.call(this, container, map); /** * @private * @type {CanvasRenderingContext2D} */ - this.context_ = ol.dom.createCanvasContext2D(); + this.context_ = _ol_dom_.createCanvasContext2D(); /** * @private @@ -43,7 +43,7 @@ ol.renderer.canvas.Map = function(container, map) { this.canvas_.style.width = '100%'; this.canvas_.style.height = '100%'; this.canvas_.style.display = 'block'; - this.canvas_.className = ol.css.CLASS_UNSELECTABLE; + this.canvas_.className = _ol_css_.CLASS_UNSELECTABLE; container.insertBefore(this.canvas_, container.childNodes[0] || null); /** @@ -56,10 +56,11 @@ ol.renderer.canvas.Map = function(container, map) { * @private * @type {ol.Transform} */ - this.transform_ = ol.transform.create(); + this.transform_ = _ol_transform_.create(); }; -ol.inherits(ol.renderer.canvas.Map, ol.renderer.Map); + +_ol_.inherits(_ol_renderer_canvas_Map_, _ol_renderer_Map_); /** @@ -67,8 +68,8 @@ ol.inherits(ol.renderer.canvas.Map, ol.renderer.Map); * @param {ol.renderer.Type} type The renderer type. * @return {boolean} The renderer can render the layer. */ -ol.renderer.canvas.Map['handles'] = function(type) { - return type === ol.renderer.Type.CANVAS; +_ol_renderer_canvas_Map_['handles'] = function(type) { + return type === _ol_renderer_Type_.CANVAS; }; @@ -78,8 +79,8 @@ ol.renderer.canvas.Map['handles'] = function(type) { * @param {ol.PluggableMap} map Map. * @return {ol.renderer.canvas.Map} The map renderer. */ -ol.renderer.canvas.Map['create'] = function(container, map) { - return new ol.renderer.canvas.Map(container, map); +_ol_renderer_canvas_Map_['create'] = function(container, map) { + return new _ol_renderer_canvas_Map_(container, map); }; @@ -88,7 +89,7 @@ ol.renderer.canvas.Map['create'] = function(container, map) { * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ = function(type, frameState) { +_ol_renderer_canvas_Map_.prototype.dispatchComposeEvent_ = function(type, frameState) { var map = this.getMap(); var context = this.context_; if (map.hasListener(type)) { @@ -99,9 +100,9 @@ ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ = function(type, frameSta var transform = this.getTransform(frameState); - var vectorContext = new ol.render.canvas.Immediate(context, pixelRatio, + var vectorContext = new _ol_render_canvas_Immediate_(context, pixelRatio, extent, transform, rotation); - var composeEvent = new ol.render.Event(type, vectorContext, + var composeEvent = new _ol_render_Event_(type, vectorContext, frameState, context, null); map.dispatchEvent(composeEvent); } @@ -113,7 +114,7 @@ ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ = function(type, frameSta * @protected * @return {!ol.Transform} Transform. */ -ol.renderer.canvas.Map.prototype.getTransform = function(frameState) { +_ol_renderer_canvas_Map_.prototype.getTransform = function(frameState) { var viewState = frameState.viewState; var dx1 = this.canvas_.width / 2; var dy1 = this.canvas_.height / 2; @@ -122,22 +123,22 @@ ol.renderer.canvas.Map.prototype.getTransform = function(frameState) { var angle = -viewState.rotation; var dx2 = -viewState.center[0]; var dy2 = -viewState.center[1]; - return ol.transform.compose(this.transform_, dx1, dy1, sx, sy, angle, dx2, dy2); + return _ol_transform_.compose(this.transform_, dx1, dy1, sx, sy, angle, dx2, dy2); }; /** * @inheritDoc */ -ol.renderer.canvas.Map.prototype.getType = function() { - return ol.renderer.Type.CANVAS; +_ol_renderer_canvas_Map_.prototype.getType = function() { + return _ol_renderer_Type_.CANVAS; }; /** * @inheritDoc */ -ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { +_ol_renderer_canvas_Map_.prototype.renderFrame = function(frameState) { if (!frameState) { if (this.renderedVisible_) { @@ -162,14 +163,14 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { this.calculateMatrices2D(frameState); - this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState); + this.dispatchComposeEvent_(_ol_render_EventType_.PRECOMPOSE, frameState); var layerStatesArray = frameState.layerStatesArray; - ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex); + _ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex); if (rotation) { context.save(); - ol.render.canvas.rotateAtOffset(context, rotation, width / 2, height / 2); + _ol_render_canvas_.rotateAtOffset(context, rotation, width / 2, height / 2); } var viewResolution = frameState.viewState.resolution; @@ -178,8 +179,8 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { layerState = layerStatesArray[i]; layer = layerState.layer; layerRenderer = /** @type {ol.renderer.canvas.Layer} */ (this.getLayerRenderer(layer)); - if (!ol.layer.Layer.visibleAtResolution(layerState, viewResolution) || - layerState.sourceState != ol.source.State.READY) { + if (!_ol_layer_Layer_.visibleAtResolution(layerState, viewResolution) || + layerState.sourceState != _ol_source_State_.READY) { continue; } if (layerRenderer.prepareFrame(frameState, layerState)) { @@ -192,7 +193,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { } this.dispatchComposeEvent_( - ol.render.EventType.POSTCOMPOSE, frameState); + _ol_render_EventType_.POSTCOMPOSE, frameState); if (!this.renderedVisible_) { this.canvas_.style.display = ''; @@ -207,7 +208,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { /** * @inheritDoc */ -ol.renderer.canvas.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, +_ol_renderer_canvas_Map_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, layerFilter, thisArg2) { var result; var viewState = frameState.viewState; @@ -216,14 +217,14 @@ ol.renderer.canvas.Map.prototype.forEachLayerAtPixel = function(pixel, frameStat var layerStates = frameState.layerStatesArray; var numLayers = layerStates.length; - var coordinate = ol.transform.apply( + var coordinate = _ol_transform_.apply( frameState.pixelToCoordinateTransform, pixel.slice()); var i; for (i = numLayers - 1; i >= 0; --i) { var layerState = layerStates[i]; var layer = layerState.layer; - if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewResolution) && layerFilter.call(thisArg2, layer)) { var layerRenderer = /** @type {ol.renderer.canvas.Layer} */ (this.getLayerRenderer(layer)); result = layerRenderer.forEachLayerAtCoordinate( @@ -235,3 +236,4 @@ ol.renderer.canvas.Map.prototype.forEachLayerAtPixel = function(pixel, frameStat } return undefined; }; +export default _ol_renderer_canvas_Map_; diff --git a/src/ol/renderer/canvas/TileLayer.js b/src/ol/renderer/canvas/TileLayer.js index d8fcd7a898..f2712ada1d 100644 --- a/src/ol/renderer/canvas/TileLayer.js +++ b/src/ol/renderer/canvas/TileLayer.js @@ -1,16 +1,16 @@ -goog.provide('ol.renderer.canvas.TileLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.TileRange'); -goog.require('ol.TileState'); -goog.require('ol.ViewHint'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.canvas.IntermediateCanvas'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/canvas/TileLayer + */ +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_TileRange_ from '../../TileRange.js'; +import _ol_TileState_ from '../../TileState.js'; +import _ol_ViewHint_ from '../../ViewHint.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_canvas_IntermediateCanvas_ from '../canvas/IntermediateCanvas.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -18,15 +18,15 @@ goog.require('ol.transform'); * @param {ol.layer.Tile|ol.layer.VectorTile} tileLayer Tile layer. * @api */ -ol.renderer.canvas.TileLayer = function(tileLayer) { +var _ol_renderer_canvas_TileLayer_ = function(tileLayer) { - ol.renderer.canvas.IntermediateCanvas.call(this, tileLayer); + _ol_renderer_canvas_IntermediateCanvas_.call(this, tileLayer); /** * @protected * @type {CanvasRenderingContext2D} */ - this.context = this.context === null ? null : ol.dom.createCanvasContext2D(); + this.context = this.context === null ? null : _ol_dom_.createCanvasContext2D(); /** * @private @@ -56,19 +56,19 @@ ol.renderer.canvas.TileLayer = function(tileLayer) { * @protected * @type {ol.Extent} */ - this.tmpExtent = ol.extent.createEmpty(); + this.tmpExtent = _ol_extent_.createEmpty(); /** * @private * @type {ol.TileRange} */ - this.tmpTileRange_ = new ol.TileRange(0, 0, 0, 0); + this.tmpTileRange_ = new _ol_TileRange_(0, 0, 0, 0); /** * @private * @type {ol.Transform} */ - this.imageTransform_ = ol.transform.create(); + this.imageTransform_ = _ol_transform_.create(); /** * @protected @@ -77,7 +77,8 @@ ol.renderer.canvas.TileLayer = function(tileLayer) { this.zDirection = 0; }; -ol.inherits(ol.renderer.canvas.TileLayer, ol.renderer.canvas.IntermediateCanvas); + +_ol_.inherits(_ol_renderer_canvas_TileLayer_, _ol_renderer_canvas_IntermediateCanvas_); /** @@ -86,8 +87,8 @@ ol.inherits(ol.renderer.canvas.TileLayer, ol.renderer.canvas.IntermediateCanvas) * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.canvas.TileLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.CANVAS && layer.getType() === ol.LayerType.TILE; +_ol_renderer_canvas_TileLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.CANVAS && layer.getType() === _ol_LayerType_.TILE; }; @@ -97,8 +98,8 @@ ol.renderer.canvas.TileLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.canvas.TileLayer} The layer renderer. */ -ol.renderer.canvas.TileLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.canvas.TileLayer(/** @type {ol.layer.Tile} */ (layer)); +_ol_renderer_canvas_TileLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_canvas_TileLayer_(/** @type {ol.layer.Tile} */ (layer)); }; @@ -107,18 +108,18 @@ ol.renderer.canvas.TileLayer['create'] = function(mapRenderer, layer) { * @param {ol.Tile} tile Tile. * @return {boolean} Tile is drawable. */ -ol.renderer.canvas.TileLayer.prototype.isDrawableTile_ = function(tile) { +_ol_renderer_canvas_TileLayer_.prototype.isDrawableTile_ = function(tile) { var tileState = tile.getState(); var useInterimTilesOnError = this.getLayer().getUseInterimTilesOnError(); - return tileState == ol.TileState.LOADED || - tileState == ol.TileState.EMPTY || - tileState == ol.TileState.ERROR && !useInterimTilesOnError; + return tileState == _ol_TileState_.LOADED || + tileState == _ol_TileState_.EMPTY || + tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; }; /** * @inheritDoc */ -ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layerState) { +_ol_renderer_canvas_TileLayer_.prototype.prepareFrame = function(frameState, layerState) { var pixelRatio = frameState.pixelRatio; var size = frameState.size; @@ -137,9 +138,9 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer var extent = frameState.extent; if (layerState.extent !== undefined) { - extent = ol.extent.getIntersection(extent, layerState.extent); + extent = _ol_extent_.getIntersection(extent, layerState.extent); } - if (ol.extent.isEmpty(extent)) { + if (_ol_extent_.isEmpty(extent)) { // Return false to prevent the rendering of the layer. return false; } @@ -165,10 +166,10 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer for (x = tileRange.minX; x <= tileRange.maxX; ++x) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) { tile = tileSource.getTile(z, x, y, pixelRatio, projection); - if (tile.getState() == ol.TileState.ERROR) { + if (tile.getState() == _ol_TileState_.ERROR) { if (!tileLayer.getUseInterimTilesOnError()) { // When useInterimTilesOnError is false, we consider the error tile as loaded. - tile.setState(ol.TileState.LOADED); + tile.setState(_ol_TileState_.LOADED); } else if (tileLayer.getPreload() > 0) { // Preloaded tiles for lower resolutions might have finished loading. newTiles = true; @@ -178,8 +179,8 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer tile = tile.getInterimTile(); } if (this.isDrawableTile_(tile)) { - var uid = ol.getUid(this); - if (tile.getState() == ol.TileState.LOADED) { + var uid = _ol_.getUid(this); + if (tile.getState() == _ol_TileState_.LOADED) { tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; var inTransition = tile.inTransition(uid); if (!newTiles && (inTransition || this.renderedTiles.indexOf(tile) === -1)) { @@ -208,10 +209,10 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer var renderedResolution = tileResolution * pixelRatio / tilePixelRatio * oversampling; var hints = frameState.viewHints; - var animatingOrInteracting = hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING]; + var animatingOrInteracting = hints[_ol_ViewHint_.ANIMATING] || hints[_ol_ViewHint_.INTERACTING]; if (!(this.renderedResolution && Date.now() - frameState.time > 16 && animatingOrInteracting) && ( newTiles || - !(this.renderedExtent_ && ol.extent.containsExtent(this.renderedExtent_, extent)) || + !(this.renderedExtent_ && _ol_extent_.containsExtent(this.renderedExtent_, extent)) || this.renderedRevision != sourceRevision || oversampling != this.oversampling_ || !animatingOrInteracting && renderedResolution != this.renderedResolution @@ -228,7 +229,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer canvas.width = width; canvas.height = height; } else { - if (this.renderedExtent_ && !ol.extent.equals(imageExtent, this.renderedExtent_)) { + if (this.renderedExtent_ && !_ol_extent_.equals(imageExtent, this.renderedExtent_)) { context.clearRect(0, 0, width, height); } oversampling = this.oversampling_; @@ -274,13 +275,13 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer } var scale = this.renderedResolution / viewResolution; - var transform = ol.transform.compose(this.imageTransform_, + var transform = _ol_transform_.compose(this.imageTransform_, pixelRatio * size[0] / 2, pixelRatio * size[1] / 2, scale, scale, 0, (this.renderedExtent_[0] - viewCenter[0]) / this.renderedResolution * pixelRatio, (viewCenter[1] - this.renderedExtent_[3]) / this.renderedResolution * pixelRatio); - ol.transform.compose(this.coordinateToCanvasPixelTransform, + _ol_transform_.compose(this.coordinateToCanvasPixelTransform, pixelRatio * size[0] / 2 - transform[4], pixelRatio * size[1] / 2 - transform[5], pixelRatio / viewResolution, -pixelRatio / viewResolution, 0, @@ -308,12 +309,12 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer * @param {number} gutter Tile gutter. * @param {boolean} transition Apply an alpha transition. */ -ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState, layerState, x, y, w, h, gutter, transition) { +_ol_renderer_canvas_TileLayer_.prototype.drawTileImage = function(tile, frameState, layerState, x, y, w, h, gutter, transition) { var image = tile.getImage(this.getLayer()); if (!image) { return; } - var uid = ol.getUid(this); + var uid = _ol_.getUid(this); var alpha = transition ? tile.getAlpha(uid, frameState.time) : 1; if (alpha === 1 && !this.getLayer().getSource().getOpaque(frameState.viewState.projection)) { this.context.clearRect(x, y, w, h); @@ -340,7 +341,7 @@ ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState /** * @inheritDoc */ -ol.renderer.canvas.TileLayer.prototype.getImage = function() { +_ol_renderer_canvas_TileLayer_.prototype.getImage = function() { var context = this.context; return context ? context.canvas : null; }; @@ -350,12 +351,13 @@ ol.renderer.canvas.TileLayer.prototype.getImage = function() { * @function * @return {ol.layer.Tile|ol.layer.VectorTile} */ -ol.renderer.canvas.TileLayer.prototype.getLayer; +_ol_renderer_canvas_TileLayer_.prototype.getLayer; /** * @inheritDoc */ -ol.renderer.canvas.TileLayer.prototype.getImageTransform = function() { +_ol_renderer_canvas_TileLayer_.prototype.getImageTransform = function() { return this.imageTransform_; }; +export default _ol_renderer_canvas_TileLayer_; diff --git a/src/ol/renderer/canvas/VectorLayer.js b/src/ol/renderer/canvas/VectorLayer.js index 6372dac53f..4c079d34f4 100644 --- a/src/ol/renderer/canvas/VectorLayer.js +++ b/src/ol/renderer/canvas/VectorLayer.js @@ -1,20 +1,20 @@ -goog.provide('ol.renderer.canvas.VectorLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.ViewHint'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.ext.rbush'); -goog.require('ol.extent'); -goog.require('ol.render.EventType'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.ReplayGroup'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.canvas.Layer'); -goog.require('ol.renderer.vector'); - +/** + * @module ol/renderer/canvas/VectorLayer + */ +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_ViewHint_ from '../../ViewHint.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_events_ from '../../events.js'; +import _ol_events_EventType_ from '../../events/EventType.js'; +import _ol_ext_rbush_ from 'rbush'; +import _ol_extent_ from '../../extent.js'; +import _ol_render_EventType_ from '../../render/EventType.js'; +import _ol_render_canvas_ from '../../render/canvas.js'; +import _ol_render_canvas_ReplayGroup_ from '../../render/canvas/ReplayGroup.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_canvas_Layer_ from '../canvas/Layer.js'; +import _ol_renderer_vector_ from '../vector.js'; /** * @constructor @@ -22,16 +22,16 @@ goog.require('ol.renderer.vector'); * @param {ol.layer.Vector} vectorLayer Vector layer. * @api */ -ol.renderer.canvas.VectorLayer = function(vectorLayer) { +var _ol_renderer_canvas_VectorLayer_ = function(vectorLayer) { - ol.renderer.canvas.Layer.call(this, vectorLayer); + _ol_renderer_canvas_Layer_.call(this, vectorLayer); /** * Declutter tree. * @private */ this.declutterTree_ = vectorLayer.getDeclutter() ? - ol.ext.rbush(9) : null; + _ol_ext_rbush_(9) : null; /** * @private @@ -55,7 +55,7 @@ ol.renderer.canvas.VectorLayer = function(vectorLayer) { * @private * @type {ol.Extent} */ - this.renderedExtent_ = ol.extent.createEmpty(); + this.renderedExtent_ = _ol_extent_.createEmpty(); /** * @private @@ -78,12 +78,13 @@ ol.renderer.canvas.VectorLayer = function(vectorLayer) { /** * @type {CanvasRenderingContext2D} */ - this.context = ol.dom.createCanvasContext2D(); + this.context = _ol_dom_.createCanvasContext2D(); - ol.events.listen(ol.render.canvas.labelCache, ol.events.EventType.CLEAR, this.handleFontsChanged_, this); + _ol_events_.listen(_ol_render_canvas_.labelCache, _ol_events_EventType_.CLEAR, this.handleFontsChanged_, this); }; -ol.inherits(ol.renderer.canvas.VectorLayer, ol.renderer.canvas.Layer); + +_ol_.inherits(_ol_renderer_canvas_VectorLayer_, _ol_renderer_canvas_Layer_); /** @@ -92,8 +93,8 @@ ol.inherits(ol.renderer.canvas.VectorLayer, ol.renderer.canvas.Layer); * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.canvas.VectorLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.CANVAS && layer.getType() === ol.LayerType.VECTOR; +_ol_renderer_canvas_VectorLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.CANVAS && layer.getType() === _ol_LayerType_.VECTOR; }; @@ -103,24 +104,24 @@ ol.renderer.canvas.VectorLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.canvas.VectorLayer} The layer renderer. */ -ol.renderer.canvas.VectorLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.canvas.VectorLayer(/** @type {ol.layer.Vector} */ (layer)); +_ol_renderer_canvas_VectorLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_canvas_VectorLayer_(/** @type {ol.layer.Vector} */ (layer)); }; /** * @inheritDoc */ -ol.renderer.canvas.VectorLayer.prototype.disposeInternal = function() { - ol.events.unlisten(ol.render.canvas.labelCache, ol.events.EventType.CLEAR, this.handleFontsChanged_, this); - ol.renderer.canvas.Layer.prototype.disposeInternal.call(this); +_ol_renderer_canvas_VectorLayer_.prototype.disposeInternal = function() { + _ol_events_.unlisten(_ol_render_canvas_.labelCache, _ol_events_EventType_.CLEAR, this.handleFontsChanged_, this); + _ol_renderer_canvas_Layer_.prototype.disposeInternal.call(this); }; /** * @inheritDoc */ -ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, layerState, context) { +_ol_renderer_canvas_VectorLayer_.prototype.composeFrame = function(frameState, layerState, context) { var extent = frameState.extent; var pixelRatio = frameState.pixelRatio; @@ -152,7 +153,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay var drawOffsetY = 0; var replayContext; var transparentLayer = layerState.opacity !== 1; - var hasRenderListeners = layer.hasListener(ol.render.EventType.RENDER); + var hasRenderListeners = layer.hasListener(_ol_render_EventType_.RENDER); if (transparentLayer || hasRenderListeners) { var drawWidth = context.canvas.width; var drawHeight = context.canvas.height; @@ -184,13 +185,13 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay var width = frameState.size[0] * pixelRatio; var height = frameState.size[1] * pixelRatio; - ol.render.canvas.rotateAtOffset(replayContext, -rotation, + _ol_render_canvas_.rotateAtOffset(replayContext, -rotation, width / 2, height / 2); replayGroup.replay(replayContext, transform, rotation, skippedFeatureUids); if (vectorSource.getWrapX() && projection.canWrapX() && - !ol.extent.containsExtent(projectionExtent, extent)) { + !_ol_extent_.containsExtent(projectionExtent, extent)) { var startX = extent[0]; - var worldWidth = ol.extent.getWidth(projectionExtent); + var worldWidth = _ol_extent_.getWidth(projectionExtent); var world = 0; var offsetX; while (startX < projectionExtent[0]) { @@ -212,7 +213,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay // restore original transform for render and compose events transform = this.getTransform(frameState, 0); } - ol.render.canvas.rotateAtOffset(replayContext, rotation, + _ol_render_canvas_.rotateAtOffset(replayContext, rotation, width / 2, height / 2); if (replayContext != context) { @@ -246,7 +247,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay /** * @inheritDoc */ -ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_canvas_VectorLayer_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { if (!this.replayGroup_) { return undefined; } else { @@ -262,7 +263,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(c * @return {?} Callback result. */ function(feature) { - var key = ol.getUid(feature).toString(); + var key = _ol_.getUid(feature).toString(); if (!(key in features)) { features[key] = true; return callback.call(thisArg, feature, layer); @@ -276,7 +277,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(c /** * @param {ol.events.Event} event Event. */ -ol.renderer.canvas.VectorLayer.prototype.handleFontsChanged_ = function(event) { +_ol_renderer_canvas_VectorLayer_.prototype.handleFontsChanged_ = function(event) { var layer = this.getLayer(); if (layer.getVisible() && this.replayGroup_) { layer.changed(); @@ -289,7 +290,7 @@ ol.renderer.canvas.VectorLayer.prototype.handleFontsChanged_ = function(event) { * @param {ol.events.Event} event Image style change event. * @private */ -ol.renderer.canvas.VectorLayer.prototype.handleStyleImageChange_ = function(event) { +_ol_renderer_canvas_VectorLayer_.prototype.handleStyleImageChange_ = function(event) { this.renderIfReadyAndVisible(); }; @@ -297,15 +298,15 @@ ol.renderer.canvas.VectorLayer.prototype.handleStyleImageChange_ = function(even /** * @inheritDoc */ -ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, layerState) { +_ol_renderer_canvas_VectorLayer_.prototype.prepareFrame = function(frameState, layerState) { var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer()); var vectorSource = vectorLayer.getSource(); this.updateLogos(frameState, vectorSource); - var animating = frameState.viewHints[ol.ViewHint.ANIMATING]; - var interacting = frameState.viewHints[ol.ViewHint.INTERACTING]; + var animating = frameState.viewHints[_ol_ViewHint_.ANIMATING]; + var interacting = frameState.viewHints[_ol_ViewHint_.INTERACTING]; var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); @@ -324,22 +325,22 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay var vectorLayerRenderOrder = vectorLayer.getRenderOrder(); if (vectorLayerRenderOrder === undefined) { - vectorLayerRenderOrder = ol.renderer.vector.defaultOrder; + vectorLayerRenderOrder = _ol_renderer_vector_.defaultOrder; } - var extent = ol.extent.buffer(frameStateExtent, + var extent = _ol_extent_.buffer(frameStateExtent, vectorLayerRenderBuffer * resolution); var projectionExtent = viewState.projection.getExtent(); if (vectorSource.getWrapX() && viewState.projection.canWrapX() && - !ol.extent.containsExtent(projectionExtent, frameState.extent)) { + !_ol_extent_.containsExtent(projectionExtent, frameState.extent)) { // For the replay group, we need an extent that intersects the real world // (-180° to +180°). To support geometries in a coordinate range from -540° // to +540°, we add at least 1 world width on each side of the projection // extent. If the viewport is wider than the world, we need to add half of // the viewport width to make sure we cover the whole viewport. - var worldWidth = ol.extent.getWidth(projectionExtent); - var buffer = Math.max(ol.extent.getWidth(extent) / 2, worldWidth); + var worldWidth = _ol_extent_.getWidth(projectionExtent); + var buffer = Math.max(_ol_extent_.getWidth(extent) / 2, worldWidth); extent[0] = projectionExtent[0] - buffer; extent[2] = projectionExtent[2] + buffer; } @@ -348,7 +349,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay this.renderedResolution_ == resolution && this.renderedRevision_ == vectorLayerRevision && this.renderedRenderOrder_ == vectorLayerRenderOrder && - ol.extent.containsExtent(this.renderedExtent_, extent)) { + _ol_extent_.containsExtent(this.renderedExtent_, extent)) { this.replayGroupChanged = false; return true; } @@ -357,8 +358,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay this.dirty_ = false; - var replayGroup = new ol.render.canvas.ReplayGroup( - ol.renderer.vector.getTolerance(resolution, pixelRatio), extent, resolution, + var replayGroup = new _ol_render_canvas_ReplayGroup_( + _ol_renderer_vector_.getTolerance(resolution, pixelRatio), extent, resolution, pixelRatio, vectorSource.getOverlaps(), this.declutterTree_, vectorLayer.getRenderBuffer()); vectorSource.loadFeatures(extent, resolution, projection); /** @@ -421,23 +422,24 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay * @param {ol.render.canvas.ReplayGroup} replayGroup Replay group. * @return {boolean} `true` if an image is loading. */ -ol.renderer.canvas.VectorLayer.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) { +_ol_renderer_canvas_VectorLayer_.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) { if (!styles) { return false; } var loading = false; if (Array.isArray(styles)) { for (var i = 0, ii = styles.length; i < ii; ++i) { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles[i], - ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio), + _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), this.handleStyleImageChange_, this) || loading; } } else { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles, - ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio), + _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), this.handleStyleImageChange_, this); } return loading; }; +export default _ol_renderer_canvas_VectorLayer_; diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index d77e440028..eaa796e12e 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -1,25 +1,25 @@ -goog.provide('ol.renderer.canvas.VectorTileLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.TileState'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.ext.rbush'); -goog.require('ol.extent'); -goog.require('ol.layer.VectorTileRenderType'); -goog.require('ol.proj'); -goog.require('ol.proj.Units'); -goog.require('ol.render.ReplayType'); -goog.require('ol.render.canvas'); -goog.require('ol.render.canvas.ReplayGroup'); -goog.require('ol.render.replay'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.renderer.vector'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/canvas/VectorTileLayer + */ +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_TileState_ from '../../TileState.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_events_ from '../../events.js'; +import _ol_events_EventType_ from '../../events/EventType.js'; +import _ol_ext_rbush_ from 'rbush'; +import _ol_extent_ from '../../extent.js'; +import _ol_layer_VectorTileRenderType_ from '../../layer/VectorTileRenderType.js'; +import _ol_proj_ from '../../proj.js'; +import _ol_proj_Units_ from '../../proj/Units.js'; +import _ol_render_ReplayType_ from '../../render/ReplayType.js'; +import _ol_render_canvas_ from '../../render/canvas.js'; +import _ol_render_canvas_ReplayGroup_ from '../../render/canvas/ReplayGroup.js'; +import _ol_render_replay_ from '../../render/replay.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_canvas_TileLayer_ from '../canvas/TileLayer.js'; +import _ol_renderer_vector_ from '../vector.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -27,20 +27,20 @@ goog.require('ol.transform'); * @param {ol.layer.VectorTile} layer VectorTile layer. * @api */ -ol.renderer.canvas.VectorTileLayer = function(layer) { +var _ol_renderer_canvas_VectorTileLayer_ = function(layer) { /** * @type {CanvasRenderingContext2D} */ this.context = null; - ol.renderer.canvas.TileLayer.call(this, layer); + _ol_renderer_canvas_TileLayer_.call(this, layer); /** * Declutter tree. * @private */ - this.declutterTree_ = layer.getDeclutter() ? ol.ext.rbush(9) : null; + this.declutterTree_ = layer.getDeclutter() ? _ol_ext_rbush_(9) : null; /** * @private @@ -58,16 +58,17 @@ ol.renderer.canvas.VectorTileLayer = function(layer) { * @private * @type {ol.Transform} */ - this.tmpTransform_ = ol.transform.create(); + this.tmpTransform_ = _ol_transform_.create(); // Use lower resolution for pure vector rendering. Closest resolution otherwise. this.zDirection = - layer.getRenderMode() == ol.layer.VectorTileRenderType.VECTOR ? 1 : 0; + layer.getRenderMode() == _ol_layer_VectorTileRenderType_.VECTOR ? 1 : 0; - ol.events.listen(ol.render.canvas.labelCache, ol.events.EventType.CLEAR, this.handleFontsChanged_, this); + _ol_events_.listen(_ol_render_canvas_.labelCache, _ol_events_EventType_.CLEAR, this.handleFontsChanged_, this); }; -ol.inherits(ol.renderer.canvas.VectorTileLayer, ol.renderer.canvas.TileLayer); + +_ol_.inherits(_ol_renderer_canvas_VectorTileLayer_, _ol_renderer_canvas_TileLayer_); /** @@ -76,8 +77,8 @@ ol.inherits(ol.renderer.canvas.VectorTileLayer, ol.renderer.canvas.TileLayer); * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.canvas.VectorTileLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.CANVAS && layer.getType() === ol.LayerType.VECTOR_TILE; +_ol_renderer_canvas_VectorTileLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.CANVAS && layer.getType() === _ol_LayerType_.VECTOR_TILE; }; @@ -87,8 +88,8 @@ ol.renderer.canvas.VectorTileLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.canvas.VectorTileLayer} The layer renderer. */ -ol.renderer.canvas.VectorTileLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.canvas.VectorTileLayer(/** @type {ol.layer.VectorTile} */ (layer)); +_ol_renderer_canvas_VectorTileLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_canvas_VectorTileLayer_(/** @type {ol.layer.VectorTile} */ (layer)); }; @@ -96,10 +97,10 @@ ol.renderer.canvas.VectorTileLayer['create'] = function(mapRenderer, layer) { * @const * @type {!Object.>} */ -ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS = { - 'image': [ol.render.ReplayType.POLYGON, ol.render.ReplayType.CIRCLE, - ol.render.ReplayType.LINE_STRING, ol.render.ReplayType.IMAGE, ol.render.ReplayType.TEXT], - 'hybrid': [ol.render.ReplayType.POLYGON, ol.render.ReplayType.LINE_STRING] +_ol_renderer_canvas_VectorTileLayer_.IMAGE_REPLAYS = { + 'image': [_ol_render_ReplayType_.POLYGON, _ol_render_ReplayType_.CIRCLE, + _ol_render_ReplayType_.LINE_STRING, _ol_render_ReplayType_.IMAGE, _ol_render_ReplayType_.TEXT], + 'hybrid': [_ol_render_ReplayType_.POLYGON, _ol_render_ReplayType_.LINE_STRING] }; @@ -107,40 +108,40 @@ ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS = { * @const * @type {!Object.>} */ -ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS = { - 'image': [ol.render.ReplayType.DEFAULT], - 'hybrid': [ol.render.ReplayType.IMAGE, ol.render.ReplayType.TEXT, ol.render.ReplayType.DEFAULT], - 'vector': ol.render.replay.ORDER +_ol_renderer_canvas_VectorTileLayer_.VECTOR_REPLAYS = { + 'image': [_ol_render_ReplayType_.DEFAULT], + 'hybrid': [_ol_render_ReplayType_.IMAGE, _ol_render_ReplayType_.TEXT, _ol_render_ReplayType_.DEFAULT], + 'vector': _ol_render_replay_.ORDER }; /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.disposeInternal = function() { - ol.events.unlisten(ol.render.canvas.labelCache, ol.events.EventType.CLEAR, this.handleFontsChanged_, this); - ol.renderer.canvas.TileLayer.prototype.disposeInternal.call(this); +_ol_renderer_canvas_VectorTileLayer_.prototype.disposeInternal = function() { + _ol_events_.unlisten(_ol_render_canvas_.labelCache, _ol_events_EventType_.CLEAR, this.handleFontsChanged_, this); + _ol_renderer_canvas_TileLayer_.prototype.disposeInternal.call(this); }; /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame = function(frameState, layerState) { +_ol_renderer_canvas_VectorTileLayer_.prototype.prepareFrame = function(frameState, layerState) { var layer = this.getLayer(); var layerRevision = layer.getRevision(); if (this.renderedLayerRevision_ != layerRevision) { this.renderedTiles.length = 0; var renderMode = layer.getRenderMode(); - if (!this.context && renderMode != ol.layer.VectorTileRenderType.VECTOR) { - this.context = ol.dom.createCanvasContext2D(); + if (!this.context && renderMode != _ol_layer_VectorTileRenderType_.VECTOR) { + this.context = _ol_dom_.createCanvasContext2D(); } - if (this.context && renderMode == ol.layer.VectorTileRenderType.VECTOR) { + if (this.context && renderMode == _ol_layer_VectorTileRenderType_.VECTOR) { this.context = null; } } this.renderedLayerRevision_ = layerRevision; - return ol.renderer.canvas.TileLayer.prototype.prepareFrame.apply(this, arguments); + return _ol_renderer_canvas_TileLayer_.prototype.prepareFrame.apply(this, arguments); }; @@ -149,7 +150,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame = function(frameState, * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function( +_ol_renderer_canvas_VectorTileLayer_.prototype.createReplayGroup_ = function( tile, frameState) { var layer = this.getLayer(); var pixelRatio = frameState.pixelRatio; @@ -173,25 +174,25 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function( var zIndexKeys = {}; for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == ol.TileState.ERROR) { + if (sourceTile.getState() == _ol_TileState_.ERROR) { continue; } var sourceTileCoord = sourceTile.tileCoord; var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord); - var sharedExtent = ol.extent.getIntersection(tileExtent, sourceTileExtent); - var bufferedExtent = ol.extent.equals(sourceTileExtent, sharedExtent) ? null : - ol.extent.buffer(sharedExtent, layer.getRenderBuffer() * resolution); + var sharedExtent = _ol_extent_.getIntersection(tileExtent, sourceTileExtent); + var bufferedExtent = _ol_extent_.equals(sourceTileExtent, sharedExtent) ? null : + _ol_extent_.buffer(sharedExtent, layer.getRenderBuffer() * resolution); var tileProjection = sourceTile.getProjection(); var reproject = false; - if (!ol.proj.equivalent(projection, tileProjection)) { + if (!_ol_proj_.equivalent(projection, tileProjection)) { reproject = true; sourceTile.setProjection(projection); } replayState.dirty = false; - var replayGroup = new ol.render.canvas.ReplayGroup(0, sharedExtent, resolution, + var replayGroup = new _ol_render_canvas_ReplayGroup_(0, sharedExtent, resolution, pixelRatio, source.getOverlaps(), this.declutterTree_, layer.getRenderBuffer()); - var squaredTolerance = ol.renderer.vector.getSquaredTolerance( + var squaredTolerance = _ol_renderer_vector_.getSquaredTolerance( resolution, pixelRatio); /** @@ -225,7 +226,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function( for (var i = 0, ii = features.length; i < ii; ++i) { feature = features[i]; if (reproject) { - if (tileProjection.getUnits() == ol.proj.Units.TILE_PIXELS) { + if (tileProjection.getUnits() == _ol_proj_Units_.TILE_PIXELS) { // projected tile extent tileProjection.setWorldExtent(sourceTileExtent); // tile extent in tile pixel space @@ -233,7 +234,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function( } feature.getGeometry().transform(tileProjection, projection); } - if (!bufferedExtent || ol.extent.intersects(bufferedExtent, feature.getGeometry().getExtent())) { + if (!bufferedExtent || _ol_extent_.intersects(bufferedExtent, feature.getGeometry().getExtent())) { renderFeature.call(this, feature); } } @@ -251,13 +252,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function( /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function( +_ol_renderer_canvas_VectorTileLayer_.prototype.drawTileImage = function( tile, frameState, layerState, x, y, w, h, gutter, transition) { var vectorImageTile = /** @type {ol.VectorImageTile} */ (tile); this.createReplayGroup_(vectorImageTile, frameState); if (this.context) { this.renderTileImage_(vectorImageTile, frameState, layerState); - ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments); + _ol_renderer_canvas_TileLayer_.prototype.drawTileImage.apply(this, arguments); } }; @@ -265,7 +266,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function( /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_canvas_VectorTileLayer_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { var resolution = frameState.viewState.resolution; var rotation = frameState.viewState.rotation; hitTolerance = hitTolerance == undefined ? 0 : hitTolerance; @@ -285,13 +286,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi tile = renderedTiles[i]; tileCoord = tile.wrappedTileCoord; tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent); - bufferedExtent = ol.extent.buffer(tileExtent, hitTolerance * resolution, bufferedExtent); - if (!ol.extent.containsCoordinate(bufferedExtent, coordinate)) { + bufferedExtent = _ol_extent_.buffer(tileExtent, hitTolerance * resolution, bufferedExtent); + if (!_ol_extent_.containsCoordinate(bufferedExtent, coordinate)) { continue; } for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == ol.TileState.ERROR) { + if (sourceTile.getState() == _ol_TileState_.ERROR) { continue; } replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); @@ -302,7 +303,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi * @return {?} Callback result. */ function(feature) { - var key = ol.getUid(feature).toString(); + var key = _ol_.getUid(feature).toString(); if (!(key in features)) { features[key] = true; return callback.call(thisArg, feature, layer); @@ -320,7 +321,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi * @return {ol.Transform} transform Transform. * @private */ -ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile, frameState) { +_ol_renderer_canvas_VectorTileLayer_.prototype.getReplayTransform_ = function(tile, frameState) { var layer = this.getLayer(); var source = /** @type {ol.source.VectorTile} */ (layer.getSource()); var tileGrid = source.getTileGrid(); @@ -331,11 +332,11 @@ ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile var renderResolution = viewState.resolution / pixelRatio; var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent); var center = viewState.center; - var origin = ol.extent.getTopLeft(tileExtent); + var origin = _ol_extent_.getTopLeft(tileExtent); var size = frameState.size; var offsetX = Math.round(pixelRatio * size[0] / 2); var offsetY = Math.round(pixelRatio * size[1] / 2); - return ol.transform.compose(this.tmpTransform_, + return _ol_transform_.compose(this.tmpTransform_, offsetX, offsetY, tileResolution / renderResolution, tileResolution / renderResolution, viewState.rotation, @@ -347,7 +348,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile /** * @param {ol.events.Event} event Event. */ -ol.renderer.canvas.VectorTileLayer.prototype.handleFontsChanged_ = function(event) { +_ol_renderer_canvas_VectorTileLayer_.prototype.handleFontsChanged_ = function(event) { var layer = this.getLayer(); if (layer.getVisible() && this.renderedLayerRevision_ !== undefined) { layer.changed(); @@ -360,7 +361,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.handleFontsChanged_ = function(even * @param {ol.events.Event} event Image style change event. * @private */ -ol.renderer.canvas.VectorTileLayer.prototype.handleStyleImageChange_ = function(event) { +_ol_renderer_canvas_VectorTileLayer_.prototype.handleStyleImageChange_ = function(event) { this.renderIfReadyAndVisible(); }; @@ -368,12 +369,12 @@ ol.renderer.canvas.VectorTileLayer.prototype.handleStyleImageChange_ = function( /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) { +_ol_renderer_canvas_VectorTileLayer_.prototype.postCompose = function(context, frameState, layerState) { var layer = this.getLayer(); var declutterReplays = layer.getDeclutter() ? {} : null; var source = /** @type {ol.source.VectorTile} */ (layer.getSource()); var renderMode = layer.getRenderMode(); - var replayTypes = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode]; + var replayTypes = _ol_renderer_canvas_VectorTileLayer_.VECTOR_REPLAYS[renderMode]; var pixelRatio = frameState.pixelRatio; var rotation = frameState.viewState.rotation; var size = frameState.size; @@ -381,7 +382,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra if (rotation) { offsetX = Math.round(pixelRatio * size[0] / 2); offsetY = Math.round(pixelRatio * size[1] / 2); - ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY); + _ol_render_canvas_.rotateAtOffset(context, -rotation, offsetX, offsetY); } if (declutterReplays) { this.declutterTree_.clear(); @@ -392,7 +393,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra var zs = []; for (var i = tiles.length - 1; i >= 0; --i) { var tile = /** @type {ol.VectorImageTile} */ (tiles[i]); - if (tile.getState() == ol.TileState.ABORT) { + if (tile.getState() == _ol_TileState_.ABORT) { continue; } var tileCoord = tile.tileCoord; @@ -401,11 +402,11 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra var transform = undefined; for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == ol.TileState.ERROR) { + if (sourceTile.getState() == _ol_TileState_.ERROR) { continue; } var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString()); - if (renderMode != ol.layer.VectorTileRenderType.VECTOR && !replayGroup.hasReplays(replayTypes)) { + if (renderMode != _ol_layer_VectorTileRenderType_.VECTOR && !replayGroup.hasReplays(replayTypes)) { continue; } if (!transform) { @@ -441,13 +442,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra } } if (declutterReplays) { - ol.render.canvas.ReplayGroup.replayDeclutter(declutterReplays, context, rotation); + _ol_render_canvas_ReplayGroup_.replayDeclutter(declutterReplays, context, rotation); } if (rotation) { - ol.render.canvas.rotateAtOffset(context, rotation, + _ol_render_canvas_.rotateAtOffset(context, rotation, /** @type {number} */ (offsetX), /** @type {number} */ (offsetY)); } - ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments); + _ol_renderer_canvas_TileLayer_.prototype.postCompose.apply(this, arguments); }; @@ -459,19 +460,19 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra * @param {ol.render.canvas.ReplayGroup} replayGroup Replay group. * @return {boolean} `true` if an image is loading. */ -ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, squaredTolerance, styles, replayGroup) { +_ol_renderer_canvas_VectorTileLayer_.prototype.renderFeature = function(feature, squaredTolerance, styles, replayGroup) { if (!styles) { return false; } var loading = false; if (Array.isArray(styles)) { for (var i = 0, ii = styles.length; i < ii; ++i) { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles[i], squaredTolerance, this.handleStyleImageChange_, this) || loading; } } else { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles, squaredTolerance, this.handleStyleImageChange_, this); } @@ -485,12 +486,12 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, s * @param {ol.LayerState} layerState Layer state. * @private */ -ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function( +_ol_renderer_canvas_VectorTileLayer_.prototype.renderTileImage_ = function( tile, frameState, layerState) { var layer = this.getLayer(); var replayState = tile.getReplayState(layer); var revision = layer.getRevision(); - var replays = ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS[layer.getRenderMode()]; + var replays = _ol_renderer_canvas_VectorTileLayer_.IMAGE_REPLAYS[layer.getRenderMode()]; if (replays && replayState.renderedTileRevision !== revision) { replayState.renderedTileRevision = revision; var tileCoord = tile.wrappedTileCoord; @@ -506,15 +507,16 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function( var tileExtent = tileGrid.getTileCoordExtent(tileCoord); for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) { var sourceTile = tile.getTile(tile.tileKeys[i]); - if (sourceTile.getState() == ol.TileState.ERROR) { + if (sourceTile.getState() == _ol_TileState_.ERROR) { continue; } var pixelScale = pixelRatio / resolution; - var transform = ol.transform.reset(this.tmpTransform_); - ol.transform.scale(transform, pixelScale, -pixelScale); - ol.transform.translate(transform, -tileExtent[0], -tileExtent[3]); + var transform = _ol_transform_.reset(this.tmpTransform_); + _ol_transform_.scale(transform, pixelScale, -pixelScale); + _ol_transform_.translate(transform, -tileExtent[0], -tileExtent[3]); var replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); replayGroup.replay(context, transform, 0, {}, replays); } } }; +export default _ol_renderer_canvas_VectorTileLayer_; diff --git a/src/ol/renderer/vector.js b/src/ol/renderer/vector.js index 8fdf23a455..528e3ce28b 100644 --- a/src/ol/renderer/vector.js +++ b/src/ol/renderer/vector.js @@ -1,9 +1,11 @@ -goog.provide('ol.renderer.vector'); - -goog.require('ol'); -goog.require('ol.ImageState'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.render.ReplayType'); +/** + * @module ol/renderer/vector + */ +import _ol_ from '../index.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_render_ReplayType_ from '../render/ReplayType.js'; +var _ol_renderer_vector_ = {}; /** @@ -11,8 +13,8 @@ goog.require('ol.render.ReplayType'); * @param {ol.Feature|ol.render.Feature} feature2 Feature 2. * @return {number} Order. */ -ol.renderer.vector.defaultOrder = function(feature1, feature2) { - return ol.getUid(feature1) - ol.getUid(feature2); +_ol_renderer_vector_.defaultOrder = function(feature1, feature2) { + return _ol_.getUid(feature1) - _ol_.getUid(feature2); }; @@ -21,8 +23,8 @@ ol.renderer.vector.defaultOrder = function(feature1, feature2) { * @param {number} pixelRatio Pixel ratio. * @return {number} Squared pixel tolerance. */ -ol.renderer.vector.getSquaredTolerance = function(resolution, pixelRatio) { - var tolerance = ol.renderer.vector.getTolerance(resolution, pixelRatio); +_ol_renderer_vector_.getSquaredTolerance = function(resolution, pixelRatio) { + var tolerance = _ol_renderer_vector_.getTolerance(resolution, pixelRatio); return tolerance * tolerance; }; @@ -32,8 +34,8 @@ ol.renderer.vector.getSquaredTolerance = function(resolution, pixelRatio) { * @param {number} pixelRatio Pixel ratio. * @return {number} Pixel tolerance. */ -ol.renderer.vector.getTolerance = function(resolution, pixelRatio) { - return ol.SIMPLIFY_TOLERANCE * resolution / pixelRatio; +_ol_renderer_vector_.getTolerance = function(resolution, pixelRatio) { + return _ol_.SIMPLIFY_TOLERANCE * resolution / pixelRatio; }; @@ -44,19 +46,19 @@ ol.renderer.vector.getTolerance = function(resolution, pixelRatio) { * @param {ol.Feature} feature Feature. * @private */ -ol.renderer.vector.renderCircleGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderCircleGeometry_ = function(replayGroup, geometry, style, feature) { var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); if (fillStyle || strokeStyle) { var circleReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.CIRCLE); + style.getZIndex(), _ol_render_ReplayType_.CIRCLE); circleReplay.setFillStrokeStyle(fillStyle, strokeStyle); circleReplay.drawCircle(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(false)); textReplay.drawText(geometry, feature); } @@ -73,18 +75,18 @@ ol.renderer.vector.renderCircleGeometry_ = function(replayGroup, geometry, style * @return {boolean} `true` if style is loading. * @template T */ -ol.renderer.vector.renderFeature = function( +_ol_renderer_vector_.renderFeature = function( replayGroup, feature, style, squaredTolerance, listener, thisArg) { var loading = false; var imageStyle, imageState; imageStyle = style.getImage(); if (imageStyle) { imageState = imageStyle.getImageState(); - if (imageState == ol.ImageState.LOADED || - imageState == ol.ImageState.ERROR) { + if (imageState == _ol_ImageState_.LOADED || + imageState == _ol_ImageState_.ERROR) { imageStyle.unlistenImageChange(listener, thisArg); } else { - if (imageState == ol.ImageState.IDLE) { + if (imageState == _ol_ImageState_.IDLE) { imageStyle.load(); } imageState = imageStyle.getImageState(); @@ -92,7 +94,7 @@ ol.renderer.vector.renderFeature = function( loading = true; } } - ol.renderer.vector.renderFeature_(replayGroup, feature, style, + _ol_renderer_vector_.renderFeature_(replayGroup, feature, style, squaredTolerance); return loading; @@ -106,7 +108,7 @@ ol.renderer.vector.renderFeature = function( * @param {number} squaredTolerance Squared tolerance. * @private */ -ol.renderer.vector.renderFeature_ = function( +_ol_renderer_vector_.renderFeature_ = function( replayGroup, feature, style, squaredTolerance) { var geometry = style.getGeometryFunction()(feature); if (!geometry) { @@ -115,10 +117,10 @@ ol.renderer.vector.renderFeature_ = function( var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance); var renderer = style.getRenderer(); if (renderer) { - ol.renderer.vector.renderGeometry_(replayGroup, simplifiedGeometry, style, feature); + _ol_renderer_vector_.renderGeometry_(replayGroup, simplifiedGeometry, style, feature); } else { var geometryRenderer = - ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()]; + _ol_renderer_vector_.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()]; geometryRenderer(replayGroup, simplifiedGeometry, style, feature); } }; @@ -131,15 +133,15 @@ ol.renderer.vector.renderFeature_ = function( * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderGeometry_ = function(replayGroup, geometry, style, feature) { - if (geometry.getType() == ol.geom.GeometryType.GEOMETRY_COLLECTION) { +_ol_renderer_vector_.renderGeometry_ = function(replayGroup, geometry, style, feature) { + if (geometry.getType() == _ol_geom_GeometryType_.GEOMETRY_COLLECTION) { var geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries(); for (var i = 0, ii = geometries.length; i < ii; ++i) { - ol.renderer.vector.renderGeometry_(replayGroup, geometries[i], style, feature); + _ol_renderer_vector_.renderGeometry_(replayGroup, geometries[i], style, feature); } return; } - var replay = replayGroup.getReplay(style.getZIndex(), ol.render.ReplayType.DEFAULT); + var replay = replayGroup.getReplay(style.getZIndex(), _ol_render_ReplayType_.DEFAULT); replay.drawCustom(/** @type {ol.geom.SimpleGeometry} */ (geometry), feature, style.getRenderer()); }; @@ -151,12 +153,12 @@ ol.renderer.vector.renderGeometry_ = function(replayGroup, geometry, style, feat * @param {ol.Feature} feature Feature. * @private */ -ol.renderer.vector.renderGeometryCollectionGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderGeometryCollectionGeometry_ = function(replayGroup, geometry, style, feature) { var geometries = geometry.getGeometriesArray(); var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { var geometryRenderer = - ol.renderer.vector.GEOMETRY_RENDERERS_[geometries[i].getType()]; + _ol_renderer_vector_.GEOMETRY_RENDERERS_[geometries[i].getType()]; geometryRenderer(replayGroup, geometries[i], style, feature); } }; @@ -169,18 +171,18 @@ ol.renderer.vector.renderGeometryCollectionGeometry_ = function(replayGroup, geo * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderLineStringGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderLineStringGeometry_ = function(replayGroup, geometry, style, feature) { var strokeStyle = style.getStroke(); if (strokeStyle) { var lineStringReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.LINE_STRING); + style.getZIndex(), _ol_render_ReplayType_.LINE_STRING); lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.drawLineString(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(false)); textReplay.drawText(geometry, feature); } @@ -194,18 +196,18 @@ ol.renderer.vector.renderLineStringGeometry_ = function(replayGroup, geometry, s * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderMultiLineStringGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderMultiLineStringGeometry_ = function(replayGroup, geometry, style, feature) { var strokeStyle = style.getStroke(); if (strokeStyle) { var lineStringReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.LINE_STRING); + style.getZIndex(), _ol_render_ReplayType_.LINE_STRING); lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.drawMultiLineString(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(false)); textReplay.drawText(geometry, feature); } @@ -219,19 +221,19 @@ ol.renderer.vector.renderMultiLineStringGeometry_ = function(replayGroup, geomet * @param {ol.Feature} feature Feature. * @private */ -ol.renderer.vector.renderMultiPolygonGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderMultiPolygonGeometry_ = function(replayGroup, geometry, style, feature) { var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); if (strokeStyle || fillStyle) { var polygonReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.POLYGON); + style.getZIndex(), _ol_render_ReplayType_.POLYGON); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.drawMultiPolygon(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(false)); textReplay.drawText(geometry, feature); } @@ -245,21 +247,21 @@ ol.renderer.vector.renderMultiPolygonGeometry_ = function(replayGroup, geometry, * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderPointGeometry_ = function(replayGroup, geometry, style, feature) { var imageStyle = style.getImage(); if (imageStyle) { - if (imageStyle.getImageState() != ol.ImageState.LOADED) { + if (imageStyle.getImageState() != _ol_ImageState_.LOADED) { return; } var imageReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.IMAGE); + style.getZIndex(), _ol_render_ReplayType_.IMAGE); imageReplay.setImageStyle(imageStyle, replayGroup.addDeclutter(false)); imageReplay.drawPoint(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(!!imageStyle)); textReplay.drawText(geometry, feature); } @@ -273,21 +275,21 @@ ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) { var imageStyle = style.getImage(); if (imageStyle) { - if (imageStyle.getImageState() != ol.ImageState.LOADED) { + if (imageStyle.getImageState() != _ol_ImageState_.LOADED) { return; } var imageReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.IMAGE); + style.getZIndex(), _ol_render_ReplayType_.IMAGE); imageReplay.setImageStyle(imageStyle, replayGroup.addDeclutter(false)); imageReplay.drawMultiPoint(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(!!imageStyle)); textReplay.drawText(geometry, feature); } @@ -301,19 +303,19 @@ ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, s * @param {ol.Feature|ol.render.Feature} feature Feature. * @private */ -ol.renderer.vector.renderPolygonGeometry_ = function(replayGroup, geometry, style, feature) { +_ol_renderer_vector_.renderPolygonGeometry_ = function(replayGroup, geometry, style, feature) { var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); if (fillStyle || strokeStyle) { var polygonReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.POLYGON); + style.getZIndex(), _ol_render_ReplayType_.POLYGON); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.drawPolygon(geometry, feature); } var textStyle = style.getText(); if (textStyle) { var textReplay = replayGroup.getReplay( - style.getZIndex(), ol.render.ReplayType.TEXT); + style.getZIndex(), _ol_render_ReplayType_.TEXT); textReplay.setTextStyle(textStyle, replayGroup.addDeclutter(false)); textReplay.drawText(geometry, feature); } @@ -327,13 +329,14 @@ ol.renderer.vector.renderPolygonGeometry_ = function(replayGroup, geometry, styl * function(ol.render.ReplayGroup, ol.geom.Geometry, * ol.style.Style, Object)>} */ -ol.renderer.vector.GEOMETRY_RENDERERS_ = { - 'Point': ol.renderer.vector.renderPointGeometry_, - 'LineString': ol.renderer.vector.renderLineStringGeometry_, - 'Polygon': ol.renderer.vector.renderPolygonGeometry_, - 'MultiPoint': ol.renderer.vector.renderMultiPointGeometry_, - 'MultiLineString': ol.renderer.vector.renderMultiLineStringGeometry_, - 'MultiPolygon': ol.renderer.vector.renderMultiPolygonGeometry_, - 'GeometryCollection': ol.renderer.vector.renderGeometryCollectionGeometry_, - 'Circle': ol.renderer.vector.renderCircleGeometry_ +_ol_renderer_vector_.GEOMETRY_RENDERERS_ = { + 'Point': _ol_renderer_vector_.renderPointGeometry_, + 'LineString': _ol_renderer_vector_.renderLineStringGeometry_, + 'Polygon': _ol_renderer_vector_.renderPolygonGeometry_, + 'MultiPoint': _ol_renderer_vector_.renderMultiPointGeometry_, + 'MultiLineString': _ol_renderer_vector_.renderMultiLineStringGeometry_, + 'MultiPolygon': _ol_renderer_vector_.renderMultiPolygonGeometry_, + 'GeometryCollection': _ol_renderer_vector_.renderGeometryCollectionGeometry_, + 'Circle': _ol_renderer_vector_.renderCircleGeometry_ }; +export default _ol_renderer_vector_; diff --git a/src/ol/renderer/webgl/ImageLayer.js b/src/ol/renderer/webgl/ImageLayer.js index e6170906c7..bd5c60a061 100644 --- a/src/ol/renderer/webgl/ImageLayer.js +++ b/src/ol/renderer/webgl/ImageLayer.js @@ -1,17 +1,17 @@ -goog.provide('ol.renderer.webgl.ImageLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.ViewHint'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.functions'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.webgl.Layer'); -goog.require('ol.transform'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Context'); - +/** + * @module ol/renderer/webgl/ImageLayer + */ +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_ViewHint_ from '../../ViewHint.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_functions_ from '../../functions.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_webgl_Layer_ from '../webgl/Layer.js'; +import _ol_transform_ from '../../transform.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Context_ from '../../webgl/Context.js'; /** * @constructor @@ -20,9 +20,9 @@ goog.require('ol.webgl.Context'); * @param {ol.layer.Image} imageLayer Tile layer. * @api */ -ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) { +var _ol_renderer_webgl_ImageLayer_ = function(mapRenderer, imageLayer) { - ol.renderer.webgl.Layer.call(this, mapRenderer, imageLayer); + _ol_renderer_webgl_Layer_.call(this, mapRenderer, imageLayer); /** * The last rendered image. @@ -44,7 +44,8 @@ ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) { this.hitTransformationMatrix_ = null; }; -ol.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer); + +_ol_.inherits(_ol_renderer_webgl_ImageLayer_, _ol_renderer_webgl_Layer_); /** @@ -53,8 +54,8 @@ ol.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer); * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.webgl.ImageLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.IMAGE; +_ol_renderer_webgl_ImageLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.WEBGL && layer.getType() === _ol_LayerType_.IMAGE; }; @@ -64,8 +65,8 @@ ol.renderer.webgl.ImageLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.webgl.ImageLayer} The layer renderer. */ -ol.renderer.webgl.ImageLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.webgl.ImageLayer( +_ol_renderer_webgl_ImageLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_webgl_ImageLayer_( /** @type {ol.renderer.webgl.Map} */ (mapRenderer), /** @type {ol.layer.Image} */ (layer) ); @@ -77,7 +78,7 @@ ol.renderer.webgl.ImageLayer['create'] = function(mapRenderer, layer) { * @private * @return {WebGLTexture} Texture. */ -ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) { +_ol_renderer_webgl_ImageLayer_.prototype.createTexture_ = function(image) { // We meet the conditions to work with non-power of two textures. // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support @@ -86,15 +87,15 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) { var imageElement = image.getImage(); var gl = this.mapRenderer.getGL(); - return ol.webgl.Context.createTexture( - gl, imageElement, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE); + return _ol_webgl_Context_.createTexture( + gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE); }; /** * @inheritDoc */ -ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_webgl_ImageLayer_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { var layer = this.getLayer(); var source = layer.getSource(); var resolution = frameState.viewState.resolution; @@ -116,7 +117,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coo /** * @inheritDoc */ -ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layerState, context) { +_ol_renderer_webgl_ImageLayer_.prototype.prepareFrame = function(frameState, layerState, context) { var gl = this.mapRenderer.getGL(); @@ -135,13 +136,13 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer var renderedExtent = frameState.extent; if (layerState.extent !== undefined) { - renderedExtent = ol.extent.getIntersection( + renderedExtent = _ol_extent_.getIntersection( renderedExtent, layerState.extent); } - if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] && - !ol.extent.isEmpty(renderedExtent)) { + if (!hints[_ol_ViewHint_.ANIMATING] && !hints[_ol_ViewHint_.INTERACTING] && + !_ol_extent_.isEmpty(renderedExtent)) { var projection = viewState.projection; - if (!ol.ENABLE_RASTER_REPROJECTION) { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { var sourceProjection = imageSource.getProjection(); if (sourceProjection) { projection = sourceProjection; @@ -182,9 +183,9 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer // Translate and scale to flip the Y coord. var texCoordMatrix = this.texCoordMatrix; - ol.transform.reset(texCoordMatrix); - ol.transform.scale(texCoordMatrix, 1, -1); - ol.transform.translate(texCoordMatrix, 0, -1); + _ol_transform_.reset(texCoordMatrix); + _ol_transform_.scale(texCoordMatrix, 1, -1); + _ol_transform_.translate(texCoordMatrix, 0, -1); this.image_ = image; this.texture = texture; @@ -206,25 +207,25 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer * @param {ol.Extent} imageExtent Image extent. * @private */ -ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ = function(canvasWidth, canvasHeight, pixelRatio, +_ol_renderer_webgl_ImageLayer_.prototype.updateProjectionMatrix_ = function(canvasWidth, canvasHeight, pixelRatio, viewCenter, viewResolution, viewRotation, imageExtent) { var canvasExtentWidth = canvasWidth * viewResolution; var canvasExtentHeight = canvasHeight * viewResolution; var projectionMatrix = this.projectionMatrix; - ol.transform.reset(projectionMatrix); - ol.transform.scale(projectionMatrix, + _ol_transform_.reset(projectionMatrix); + _ol_transform_.scale(projectionMatrix, pixelRatio * 2 / canvasExtentWidth, pixelRatio * 2 / canvasExtentHeight); - ol.transform.rotate(projectionMatrix, -viewRotation); - ol.transform.translate(projectionMatrix, + _ol_transform_.rotate(projectionMatrix, -viewRotation); + _ol_transform_.translate(projectionMatrix, imageExtent[0] - viewCenter[0], imageExtent[1] - viewCenter[1]); - ol.transform.scale(projectionMatrix, + _ol_transform_.scale(projectionMatrix, (imageExtent[2] - imageExtent[0]) / 2, (imageExtent[3] - imageExtent[1]) / 2); - ol.transform.translate(projectionMatrix, 1, 1); + _ol_transform_.translate(projectionMatrix, 1, 1); }; @@ -232,9 +233,9 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ = function(canvas /** * @inheritDoc */ -ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) { +_ol_renderer_webgl_ImageLayer_.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) { var hasFeature = this.forEachFeatureAtCoordinate( - coordinate, frameState, 0, ol.functions.TRUE, this); + coordinate, frameState, 0, _ol_functions_.TRUE, this); return hasFeature !== undefined; }; @@ -242,18 +243,18 @@ ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate = function(coordin /** * @inheritDoc */ -ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { +_ol_renderer_webgl_ImageLayer_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { if (!this.image_ || !this.image_.getImage()) { return undefined; } - if (this.getLayer().getSource().forEachFeatureAtCoordinate !== ol.nullFunction) { + if (this.getLayer().getSource().forEachFeatureAtCoordinate !== _ol_.nullFunction) { // for ImageCanvas sources use the original hit-detection logic, // so that for example also transparent polygons are detected - var coordinate = ol.transform.apply( + var coordinate = _ol_transform_.apply( frameState.pixelToCoordinateTransform, pixel.slice()); var hasFeature = this.forEachFeatureAtCoordinate( - coordinate, frameState, 0, ol.functions.TRUE, this); + coordinate, frameState, 0, _ol_functions_.TRUE, this); if (hasFeature) { return callback.call(thisArg, this.getLayer(), null); @@ -269,7 +270,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra frameState.size, imageSize); } - var pixelOnFrameBuffer = ol.transform.apply( + var pixelOnFrameBuffer = _ol_transform_.apply( this.hitTransformationMatrix_, pixel.slice()); if (pixelOnFrameBuffer[0] < 0 || pixelOnFrameBuffer[0] > imageSize[0] || @@ -279,7 +280,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra } if (!this.hitCanvasContext_) { - this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1); + this.hitCanvasContext_ = _ol_dom_.createCanvasContext2D(1, 1); } this.hitCanvasContext_.clearRect(0, 0, 1, 1); @@ -304,28 +305,29 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fra * @return {ol.Transform} The transformation matrix. * @private */ -ol.renderer.webgl.ImageLayer.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) { +_ol_renderer_webgl_ImageLayer_.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) { // the first matrix takes a map pixel, flips the y-axis and scales to // a range between -1 ... 1 - var mapCoordTransform = ol.transform.create(); - ol.transform.translate(mapCoordTransform, -1, -1); - ol.transform.scale(mapCoordTransform, 2 / mapSize[0], 2 / mapSize[1]); - ol.transform.translate(mapCoordTransform, 0, mapSize[1]); - ol.transform.scale(mapCoordTransform, 1, -1); + var mapCoordTransform = _ol_transform_.create(); + _ol_transform_.translate(mapCoordTransform, -1, -1); + _ol_transform_.scale(mapCoordTransform, 2 / mapSize[0], 2 / mapSize[1]); + _ol_transform_.translate(mapCoordTransform, 0, mapSize[1]); + _ol_transform_.scale(mapCoordTransform, 1, -1); // the second matrix is the inverse of the projection matrix used in the // shader for drawing - var projectionMatrixInv = ol.transform.invert(this.projectionMatrix.slice()); + var projectionMatrixInv = _ol_transform_.invert(this.projectionMatrix.slice()); // the third matrix scales to the image dimensions and flips the y-axis again - var transform = ol.transform.create(); - ol.transform.translate(transform, 0, imageSize[1]); - ol.transform.scale(transform, 1, -1); - ol.transform.scale(transform, imageSize[0] / 2, imageSize[1] / 2); - ol.transform.translate(transform, 1, 1); + var transform = _ol_transform_.create(); + _ol_transform_.translate(transform, 0, imageSize[1]); + _ol_transform_.scale(transform, 1, -1); + _ol_transform_.scale(transform, imageSize[0] / 2, imageSize[1] / 2); + _ol_transform_.translate(transform, 1, 1); - ol.transform.multiply(transform, projectionMatrixInv); - ol.transform.multiply(transform, mapCoordTransform); + _ol_transform_.multiply(transform, projectionMatrixInv); + _ol_transform_.multiply(transform, mapCoordTransform); return transform; }; +export default _ol_renderer_webgl_ImageLayer_; diff --git a/src/ol/renderer/webgl/Layer.js b/src/ol/renderer/webgl/Layer.js index a119c1401d..f62c4bf084 100644 --- a/src/ol/renderer/webgl/Layer.js +++ b/src/ol/renderer/webgl/Layer.js @@ -1,18 +1,18 @@ -goog.provide('ol.renderer.webgl.Layer'); - -goog.require('ol'); -goog.require('ol.render.Event'); -goog.require('ol.render.EventType'); -goog.require('ol.render.webgl.Immediate'); -goog.require('ol.renderer.Layer'); -goog.require('ol.renderer.webgl.defaultmapshader'); -goog.require('ol.renderer.webgl.defaultmapshader.Locations'); -goog.require('ol.transform'); -goog.require('ol.vec.Mat4'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Buffer'); -goog.require('ol.webgl.Context'); - +/** + * @module ol/renderer/webgl/Layer + */ +import _ol_ from '../../index.js'; +import _ol_render_Event_ from '../../render/Event.js'; +import _ol_render_EventType_ from '../../render/EventType.js'; +import _ol_render_webgl_Immediate_ from '../../render/webgl/Immediate.js'; +import _ol_renderer_Layer_ from '../Layer.js'; +import _ol_renderer_webgl_defaultmapshader_ from '../webgl/defaultmapshader.js'; +import _ol_renderer_webgl_defaultmapshader_Locations_ from '../webgl/defaultmapshader/Locations.js'; +import _ol_transform_ from '../../transform.js'; +import _ol_vec_Mat4_ from '../../vec/Mat4.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; +import _ol_webgl_Context_ from '../../webgl/Context.js'; /** * @constructor @@ -21,9 +21,9 @@ goog.require('ol.webgl.Context'); * @param {ol.renderer.webgl.Map} mapRenderer Map renderer. * @param {ol.layer.Layer} layer Layer. */ -ol.renderer.webgl.Layer = function(mapRenderer, layer) { +var _ol_renderer_webgl_Layer_ = function(mapRenderer, layer) { - ol.renderer.Layer.call(this, layer); + _ol_renderer_Layer_.call(this, layer); /** * @protected @@ -35,7 +35,7 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) { * @private * @type {ol.webgl.Buffer} */ - this.arrayBuffer_ = new ol.webgl.Buffer([ + this.arrayBuffer_ = new _ol_webgl_Buffer_([ -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, @@ -64,19 +64,19 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) { * @protected * @type {ol.Transform} */ - this.texCoordMatrix = ol.transform.create(); + this.texCoordMatrix = _ol_transform_.create(); /** * @protected * @type {ol.Transform} */ - this.projectionMatrix = ol.transform.create(); + this.projectionMatrix = _ol_transform_.create(); /** * @type {Array.} * @private */ - this.tmpMat4_ = ol.vec.Mat4.create(); + this.tmpMat4_ = _ol_vec_Mat4_.create(); /** * @private @@ -85,7 +85,8 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) { this.defaultLocations_ = null; }; -ol.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer); + +_ol_.inherits(_ol_renderer_webgl_Layer_, _ol_renderer_Layer_); /** @@ -93,7 +94,7 @@ ol.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer); * @param {number} framebufferDimension Framebuffer dimension. * @protected */ -ol.renderer.webgl.Layer.prototype.bindFramebuffer = function(frameState, framebufferDimension) { +_ol_renderer_webgl_Layer_.prototype.bindFramebuffer = function(frameState, framebufferDimension) { var gl = this.mapRenderer.getGL(); @@ -115,20 +116,20 @@ ol.renderer.webgl.Layer.prototype.bindFramebuffer = function(frameState, framebu /** @type {ol.PostRenderFunction} */ (postRenderFunction) ); - var texture = ol.webgl.Context.createEmptyTexture( + var texture = _ol_webgl_Context_.createEmptyTexture( gl, framebufferDimension, framebufferDimension); var framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(ol.webgl.FRAMEBUFFER, framebuffer); - gl.framebufferTexture2D(ol.webgl.FRAMEBUFFER, - ol.webgl.COLOR_ATTACHMENT0, ol.webgl.TEXTURE_2D, texture, 0); + gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, framebuffer); + gl.framebufferTexture2D(_ol_webgl_.FRAMEBUFFER, + _ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0); this.texture = texture; this.framebuffer = framebuffer; this.framebufferDimension = framebufferDimension; } else { - gl.bindFramebuffer(ol.webgl.FRAMEBUFFER, this.framebuffer); + gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, this.framebuffer); } }; @@ -139,23 +140,23 @@ ol.renderer.webgl.Layer.prototype.bindFramebuffer = function(frameState, framebu * @param {ol.LayerState} layerState Layer state. * @param {ol.webgl.Context} context Context. */ -ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState, context) { +_ol_renderer_webgl_Layer_.prototype.composeFrame = function(frameState, layerState, context) { this.dispatchComposeEvent_( - ol.render.EventType.PRECOMPOSE, context, frameState); + _ol_render_EventType_.PRECOMPOSE, context, frameState); - context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.arrayBuffer_); + context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.arrayBuffer_); var gl = context.getGL(); - var fragmentShader = ol.renderer.webgl.defaultmapshader.fragment; - var vertexShader = ol.renderer.webgl.defaultmapshader.vertex; + var fragmentShader = _ol_renderer_webgl_defaultmapshader_.fragment; + var vertexShader = _ol_renderer_webgl_defaultmapshader_.vertex; var program = context.getProgram(fragmentShader, vertexShader); var locations; if (!this.defaultLocations_) { - locations = new ol.renderer.webgl.defaultmapshader.Locations(gl, program); + locations = new _ol_renderer_webgl_defaultmapshader_Locations_(gl, program); this.defaultLocations_ = locations; } else { locations = this.defaultLocations_; @@ -164,23 +165,23 @@ ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState if (context.useProgram(program)) { gl.enableVertexAttribArray(locations.a_position); gl.vertexAttribPointer( - locations.a_position, 2, ol.webgl.FLOAT, false, 16, 0); + locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0); gl.enableVertexAttribArray(locations.a_texCoord); gl.vertexAttribPointer( - locations.a_texCoord, 2, ol.webgl.FLOAT, false, 16, 8); + locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8); gl.uniform1i(locations.u_texture, 0); } gl.uniformMatrix4fv(locations.u_texCoordMatrix, false, - ol.vec.Mat4.fromTransform(this.tmpMat4_, this.getTexCoordMatrix())); + _ol_vec_Mat4_.fromTransform(this.tmpMat4_, this.getTexCoordMatrix())); gl.uniformMatrix4fv(locations.u_projectionMatrix, false, - ol.vec.Mat4.fromTransform(this.tmpMat4_, this.getProjectionMatrix())); + _ol_vec_Mat4_.fromTransform(this.tmpMat4_, this.getProjectionMatrix())); gl.uniform1f(locations.u_opacity, layerState.opacity); - gl.bindTexture(ol.webgl.TEXTURE_2D, this.getTexture()); - gl.drawArrays(ol.webgl.TRIANGLE_STRIP, 0, 4); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, this.getTexture()); + gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4); this.dispatchComposeEvent_( - ol.render.EventType.POSTCOMPOSE, context, frameState); + _ol_render_EventType_.POSTCOMPOSE, context, frameState); }; @@ -191,7 +192,7 @@ ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState) { +_ol_renderer_webgl_Layer_.prototype.dispatchComposeEvent_ = function(type, context, frameState) { var layer = this.getLayer(); if (layer.hasListener(type)) { var viewState = frameState.viewState; @@ -202,9 +203,9 @@ ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context var rotation = viewState.rotation; var size = frameState.size; - var render = new ol.render.webgl.Immediate( + var render = new _ol_render_webgl_Immediate_( context, center, resolution, rotation, size, extent, pixelRatio); - var composeEvent = new ol.render.Event( + var composeEvent = new _ol_render_Event_( type, render, frameState, null, context); layer.dispatchEvent(composeEvent); } @@ -214,7 +215,7 @@ ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context /** * @return {!ol.Transform} Matrix. */ -ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() { +_ol_renderer_webgl_Layer_.prototype.getTexCoordMatrix = function() { return this.texCoordMatrix; }; @@ -222,7 +223,7 @@ ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() { /** * @return {WebGLTexture} Texture. */ -ol.renderer.webgl.Layer.prototype.getTexture = function() { +_ol_renderer_webgl_Layer_.prototype.getTexture = function() { return this.texture; }; @@ -230,7 +231,7 @@ ol.renderer.webgl.Layer.prototype.getTexture = function() { /** * @return {!ol.Transform} Matrix. */ -ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() { +_ol_renderer_webgl_Layer_.prototype.getProjectionMatrix = function() { return this.projectionMatrix; }; @@ -238,7 +239,7 @@ ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() { /** * Handle webglcontextlost. */ -ol.renderer.webgl.Layer.prototype.handleWebGLContextLost = function() { +_ol_renderer_webgl_Layer_.prototype.handleWebGLContextLost = function() { this.texture = null; this.framebuffer = null; this.framebufferDimension = undefined; @@ -252,7 +253,7 @@ ol.renderer.webgl.Layer.prototype.handleWebGLContextLost = function() { * @param {ol.webgl.Context} context Context. * @return {boolean} whether composeFrame should be called. */ -ol.renderer.webgl.Layer.prototype.prepareFrame = function(frameState, layerState, context) {}; +_ol_renderer_webgl_Layer_.prototype.prepareFrame = function(frameState, layerState, context) {}; /** @@ -265,4 +266,5 @@ ol.renderer.webgl.Layer.prototype.prepareFrame = function(frameState, layerState * @return {T|undefined} Callback result. * @template S,T,U */ -ol.renderer.webgl.Layer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {}; +_ol_renderer_webgl_Layer_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {}; +export default _ol_renderer_webgl_Layer_; diff --git a/src/ol/renderer/webgl/Map.js b/src/ol/renderer/webgl/Map.js index f3107c07b7..802a79c4aa 100644 --- a/src/ol/renderer/webgl/Map.js +++ b/src/ol/renderer/webgl/Map.js @@ -1,26 +1,26 @@ +/** + * @module ol/renderer/webgl/Map + */ // FIXME check against gl.getParameter(webgl.MAX_TEXTURE_SIZE) -goog.provide('ol.renderer.webgl.Map'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.css'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.has'); -goog.require('ol.layer.Layer'); -goog.require('ol.render.Event'); -goog.require('ol.render.EventType'); -goog.require('ol.render.webgl.Immediate'); -goog.require('ol.renderer.Map'); -goog.require('ol.renderer.Type'); -goog.require('ol.source.State'); -goog.require('ol.structs.LRUCache'); -goog.require('ol.structs.PriorityQueue'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Context'); -goog.require('ol.webgl.ContextEventType'); - +import _ol_ from '../../index.js'; +import _ol_array_ from '../../array.js'; +import _ol_css_ from '../../css.js'; +import _ol_dom_ from '../../dom.js'; +import _ol_events_ from '../../events.js'; +import _ol_has_ from '../../has.js'; +import _ol_layer_Layer_ from '../../layer/Layer.js'; +import _ol_render_Event_ from '../../render/Event.js'; +import _ol_render_EventType_ from '../../render/EventType.js'; +import _ol_render_webgl_Immediate_ from '../../render/webgl/Immediate.js'; +import _ol_renderer_Map_ from '../Map.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_source_State_ from '../../source/State.js'; +import _ol_structs_LRUCache_ from '../../structs/LRUCache.js'; +import _ol_structs_PriorityQueue_ from '../../structs/PriorityQueue.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Context_ from '../../webgl/Context.js'; +import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js'; /** * @constructor @@ -29,8 +29,8 @@ goog.require('ol.webgl.ContextEventType'); * @param {ol.PluggableMap} map Map. * @api */ -ol.renderer.webgl.Map = function(container, map) { - ol.renderer.Map.call(this, container, map); +var _ol_renderer_webgl_Map_ = function(container, map) { + _ol_renderer_Map_.call(this, container, map); /** * @private @@ -41,7 +41,7 @@ ol.renderer.webgl.Map = function(container, map) { this.canvas_.style.width = '100%'; this.canvas_.style.height = '100%'; this.canvas_.style.display = 'block'; - this.canvas_.className = ol.css.CLASS_UNSELECTABLE; + this.canvas_.className = _ol_css_.CLASS_UNSELECTABLE; container.insertBefore(this.canvas_, container.childNodes[0] || null); /** @@ -60,7 +60,7 @@ ol.renderer.webgl.Map = function(container, map) { * @private * @type {CanvasRenderingContext2D} */ - this.clipTileContext_ = ol.dom.createCanvasContext2D(); + this.clipTileContext_ = _ol_dom_.createCanvasContext2D(); /** * @private @@ -72,7 +72,7 @@ ol.renderer.webgl.Map = function(container, map) { * @private * @type {WebGLRenderingContext} */ - this.gl_ = ol.webgl.getContext(this.canvas_, { + this.gl_ = _ol_webgl_.getContext(this.canvas_, { antialias: true, depth: true, failIfMajorPerformanceCaveat: true, @@ -84,18 +84,18 @@ ol.renderer.webgl.Map = function(container, map) { * @private * @type {ol.webgl.Context} */ - this.context_ = new ol.webgl.Context(this.canvas_, this.gl_); + this.context_ = new _ol_webgl_Context_(this.canvas_, this.gl_); - ol.events.listen(this.canvas_, ol.webgl.ContextEventType.LOST, + _ol_events_.listen(this.canvas_, _ol_webgl_ContextEventType_.LOST, this.handleWebGLContextLost, this); - ol.events.listen(this.canvas_, ol.webgl.ContextEventType.RESTORED, + _ol_events_.listen(this.canvas_, _ol_webgl_ContextEventType_.RESTORED, this.handleWebGLContextRestored, this); /** * @private * @type {ol.structs.LRUCache.} */ - this.textureCache_ = new ol.structs.LRUCache(); + this.textureCache_ = new _ol_structs_LRUCache_(); /** * @private @@ -107,7 +107,7 @@ ol.renderer.webgl.Map = function(container, map) { * @private * @type {ol.structs.PriorityQueue.} */ - this.tileTextureQueue_ = new ol.structs.PriorityQueue( + this.tileTextureQueue_ = new _ol_structs_PriorityQueue_( /** * @param {Array.<*>} element Element. * @return {number} Priority. @@ -145,7 +145,7 @@ ol.renderer.webgl.Map = function(container, map) { var tileSize = /** @type {ol.Size} */ (element[3]); var tileGutter = /** @type {number} */ (element[4]); this.bindTileTexture( - tile, tileSize, tileGutter, ol.webgl.LINEAR, ol.webgl.LINEAR); + tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR); } return false; }.bind(this); @@ -159,7 +159,8 @@ ol.renderer.webgl.Map = function(container, map) { this.initializeGL_(); }; -ol.inherits(ol.renderer.webgl.Map, ol.renderer.Map); + +_ol_.inherits(_ol_renderer_webgl_Map_, _ol_renderer_Map_); /** @@ -167,8 +168,8 @@ ol.inherits(ol.renderer.webgl.Map, ol.renderer.Map); * @param {ol.renderer.Type} type The renderer type. * @return {boolean} The renderer can render the layer. */ -ol.renderer.webgl.Map['handles'] = function(type) { - return ol.has.WEBGL && type === ol.renderer.Type.WEBGL; +_ol_renderer_webgl_Map_['handles'] = function(type) { + return _ol_has_.WEBGL && type === _ol_renderer_Type_.WEBGL; }; @@ -178,8 +179,8 @@ ol.renderer.webgl.Map['handles'] = function(type) { * @param {ol.PluggableMap} map Map. * @return {ol.renderer.webgl.Map} The map renderer. */ -ol.renderer.webgl.Map['create'] = function(container, map) { - return new ol.renderer.webgl.Map(container, map); +_ol_renderer_webgl_Map_['create'] = function(container, map) { + return new _ol_renderer_webgl_Map_(container, map); }; @@ -190,25 +191,25 @@ ol.renderer.webgl.Map['create'] = function(container, map) { * @param {number} magFilter Mag filter. * @param {number} minFilter Min filter. */ -ol.renderer.webgl.Map.prototype.bindTileTexture = function(tile, tileSize, tileGutter, magFilter, minFilter) { +_ol_renderer_webgl_Map_.prototype.bindTileTexture = function(tile, tileSize, tileGutter, magFilter, minFilter) { var gl = this.getGL(); var tileKey = tile.getKey(); if (this.textureCache_.containsKey(tileKey)) { var textureCacheEntry = this.textureCache_.get(tileKey); - gl.bindTexture(ol.webgl.TEXTURE_2D, textureCacheEntry.texture); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, textureCacheEntry.texture); if (textureCacheEntry.magFilter != magFilter) { gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_MAG_FILTER, magFilter); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter); textureCacheEntry.magFilter = magFilter; } if (textureCacheEntry.minFilter != minFilter) { gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_MIN_FILTER, minFilter); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter); textureCacheEntry.minFilter = minFilter; } } else { var texture = gl.createTexture(); - gl.bindTexture(ol.webgl.TEXTURE_2D, texture); + gl.bindTexture(_ol_webgl_.TEXTURE_2D, texture); if (tileGutter > 0) { var clipTileCanvas = this.clipTileContext_.canvas; var clipTileContext = this.clipTileContext_; @@ -223,22 +224,22 @@ ol.renderer.webgl.Map.prototype.bindTileTexture = function(tile, tileSize, tileG } clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter, tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]); - gl.texImage2D(ol.webgl.TEXTURE_2D, 0, - ol.webgl.RGBA, ol.webgl.RGBA, - ol.webgl.UNSIGNED_BYTE, clipTileCanvas); + gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0, + _ol_webgl_.RGBA, _ol_webgl_.RGBA, + _ol_webgl_.UNSIGNED_BYTE, clipTileCanvas); } else { - gl.texImage2D(ol.webgl.TEXTURE_2D, 0, - ol.webgl.RGBA, ol.webgl.RGBA, - ol.webgl.UNSIGNED_BYTE, tile.getImage()); + gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0, + _ol_webgl_.RGBA, _ol_webgl_.RGBA, + _ol_webgl_.UNSIGNED_BYTE, tile.getImage()); } gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_MAG_FILTER, magFilter); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter); gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_WRAP_S, - ol.webgl.CLAMP_TO_EDGE); - gl.texParameteri(ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_WRAP_T, - ol.webgl.CLAMP_TO_EDGE); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S, + _ol_webgl_.CLAMP_TO_EDGE); + gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T, + _ol_webgl_.CLAMP_TO_EDGE); this.textureCache_.set(tileKey, { texture: texture, magFilter: magFilter, @@ -253,7 +254,7 @@ ol.renderer.webgl.Map.prototype.bindTileTexture = function(tile, tileSize, tileG * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.webgl.Map.prototype.dispatchComposeEvent_ = function(type, frameState) { +_ol_renderer_webgl_Map_.prototype.dispatchComposeEvent_ = function(type, frameState) { var map = this.getMap(); if (map.hasListener(type)) { var context = this.context_; @@ -267,9 +268,9 @@ ol.renderer.webgl.Map.prototype.dispatchComposeEvent_ = function(type, frameStat var center = viewState.center; var rotation = viewState.rotation; - var vectorContext = new ol.render.webgl.Immediate(context, + var vectorContext = new _ol_render_webgl_Immediate_(context, center, resolution, rotation, size, extent, pixelRatio); - var composeEvent = new ol.render.Event(type, vectorContext, + var composeEvent = new _ol_render_Event_(type, vectorContext, frameState, null, context); map.dispatchEvent(composeEvent); } @@ -279,7 +280,7 @@ ol.renderer.webgl.Map.prototype.dispatchComposeEvent_ = function(type, frameStat /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.disposeInternal = function() { +_ol_renderer_webgl_Map_.prototype.disposeInternal = function() { var gl = this.getGL(); if (!gl.isContextLost()) { this.textureCache_.forEach( @@ -294,7 +295,7 @@ ol.renderer.webgl.Map.prototype.disposeInternal = function() { }); } this.context_.dispose(); - ol.renderer.Map.prototype.disposeInternal.call(this); + _ol_renderer_Map_.prototype.disposeInternal.call(this); }; @@ -303,11 +304,11 @@ ol.renderer.webgl.Map.prototype.disposeInternal = function() { * @param {olx.FrameState} frameState Frame state. * @private */ -ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) { +_ol_renderer_webgl_Map_.prototype.expireCache_ = function(map, frameState) { var gl = this.getGL(); var textureCacheEntry; while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ > - ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { + _ol_.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { textureCacheEntry = this.textureCache_.peekLast(); if (!textureCacheEntry) { if (+this.textureCache_.peekLastKey() == frameState.index) { @@ -326,7 +327,7 @@ ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) { /** * @return {ol.webgl.Context} The context. */ -ol.renderer.webgl.Map.prototype.getContext = function() { +_ol_renderer_webgl_Map_.prototype.getContext = function() { return this.context_; }; @@ -334,7 +335,7 @@ ol.renderer.webgl.Map.prototype.getContext = function() { /** * @return {WebGLRenderingContext} GL. */ -ol.renderer.webgl.Map.prototype.getGL = function() { +_ol_renderer_webgl_Map_.prototype.getGL = function() { return this.gl_; }; @@ -342,7 +343,7 @@ ol.renderer.webgl.Map.prototype.getGL = function() { /** * @return {ol.structs.PriorityQueue.} Tile texture queue. */ -ol.renderer.webgl.Map.prototype.getTileTextureQueue = function() { +_ol_renderer_webgl_Map_.prototype.getTileTextureQueue = function() { return this.tileTextureQueue_; }; @@ -350,8 +351,8 @@ ol.renderer.webgl.Map.prototype.getTileTextureQueue = function() { /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.getType = function() { - return ol.renderer.Type.WEBGL; +_ol_renderer_webgl_Map_.prototype.getType = function() { + return _ol_renderer_Type_.WEBGL; }; @@ -359,7 +360,7 @@ ol.renderer.webgl.Map.prototype.getType = function() { * @param {ol.events.Event} event Event. * @protected */ -ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) { +_ol_renderer_webgl_Map_.prototype.handleWebGLContextLost = function(event) { event.preventDefault(); this.textureCache_.clear(); this.textureCacheFrameMarkerCount_ = 0; @@ -375,7 +376,7 @@ ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) { /** * @protected */ -ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() { +_ol_renderer_webgl_Map_.prototype.handleWebGLContextRestored = function() { this.initializeGL_(); this.getMap().render(); }; @@ -384,16 +385,16 @@ ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() { /** * @private */ -ol.renderer.webgl.Map.prototype.initializeGL_ = function() { +_ol_renderer_webgl_Map_.prototype.initializeGL_ = function() { var gl = this.gl_; - gl.activeTexture(ol.webgl.TEXTURE0); + gl.activeTexture(_ol_webgl_.TEXTURE0); gl.blendFuncSeparate( - ol.webgl.SRC_ALPHA, ol.webgl.ONE_MINUS_SRC_ALPHA, - ol.webgl.ONE, ol.webgl.ONE_MINUS_SRC_ALPHA); - gl.disable(ol.webgl.CULL_FACE); - gl.disable(ol.webgl.DEPTH_TEST); - gl.disable(ol.webgl.SCISSOR_TEST); - gl.disable(ol.webgl.STENCIL_TEST); + _ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA, + _ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA); + gl.disable(_ol_webgl_.CULL_FACE); + gl.disable(_ol_webgl_.DEPTH_TEST); + gl.disable(_ol_webgl_.SCISSOR_TEST); + gl.disable(_ol_webgl_.STENCIL_TEST); }; @@ -401,7 +402,7 @@ ol.renderer.webgl.Map.prototype.initializeGL_ = function() { * @param {ol.Tile} tile Tile. * @return {boolean} Is tile texture loaded. */ -ol.renderer.webgl.Map.prototype.isTileTextureLoaded = function(tile) { +_ol_renderer_webgl_Map_.prototype.isTileTextureLoaded = function(tile) { return this.textureCache_.containsKey(tile.getKey()); }; @@ -409,7 +410,7 @@ ol.renderer.webgl.Map.prototype.isTileTextureLoaded = function(tile) { /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { +_ol_renderer_webgl_Map_.prototype.renderFrame = function(frameState) { var context = this.getContext(); var gl = this.getGL(); @@ -431,19 +432,19 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { this.textureCache_.set((-frameState.index).toString(), null); ++this.textureCacheFrameMarkerCount_; - this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState); + this.dispatchComposeEvent_(_ol_render_EventType_.PRECOMPOSE, frameState); /** @type {Array.} */ var layerStatesToDraw = []; var layerStatesArray = frameState.layerStatesArray; - ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex); + _ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex); var viewResolution = frameState.viewState.resolution; var i, ii, layerRenderer, layerState; for (i = 0, ii = layerStatesArray.length; i < ii; ++i) { layerState = layerStatesArray[i]; - if (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && - layerState.sourceState == ol.source.State.READY) { + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewResolution) && + layerState.sourceState == _ol_source_State_.READY) { layerRenderer = /** @type {ol.renderer.webgl.Layer} */ (this.getLayerRenderer(layerState.layer)); if (layerRenderer.prepareFrame(frameState, layerState, context)) { layerStatesToDraw.push(layerState); @@ -458,11 +459,11 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { this.canvas_.height = height; } - gl.bindFramebuffer(ol.webgl.FRAMEBUFFER, null); + gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, null); gl.clearColor(0, 0, 0, 0); - gl.clear(ol.webgl.COLOR_BUFFER_BIT); - gl.enable(ol.webgl.BLEND); + gl.clear(_ol_webgl_.COLOR_BUFFER_BIT); + gl.enable(_ol_webgl_.BLEND); gl.viewport(0, 0, this.canvas_.width, this.canvas_.height); for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) { @@ -479,7 +480,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { this.calculateMatrices2D(frameState); if (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ > - ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { + _ol_.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { frameState.postRenderFunctions.push( /** @type {ol.PostRenderFunction} */ (this.expireCache_.bind(this)) ); @@ -490,7 +491,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { frameState.animate = true; } - this.dispatchComposeEvent_(ol.render.EventType.POSTCOMPOSE, frameState); + this.dispatchComposeEvent_(_ol_render_EventType_.POSTCOMPOSE, frameState); this.scheduleRemoveUnusedLayerRenderers(frameState); this.scheduleExpireIconCache(frameState); @@ -501,7 +502,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, +_ol_renderer_webgl_Map_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) { var result; @@ -517,7 +518,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate for (i = numLayers - 1; i >= 0; --i) { var layerState = layerStates[i]; var layer = layerState.layer; - if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) && + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewState.resolution) && layerFilter.call(thisArg2, layer)) { var layerRenderer = this.getLayerRenderer(layer); result = layerRenderer.forEachFeatureAtCoordinate( @@ -534,7 +535,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) { +_ol_renderer_webgl_Map_.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) { var hasFeature = false; if (this.getGL().isContextLost()) { @@ -549,7 +550,7 @@ ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, fr for (i = numLayers - 1; i >= 0; --i) { var layerState = layerStates[i]; var layer = layerState.layer; - if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) && + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewState.resolution) && layerFilter.call(thisArg, layer)) { var layerRenderer = this.getLayerRenderer(layer); hasFeature = @@ -566,7 +567,7 @@ ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, fr /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, +_ol_renderer_webgl_Map_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg, layerFilter, thisArg2) { if (this.getGL().isContextLost()) { return false; @@ -581,7 +582,7 @@ ol.renderer.webgl.Map.prototype.forEachLayerAtPixel = function(pixel, frameState for (i = numLayers - 1; i >= 0; --i) { var layerState = layerStates[i]; var layer = layerState.layer; - if (ol.layer.Layer.visibleAtResolution(layerState, viewState.resolution) && + if (_ol_layer_Layer_.visibleAtResolution(layerState, viewState.resolution) && layerFilter.call(thisArg, layer)) { var layerRenderer = /** @type {ol.renderer.webgl.Layer} */ (this.getLayerRenderer(layer)); result = layerRenderer.forEachLayerAtPixel( @@ -593,3 +594,4 @@ ol.renderer.webgl.Map.prototype.forEachLayerAtPixel = function(pixel, frameState } return undefined; }; +export default _ol_renderer_webgl_Map_; diff --git a/src/ol/renderer/webgl/TileLayer.js b/src/ol/renderer/webgl/TileLayer.js index 6d1f554a5d..2eba29ec4b 100644 --- a/src/ol/renderer/webgl/TileLayer.js +++ b/src/ol/renderer/webgl/TileLayer.js @@ -1,24 +1,24 @@ +/** + * @module ol/renderer/webgl/TileLayer + */ // FIXME large resolutions lead to too large framebuffers :-( // FIXME animated shaders! check in redraw -goog.provide('ol.renderer.webgl.TileLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.TileRange'); -goog.require('ol.TileState'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.webgl.Layer'); -goog.require('ol.renderer.webgl.tilelayershader'); -goog.require('ol.renderer.webgl.tilelayershader.Locations'); -goog.require('ol.size'); -goog.require('ol.transform'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Buffer'); - +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_TileRange_ from '../../TileRange.js'; +import _ol_TileState_ from '../../TileState.js'; +import _ol_array_ from '../../array.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_math_ from '../../math.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_webgl_Layer_ from '../webgl/Layer.js'; +import _ol_renderer_webgl_tilelayershader_ from '../webgl/tilelayershader.js'; +import _ol_renderer_webgl_tilelayershader_Locations_ from '../webgl/tilelayershader/Locations.js'; +import _ol_size_ from '../../size.js'; +import _ol_transform_ from '../../transform.js'; +import _ol_webgl_ from '../../webgl.js'; +import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; /** * @constructor @@ -27,21 +27,21 @@ goog.require('ol.webgl.Buffer'); * @param {ol.layer.Tile} tileLayer Tile layer. * @api */ -ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) { +var _ol_renderer_webgl_TileLayer_ = function(mapRenderer, tileLayer) { - ol.renderer.webgl.Layer.call(this, mapRenderer, tileLayer); + _ol_renderer_webgl_Layer_.call(this, mapRenderer, tileLayer); /** * @private * @type {ol.webgl.Fragment} */ - this.fragmentShader_ = ol.renderer.webgl.tilelayershader.fragment; + this.fragmentShader_ = _ol_renderer_webgl_tilelayershader_.fragment; /** * @private * @type {ol.webgl.Vertex} */ - this.vertexShader_ = ol.renderer.webgl.tilelayershader.vertex; + this.vertexShader_ = _ol_renderer_webgl_tilelayershader_.vertex; /** * @private @@ -53,7 +53,7 @@ ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) { * @private * @type {ol.webgl.Buffer} */ - this.renderArrayBuffer_ = new ol.webgl.Buffer([ + this.renderArrayBuffer_ = new _ol_webgl_Buffer_([ 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, @@ -85,7 +85,8 @@ ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) { this.tmpSize_ = [0, 0]; }; -ol.inherits(ol.renderer.webgl.TileLayer, ol.renderer.webgl.Layer); + +_ol_.inherits(_ol_renderer_webgl_TileLayer_, _ol_renderer_webgl_Layer_); /** @@ -94,8 +95,8 @@ ol.inherits(ol.renderer.webgl.TileLayer, ol.renderer.webgl.Layer); * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.webgl.TileLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.TILE; +_ol_renderer_webgl_TileLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.WEBGL && layer.getType() === _ol_LayerType_.TILE; }; @@ -105,8 +106,8 @@ ol.renderer.webgl.TileLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.webgl.TileLayer} The layer renderer. */ -ol.renderer.webgl.TileLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.webgl.TileLayer( +_ol_renderer_webgl_TileLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_webgl_TileLayer_( /** @type {ol.renderer.webgl.Map} */ (mapRenderer), /** @type {ol.layer.Tile} */ (layer) ); @@ -116,17 +117,17 @@ ol.renderer.webgl.TileLayer['create'] = function(mapRenderer, layer) { /** * @inheritDoc */ -ol.renderer.webgl.TileLayer.prototype.disposeInternal = function() { +_ol_renderer_webgl_TileLayer_.prototype.disposeInternal = function() { var context = this.mapRenderer.getContext(); context.deleteBuffer(this.renderArrayBuffer_); - ol.renderer.webgl.Layer.prototype.disposeInternal.call(this); + _ol_renderer_webgl_Layer_.prototype.disposeInternal.call(this); }; /** * @inheritDoc */ -ol.renderer.webgl.TileLayer.prototype.createLoadedTileFinder = function(source, projection, tiles) { +_ol_renderer_webgl_TileLayer_.prototype.createLoadedTileFinder = function(source, projection, tiles) { var mapRenderer = this.mapRenderer; return ( @@ -154,8 +155,8 @@ ol.renderer.webgl.TileLayer.prototype.createLoadedTileFinder = function(source, /** * @inheritDoc */ -ol.renderer.webgl.TileLayer.prototype.handleWebGLContextLost = function() { - ol.renderer.webgl.Layer.prototype.handleWebGLContextLost.call(this); +_ol_renderer_webgl_TileLayer_.prototype.handleWebGLContextLost = function() { + _ol_renderer_webgl_Layer_.prototype.handleWebGLContextLost.call(this); this.locations_ = null; }; @@ -163,7 +164,7 @@ ol.renderer.webgl.TileLayer.prototype.handleWebGLContextLost = function() { /** * @inheritDoc */ -ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerState, context) { +_ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, layerState, context) { var mapRenderer = this.mapRenderer; var gl = context.getGL(); @@ -180,7 +181,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS var tilePixelSize = tileSource.getTilePixelSize(z, frameState.pixelRatio, projection); var pixelRatio = tilePixelSize[0] / - ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize_)[0]; + _ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize_)[0]; var tilePixelResolution = tileResolution / pixelRatio; var tileGutter = tileSource.getTilePixelRatio(pixelRatio) * tileSource.getGutter(projection); @@ -200,7 +201,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS var maxDimension = Math.max( tileRangeSize[0] * tilePixelSize[0], tileRangeSize[1] * tilePixelSize[1]); - var framebufferDimension = ol.math.roundUpToPowerOfTwo(maxDimension); + var framebufferDimension = _ol_math_.roundUpToPowerOfTwo(maxDimension); var framebufferExtentDimension = tilePixelResolution * framebufferDimension; var origin = tileGrid.getOrigin(z); var minX = origin[0] + @@ -216,22 +217,22 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS gl.viewport(0, 0, framebufferDimension, framebufferDimension); gl.clearColor(0, 0, 0, 0); - gl.clear(ol.webgl.COLOR_BUFFER_BIT); - gl.disable(ol.webgl.BLEND); + gl.clear(_ol_webgl_.COLOR_BUFFER_BIT); + gl.disable(_ol_webgl_.BLEND); var program = context.getProgram(this.fragmentShader_, this.vertexShader_); context.useProgram(program); if (!this.locations_) { - this.locations_ = new ol.renderer.webgl.tilelayershader.Locations(gl, program); + this.locations_ = new _ol_renderer_webgl_tilelayershader_Locations_(gl, program); } - context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.renderArrayBuffer_); + context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.renderArrayBuffer_); gl.enableVertexAttribArray(this.locations_.a_position); gl.vertexAttribPointer( - this.locations_.a_position, 2, ol.webgl.FLOAT, false, 16, 0); + this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0); gl.enableVertexAttribArray(this.locations_.a_texCoord); gl.vertexAttribPointer( - this.locations_.a_texCoord, 2, ol.webgl.FLOAT, false, 16, 8); + this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8); gl.uniform1i(this.locations_.u_texture, 0); /** @@ -245,8 +246,8 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError(); var allTilesLoaded = true; - var tmpExtent = ol.extent.createEmpty(); - var tmpTileRange = new ol.TileRange(0, 0, 0, 0); + var tmpExtent = _ol_extent_.createEmpty(); + var tmpTileRange = new _ol_TileRange_(0, 0, 0, 0); var childTileRange, drawable, fullyLoaded, tile, tileState; var x, y, tileExtent; for (x = tileRange.minX; x <= tileRange.maxX; ++x) { @@ -256,25 +257,25 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS if (layerState.extent !== undefined) { // ignore tiles outside layer extent tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent); - if (!ol.extent.intersects(tileExtent, layerState.extent)) { + if (!_ol_extent_.intersects(tileExtent, layerState.extent)) { continue; } } tileState = tile.getState(); - drawable = tileState == ol.TileState.LOADED || - tileState == ol.TileState.EMPTY || - tileState == ol.TileState.ERROR && !useInterimTilesOnError; + drawable = tileState == _ol_TileState_.LOADED || + tileState == _ol_TileState_.EMPTY || + tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; if (!drawable) { tile = tile.getInterimTile(); } tileState = tile.getState(); - if (tileState == ol.TileState.LOADED) { + if (tileState == _ol_TileState_.LOADED) { if (mapRenderer.isTileTextureLoaded(tile)) { tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; continue; } - } else if (tileState == ol.TileState.EMPTY || - (tileState == ol.TileState.ERROR && + } else if (tileState == _ol_TileState_.EMPTY || + (tileState == _ol_TileState_.ERROR && !useInterimTilesOnError)) { continue; } @@ -296,7 +297,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS /** @type {Array.} */ var zs = Object.keys(tilesToDrawByZ).map(Number); - zs.sort(ol.array.numberSafeCompareFunction); + zs.sort(_ol_array_.numberSafeCompareFunction); var u_tileOffset = new Float32Array(4); var i, ii, tileKey, tilesToDraw; for (i = 0, ii = zs.length; i < ii; ++i) { @@ -314,8 +315,8 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS framebufferExtentDimension - 1; gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset); mapRenderer.bindTileTexture(tile, tilePixelSize, - tileGutter * pixelRatio, ol.webgl.LINEAR, ol.webgl.LINEAR); - gl.drawArrays(ol.webgl.TRIANGLE_STRIP, 0, 4); + tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR); + gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4); } } @@ -341,7 +342,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS * @param {ol.Tile} tile Tile. */ function(tile) { - if (tile.getState() == ol.TileState.LOADED && + if (tile.getState() == _ol_TileState_.LOADED && !mapRenderer.isTileTextureLoaded(tile) && !tileTextureQueue.isKeyQueued(tile.getKey())) { tileTextureQueue.enqueue([ @@ -356,21 +357,21 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS this.updateLogos(frameState, tileSource); var texCoordMatrix = this.texCoordMatrix; - ol.transform.reset(texCoordMatrix); - ol.transform.translate(texCoordMatrix, + _ol_transform_.reset(texCoordMatrix); + _ol_transform_.translate(texCoordMatrix, (Math.round(center[0] / tileResolution) * tileResolution - framebufferExtent[0]) / (framebufferExtent[2] - framebufferExtent[0]), (Math.round(center[1] / tileResolution) * tileResolution - framebufferExtent[1]) / (framebufferExtent[3] - framebufferExtent[1])); if (viewState.rotation !== 0) { - ol.transform.rotate(texCoordMatrix, viewState.rotation); + _ol_transform_.rotate(texCoordMatrix, viewState.rotation); } - ol.transform.scale(texCoordMatrix, + _ol_transform_.scale(texCoordMatrix, frameState.size[0] * viewState.resolution / (framebufferExtent[2] - framebufferExtent[0]), frameState.size[1] * viewState.resolution / (framebufferExtent[3] - framebufferExtent[1])); - ol.transform.translate(texCoordMatrix, -0.5, -0.5); + _ol_transform_.translate(texCoordMatrix, -0.5, -0.5); return true; }; @@ -379,7 +380,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS /** * @inheritDoc */ -ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { +_ol_renderer_webgl_TileLayer_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { if (!this.framebuffer) { return undefined; } @@ -388,7 +389,7 @@ ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, fram pixel[0] / frameState.size[0], (frameState.size[1] - pixel[1]) / frameState.size[1]]; - var pixelOnFrameBufferScaled = ol.transform.apply( + var pixelOnFrameBufferScaled = _ol_transform_.apply( this.texCoordMatrix, pixelOnMapScaled.slice()); var pixelOnFrameBuffer = [ pixelOnFrameBufferScaled[0] * this.framebufferDimension, @@ -406,3 +407,4 @@ ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, fram return undefined; } }; +export default _ol_renderer_webgl_TileLayer_; diff --git a/src/ol/renderer/webgl/VectorLayer.js b/src/ol/renderer/webgl/VectorLayer.js index d6ee33b21d..a6f134d72d 100644 --- a/src/ol/renderer/webgl/VectorLayer.js +++ b/src/ol/renderer/webgl/VectorLayer.js @@ -1,15 +1,15 @@ -goog.provide('ol.renderer.webgl.VectorLayer'); - -goog.require('ol'); -goog.require('ol.LayerType'); -goog.require('ol.ViewHint'); -goog.require('ol.extent'); -goog.require('ol.render.webgl.ReplayGroup'); -goog.require('ol.renderer.Type'); -goog.require('ol.renderer.vector'); -goog.require('ol.renderer.webgl.Layer'); -goog.require('ol.transform'); - +/** + * @module ol/renderer/webgl/VectorLayer + */ +import _ol_ from '../../index.js'; +import _ol_LayerType_ from '../../LayerType.js'; +import _ol_ViewHint_ from '../../ViewHint.js'; +import _ol_extent_ from '../../extent.js'; +import _ol_render_webgl_ReplayGroup_ from '../../render/webgl/ReplayGroup.js'; +import _ol_renderer_Type_ from '../Type.js'; +import _ol_renderer_vector_ from '../vector.js'; +import _ol_renderer_webgl_Layer_ from '../webgl/Layer.js'; +import _ol_transform_ from '../../transform.js'; /** * @constructor @@ -18,9 +18,9 @@ goog.require('ol.transform'); * @param {ol.layer.Vector} vectorLayer Vector layer. * @api */ -ol.renderer.webgl.VectorLayer = function(mapRenderer, vectorLayer) { +var _ol_renderer_webgl_VectorLayer_ = function(mapRenderer, vectorLayer) { - ol.renderer.webgl.Layer.call(this, mapRenderer, vectorLayer); + _ol_renderer_webgl_Layer_.call(this, mapRenderer, vectorLayer); /** * @private @@ -44,7 +44,7 @@ ol.renderer.webgl.VectorLayer = function(mapRenderer, vectorLayer) { * @private * @type {ol.Extent} */ - this.renderedExtent_ = ol.extent.createEmpty(); + this.renderedExtent_ = _ol_extent_.createEmpty(); /** * @private @@ -66,7 +66,8 @@ ol.renderer.webgl.VectorLayer = function(mapRenderer, vectorLayer) { this.layerState_ = null; }; -ol.inherits(ol.renderer.webgl.VectorLayer, ol.renderer.webgl.Layer); + +_ol_.inherits(_ol_renderer_webgl_VectorLayer_, _ol_renderer_webgl_Layer_); /** @@ -75,8 +76,8 @@ ol.inherits(ol.renderer.webgl.VectorLayer, ol.renderer.webgl.Layer); * @param {ol.layer.Layer} layer The candidate layer. * @return {boolean} The renderer can render the layer. */ -ol.renderer.webgl.VectorLayer['handles'] = function(type, layer) { - return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.VECTOR; +_ol_renderer_webgl_VectorLayer_['handles'] = function(type, layer) { + return type === _ol_renderer_Type_.WEBGL && layer.getType() === _ol_LayerType_.VECTOR; }; @@ -86,8 +87,8 @@ ol.renderer.webgl.VectorLayer['handles'] = function(type, layer) { * @param {ol.layer.Layer} layer The layer to be rendererd. * @return {ol.renderer.webgl.VectorLayer} The layer renderer. */ -ol.renderer.webgl.VectorLayer['create'] = function(mapRenderer, layer) { - return new ol.renderer.webgl.VectorLayer( +_ol_renderer_webgl_VectorLayer_['create'] = function(mapRenderer, layer) { + return new _ol_renderer_webgl_VectorLayer_( /** @type {ol.renderer.webgl.Map} */ (mapRenderer), /** @type {ol.layer.Vector} */ (layer) ); @@ -97,7 +98,7 @@ ol.renderer.webgl.VectorLayer['create'] = function(mapRenderer, layer) { /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.composeFrame = function(frameState, layerState, context) { +_ol_renderer_webgl_VectorLayer_.prototype.composeFrame = function(frameState, layerState, context) { this.layerState_ = layerState; var viewState = frameState.viewState; var replayGroup = this.replayGroup_; @@ -120,21 +121,21 @@ ol.renderer.webgl.VectorLayer.prototype.composeFrame = function(frameState, laye /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() { +_ol_renderer_webgl_VectorLayer_.prototype.disposeInternal = function() { var replayGroup = this.replayGroup_; if (replayGroup) { var context = this.mapRenderer.getContext(); replayGroup.getDeleteResourcesFunction(context)(); this.replayGroup_ = null; } - ol.renderer.webgl.Layer.prototype.disposeInternal.call(this); + _ol_renderer_webgl_Layer_.prototype.disposeInternal.call(this); }; /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { +_ol_renderer_webgl_VectorLayer_.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { if (!this.replayGroup_ || !this.layerState_) { return undefined; } else { @@ -153,7 +154,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(co * @return {?} Callback result. */ function(feature) { - var key = ol.getUid(feature).toString(); + var key = _ol_.getUid(feature).toString(); if (!(key in features)) { features[key] = true; return callback.call(thisArg, feature, layer); @@ -166,7 +167,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(co /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) { +_ol_renderer_webgl_VectorLayer_.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) { if (!this.replayGroup_ || !this.layerState_) { return false; } else { @@ -184,8 +185,8 @@ ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = function(coordi /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { - var coordinate = ol.transform.apply( +_ol_renderer_webgl_VectorLayer_.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) { + var coordinate = _ol_transform_.apply( frameState.pixelToCoordinateTransform, pixel.slice()); var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState); @@ -202,7 +203,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = function(pixel, fr * @param {ol.events.Event} event Image style change event. * @private */ -ol.renderer.webgl.VectorLayer.prototype.handleStyleImageChange_ = function(event) { +_ol_renderer_webgl_VectorLayer_.prototype.handleStyleImageChange_ = function(event) { this.renderIfReadyAndVisible(); }; @@ -210,15 +211,15 @@ ol.renderer.webgl.VectorLayer.prototype.handleStyleImageChange_ = function(event /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, layerState, context) { +_ol_renderer_webgl_VectorLayer_.prototype.prepareFrame = function(frameState, layerState, context) { var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer()); var vectorSource = vectorLayer.getSource(); this.updateLogos(frameState, vectorSource); - var animating = frameState.viewHints[ol.ViewHint.ANIMATING]; - var interacting = frameState.viewHints[ol.ViewHint.INTERACTING]; + var animating = frameState.viewHints[_ol_ViewHint_.ANIMATING]; + var interacting = frameState.viewHints[_ol_ViewHint_.INTERACTING]; var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating(); var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting(); @@ -237,17 +238,17 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, laye var vectorLayerRenderOrder = vectorLayer.getRenderOrder(); if (vectorLayerRenderOrder === undefined) { - vectorLayerRenderOrder = ol.renderer.vector.defaultOrder; + vectorLayerRenderOrder = _ol_renderer_vector_.defaultOrder; } - var extent = ol.extent.buffer(frameStateExtent, + var extent = _ol_extent_.buffer(frameStateExtent, vectorLayerRenderBuffer * resolution); if (!this.dirty_ && this.renderedResolution_ == resolution && this.renderedRevision_ == vectorLayerRevision && this.renderedRenderOrder_ == vectorLayerRenderOrder && - ol.extent.containsExtent(this.renderedExtent_, extent)) { + _ol_extent_.containsExtent(this.renderedExtent_, extent)) { return true; } @@ -258,8 +259,8 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, laye this.dirty_ = false; - var replayGroup = new ol.render.webgl.ReplayGroup( - ol.renderer.vector.getTolerance(resolution, pixelRatio), + var replayGroup = new _ol_render_webgl_ReplayGroup_( + _ol_renderer_vector_.getTolerance(resolution, pixelRatio), extent, vectorLayer.getRenderBuffer()); vectorSource.loadFeatures(extent, resolution, projection); /** @@ -319,23 +320,24 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, laye * @param {ol.render.webgl.ReplayGroup} replayGroup Replay group. * @return {boolean} `true` if an image is loading. */ -ol.renderer.webgl.VectorLayer.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) { +_ol_renderer_webgl_VectorLayer_.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) { if (!styles) { return false; } var loading = false; if (Array.isArray(styles)) { for (var i = styles.length - 1, ii = 0; i >= ii; --i) { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles[i], - ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio), + _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), this.handleStyleImageChange_, this) || loading; } } else { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles, - ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio), + _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), this.handleStyleImageChange_, this) || loading; } return loading; }; +export default _ol_renderer_webgl_VectorLayer_; diff --git a/src/ol/renderer/webgl/defaultmapshader.js b/src/ol/renderer/webgl/defaultmapshader.js index 6ffc781216..158ac27381 100644 --- a/src/ol/renderer/webgl/defaultmapshader.js +++ b/src/ol/renderer/webgl/defaultmapshader.js @@ -1,15 +1,18 @@ +/** + * @module ol/renderer/webgl/defaultmapshader + */ // This file is automatically generated, do not edit -goog.provide('ol.renderer.webgl.defaultmapshader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../index.js'; +import _ol_webgl_Fragment_ from '../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../webgl/Vertex.js'; +var _ol_renderer_webgl_defaultmapshader_ = {}; -ol.renderer.webgl.defaultmapshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_renderer_webgl_defaultmapshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n' : 'precision mediump float;varying vec2 a;uniform float f;uniform sampler2D g;void main(void){vec4 texColor=texture2D(g,a);gl_FragColor.rgb=texColor.rgb;gl_FragColor.a=texColor.a*f;}'); -ol.renderer.webgl.defaultmapshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_renderer_webgl_defaultmapshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat4 u_texCoordMatrix;\nuniform mat4 u_projectionMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;\n}\n\n\n' : 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform mat4 d;uniform mat4 e;void main(void){gl_Position=e*vec4(b,0.,1.);a=(d*vec4(c,0.,1.)).st;}'); +export default _ol_renderer_webgl_defaultmapshader_; diff --git a/src/ol/renderer/webgl/defaultmapshader/Locations.js b/src/ol/renderer/webgl/defaultmapshader/Locations.js index 9d6e2533b0..632a32a710 100644 --- a/src/ol/renderer/webgl/defaultmapshader/Locations.js +++ b/src/ol/renderer/webgl/defaultmapshader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/renderer/webgl/defaultmapshader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.renderer.webgl.defaultmapshader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../index.js'; /** * @constructor @@ -10,41 +10,43 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.renderer.webgl.defaultmapshader.Locations = function(gl, program) { +var _ol_renderer_webgl_defaultmapshader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_texCoordMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_texCoordMatrix' : 'd'); + program, _ol_.DEBUG_WEBGL ? 'u_texCoordMatrix' : 'd'); /** * @type {WebGLUniformLocation} */ this.u_projectionMatrix = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'e'); /** * @type {WebGLUniformLocation} */ this.u_opacity = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_opacity' : 'f'); + program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'f'); /** * @type {WebGLUniformLocation} */ this.u_texture = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_texture' : 'g'); + program, _ol_.DEBUG_WEBGL ? 'u_texture' : 'g'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'b'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'b'); /** * @type {number} */ this.a_texCoord = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c'); + program, _ol_.DEBUG_WEBGL ? 'a_texCoord' : 'c'); }; + +export default _ol_renderer_webgl_defaultmapshader_Locations_; diff --git a/src/ol/renderer/webgl/tilelayershader.js b/src/ol/renderer/webgl/tilelayershader.js index ef08b16a54..7bbcbc7c8a 100644 --- a/src/ol/renderer/webgl/tilelayershader.js +++ b/src/ol/renderer/webgl/tilelayershader.js @@ -1,15 +1,18 @@ +/** + * @module ol/renderer/webgl/tilelayershader + */ // This file is automatically generated, do not edit -goog.provide('ol.renderer.webgl.tilelayershader'); - -goog.require('ol'); -goog.require('ol.webgl.Fragment'); -goog.require('ol.webgl.Vertex'); +import _ol_ from '../../index.js'; +import _ol_webgl_Fragment_ from '../../webgl/Fragment.js'; +import _ol_webgl_Vertex_ from '../../webgl/Vertex.js'; +var _ol_renderer_webgl_tilelayershader_ = {}; -ol.renderer.webgl.tilelayershader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ? +_ol_renderer_webgl_tilelayershader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ? 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n}\n' : 'precision mediump float;varying vec2 a;uniform sampler2D e;void main(void){gl_FragColor=texture2D(e,a);}'); -ol.renderer.webgl.tilelayershader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ? +_ol_renderer_webgl_tilelayershader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ? 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nuniform vec4 u_tileOffset;\n\nvoid main(void) {\n gl_Position = vec4(a_position * u_tileOffset.xy + u_tileOffset.zw, 0., 1.);\n v_texCoord = a_texCoord;\n}\n\n\n' : 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform vec4 d;void main(void){gl_Position=vec4(b*d.xy+d.zw,0.,1.);a=c;}'); +export default _ol_renderer_webgl_tilelayershader_; diff --git a/src/ol/renderer/webgl/tilelayershader/Locations.js b/src/ol/renderer/webgl/tilelayershader/Locations.js index 09686582c3..feb5c8dc5f 100644 --- a/src/ol/renderer/webgl/tilelayershader/Locations.js +++ b/src/ol/renderer/webgl/tilelayershader/Locations.js @@ -1,8 +1,8 @@ +/** + * @module ol/renderer/webgl/tilelayershader/Locations + */ // This file is automatically generated, do not edit -goog.provide('ol.renderer.webgl.tilelayershader.Locations'); - -goog.require('ol'); - +import _ol_ from '../../../index.js'; /** * @constructor @@ -10,29 +10,31 @@ goog.require('ol'); * @param {WebGLProgram} program Program. * @struct */ -ol.renderer.webgl.tilelayershader.Locations = function(gl, program) { +var _ol_renderer_webgl_tilelayershader_Locations_ = function(gl, program) { /** * @type {WebGLUniformLocation} */ this.u_tileOffset = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_tileOffset' : 'd'); + program, _ol_.DEBUG_WEBGL ? 'u_tileOffset' : 'd'); /** * @type {WebGLUniformLocation} */ this.u_texture = gl.getUniformLocation( - program, ol.DEBUG_WEBGL ? 'u_texture' : 'e'); + program, _ol_.DEBUG_WEBGL ? 'u_texture' : 'e'); /** * @type {number} */ this.a_position = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_position' : 'b'); + program, _ol_.DEBUG_WEBGL ? 'a_position' : 'b'); /** * @type {number} */ this.a_texCoord = gl.getAttribLocation( - program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c'); + program, _ol_.DEBUG_WEBGL ? 'a_texCoord' : 'c'); }; + +export default _ol_renderer_webgl_tilelayershader_Locations_; diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 32422c8e8d..7eb6ff653e 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -1,9 +1,11 @@ -goog.provide('ol.reproj'); - -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.proj'); +/** + * @module ol/reproj + */ +import _ol_dom_ from './dom.js'; +import _ol_extent_ from './extent.js'; +import _ol_math_ from './math.js'; +import _ol_proj_ from './proj.js'; +var _ol_reproj_ = {}; /** @@ -18,14 +20,14 @@ goog.require('ol.proj'); * @param {number} targetResolution Target resolution. * @return {number} The best resolution to use. Can be +-Infinity, NaN or 0. */ -ol.reproj.calculateSourceResolution = function(sourceProj, targetProj, +_ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj, targetCenter, targetResolution) { - var sourceCenter = ol.proj.transform(targetCenter, targetProj, sourceProj); + var sourceCenter = _ol_proj_.transform(targetCenter, targetProj, sourceProj); // calculate the ideal resolution of the source data var sourceResolution = - ol.proj.getPointResolution(targetProj, targetResolution, targetCenter); + _ol_proj_.getPointResolution(targetProj, targetResolution, targetCenter); var targetMetersPerUnit = targetProj.getMetersPerUnit(); if (targetMetersPerUnit !== undefined) { @@ -41,9 +43,9 @@ ol.reproj.calculateSourceResolution = function(sourceProj, targetProj, // in order to achieve optimal results. var sourceExtent = sourceProj.getExtent(); - if (!sourceExtent || ol.extent.containsCoordinate(sourceExtent, sourceCenter)) { + if (!sourceExtent || _ol_extent_.containsCoordinate(sourceExtent, sourceCenter)) { var compensationFactor = - ol.proj.getPointResolution(sourceProj, sourceResolution, sourceCenter) / + _ol_proj_.getPointResolution(sourceProj, sourceResolution, sourceCenter) / sourceResolution; if (isFinite(compensationFactor) && compensationFactor > 0) { sourceResolution /= compensationFactor; @@ -65,7 +67,7 @@ ol.reproj.calculateSourceResolution = function(sourceProj, targetProj, * @return {ol.Coordinate} New point 1 px farther from the centroid. * @private */ -ol.reproj.enlargeClipPoint_ = function(centroidX, centroidY, x, y) { +_ol_reproj_.enlargeClipPoint_ = function(centroidX, centroidY, x, y) { var dX = x - centroidX, dY = y - centroidY; var distance = Math.sqrt(dX * dX + dY * dY); return [Math.round(x + dX / distance), Math.round(y + dY / distance)]; @@ -90,11 +92,11 @@ ol.reproj.enlargeClipPoint_ = function(centroidX, centroidY, x, y) { * @param {boolean=} opt_renderEdges Render reprojection edges. * @return {HTMLCanvasElement} Canvas with reprojected data. */ -ol.reproj.render = function(width, height, pixelRatio, +_ol_reproj_.render = function(width, height, pixelRatio, sourceResolution, sourceExtent, targetResolution, targetExtent, triangulation, sources, gutter, opt_renderEdges) { - var context = ol.dom.createCanvasContext2D(Math.round(pixelRatio * width), + var context = _ol_dom_.createCanvasContext2D(Math.round(pixelRatio * width), Math.round(pixelRatio * height)); if (sources.length === 0) { @@ -103,14 +105,14 @@ ol.reproj.render = function(width, height, pixelRatio, context.scale(pixelRatio, pixelRatio); - var sourceDataExtent = ol.extent.createEmpty(); + var sourceDataExtent = _ol_extent_.createEmpty(); sources.forEach(function(src, i, arr) { - ol.extent.extend(sourceDataExtent, src.extent); + _ol_extent_.extend(sourceDataExtent, src.extent); }); - var canvasWidthInUnits = ol.extent.getWidth(sourceDataExtent); - var canvasHeightInUnits = ol.extent.getHeight(sourceDataExtent); - var stitchContext = ol.dom.createCanvasContext2D( + var canvasWidthInUnits = _ol_extent_.getWidth(sourceDataExtent); + var canvasHeightInUnits = _ol_extent_.getHeight(sourceDataExtent); + var stitchContext = _ol_dom_.createCanvasContext2D( Math.round(pixelRatio * canvasWidthInUnits / sourceResolution), Math.round(pixelRatio * canvasHeightInUnits / sourceResolution)); @@ -119,8 +121,8 @@ ol.reproj.render = function(width, height, pixelRatio, sources.forEach(function(src, i, arr) { var xPos = src.extent[0] - sourceDataExtent[0]; var yPos = -(src.extent[3] - sourceDataExtent[3]); - var srcWidth = ol.extent.getWidth(src.extent); - var srcHeight = ol.extent.getHeight(src.extent); + var srcWidth = _ol_extent_.getWidth(src.extent); + var srcHeight = _ol_extent_.getHeight(src.extent); stitchContext.drawImage( src.image, @@ -130,7 +132,7 @@ ol.reproj.render = function(width, height, pixelRatio, srcWidth * stitchScale, srcHeight * stitchScale); }); - var targetTopLeft = ol.extent.getTopLeft(targetExtent); + var targetTopLeft = _ol_extent_.getTopLeft(targetExtent); triangulation.getTriangles().forEach(function(triangle, i, arr) { /* Calculate affine transform (src -> dst) @@ -181,7 +183,7 @@ ol.reproj.render = function(width, height, pixelRatio, [0, 0, x1, y1, v1 - v0], [0, 0, x2, y2, v2 - v0] ]; - var affineCoefs = ol.math.solveLinearSystem(augmentedMatrix); + var affineCoefs = _ol_math_.solveLinearSystem(augmentedMatrix); if (!affineCoefs) { return; } @@ -189,9 +191,9 @@ ol.reproj.render = function(width, height, pixelRatio, context.save(); context.beginPath(); var centroidX = (u0 + u1 + u2) / 3, centroidY = (v0 + v1 + v2) / 3; - var p0 = ol.reproj.enlargeClipPoint_(centroidX, centroidY, u0, v0); - var p1 = ol.reproj.enlargeClipPoint_(centroidX, centroidY, u1, v1); - var p2 = ol.reproj.enlargeClipPoint_(centroidX, centroidY, u2, v2); + var p0 = _ol_reproj_.enlargeClipPoint_(centroidX, centroidY, u0, v0); + var p1 = _ol_reproj_.enlargeClipPoint_(centroidX, centroidY, u1, v1); + var p2 = _ol_reproj_.enlargeClipPoint_(centroidX, centroidY, u2, v2); context.moveTo(p1[0], p1[1]); context.lineTo(p0[0], p0[1]); @@ -238,3 +240,4 @@ ol.reproj.render = function(width, height, pixelRatio, } return context.canvas; }; +export default _ol_reproj_; diff --git a/src/ol/reproj/Image.js b/src/ol/reproj/Image.js index fa3a921e01..dfa6088e63 100644 --- a/src/ol/reproj/Image.js +++ b/src/ol/reproj/Image.js @@ -1,14 +1,14 @@ -goog.provide('ol.reproj.Image'); - -goog.require('ol'); -goog.require('ol.ImageBase'); -goog.require('ol.ImageState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.reproj'); -goog.require('ol.reproj.Triangulation'); - +/** + * @module ol/reproj/Image + */ +import _ol_ from '../index.js'; +import _ol_ImageBase_ from '../ImageBase.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_reproj_ from '../reproj.js'; +import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js'; /** * @classdesc @@ -25,7 +25,7 @@ goog.require('ol.reproj.Triangulation'); * @param {ol.ReprojImageFunctionType} getImageFunction * Function returning source images (extent, resolution, pixelRatio). */ -ol.reproj.Image = function(sourceProj, targetProj, +var _ol_reproj_Image_ = function(sourceProj, targetProj, targetExtent, targetResolution, pixelRatio, getImageFunction) { /** @@ -42,19 +42,19 @@ ol.reproj.Image = function(sourceProj, targetProj, var maxTargetExtent = targetProj.getExtent(); var limitedTargetExtent = maxTargetExtent ? - ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent; + _ol_extent_.getIntersection(targetExtent, maxTargetExtent) : targetExtent; - var targetCenter = ol.extent.getCenter(limitedTargetExtent); - var sourceResolution = ol.reproj.calculateSourceResolution( + var targetCenter = _ol_extent_.getCenter(limitedTargetExtent); + var sourceResolution = _ol_reproj_.calculateSourceResolution( sourceProj, targetProj, targetCenter, targetResolution); - var errorThresholdInPixels = ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; + var errorThresholdInPixels = _ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; /** * @private * @type {!ol.reproj.Triangulation} */ - this.triangulation_ = new ol.reproj.Triangulation( + this.triangulation_ = new _ol_reproj_Triangulation_( sourceProj, targetProj, limitedTargetExtent, this.maxSourceExtent_, sourceResolution * errorThresholdInPixels); @@ -99,32 +99,33 @@ ol.reproj.Image = function(sourceProj, targetProj, this.sourceListenerKey_ = null; - var state = ol.ImageState.LOADED; + var state = _ol_ImageState_.LOADED; if (this.sourceImage_) { - state = ol.ImageState.IDLE; + state = _ol_ImageState_.IDLE; } - ol.ImageBase.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state); + _ol_ImageBase_.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state); }; -ol.inherits(ol.reproj.Image, ol.ImageBase); + +_ol_.inherits(_ol_reproj_Image_, _ol_ImageBase_); /** * @inheritDoc */ -ol.reproj.Image.prototype.disposeInternal = function() { - if (this.state == ol.ImageState.LOADING) { +_ol_reproj_Image_.prototype.disposeInternal = function() { + if (this.state == _ol_ImageState_.LOADING) { this.unlistenSource_(); } - ol.ImageBase.prototype.disposeInternal.call(this); + _ol_ImageBase_.prototype.disposeInternal.call(this); }; /** * @inheritDoc */ -ol.reproj.Image.prototype.getImage = function() { +_ol_reproj_Image_.prototype.getImage = function() { return this.canvas_; }; @@ -132,7 +133,7 @@ ol.reproj.Image.prototype.getImage = function() { /** * @return {ol.proj.Projection} Projection. */ -ol.reproj.Image.prototype.getProjection = function() { +_ol_reproj_Image_.prototype.getProjection = function() { return this.targetProj_; }; @@ -140,14 +141,14 @@ ol.reproj.Image.prototype.getProjection = function() { /** * @private */ -ol.reproj.Image.prototype.reproject_ = function() { +_ol_reproj_Image_.prototype.reproject_ = function() { var sourceState = this.sourceImage_.getState(); - if (sourceState == ol.ImageState.LOADED) { - var width = ol.extent.getWidth(this.targetExtent_) / this.targetResolution_; + if (sourceState == _ol_ImageState_.LOADED) { + var width = _ol_extent_.getWidth(this.targetExtent_) / this.targetResolution_; var height = - ol.extent.getHeight(this.targetExtent_) / this.targetResolution_; + _ol_extent_.getHeight(this.targetExtent_) / this.targetResolution_; - this.canvas_ = ol.reproj.render(width, height, this.sourcePixelRatio_, + this.canvas_ = _ol_reproj_.render(width, height, this.sourcePixelRatio_, this.sourceImage_.getResolution(), this.maxSourceExtent_, this.targetResolution_, this.targetExtent_, this.triangulation_, [{ extent: this.sourceImage_.getExtent(), @@ -162,21 +163,21 @@ ol.reproj.Image.prototype.reproject_ = function() { /** * @inheritDoc */ -ol.reproj.Image.prototype.load = function() { - if (this.state == ol.ImageState.IDLE) { - this.state = ol.ImageState.LOADING; +_ol_reproj_Image_.prototype.load = function() { + if (this.state == _ol_ImageState_.IDLE) { + this.state = _ol_ImageState_.LOADING; this.changed(); var sourceState = this.sourceImage_.getState(); - if (sourceState == ol.ImageState.LOADED || - sourceState == ol.ImageState.ERROR) { + if (sourceState == _ol_ImageState_.LOADED || + sourceState == _ol_ImageState_.ERROR) { this.reproject_(); } else { - this.sourceListenerKey_ = ol.events.listen(this.sourceImage_, - ol.events.EventType.CHANGE, function(e) { + this.sourceListenerKey_ = _ol_events_.listen(this.sourceImage_, + _ol_events_EventType_.CHANGE, function(e) { var sourceState = this.sourceImage_.getState(); - if (sourceState == ol.ImageState.LOADED || - sourceState == ol.ImageState.ERROR) { + if (sourceState == _ol_ImageState_.LOADED || + sourceState == _ol_ImageState_.ERROR) { this.unlistenSource_(); this.reproject_(); } @@ -190,7 +191,8 @@ ol.reproj.Image.prototype.load = function() { /** * @private */ -ol.reproj.Image.prototype.unlistenSource_ = function() { - ol.events.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_)); +_ol_reproj_Image_.prototype.unlistenSource_ = function() { + _ol_events_.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_)); this.sourceListenerKey_ = null; }; +export default _ol_reproj_Image_; diff --git a/src/ol/reproj/Tile.js b/src/ol/reproj/Tile.js index 71d77b318a..fa7ca68250 100644 --- a/src/ol/reproj/Tile.js +++ b/src/ol/reproj/Tile.js @@ -1,15 +1,15 @@ -goog.provide('ol.reproj.Tile'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.reproj'); -goog.require('ol.reproj.Triangulation'); - +/** + * @module ol/reproj/Tile + */ +import _ol_ from '../index.js'; +import _ol_Tile_ from '../Tile.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_math_ from '../math.js'; +import _ol_reproj_ from '../reproj.js'; +import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js'; /** * @classdesc @@ -31,11 +31,11 @@ goog.require('ol.reproj.Triangulation'); * @param {number=} opt_errorThreshold Acceptable reprojection error (in px). * @param {boolean=} opt_renderEdges Render reprojection edges. */ -ol.reproj.Tile = function(sourceProj, sourceTileGrid, +var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, targetProj, targetTileGrid, tileCoord, wrappedTileCoord, pixelRatio, gutter, getTileFunction, opt_errorThreshold, opt_renderEdges) { - ol.Tile.call(this, tileCoord, ol.TileState.IDLE); + _ol_Tile_.call(this, tileCoord, _ol_TileState_.IDLE); /** * @private @@ -102,12 +102,12 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid, var maxSourceExtent = this.sourceTileGrid_.getExtent(); var limitedTargetExtent = maxTargetExtent ? - ol.extent.getIntersection(targetExtent, maxTargetExtent) : targetExtent; + _ol_extent_.getIntersection(targetExtent, maxTargetExtent) : targetExtent; - if (ol.extent.getArea(limitedTargetExtent) === 0) { + if (_ol_extent_.getArea(limitedTargetExtent) === 0) { // Tile is completely outside range -> EMPTY // TODO: is it actually correct that the source even creates the tile ? - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; return; } @@ -116,7 +116,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid, if (!maxSourceExtent) { maxSourceExtent = sourceProjExtent; } else { - maxSourceExtent = ol.extent.getIntersection( + maxSourceExtent = _ol_extent_.getIntersection( maxSourceExtent, sourceProjExtent); } } @@ -124,31 +124,31 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid, var targetResolution = targetTileGrid.getResolution( this.wrappedTileCoord_[0]); - var targetCenter = ol.extent.getCenter(limitedTargetExtent); - var sourceResolution = ol.reproj.calculateSourceResolution( + var targetCenter = _ol_extent_.getCenter(limitedTargetExtent); + var sourceResolution = _ol_reproj_.calculateSourceResolution( sourceProj, targetProj, targetCenter, targetResolution); if (!isFinite(sourceResolution) || sourceResolution <= 0) { // invalid sourceResolution -> EMPTY // probably edges of the projections when no extent is defined - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; return; } var errorThresholdInPixels = opt_errorThreshold !== undefined ? - opt_errorThreshold : ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; + opt_errorThreshold : _ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; /** * @private * @type {!ol.reproj.Triangulation} */ - this.triangulation_ = new ol.reproj.Triangulation( + this.triangulation_ = new _ol_reproj_Triangulation_( sourceProj, targetProj, limitedTargetExtent, maxSourceExtent, sourceResolution * errorThresholdInPixels); if (this.triangulation_.getTriangles().length === 0) { // no valid triangles -> EMPTY - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; return; } @@ -157,17 +157,17 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid, if (maxSourceExtent) { if (sourceProj.canWrapX()) { - sourceExtent[1] = ol.math.clamp( + sourceExtent[1] = _ol_math_.clamp( sourceExtent[1], maxSourceExtent[1], maxSourceExtent[3]); - sourceExtent[3] = ol.math.clamp( + sourceExtent[3] = _ol_math_.clamp( sourceExtent[3], maxSourceExtent[1], maxSourceExtent[3]); } else { - sourceExtent = ol.extent.getIntersection(sourceExtent, maxSourceExtent); + sourceExtent = _ol_extent_.getIntersection(sourceExtent, maxSourceExtent); } } - if (!ol.extent.getArea(sourceExtent)) { - this.state = ol.TileState.EMPTY; + if (!_ol_extent_.getArea(sourceExtent)) { + this.state = _ol_TileState_.EMPTY; } else { var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ( sourceExtent, this.sourceZ_); @@ -182,21 +182,22 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid, } if (this.sourceTiles_.length === 0) { - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; } } }; -ol.inherits(ol.reproj.Tile, ol.Tile); + +_ol_.inherits(_ol_reproj_Tile_, _ol_Tile_); /** * @inheritDoc */ -ol.reproj.Tile.prototype.disposeInternal = function() { - if (this.state == ol.TileState.LOADING) { +_ol_reproj_Tile_.prototype.disposeInternal = function() { + if (this.state == _ol_TileState_.LOADING) { this.unlistenSources_(); } - ol.Tile.prototype.disposeInternal.call(this); + _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -204,7 +205,7 @@ ol.reproj.Tile.prototype.disposeInternal = function() { * Get the HTML Canvas element for this tile. * @return {HTMLCanvasElement} Canvas. */ -ol.reproj.Tile.prototype.getImage = function() { +_ol_reproj_Tile_.prototype.getImage = function() { return this.canvas_; }; @@ -212,10 +213,10 @@ ol.reproj.Tile.prototype.getImage = function() { /** * @private */ -ol.reproj.Tile.prototype.reproject_ = function() { +_ol_reproj_Tile_.prototype.reproject_ = function() { var sources = []; this.sourceTiles_.forEach(function(tile, i, arr) { - if (tile && tile.getState() == ol.TileState.LOADED) { + if (tile && tile.getState() == _ol_TileState_.LOADED) { sources.push({ extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord), image: tile.getImage() @@ -225,7 +226,7 @@ ol.reproj.Tile.prototype.reproject_ = function() { this.sourceTiles_.length = 0; if (sources.length === 0) { - this.state = ol.TileState.ERROR; + this.state = _ol_TileState_.ERROR; } else { var z = this.wrappedTileCoord_[0]; var size = this.targetTileGrid_.getTileSize(z); @@ -236,12 +237,12 @@ ol.reproj.Tile.prototype.reproject_ = function() { var targetExtent = this.targetTileGrid_.getTileCoordExtent( this.wrappedTileCoord_); - this.canvas_ = ol.reproj.render(width, height, this.pixelRatio_, + this.canvas_ = _ol_reproj_.render(width, height, this.pixelRatio_, sourceResolution, this.sourceTileGrid_.getExtent(), targetResolution, targetExtent, this.triangulation_, sources, this.gutter_, this.renderEdges_); - this.state = ol.TileState.LOADED; + this.state = _ol_TileState_.LOADED; } this.changed(); }; @@ -250,9 +251,9 @@ ol.reproj.Tile.prototype.reproject_ = function() { /** * @inheritDoc */ -ol.reproj.Tile.prototype.load = function() { - if (this.state == ol.TileState.IDLE) { - this.state = ol.TileState.LOADING; +_ol_reproj_Tile_.prototype.load = function() { + if (this.state == _ol_TileState_.IDLE) { + this.state = _ol_TileState_.LOADING; this.changed(); var leftToLoad = 0; @@ -260,17 +261,17 @@ ol.reproj.Tile.prototype.load = function() { this.sourcesListenerKeys_ = []; this.sourceTiles_.forEach(function(tile, i, arr) { var state = tile.getState(); - if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) { + if (state == _ol_TileState_.IDLE || state == _ol_TileState_.LOADING) { leftToLoad++; var sourceListenKey; - sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE, + sourceListenKey = _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(e) { var state = tile.getState(); - if (state == ol.TileState.LOADED || - state == ol.TileState.ERROR || - state == ol.TileState.EMPTY) { - ol.events.unlistenByKey(sourceListenKey); + if (state == _ol_TileState_.LOADED || + state == _ol_TileState_.ERROR || + state == _ol_TileState_.EMPTY) { + _ol_events_.unlistenByKey(sourceListenKey); leftToLoad--; if (leftToLoad === 0) { this.unlistenSources_(); @@ -284,7 +285,7 @@ ol.reproj.Tile.prototype.load = function() { this.sourceTiles_.forEach(function(tile, i, arr) { var state = tile.getState(); - if (state == ol.TileState.IDLE) { + if (state == _ol_TileState_.IDLE) { tile.load(); } }); @@ -299,7 +300,8 @@ ol.reproj.Tile.prototype.load = function() { /** * @private */ -ol.reproj.Tile.prototype.unlistenSources_ = function() { - this.sourcesListenerKeys_.forEach(ol.events.unlistenByKey); +_ol_reproj_Tile_.prototype.unlistenSources_ = function() { + this.sourcesListenerKeys_.forEach(_ol_events_.unlistenByKey); this.sourcesListenerKeys_ = null; }; +export default _ol_reproj_Tile_; diff --git a/src/ol/reproj/Triangulation.js b/src/ol/reproj/Triangulation.js index e4ef2e33d1..bc3eaf5b50 100644 --- a/src/ol/reproj/Triangulation.js +++ b/src/ol/reproj/Triangulation.js @@ -1,10 +1,10 @@ -goog.provide('ol.reproj.Triangulation'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.proj'); - +/** + * @module ol/reproj/Triangulation + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_math_ from '../math.js'; +import _ol_proj_ from '../proj.js'; /** * @classdesc @@ -18,7 +18,7 @@ goog.require('ol.proj'); * @param {number} errorThreshold Acceptable error (in source units). * @constructor */ -ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent, +var _ol_reproj_Triangulation_ = function(sourceProj, targetProj, targetExtent, maxSourceExtent, errorThreshold) { /** @@ -35,7 +35,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent, /** @type {!Object.} */ var transformInvCache = {}; - var transformInv = ol.proj.getTransform(this.targetProj_, this.sourceProj_); + var transformInv = _ol_proj_.getTransform(this.targetProj_, this.sourceProj_); /** * @param {ol.Coordinate} c A coordinate. @@ -82,27 +82,27 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent, this.canWrapXInSource_ = this.sourceProj_.canWrapX() && !!maxSourceExtent && !!this.sourceProj_.getExtent() && - (ol.extent.getWidth(maxSourceExtent) == - ol.extent.getWidth(this.sourceProj_.getExtent())); + (_ol_extent_.getWidth(maxSourceExtent) == + _ol_extent_.getWidth(this.sourceProj_.getExtent())); /** * @type {?number} * @private */ this.sourceWorldWidth_ = this.sourceProj_.getExtent() ? - ol.extent.getWidth(this.sourceProj_.getExtent()) : null; + _ol_extent_.getWidth(this.sourceProj_.getExtent()) : null; /** * @type {?number} * @private */ this.targetWorldWidth_ = this.targetProj_.getExtent() ? - ol.extent.getWidth(this.targetProj_.getExtent()) : null; + _ol_extent_.getWidth(this.targetProj_.getExtent()) : null; - var destinationTopLeft = ol.extent.getTopLeft(targetExtent); - var destinationTopRight = ol.extent.getTopRight(targetExtent); - var destinationBottomRight = ol.extent.getBottomRight(targetExtent); - var destinationBottomLeft = ol.extent.getBottomLeft(targetExtent); + var destinationTopLeft = _ol_extent_.getTopLeft(targetExtent); + var destinationTopRight = _ol_extent_.getTopRight(targetExtent); + var destinationBottomRight = _ol_extent_.getBottomRight(targetExtent); + var destinationBottomLeft = _ol_extent_.getBottomLeft(targetExtent); var sourceTopLeft = this.transformInv_(destinationTopLeft); var sourceTopRight = this.transformInv_(destinationTopRight); var sourceBottomRight = this.transformInv_(destinationBottomRight); @@ -112,7 +112,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent, destinationTopLeft, destinationTopRight, destinationBottomRight, destinationBottomLeft, sourceTopLeft, sourceTopRight, sourceBottomRight, sourceBottomLeft, - ol.RASTER_REPROJECTION_MAX_SUBDIVISION); + _ol_.RASTER_REPROJECTION_MAX_SUBDIVISION); if (this.wrapsXInSource_) { var leftBound = Infinity; @@ -167,7 +167,7 @@ ol.reproj.Triangulation = function(sourceProj, targetProj, targetExtent, * @param {ol.Coordinate} cSrc The source c coordinate. * @private */ -ol.reproj.Triangulation.prototype.addTriangle_ = function(a, b, c, +_ol_reproj_Triangulation_.prototype.addTriangle_ = function(a, b, c, aSrc, bSrc, cSrc) { this.triangles_.push({ source: [aSrc, bSrc, cSrc], @@ -192,12 +192,12 @@ ol.reproj.Triangulation.prototype.addTriangle_ = function(a, b, c, * @param {number} maxSubdivision Maximal allowed subdivision of the quad. * @private */ -ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d, +_ol_reproj_Triangulation_.prototype.addQuad_ = function(a, b, c, d, aSrc, bSrc, cSrc, dSrc, maxSubdivision) { - var sourceQuadExtent = ol.extent.boundingExtent([aSrc, bSrc, cSrc, dSrc]); + var sourceQuadExtent = _ol_extent_.boundingExtent([aSrc, bSrc, cSrc, dSrc]); var sourceCoverageX = this.sourceWorldWidth_ ? - ol.extent.getWidth(sourceQuadExtent) / this.sourceWorldWidth_ : null; + _ol_extent_.getWidth(sourceQuadExtent) / this.sourceWorldWidth_ : null; var sourceWorldWidth = /** @type {number} */ (this.sourceWorldWidth_); // when the quad is wrapped in the source projection @@ -209,20 +209,20 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d, if (maxSubdivision > 0) { if (this.targetProj_.isGlobal() && this.targetWorldWidth_) { - var targetQuadExtent = ol.extent.boundingExtent([a, b, c, d]); + var targetQuadExtent = _ol_extent_.boundingExtent([a, b, c, d]); var targetCoverageX = - ol.extent.getWidth(targetQuadExtent) / this.targetWorldWidth_; + _ol_extent_.getWidth(targetQuadExtent) / this.targetWorldWidth_; needsSubdivision |= - targetCoverageX > ol.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; + targetCoverageX > _ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; } if (!wrapsX && this.sourceProj_.isGlobal() && sourceCoverageX) { needsSubdivision |= - sourceCoverageX > ol.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; + sourceCoverageX > _ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; } } if (!needsSubdivision && this.maxSourceExtent_) { - if (!ol.extent.intersects(sourceQuadExtent, this.maxSourceExtent_)) { + if (!_ol_extent_.intersects(sourceQuadExtent, this.maxSourceExtent_)) { // whole quad outside source projection extent -> ignore return; } @@ -249,10 +249,10 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d, var dx; if (wrapsX) { var centerSrcEstimX = - (ol.math.modulo(aSrc[0], sourceWorldWidth) + - ol.math.modulo(cSrc[0], sourceWorldWidth)) / 2; + (_ol_math_.modulo(aSrc[0], sourceWorldWidth) + + _ol_math_.modulo(cSrc[0], sourceWorldWidth)) / 2; dx = centerSrcEstimX - - ol.math.modulo(centerSrc[0], sourceWorldWidth); + _ol_math_.modulo(centerSrc[0], sourceWorldWidth); } else { dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0]; } @@ -305,14 +305,14 @@ ol.reproj.Triangulation.prototype.addQuad_ = function(a, b, c, d, * * @return {ol.Extent} Calculated extent. */ -ol.reproj.Triangulation.prototype.calculateSourceExtent = function() { - var extent = ol.extent.createEmpty(); +_ol_reproj_Triangulation_.prototype.calculateSourceExtent = function() { + var extent = _ol_extent_.createEmpty(); this.triangles_.forEach(function(triangle, i, arr) { var src = triangle.source; - ol.extent.extendCoordinate(extent, src[0]); - ol.extent.extendCoordinate(extent, src[1]); - ol.extent.extendCoordinate(extent, src[2]); + _ol_extent_.extendCoordinate(extent, src[0]); + _ol_extent_.extendCoordinate(extent, src[1]); + _ol_extent_.extendCoordinate(extent, src[2]); }); return extent; @@ -322,6 +322,7 @@ ol.reproj.Triangulation.prototype.calculateSourceExtent = function() { /** * @return {Array.} Array of the calculated triangles. */ -ol.reproj.Triangulation.prototype.getTriangles = function() { +_ol_reproj_Triangulation_.prototype.getTriangles = function() { return this.triangles_; }; +export default _ol_reproj_Triangulation_; diff --git a/src/ol/size.js b/src/ol/size.js index 390b4729c7..e9db34087a 100644 --- a/src/ol/size.js +++ b/src/ol/size.js @@ -1,4 +1,7 @@ -goog.provide('ol.size'); +/** + * @module ol/size + */ +var _ol_size_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.size'); * @param {ol.Size=} opt_size Optional reusable size array. * @return {ol.Size} The buffered size. */ -ol.size.buffer = function(size, buffer, opt_size) { +_ol_size_.buffer = function(size, buffer, opt_size) { if (opt_size === undefined) { opt_size = [0, 0]; } @@ -23,7 +26,7 @@ ol.size.buffer = function(size, buffer, opt_size) { * @param {ol.Size} size The size to test. * @return {boolean} The size has a positive area. */ -ol.size.hasArea = function(size) { +_ol_size_.hasArea = function(size) { return size[0] > 0 && size[1] > 0; }; @@ -35,7 +38,7 @@ ol.size.hasArea = function(size) { * @param {ol.Size=} opt_size Optional reusable size array. * @return {ol.Size} The scaled size. */ -ol.size.scale = function(size, ratio, opt_size) { +_ol_size_.scale = function(size, ratio, opt_size) { if (opt_size === undefined) { opt_size = [0, 0]; } @@ -54,7 +57,7 @@ ol.size.scale = function(size, ratio, opt_size) { * @return {ol.Size} Size. * @api */ -ol.size.toSize = function(size, opt_size) { +_ol_size_.toSize = function(size, opt_size) { if (Array.isArray(size)) { return size; } else { @@ -66,3 +69,4 @@ ol.size.toSize = function(size, opt_size) { return opt_size; } }; +export default _ol_size_; diff --git a/src/ol/source/BingMaps.js b/src/ol/source/BingMaps.js index ee9b55ab03..007b406427 100644 --- a/src/ol/source/BingMaps.js +++ b/src/ol/source/BingMaps.js @@ -1,15 +1,15 @@ -goog.provide('ol.source.BingMaps'); - -goog.require('ol'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.extent'); -goog.require('ol.net'); -goog.require('ol.proj'); -goog.require('ol.source.State'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/BingMaps + */ +import _ol_ from '../index.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_extent_ from '../extent.js'; +import _ol_net_ from '../net.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -20,7 +20,7 @@ goog.require('ol.tilegrid'); * @param {olx.source.BingMapsOptions} options Bing Maps options. * @api */ -ol.source.BingMaps = function(options) { +var _ol_source_BingMaps_ = function(options) { /** * @private @@ -28,13 +28,13 @@ ol.source.BingMaps = function(options) { */ this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false; - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { cacheSize: options.cacheSize, crossOrigin: 'anonymous', opaque: true, - projection: ol.proj.get('EPSG:3857'), + projection: _ol_proj_.get('EPSG:3857'), reprojectionErrorThreshold: options.reprojectionErrorThreshold, - state: ol.source.State.LOADING, + state: _ol_source_State_.LOADING, tileLoadFunction: options.tileLoadFunction, tilePixelRatio: this.hidpi_ ? 2 : 1, wrapX: options.wrapX !== undefined ? options.wrapX : true, @@ -70,11 +70,12 @@ ol.source.BingMaps = function(options) { '?uriScheme=https&include=ImageryProviders&key=' + this.apiKey_ + '&c=' + this.culture_; - ol.net.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined, + _ol_net_.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined, 'jsonp'); }; -ol.inherits(ol.source.BingMaps, ol.source.TileImage); + +_ol_.inherits(_ol_source_BingMaps_, _ol_source_TileImage_); /** @@ -84,7 +85,7 @@ ol.inherits(ol.source.BingMaps, ol.source.TileImage); * @type {string} * @api */ -ol.source.BingMaps.TOS_ATTRIBUTION = '' + 'Terms of Use'; @@ -95,7 +96,7 @@ ol.source.BingMaps.TOS_ATTRIBUTION = '= coverageArea.zoomMin && zoom <= coverageArea.zoomMax) { var bbox = coverageArea.bbox; var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]]; - var extent = ol.extent.applyTransform(epsg4326Extent, transform); - if (ol.extent.intersects(extent, frameState.extent)) { + var extent = _ol_extent_.applyTransform(epsg4326Extent, transform); + if (_ol_extent_.intersects(extent, frameState.extent)) { intersects = true; break; } @@ -202,12 +204,13 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) } }); - attributions.push(ol.source.BingMaps.TOS_ATTRIBUTION); + attributions.push(_ol_source_BingMaps_.TOS_ATTRIBUTION); return attributions; }); } this.setLogo(brandLogoUri); - this.setState(ol.source.State.READY); + this.setState(_ol_source_State_.READY); }; +export default _ol_source_BingMaps_; diff --git a/src/ol/source/CartoDB.js b/src/ol/source/CartoDB.js index 033015c3c6..a992d0ab06 100644 --- a/src/ol/source/CartoDB.js +++ b/src/ol/source/CartoDB.js @@ -1,10 +1,10 @@ -goog.provide('ol.source.CartoDB'); - -goog.require('ol'); -goog.require('ol.obj'); -goog.require('ol.source.State'); -goog.require('ol.source.XYZ'); - +/** + * @module ol/source/CartoDB + */ +import _ol_ from '../index.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_XYZ_ from '../source/XYZ.js'; /** * @classdesc @@ -15,7 +15,7 @@ goog.require('ol.source.XYZ'); * @param {olx.source.CartoDBOptions} options CartoDB options. * @api */ -ol.source.CartoDB = function(options) { +var _ol_source_CartoDB_ = function(options) { /** * @type {string} @@ -41,7 +41,7 @@ ol.source.CartoDB = function(options) { */ this.templateCache_ = {}; - ol.source.XYZ.call(this, { + _ol_source_XYZ_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -49,12 +49,13 @@ ol.source.CartoDB = function(options) { maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18, minZoom: options.minZoom, projection: options.projection, - state: ol.source.State.LOADING, + state: _ol_source_State_.LOADING, wrapX: options.wrapX }); this.initializeMap_(); }; -ol.inherits(ol.source.CartoDB, ol.source.XYZ); + +_ol_.inherits(_ol_source_CartoDB_, _ol_source_XYZ_); /** @@ -62,7 +63,7 @@ ol.inherits(ol.source.CartoDB, ol.source.XYZ); * @return {!Object} The current configuration. * @api */ -ol.source.CartoDB.prototype.getConfig = function() { +_ol_source_CartoDB_.prototype.getConfig = function() { return this.config_; }; @@ -73,8 +74,8 @@ ol.source.CartoDB.prototype.getConfig = function() { * in the config. * @api */ -ol.source.CartoDB.prototype.updateConfig = function(config) { - ol.obj.assign(this.config_, config); +_ol_source_CartoDB_.prototype.updateConfig = function(config) { + _ol_obj_.assign(this.config_, config); this.initializeMap_(); }; @@ -86,7 +87,7 @@ ol.source.CartoDB.prototype.updateConfig = function(config) { * If using named maps, a key-value lookup with the template parameters. * @api */ -ol.source.CartoDB.prototype.setConfig = function(config) { +_ol_source_CartoDB_.prototype.setConfig = function(config) { this.config_ = config || {}; this.initializeMap_(); }; @@ -96,7 +97,7 @@ ol.source.CartoDB.prototype.setConfig = function(config) { * Issue a request to initialize the CartoDB map. * @private */ -ol.source.CartoDB.prototype.initializeMap_ = function() { +_ol_source_CartoDB_.prototype.initializeMap_ = function() { var paramHash = JSON.stringify(this.config_); if (this.templateCache_[paramHash]) { this.applyTemplate_(this.templateCache_[paramHash]); @@ -124,7 +125,7 @@ ol.source.CartoDB.prototype.initializeMap_ = function() { * @param {Event} event Event. * @private */ -ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) { +_ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) { var client = /** @type {XMLHttpRequest} */ (event.target); // status will be 0 for file:// urls if (!client.status || client.status >= 200 && client.status < 300) { @@ -132,14 +133,14 @@ ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) { try { response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText)); } catch (err) { - this.setState(ol.source.State.ERROR); + this.setState(_ol_source_State_.ERROR); return; } this.applyTemplate_(response); this.templateCache_[paramHash] = response; - this.setState(ol.source.State.READY); + this.setState(_ol_source_State_.READY); } else { - this.setState(ol.source.State.ERROR); + this.setState(_ol_source_State_.ERROR); } }; @@ -148,8 +149,8 @@ ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) { * @private * @param {Event} event Event. */ -ol.source.CartoDB.prototype.handleInitError_ = function(event) { - this.setState(ol.source.State.ERROR); +_ol_source_CartoDB_.prototype.handleInitError_ = function(event) { + this.setState(_ol_source_State_.ERROR); }; @@ -158,8 +159,9 @@ ol.source.CartoDB.prototype.handleInitError_ = function(event) { * @param {CartoDBLayerInfo} data Result of carto db call. * @private */ -ol.source.CartoDB.prototype.applyTemplate_ = function(data) { +_ol_source_CartoDB_.prototype.applyTemplate_ = function(data) { var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ + '/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png'; this.setUrl(tilesUrl); }; +export default _ol_source_CartoDB_; diff --git a/src/ol/source/Cluster.js b/src/ol/source/Cluster.js index fc544a37d5..438528878e 100644 --- a/src/ol/source/Cluster.js +++ b/src/ol/source/Cluster.js @@ -1,17 +1,17 @@ +/** + * @module ol/source/Cluster + */ // FIXME keep cluster cache by resolution ? // FIXME distance not respected because of the centroid -goog.provide('ol.source.Cluster'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.Feature'); -goog.require('ol.coordinate'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.geom.Point'); -goog.require('ol.source.Vector'); - +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_Feature_ from '../Feature.js'; +import _ol_coordinate_ from '../coordinate.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_geom_Point_ from '../geom/Point.js'; +import _ol_source_Vector_ from '../source/Vector.js'; /** * @classdesc @@ -24,8 +24,8 @@ goog.require('ol.source.Vector'); * @extends {ol.source.Vector} * @api */ -ol.source.Cluster = function(options) { - ol.source.Vector.call(this, { +var _ol_source_Cluster_ = function(options) { + _ol_source_Vector_.call(this, { attributions: options.attributions, extent: options.extent, logo: options.logo, @@ -58,7 +58,7 @@ ol.source.Cluster = function(options) { */ this.geometryFunction = options.geometryFunction || function(feature) { var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry()); - ol.asserts.assert(geometry instanceof ol.geom.Point, + _ol_asserts_.assert(geometry instanceof _ol_geom_Point_, 10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries return geometry; }; @@ -69,10 +69,11 @@ ol.source.Cluster = function(options) { */ this.source = options.source; - this.source.on(ol.events.EventType.CHANGE, - ol.source.Cluster.prototype.refresh, this); + this.source.on(_ol_events_EventType_.CHANGE, + _ol_source_Cluster_.prototype.refresh, this); }; -ol.inherits(ol.source.Cluster, ol.source.Vector); + +_ol_.inherits(_ol_source_Cluster_, _ol_source_Vector_); /** @@ -80,7 +81,7 @@ ol.inherits(ol.source.Cluster, ol.source.Vector); * @return {number} Distance. * @api */ -ol.source.Cluster.prototype.getDistance = function() { +_ol_source_Cluster_.prototype.getDistance = function() { return this.distance; }; @@ -90,7 +91,7 @@ ol.source.Cluster.prototype.getDistance = function() { * @return {ol.source.Vector} Source. * @api */ -ol.source.Cluster.prototype.getSource = function() { +_ol_source_Cluster_.prototype.getSource = function() { return this.source; }; @@ -98,7 +99,7 @@ ol.source.Cluster.prototype.getSource = function() { /** * @inheritDoc */ -ol.source.Cluster.prototype.loadFeatures = function(extent, resolution, +_ol_source_Cluster_.prototype.loadFeatures = function(extent, resolution, projection) { this.source.loadFeatures(extent, resolution, projection); if (resolution !== this.resolution) { @@ -115,7 +116,7 @@ ol.source.Cluster.prototype.loadFeatures = function(extent, resolution, * @param {number} distance The distance in pixels. * @api */ -ol.source.Cluster.prototype.setDistance = function(distance) { +_ol_source_Cluster_.prototype.setDistance = function(distance) { this.distance = distance; this.refresh(); }; @@ -125,23 +126,23 @@ ol.source.Cluster.prototype.setDistance = function(distance) { * handle the source changing * @override */ -ol.source.Cluster.prototype.refresh = function() { +_ol_source_Cluster_.prototype.refresh = function() { this.clear(); this.cluster(); this.addFeatures(this.features); - ol.source.Vector.prototype.refresh.call(this); + _ol_source_Vector_.prototype.refresh.call(this); }; /** * @protected */ -ol.source.Cluster.prototype.cluster = function() { +_ol_source_Cluster_.prototype.cluster = function() { if (this.resolution === undefined) { return; } this.features.length = 0; - var extent = ol.extent.createEmpty(); + var extent = _ol_extent_.createEmpty(); var mapDistance = this.distance * this.resolution; var features = this.source.getFeatures(); @@ -152,16 +153,16 @@ ol.source.Cluster.prototype.cluster = function() { for (var i = 0, ii = features.length; i < ii; i++) { var feature = features[i]; - if (!(ol.getUid(feature).toString() in clustered)) { + if (!(_ol_.getUid(feature).toString() in clustered)) { var geometry = this.geometryFunction(feature); if (geometry) { var coordinates = geometry.getCoordinates(); - ol.extent.createOrUpdateFromCoordinate(coordinates, extent); - ol.extent.buffer(extent, mapDistance, extent); + _ol_extent_.createOrUpdateFromCoordinate(coordinates, extent); + _ol_extent_.buffer(extent, mapDistance, extent); var neighbors = this.source.getFeaturesInExtent(extent); neighbors = neighbors.filter(function(neighbor) { - var uid = ol.getUid(neighbor).toString(); + var uid = _ol_.getUid(neighbor).toString(); if (!(uid in clustered)) { clustered[uid] = true; return true; @@ -181,19 +182,20 @@ ol.source.Cluster.prototype.cluster = function() { * @return {ol.Feature} The cluster feature. * @protected */ -ol.source.Cluster.prototype.createCluster = function(features) { +_ol_source_Cluster_.prototype.createCluster = function(features) { var centroid = [0, 0]; for (var i = features.length - 1; i >= 0; --i) { var geometry = this.geometryFunction(features[i]); if (geometry) { - ol.coordinate.add(centroid, geometry.getCoordinates()); + _ol_coordinate_.add(centroid, geometry.getCoordinates()); } else { features.splice(i, 1); } } - ol.coordinate.scale(centroid, 1 / features.length); + _ol_coordinate_.scale(centroid, 1 / features.length); - var cluster = new ol.Feature(new ol.geom.Point(centroid)); + var cluster = new _ol_Feature_(new _ol_geom_Point_(centroid)); cluster.set('features', features); return cluster; }; +export default _ol_source_Cluster_; diff --git a/src/ol/source/Image.js b/src/ol/source/Image.js index bab5982478..92645d7a67 100644 --- a/src/ol/source/Image.js +++ b/src/ol/source/Image.js @@ -1,14 +1,14 @@ -goog.provide('ol.source.Image'); - -goog.require('ol'); -goog.require('ol.ImageState'); -goog.require('ol.array'); -goog.require('ol.events.Event'); -goog.require('ol.extent'); -goog.require('ol.proj'); -goog.require('ol.reproj.Image'); -goog.require('ol.source.Source'); - +/** + * @module ol/source/Image + */ +import _ol_ from '../index.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_array_ from '../array.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_extent_ from '../extent.js'; +import _ol_proj_ from '../proj.js'; +import _ol_reproj_Image_ from '../reproj/Image.js'; +import _ol_source_Source_ from '../source/Source.js'; /** * @classdesc @@ -22,8 +22,8 @@ goog.require('ol.source.Source'); * @param {ol.SourceImageOptions} options Single image source options. * @api */ -ol.source.Image = function(options) { - ol.source.Source.call(this, { +var _ol_source_Image_ = function(options) { + _ol_source_Source_.call(this, { attributions: options.attributions, extent: options.extent, logo: options.logo, @@ -52,14 +52,15 @@ ol.source.Image = function(options) { */ this.reprojectedRevision_ = 0; }; -ol.inherits(ol.source.Image, ol.source.Source); + +_ol_.inherits(_ol_source_Image_, _ol_source_Source_); /** * @return {Array.} Resolutions. * @override */ -ol.source.Image.prototype.getResolutions = function() { +_ol_source_Image_.prototype.getResolutions = function() { return this.resolutions_; }; @@ -69,9 +70,9 @@ ol.source.Image.prototype.getResolutions = function() { * @param {number} resolution Resolution. * @return {number} Resolution. */ -ol.source.Image.prototype.findNearestResolution = function(resolution) { +_ol_source_Image_.prototype.findNearestResolution = function(resolution) { if (this.resolutions_) { - var idx = ol.array.linearFindNearest(this.resolutions_, resolution, 0); + var idx = _ol_array_.linearFindNearest(this.resolutions_, resolution, 0); resolution = this.resolutions_[idx]; } return resolution; @@ -85,12 +86,12 @@ ol.source.Image.prototype.findNearestResolution = function(resolution) { * @param {ol.proj.Projection} projection Projection. * @return {ol.ImageBase} Single image. */ -ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, projection) { +_ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio, projection) { var sourceProjection = this.getProjection(); - if (!ol.ENABLE_RASTER_REPROJECTION || + if (!_ol_.ENABLE_RASTER_REPROJECTION || !sourceProjection || !projection || - ol.proj.equivalent(sourceProjection, projection)) { + _ol_proj_.equivalent(sourceProjection, projection)) { if (sourceProjection) { projection = sourceProjection; } @@ -98,17 +99,17 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr } else { if (this.reprojectedImage_) { if (this.reprojectedRevision_ == this.getRevision() && - ol.proj.equivalent( + _ol_proj_.equivalent( this.reprojectedImage_.getProjection(), projection) && this.reprojectedImage_.getResolution() == resolution && - ol.extent.equals(this.reprojectedImage_.getExtent(), extent)) { + _ol_extent_.equals(this.reprojectedImage_.getExtent(), extent)) { return this.reprojectedImage_; } this.reprojectedImage_.dispose(); this.reprojectedImage_ = null; } - this.reprojectedImage_ = new ol.reproj.Image( + this.reprojectedImage_ = new _ol_reproj_Image_( sourceProjection, projection, extent, resolution, pixelRatio, function(extent, resolution, pixelRatio) { return this.getImageInternal(extent, resolution, @@ -130,7 +131,7 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr * @return {ol.ImageBase} Single image. * @protected */ -ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {}; +_ol_source_Image_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {}; /** @@ -138,22 +139,22 @@ ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelR * @param {ol.events.Event} event Event. * @protected */ -ol.source.Image.prototype.handleImageChange = function(event) { +_ol_source_Image_.prototype.handleImageChange = function(event) { var image = /** @type {ol.Image} */ (event.target); switch (image.getState()) { - case ol.ImageState.LOADING: + case _ol_ImageState_.LOADING: this.dispatchEvent( - new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADSTART, + new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADSTART, image)); break; - case ol.ImageState.LOADED: + case _ol_ImageState_.LOADED: this.dispatchEvent( - new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADEND, + new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADEND, image)); break; - case ol.ImageState.ERROR: + case _ol_ImageState_.ERROR: this.dispatchEvent( - new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADERROR, + new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADERROR, image)); break; default: @@ -168,7 +169,7 @@ ol.source.Image.prototype.handleImageChange = function(event) { * @param {ol.Image} image Image. * @param {string} src Source. */ -ol.source.Image.defaultImageLoadFunction = function(image, src) { +_ol_source_Image_.defaultImageLoadFunction = function(image, src) { image.getImage().src = src; }; @@ -184,9 +185,9 @@ ol.source.Image.defaultImageLoadFunction = function(image, src) { * @param {string} type Type. * @param {ol.Image} image The image. */ -ol.source.Image.Event = function(type, image) { +_ol_source_Image_.Event = function(type, image) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The image related to the event. @@ -196,14 +197,14 @@ ol.source.Image.Event = function(type, image) { this.image = image; }; -ol.inherits(ol.source.Image.Event, ol.events.Event); +_ol_.inherits(_ol_source_Image_.Event, _ol_events_Event_); /** * @enum {string} * @private */ -ol.source.Image.EventType_ = { +_ol_source_Image_.EventType_ = { /** * Triggered when an image starts loading. @@ -227,3 +228,4 @@ ol.source.Image.EventType_ = { IMAGELOADERROR: 'imageloaderror' }; +export default _ol_source_Image_; diff --git a/src/ol/source/ImageArcGISRest.js b/src/ol/source/ImageArcGISRest.js index 07bea9743f..3c19f28e22 100644 --- a/src/ol/source/ImageArcGISRest.js +++ b/src/ol/source/ImageArcGISRest.js @@ -1,15 +1,15 @@ -goog.provide('ol.source.ImageArcGISRest'); - -goog.require('ol'); -goog.require('ol.Image'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.source.Image'); -goog.require('ol.uri'); - +/** + * @module ol/source/ImageArcGISRest + */ +import _ol_ from '../index.js'; +import _ol_Image_ from '../Image.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_Image_ from '../source/Image.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -26,11 +26,11 @@ goog.require('ol.uri'); * @param {olx.source.ImageArcGISRestOptions=} opt_options Image ArcGIS Rest Options. * @api */ -ol.source.ImageArcGISRest = function(opt_options) { +var _ol_source_ImageArcGISRest_ = function(opt_options) { var options = opt_options || {}; - ol.source.Image.call(this, { + _ol_source_Image_.call(this, { attributions: options.attributions, logo: options.logo, projection: options.projection, @@ -61,7 +61,7 @@ ol.source.ImageArcGISRest = function(opt_options) { * @type {ol.ImageLoadFunctionType} */ this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? - options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; + options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction; /** @@ -96,7 +96,8 @@ ol.source.ImageArcGISRest = function(opt_options) { this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5; }; -ol.inherits(ol.source.ImageArcGISRest, ol.source.Image); + +_ol_.inherits(_ol_source_ImageArcGISRest_, _ol_source_Image_); /** @@ -105,7 +106,7 @@ ol.inherits(ol.source.ImageArcGISRest, ol.source.Image); * @return {Object} Params. * @api */ -ol.source.ImageArcGISRest.prototype.getParams = function() { +_ol_source_ImageArcGISRest_.prototype.getParams = function() { return this.params_; }; @@ -113,7 +114,7 @@ ol.source.ImageArcGISRest.prototype.getParams = function() { /** * @inheritDoc */ -ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { +_ol_source_ImageArcGISRest_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { if (this.url_ === undefined) { return null; @@ -127,7 +128,7 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti this.renderedRevision_ == this.getRevision() && image.getResolution() == resolution && image.getPixelRatio() == pixelRatio && - ol.extent.containsExtent(image.getExtent(), extent)) { + _ol_extent_.containsExtent(image.getExtent(), extent)) { return image; } @@ -136,14 +137,14 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti 'FORMAT': 'PNG32', 'TRANSPARENT': true }; - ol.obj.assign(params, this.params_); + _ol_obj_.assign(params, this.params_); extent = extent.slice(); var centerX = (extent[0] + extent[2]) / 2; var centerY = (extent[1] + extent[3]) / 2; if (this.ratio_ != 1) { - var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2; - var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2; + var halfWidth = this.ratio_ * _ol_extent_.getWidth(extent) / 2; + var halfHeight = this.ratio_ * _ol_extent_.getHeight(extent) / 2; extent[0] = centerX - halfWidth; extent[1] = centerY - halfHeight; extent[2] = centerX + halfWidth; @@ -153,8 +154,8 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti var imageResolution = resolution / pixelRatio; // Compute an integer width and height. - var width = Math.ceil(ol.extent.getWidth(extent) / imageResolution); - var height = Math.ceil(ol.extent.getHeight(extent) / imageResolution); + var width = Math.ceil(_ol_extent_.getWidth(extent) / imageResolution); + var height = Math.ceil(_ol_extent_.getHeight(extent) / imageResolution); // Modify the extent to match the integer width and height. extent[0] = centerX - imageResolution * width / 2; @@ -168,12 +169,12 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti var url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio, projection, params); - this.image_ = new ol.Image(extent, resolution, pixelRatio, + this.image_ = new _ol_Image_(extent, resolution, pixelRatio, url, this.crossOrigin_, this.imageLoadFunction_); this.renderedRevision_ = this.getRevision(); - ol.events.listen(this.image_, ol.events.EventType.CHANGE, + _ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE, this.handleImageChange, this); return this.image_; @@ -186,7 +187,7 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti * @return {ol.ImageLoadFunctionType} The image load function. * @api */ -ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() { +_ol_source_ImageArcGISRest_.prototype.getImageLoadFunction = function() { return this.imageLoadFunction_; }; @@ -200,7 +201,7 @@ ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() { * @return {string} Request URL. * @private */ -ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { +_ol_source_ImageArcGISRest_.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { // ArcGIS Server only wants the numeric portion of the projection ID. var srid = projection.getCode().split(':').pop(); @@ -216,9 +217,9 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe .replace(/MapServer\/?$/, 'MapServer/export') .replace(/ImageServer\/?$/, 'ImageServer/exportImage'); if (modifiedUrl == url) { - ol.asserts.assert(false, 50); // `options.featureTypes` should be an Array + _ol_asserts_.assert(false, 50); // `options.featureTypes` should be an Array } - return ol.uri.appendParams(modifiedUrl, params); + return _ol_uri_.appendParams(modifiedUrl, params); }; @@ -227,7 +228,7 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe * @return {string|undefined} URL. * @api */ -ol.source.ImageArcGISRest.prototype.getUrl = function() { +_ol_source_ImageArcGISRest_.prototype.getUrl = function() { return this.url_; }; @@ -237,7 +238,7 @@ ol.source.ImageArcGISRest.prototype.getUrl = function() { * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. * @api */ -ol.source.ImageArcGISRest.prototype.setImageLoadFunction = function(imageLoadFunction) { +_ol_source_ImageArcGISRest_.prototype.setImageLoadFunction = function(imageLoadFunction) { this.image_ = null; this.imageLoadFunction_ = imageLoadFunction; this.changed(); @@ -249,7 +250,7 @@ ol.source.ImageArcGISRest.prototype.setImageLoadFunction = function(imageLoadFun * @param {string|undefined} url URL. * @api */ -ol.source.ImageArcGISRest.prototype.setUrl = function(url) { +_ol_source_ImageArcGISRest_.prototype.setUrl = function(url) { if (url != this.url_) { this.url_ = url; this.image_ = null; @@ -263,8 +264,9 @@ ol.source.ImageArcGISRest.prototype.setUrl = function(url) { * @param {Object} params Params. * @api */ -ol.source.ImageArcGISRest.prototype.updateParams = function(params) { - ol.obj.assign(this.params_, params); +_ol_source_ImageArcGISRest_.prototype.updateParams = function(params) { + _ol_obj_.assign(this.params_, params); this.image_ = null; this.changed(); }; +export default _ol_source_ImageArcGISRest_; diff --git a/src/ol/source/ImageCanvas.js b/src/ol/source/ImageCanvas.js index 2b622dc0e0..775d3aea5b 100644 --- a/src/ol/source/ImageCanvas.js +++ b/src/ol/source/ImageCanvas.js @@ -1,10 +1,10 @@ -goog.provide('ol.source.ImageCanvas'); - -goog.require('ol'); -goog.require('ol.ImageCanvas'); -goog.require('ol.extent'); -goog.require('ol.source.Image'); - +/** + * @module ol/source/ImageCanvas + */ +import _ol_ from '../index.js'; +import _ol_ImageCanvas_ from '../ImageCanvas.js'; +import _ol_extent_ from '../extent.js'; +import _ol_source_Image_ from '../source/Image.js'; /** * @classdesc @@ -15,9 +15,9 @@ goog.require('ol.source.Image'); * @param {olx.source.ImageCanvasOptions} options Constructor options. * @api */ -ol.source.ImageCanvas = function(options) { +var _ol_source_ImageCanvas_ = function(options) { - ol.source.Image.call(this, { + _ol_source_Image_.call(this, { attributions: options.attributions, logo: options.logo, projection: options.projection, @@ -51,13 +51,14 @@ ol.source.ImageCanvas = function(options) { options.ratio : 1.5; }; -ol.inherits(ol.source.ImageCanvas, ol.source.Image); + +_ol_.inherits(_ol_source_ImageCanvas_, _ol_source_Image_); /** * @inheritDoc */ -ol.source.ImageCanvas.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { +_ol_source_ImageCanvas_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { resolution = this.findNearestResolution(resolution); var canvas = this.canvas_; @@ -65,23 +66,24 @@ ol.source.ImageCanvas.prototype.getImageInternal = function(extent, resolution, this.renderedRevision_ == this.getRevision() && canvas.getResolution() == resolution && canvas.getPixelRatio() == pixelRatio && - ol.extent.containsExtent(canvas.getExtent(), extent)) { + _ol_extent_.containsExtent(canvas.getExtent(), extent)) { return canvas; } extent = extent.slice(); - ol.extent.scaleFromCenter(extent, this.ratio_); - var width = ol.extent.getWidth(extent) / resolution; - var height = ol.extent.getHeight(extent) / resolution; + _ol_extent_.scaleFromCenter(extent, this.ratio_); + var width = _ol_extent_.getWidth(extent) / resolution; + var height = _ol_extent_.getHeight(extent) / resolution; var size = [width * pixelRatio, height * pixelRatio]; var canvasElement = this.canvasFunction_( extent, resolution, pixelRatio, size, projection); if (canvasElement) { - canvas = new ol.ImageCanvas(extent, resolution, pixelRatio, canvasElement); + canvas = new _ol_ImageCanvas_(extent, resolution, pixelRatio, canvasElement); } this.canvas_ = canvas; this.renderedRevision_ = this.getRevision(); return canvas; }; +export default _ol_source_ImageCanvas_; diff --git a/src/ol/source/ImageMapGuide.js b/src/ol/source/ImageMapGuide.js index 605fd1150b..5633fbf6df 100644 --- a/src/ol/source/ImageMapGuide.js +++ b/src/ol/source/ImageMapGuide.js @@ -1,14 +1,14 @@ -goog.provide('ol.source.ImageMapGuide'); - -goog.require('ol'); -goog.require('ol.Image'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.source.Image'); -goog.require('ol.uri'); - +/** + * @module ol/source/ImageMapGuide + */ +import _ol_ from '../index.js'; +import _ol_Image_ from '../Image.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_Image_ from '../source/Image.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -20,9 +20,9 @@ goog.require('ol.uri'); * @param {olx.source.ImageMapGuideOptions} options Options. * @api */ -ol.source.ImageMapGuide = function(options) { +var _ol_source_ImageMapGuide_ = function(options) { - ol.source.Image.call(this, { + _ol_source_Image_.call(this, { projection: options.projection, resolutions: options.resolutions }); @@ -58,7 +58,7 @@ ol.source.ImageMapGuide = function(options) { * @type {ol.ImageLoadFunctionType} */ this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? - options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; + options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction; /** * @private @@ -99,7 +99,8 @@ ol.source.ImageMapGuide = function(options) { this.renderedRevision_ = 0; }; -ol.inherits(ol.source.ImageMapGuide, ol.source.Image); + +_ol_.inherits(_ol_source_ImageMapGuide_, _ol_source_Image_); /** @@ -108,7 +109,7 @@ ol.inherits(ol.source.ImageMapGuide, ol.source.Image); * @return {Object} Params. * @api */ -ol.source.ImageMapGuide.prototype.getParams = function() { +_ol_source_ImageMapGuide_.prototype.getParams = function() { return this.params_; }; @@ -116,7 +117,7 @@ ol.source.ImageMapGuide.prototype.getParams = function() { /** * @inheritDoc */ -ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { +_ol_source_ImageMapGuide_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { resolution = this.findNearestResolution(resolution); pixelRatio = this.hidpi_ ? pixelRatio : 1; @@ -125,25 +126,25 @@ ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution this.renderedRevision_ == this.getRevision() && image.getResolution() == resolution && image.getPixelRatio() == pixelRatio && - ol.extent.containsExtent(image.getExtent(), extent)) { + _ol_extent_.containsExtent(image.getExtent(), extent)) { return image; } if (this.ratio_ != 1) { extent = extent.slice(); - ol.extent.scaleFromCenter(extent, this.ratio_); + _ol_extent_.scaleFromCenter(extent, this.ratio_); } - var width = ol.extent.getWidth(extent) / resolution; - var height = ol.extent.getHeight(extent) / resolution; + var width = _ol_extent_.getWidth(extent) / resolution; + var height = _ol_extent_.getHeight(extent) / resolution; var size = [width * pixelRatio, height * pixelRatio]; if (this.url_ !== undefined) { var imageUrl = this.getUrl(this.url_, this.params_, extent, size, projection); - image = new ol.Image(extent, resolution, pixelRatio, + image = new _ol_Image_(extent, resolution, pixelRatio, imageUrl, this.crossOrigin_, this.imageLoadFunction_); - ol.events.listen(image, ol.events.EventType.CHANGE, + _ol_events_.listen(image, _ol_events_EventType_.CHANGE, this.handleImageChange, this); } else { image = null; @@ -160,7 +161,7 @@ ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution * @return {ol.ImageLoadFunctionType} The image load function. * @api */ -ol.source.ImageMapGuide.prototype.getImageLoadFunction = function() { +_ol_source_ImageMapGuide_.prototype.getImageLoadFunction = function() { return this.imageLoadFunction_; }; @@ -172,9 +173,9 @@ ol.source.ImageMapGuide.prototype.getImageLoadFunction = function() { * @param {number} dpi The display resolution. * @return {number} The computed map scale. */ -ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) { - var mcsW = ol.extent.getWidth(extent); - var mcsH = ol.extent.getHeight(extent); +_ol_source_ImageMapGuide_.getScale = function(extent, size, metersPerUnit, dpi) { + var mcsW = _ol_extent_.getWidth(extent); + var mcsH = _ol_extent_.getHeight(extent); var devW = size[0]; var devH = size[1]; var mpp = 0.0254 / dpi; @@ -191,8 +192,8 @@ ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) { * @param {Object} params Params. * @api */ -ol.source.ImageMapGuide.prototype.updateParams = function(params) { - ol.obj.assign(this.params_, params); +_ol_source_ImageMapGuide_.prototype.updateParams = function(params) { + _ol_obj_.assign(this.params_, params); this.changed(); }; @@ -205,10 +206,10 @@ ol.source.ImageMapGuide.prototype.updateParams = function(params) { * @param {ol.proj.Projection} projection Projection. * @return {string} The mapagent map image request URL. */ -ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, size, projection) { - var scale = ol.source.ImageMapGuide.getScale(extent, size, +_ol_source_ImageMapGuide_.prototype.getUrl = function(baseUrl, params, extent, size, projection) { + var scale = _ol_source_ImageMapGuide_.getScale(extent, size, this.metersPerUnit_, this.displayDpi_); - var center = ol.extent.getCenter(extent); + var center = _ol_extent_.getCenter(extent); var baseParams = { 'OPERATION': this.useOverlay_ ? 'GETDYNAMICMAPOVERLAYIMAGE' : 'GETMAPIMAGE', 'VERSION': '2.0.0', @@ -222,8 +223,8 @@ ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, siz 'SETVIEWCENTERX': center[0], 'SETVIEWCENTERY': center[1] }; - ol.obj.assign(baseParams, params); - return ol.uri.appendParams(baseUrl, baseParams); + _ol_obj_.assign(baseParams, params); + return _ol_uri_.appendParams(baseUrl, baseParams); }; @@ -232,9 +233,10 @@ ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, siz * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. * @api */ -ol.source.ImageMapGuide.prototype.setImageLoadFunction = function( +_ol_source_ImageMapGuide_.prototype.setImageLoadFunction = function( imageLoadFunction) { this.image_ = null; this.imageLoadFunction_ = imageLoadFunction; this.changed(); }; +export default _ol_source_ImageMapGuide_; diff --git a/src/ol/source/ImageStatic.js b/src/ol/source/ImageStatic.js index 888ee26218..27a6b3dbc8 100644 --- a/src/ol/source/ImageStatic.js +++ b/src/ol/source/ImageStatic.js @@ -1,15 +1,15 @@ -goog.provide('ol.source.ImageStatic'); - -goog.require('ol'); -goog.require('ol.Image'); -goog.require('ol.ImageState'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.proj'); -goog.require('ol.source.Image'); - +/** + * @module ol/source/ImageStatic + */ +import _ol_ from '../index.js'; +import _ol_Image_ from '../Image.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_Image_ from '../source/Image.js'; /** * @classdesc @@ -20,7 +20,7 @@ goog.require('ol.source.Image'); * @param {olx.source.ImageStaticOptions} options Options. * @api */ -ol.source.ImageStatic = function(options) { +var _ol_source_ImageStatic_ = function(options) { var imageExtent = options.imageExtent; var crossOrigin = options.crossOrigin !== undefined ? @@ -28,19 +28,19 @@ ol.source.ImageStatic = function(options) { var /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction = options.imageLoadFunction !== undefined ? - options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; + options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction; - ol.source.Image.call(this, { + _ol_source_Image_.call(this, { attributions: options.attributions, logo: options.logo, - projection: ol.proj.get(options.projection) + projection: _ol_proj_.get(options.projection) }); /** * @private * @type {ol.Image} */ - this.image_ = new ol.Image(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction); + this.image_ = new _ol_Image_(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction); /** * @private @@ -48,18 +48,19 @@ ol.source.ImageStatic = function(options) { */ this.imageSize_ = options.imageSize ? options.imageSize : null; - ol.events.listen(this.image_, ol.events.EventType.CHANGE, + _ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE, this.handleImageChange, this); }; -ol.inherits(ol.source.ImageStatic, ol.source.Image); + +_ol_.inherits(_ol_source_ImageStatic_, _ol_source_Image_); /** * @inheritDoc */ -ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { - if (ol.extent.intersects(extent, this.image_.getExtent())) { +_ol_source_ImageStatic_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { + if (_ol_extent_.intersects(extent, this.image_.getExtent())) { return this.image_; } return null; @@ -69,8 +70,8 @@ ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution, /** * @inheritDoc */ -ol.source.ImageStatic.prototype.handleImageChange = function(evt) { - if (this.image_.getState() == ol.ImageState.LOADED) { +_ol_source_ImageStatic_.prototype.handleImageChange = function(evt) { + if (this.image_.getState() == _ol_ImageState_.LOADED) { var imageExtent = this.image_.getExtent(); var image = this.image_.getImage(); var imageWidth, imageHeight; @@ -81,15 +82,16 @@ ol.source.ImageStatic.prototype.handleImageChange = function(evt) { imageWidth = image.width; imageHeight = image.height; } - var resolution = ol.extent.getHeight(imageExtent) / imageHeight; - var targetWidth = Math.ceil(ol.extent.getWidth(imageExtent) / resolution); + var resolution = _ol_extent_.getHeight(imageExtent) / imageHeight; + var targetWidth = Math.ceil(_ol_extent_.getWidth(imageExtent) / resolution); if (targetWidth != imageWidth) { - var context = ol.dom.createCanvasContext2D(targetWidth, imageHeight); + var context = _ol_dom_.createCanvasContext2D(targetWidth, imageHeight); var canvas = context.canvas; context.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, canvas.width, canvas.height); this.image_.setImage(canvas); } } - ol.source.Image.prototype.handleImageChange.call(this, evt); + _ol_source_Image_.prototype.handleImageChange.call(this, evt); }; +export default _ol_source_ImageStatic_; diff --git a/src/ol/source/ImageVector.js b/src/ol/source/ImageVector.js index 50e690a583..aaa1a0d8a7 100644 --- a/src/ol/source/ImageVector.js +++ b/src/ol/source/ImageVector.js @@ -1,17 +1,17 @@ -goog.provide('ol.source.ImageVector'); - -goog.require('ol'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.ext.rbush'); -goog.require('ol.extent'); -goog.require('ol.render.canvas.ReplayGroup'); -goog.require('ol.renderer.vector'); -goog.require('ol.source.ImageCanvas'); -goog.require('ol.style.Style'); -goog.require('ol.transform'); - +/** + * @module ol/source/ImageVector + */ +import _ol_ from '../index.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_ext_rbush_ from 'rbush'; +import _ol_extent_ from '../extent.js'; +import _ol_render_canvas_ReplayGroup_ from '../render/canvas/ReplayGroup.js'; +import _ol_renderer_vector_ from '../renderer/vector.js'; +import _ol_source_ImageCanvas_ from '../source/ImageCanvas.js'; +import _ol_style_Style_ from '../style/Style.js'; +import _ol_transform_ from '../transform.js'; /** * @deprecated @@ -34,7 +34,7 @@ goog.require('ol.transform'); * @param {olx.source.ImageVectorOptions} options Options. * @api */ -ol.source.ImageVector = function(options) { +var _ol_source_ImageVector_ = function(options) { /** * @private @@ -46,13 +46,13 @@ ol.source.ImageVector = function(options) { * @private * @type {ol.Transform} */ - this.transform_ = ol.transform.create(); + this.transform_ = _ol_transform_.create(); /** * @private * @type {CanvasRenderingContext2D} */ - this.canvasContext_ = ol.dom.createCanvasContext2D(); + this.canvasContext_ = _ol_dom_.createCanvasContext2D(); /** * @private @@ -64,7 +64,7 @@ ol.source.ImageVector = function(options) { * Declutter tree. * @private */ - this.declutterTree_ = ol.ext.rbush(9); + this.declutterTree_ = _ol_ext_rbush_(9); /** * @private @@ -78,7 +78,7 @@ ol.source.ImageVector = function(options) { */ this.replayGroup_ = null; - ol.source.ImageCanvas.call(this, { + _ol_source_ImageCanvas_.call(this, { attributions: options.attributions, canvasFunction: this.canvasFunctionInternal_.bind(this), logo: options.logo, @@ -104,11 +104,12 @@ ol.source.ImageVector = function(options) { this.setStyle(options.style); - ol.events.listen(this.source_, ol.events.EventType.CHANGE, + _ol_events_.listen(this.source_, _ol_events_EventType_.CHANGE, this.handleSourceChange_, this); }; -ol.inherits(ol.source.ImageVector, ol.source.ImageCanvas); + +_ol_.inherits(_ol_source_ImageVector_, _ol_source_ImageCanvas_); /** @@ -120,10 +121,10 @@ ol.inherits(ol.source.ImageVector, ol.source.ImageCanvas); * @return {HTMLCanvasElement} Canvas element. * @private */ -ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resolution, pixelRatio, size, projection) { +_ol_source_ImageVector_.prototype.canvasFunctionInternal_ = function(extent, resolution, pixelRatio, size, projection) { - var replayGroup = new ol.render.canvas.ReplayGroup( - ol.renderer.vector.getTolerance(resolution, pixelRatio), extent, + var replayGroup = new _ol_render_canvas_ReplayGroup_( + _ol_renderer_vector_.getTolerance(resolution, pixelRatio), extent, resolution, pixelRatio, this.source_.getOverlaps(), this.declutterTree_, this.renderBuffer_); this.source_.loadFeatures(extent, resolution, projection); @@ -154,7 +155,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol this.declutterTree_.clear(); - var transform = this.getTransform_(ol.extent.getCenter(extent), + var transform = this.getTransform_(_ol_extent_.getCenter(extent), resolution, pixelRatio, size); replayGroup.replay(this.canvasContext_, transform, 0, {}); @@ -167,7 +168,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol /** * @inheritDoc */ -ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( +_ol_source_ImageVector_.prototype.forEachFeatureAtCoordinate = function( coordinate, resolution, rotation, hitTolerance, skippedFeatureUids, callback) { if (!this.replayGroup_) { return undefined; @@ -181,7 +182,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( * @return {?} Callback result. */ function(feature) { - var key = ol.getUid(feature).toString(); + var key = _ol_.getUid(feature).toString(); if (!(key in features)) { features[key] = true; return callback(feature); @@ -197,7 +198,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( * @return {ol.source.Vector} Source. * @api */ -ol.source.ImageVector.prototype.getSource = function() { +_ol_source_ImageVector_.prototype.getSource = function() { return this.source_; }; @@ -209,7 +210,7 @@ ol.source.ImageVector.prototype.getSource = function() { * Layer style. * @api */ -ol.source.ImageVector.prototype.getStyle = function() { +_ol_source_ImageVector_.prototype.getStyle = function() { return this.style_; }; @@ -219,7 +220,7 @@ ol.source.ImageVector.prototype.getStyle = function() { * @return {ol.StyleFunction|undefined} Layer style function. * @api */ -ol.source.ImageVector.prototype.getStyleFunction = function() { +_ol_source_ImageVector_.prototype.getStyleFunction = function() { return this.styleFunction_; }; @@ -232,7 +233,7 @@ ol.source.ImageVector.prototype.getStyleFunction = function() { * @return {!ol.Transform} Transform. * @private */ -ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pixelRatio, size) { +_ol_source_ImageVector_.prototype.getTransform_ = function(center, resolution, pixelRatio, size) { var dx1 = size[0] / 2; var dy1 = size[1] / 2; var sx = pixelRatio / resolution; @@ -240,7 +241,7 @@ ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pix var dx2 = -center[0]; var dy2 = -center[1]; - return ol.transform.compose(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2); + return _ol_transform_.compose(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2); }; @@ -249,7 +250,7 @@ ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pix * @param {ol.events.Event} event Image style change event. * @private */ -ol.source.ImageVector.prototype.handleImageChange_ = function(event) { +_ol_source_ImageVector_.prototype.handleImageChange_ = function(event) { this.changed(); }; @@ -257,7 +258,7 @@ ol.source.ImageVector.prototype.handleImageChange_ = function(event) { /** * @private */ -ol.source.ImageVector.prototype.handleSourceChange_ = function() { +_ol_source_ImageVector_.prototype.handleSourceChange_ = function() { // setState will trigger a CHANGE event, so we always rely // change events by calling setState. this.setState(this.source_.getState()); @@ -272,7 +273,7 @@ ol.source.ImageVector.prototype.handleSourceChange_ = function() { * @return {boolean} `true` if an image is loading. * @private */ -ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) { +_ol_source_ImageVector_.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) { var styles; var styleFunction = feature.getStyleFunction(); if (styleFunction) { @@ -288,9 +289,9 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p styles = [styles]; } for (i = 0, ii = styles.length; i < ii; ++i) { - loading = ol.renderer.vector.renderFeature( + loading = _ol_renderer_vector_.renderFeature( replayGroup, feature, styles[i], - ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio), + _ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio), this.handleImageChange_, this) || loading; } return loading; @@ -308,9 +309,10 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p * style Layer style. * @api */ -ol.source.ImageVector.prototype.setStyle = function(style) { - this.style_ = style !== undefined ? style : ol.style.Style.defaultFunction; +_ol_source_ImageVector_.prototype.setStyle = function(style) { + this.style_ = style !== undefined ? style : _ol_style_Style_.defaultFunction; this.styleFunction_ = !style ? - undefined : ol.style.Style.createFunction(this.style_); + undefined : _ol_style_Style_.createFunction(this.style_); this.changed(); }; +export default _ol_source_ImageVector_; diff --git a/src/ol/source/ImageWMS.js b/src/ol/source/ImageWMS.js index 62f8ef9fcf..1e7d984738 100644 --- a/src/ol/source/ImageWMS.js +++ b/src/ol/source/ImageWMS.js @@ -1,21 +1,21 @@ +/** + * @module ol/source/ImageWMS + */ // FIXME cannot be shared between maps with different projections -goog.provide('ol.source.ImageWMS'); - -goog.require('ol'); -goog.require('ol.Image'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.reproj'); -goog.require('ol.source.Image'); -goog.require('ol.source.WMSServerType'); -goog.require('ol.string'); -goog.require('ol.uri'); - +import _ol_ from '../index.js'; +import _ol_Image_ from '../Image.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_reproj_ from '../reproj.js'; +import _ol_source_Image_ from '../source/Image.js'; +import _ol_source_WMSServerType_ from '../source/WMSServerType.js'; +import _ol_string_ from '../string.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -27,11 +27,11 @@ goog.require('ol.uri'); * @param {olx.source.ImageWMSOptions=} opt_options Options. * @api */ -ol.source.ImageWMS = function(opt_options) { +var _ol_source_ImageWMS_ = function(opt_options) { var options = opt_options || {}; - ol.source.Image.call(this, { + _ol_source_Image_.call(this, { attributions: options.attributions, logo: options.logo, projection: options.projection, @@ -56,7 +56,7 @@ ol.source.ImageWMS = function(opt_options) { * @type {ol.ImageLoadFunctionType} */ this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? - options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction; + options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction; /** * @private @@ -108,7 +108,8 @@ ol.source.ImageWMS = function(opt_options) { this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5; }; -ol.inherits(ol.source.ImageWMS, ol.source.Image); + +_ol_.inherits(_ol_source_ImageWMS_, _ol_source_Image_); /** @@ -116,7 +117,7 @@ ol.inherits(ol.source.ImageWMS, ol.source.Image); * @type {ol.Size} * @private */ -ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; +_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; /** @@ -133,31 +134,31 @@ ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101]; * @return {string|undefined} GetFeatureInfo URL. * @api */ -ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { +_ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { if (this.url_ === undefined) { return undefined; } - var projectionObj = ol.proj.get(projection); + var projectionObj = _ol_proj_.get(projection); var sourceProjectionObj = this.getProjection(); if (sourceProjectionObj && sourceProjectionObj !== projectionObj) { - resolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution); - coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj); + resolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution); + coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj); } - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( coordinate, resolution, 0, - ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_); + _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_); var baseParams = { 'SERVICE': 'WMS', - 'VERSION': ol.DEFAULT_WMS_VERSION, + 'VERSION': _ol_.DEFAULT_WMS_VERSION, 'REQUEST': 'GetFeatureInfo', 'FORMAT': 'image/png', 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'] }; - ol.obj.assign(baseParams, this.params_, params); + _ol_obj_.assign(baseParams, this.params_, params); var x = Math.floor((coordinate[0] - extent[0]) / resolution); var y = Math.floor((extent[3] - coordinate[1]) / resolution); @@ -165,7 +166,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut baseParams[this.v13_ ? 'J' : 'Y'] = y; return this.getRequestUrl_( - extent, ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_, + extent, _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_, 1, sourceProjectionObj || projectionObj, baseParams); }; @@ -176,7 +177,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut * @return {Object} Params. * @api */ -ol.source.ImageWMS.prototype.getParams = function() { +_ol_source_ImageWMS_.prototype.getParams = function() { return this.params_; }; @@ -184,7 +185,7 @@ ol.source.ImageWMS.prototype.getParams = function() { /** * @inheritDoc */ -ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { +_ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) { if (this.url_ === undefined) { return null; @@ -198,14 +199,14 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix var imageResolution = resolution / pixelRatio; - var center = ol.extent.getCenter(extent); - var viewWidth = Math.ceil(ol.extent.getWidth(extent) / imageResolution); - var viewHeight = Math.ceil(ol.extent.getHeight(extent) / imageResolution); - var viewExtent = ol.extent.getForViewAndSize(center, imageResolution, 0, + var center = _ol_extent_.getCenter(extent); + var viewWidth = Math.ceil(_ol_extent_.getWidth(extent) / imageResolution); + var viewHeight = Math.ceil(_ol_extent_.getHeight(extent) / imageResolution); + var viewExtent = _ol_extent_.getForViewAndSize(center, imageResolution, 0, [viewWidth, viewHeight]); - var requestWidth = Math.ceil(this.ratio_ * ol.extent.getWidth(extent) / imageResolution); - var requestHeight = Math.ceil(this.ratio_ * ol.extent.getHeight(extent) / imageResolution); - var requestExtent = ol.extent.getForViewAndSize(center, imageResolution, 0, + var requestWidth = Math.ceil(this.ratio_ * _ol_extent_.getWidth(extent) / imageResolution); + var requestHeight = Math.ceil(this.ratio_ * _ol_extent_.getHeight(extent) / imageResolution); + var requestExtent = _ol_extent_.getForViewAndSize(center, imageResolution, 0, [requestWidth, requestHeight]); var image = this.image_; @@ -213,31 +214,31 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix this.renderedRevision_ == this.getRevision() && image.getResolution() == resolution && image.getPixelRatio() == pixelRatio && - ol.extent.containsExtent(image.getExtent(), viewExtent)) { + _ol_extent_.containsExtent(image.getExtent(), viewExtent)) { return image; } var params = { 'SERVICE': 'WMS', - 'VERSION': ol.DEFAULT_WMS_VERSION, + 'VERSION': _ol_.DEFAULT_WMS_VERSION, 'REQUEST': 'GetMap', 'FORMAT': 'image/png', 'TRANSPARENT': true }; - ol.obj.assign(params, this.params_); + _ol_obj_.assign(params, this.params_); - this.imageSize_[0] = Math.round(ol.extent.getWidth(requestExtent) / imageResolution); - this.imageSize_[1] = Math.round(ol.extent.getHeight(requestExtent) / imageResolution); + this.imageSize_[0] = Math.round(_ol_extent_.getWidth(requestExtent) / imageResolution); + this.imageSize_[1] = Math.round(_ol_extent_.getHeight(requestExtent) / imageResolution); var url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio, projection, params); - this.image_ = new ol.Image(requestExtent, resolution, pixelRatio, + this.image_ = new _ol_Image_(requestExtent, resolution, pixelRatio, url, this.crossOrigin_, this.imageLoadFunction_); this.renderedRevision_ = this.getRevision(); - ol.events.listen(this.image_, ol.events.EventType.CHANGE, + _ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE, this.handleImageChange, this); return this.image_; @@ -250,7 +251,7 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix * @return {ol.ImageLoadFunctionType} The image load function. * @api */ -ol.source.ImageWMS.prototype.getImageLoadFunction = function() { +_ol_source_ImageWMS_.prototype.getImageLoadFunction = function() { return this.imageLoadFunction_; }; @@ -264,9 +265,9 @@ ol.source.ImageWMS.prototype.getImageLoadFunction = function() { * @return {string} Request URL. * @private */ -ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { +_ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) { - ol.asserts.assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()` + _ol_asserts_.assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()` params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode(); @@ -276,7 +277,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, if (pixelRatio != 1) { switch (this.serverType_) { - case ol.source.WMSServerType.GEOSERVER: + case _ol_source_WMSServerType_.GEOSERVER: var dpi = (90 * pixelRatio + 0.5) | 0; if ('FORMAT_OPTIONS' in params) { params['FORMAT_OPTIONS'] += ';dpi:' + dpi; @@ -284,15 +285,15 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, params['FORMAT_OPTIONS'] = 'dpi:' + dpi; } break; - case ol.source.WMSServerType.MAPSERVER: + case _ol_source_WMSServerType_.MAPSERVER: params['MAP_RESOLUTION'] = 90 * pixelRatio; break; - case ol.source.WMSServerType.CARMENTA_SERVER: - case ol.source.WMSServerType.QGIS: + case _ol_source_WMSServerType_.CARMENTA_SERVER: + case _ol_source_WMSServerType_.QGIS: params['DPI'] = 90 * pixelRatio; break; default: - ol.asserts.assert(false, 8); // Unknown `serverType` configured + _ol_asserts_.assert(false, 8); // Unknown `serverType` configured break; } } @@ -309,7 +310,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, } params['BBOX'] = bbox.join(','); - return ol.uri.appendParams(/** @type {string} */ (this.url_), params); + return _ol_uri_.appendParams(/** @type {string} */ (this.url_), params); }; @@ -318,7 +319,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, * @return {string|undefined} URL. * @api */ -ol.source.ImageWMS.prototype.getUrl = function() { +_ol_source_ImageWMS_.prototype.getUrl = function() { return this.url_; }; @@ -328,7 +329,7 @@ ol.source.ImageWMS.prototype.getUrl = function() { * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. * @api */ -ol.source.ImageWMS.prototype.setImageLoadFunction = function( +_ol_source_ImageWMS_.prototype.setImageLoadFunction = function( imageLoadFunction) { this.image_ = null; this.imageLoadFunction_ = imageLoadFunction; @@ -341,7 +342,7 @@ ol.source.ImageWMS.prototype.setImageLoadFunction = function( * @param {string|undefined} url URL. * @api */ -ol.source.ImageWMS.prototype.setUrl = function(url) { +_ol_source_ImageWMS_.prototype.setUrl = function(url) { if (url != this.url_) { this.url_ = url; this.image_ = null; @@ -355,8 +356,8 @@ ol.source.ImageWMS.prototype.setUrl = function(url) { * @param {Object} params Params. * @api */ -ol.source.ImageWMS.prototype.updateParams = function(params) { - ol.obj.assign(this.params_, params); +_ol_source_ImageWMS_.prototype.updateParams = function(params) { + _ol_obj_.assign(this.params_, params); this.updateV13_(); this.image_ = null; this.changed(); @@ -366,7 +367,8 @@ ol.source.ImageWMS.prototype.updateParams = function(params) { /** * @private */ -ol.source.ImageWMS.prototype.updateV13_ = function() { - var version = this.params_['VERSION'] || ol.DEFAULT_WMS_VERSION; - this.v13_ = ol.string.compareVersions(version, '1.3') >= 0; +_ol_source_ImageWMS_.prototype.updateV13_ = function() { + var version = this.params_['VERSION'] || _ol_.DEFAULT_WMS_VERSION; + this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0; }; +export default _ol_source_ImageWMS_; diff --git a/src/ol/source/OSM.js b/src/ol/source/OSM.js index 5ae100c639..1ce669d97e 100644 --- a/src/ol/source/OSM.js +++ b/src/ol/source/OSM.js @@ -1,8 +1,8 @@ -goog.provide('ol.source.OSM'); - -goog.require('ol'); -goog.require('ol.source.XYZ'); - +/** + * @module ol/source/OSM + */ +import _ol_ from '../index.js'; +import _ol_source_XYZ_ from '../source/XYZ.js'; /** * @classdesc @@ -13,7 +13,7 @@ goog.require('ol.source.XYZ'); * @param {olx.source.OSMOptions=} opt_options Open Street Map options. * @api */ -ol.source.OSM = function(opt_options) { +var _ol_source_OSM_ = function(opt_options) { var options = opt_options || {}; @@ -21,7 +21,7 @@ ol.source.OSM = function(opt_options) { if (options.attributions !== undefined) { attributions = options.attributions; } else { - attributions = [ol.source.OSM.ATTRIBUTION]; + attributions = [_ol_source_OSM_.ATTRIBUTION]; } var crossOrigin = options.crossOrigin !== undefined ? @@ -30,7 +30,7 @@ ol.source.OSM = function(opt_options) { var url = options.url !== undefined ? options.url : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; - ol.source.XYZ.call(this, { + _ol_source_XYZ_.call(this, { attributions: attributions, cacheSize: options.cacheSize, crossOrigin: crossOrigin, @@ -43,7 +43,8 @@ ol.source.OSM = function(opt_options) { }); }; -ol.inherits(ol.source.OSM, ol.source.XYZ); + +_ol_.inherits(_ol_source_OSM_, _ol_source_XYZ_); /** @@ -53,6 +54,7 @@ ol.inherits(ol.source.OSM, ol.source.XYZ); * @type {string} * @api */ -ol.source.OSM.ATTRIBUTION = '© ' + +_ol_source_OSM_.ATTRIBUTION = '© ' + 'OpenStreetMap ' + 'contributors.'; +export default _ol_source_OSM_; diff --git a/src/ol/source/Raster.js b/src/ol/source/Raster.js index 3d133c859f..5170945cd1 100644 --- a/src/ol/source/Raster.js +++ b/src/ol/source/Raster.js @@ -1,25 +1,25 @@ -goog.provide('ol.source.Raster'); - -goog.require('ol'); -goog.require('ol.ImageCanvas'); -goog.require('ol.TileQueue'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.ext.pixelworks.Processor'); -goog.require('ol.extent'); -goog.require('ol.layer.Image'); -goog.require('ol.layer.Tile'); -goog.require('ol.obj'); -goog.require('ol.renderer.canvas.ImageLayer'); -goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.source.Image'); -goog.require('ol.source.RasterOperationType'); -goog.require('ol.source.State'); -goog.require('ol.source.Tile'); -goog.require('ol.transform'); - +/** + * @module ol/source/Raster + */ +import _ol_ from '../index.js'; +import _ol_ImageCanvas_ from '../ImageCanvas.js'; +import _ol_TileQueue_ from '../TileQueue.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import {Processor as _ol_ext_pixelworks_Processor_} from 'pixelworks'; +import _ol_extent_ from '../extent.js'; +import _ol_layer_Image_ from '../layer/Image.js'; +import _ol_layer_Tile_ from '../layer/Tile.js'; +import _ol_obj_ from '../obj.js'; +import _ol_renderer_canvas_ImageLayer_ from '../renderer/canvas/ImageLayer.js'; +import _ol_renderer_canvas_TileLayer_ from '../renderer/canvas/TileLayer.js'; +import _ol_source_Image_ from '../source/Image.js'; +import _ol_source_RasterOperationType_ from '../source/RasterOperationType.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_Tile_ from '../source/Tile.js'; +import _ol_transform_ from '../transform.js'; /** * @classdesc @@ -33,7 +33,7 @@ goog.require('ol.transform'); * @param {olx.source.RasterOptions} options Options. * @api */ -ol.source.Raster = function(options) { +var _ol_source_Raster_ = function(options) { /** * @private @@ -46,7 +46,7 @@ ol.source.Raster = function(options) { * @type {ol.source.RasterOperationType} */ this.operationType_ = options.operationType !== undefined ? - options.operationType : ol.source.RasterOperationType.PIXEL; + options.operationType : _ol_source_RasterOperationType_.PIXEL; /** * @private @@ -58,10 +58,10 @@ ol.source.Raster = function(options) { * @private * @type {Array.} */ - this.renderers_ = ol.source.Raster.createRenderers_(options.sources); + this.renderers_ = _ol_source_Raster_.createRenderers_(options.sources); for (var r = 0, rr = this.renderers_.length; r < rr; ++r) { - ol.events.listen(this.renderers_[r], ol.events.EventType.CHANGE, + _ol_events_.listen(this.renderers_[r], _ol_events_EventType_.CHANGE, this.changed, this); } @@ -69,16 +69,16 @@ ol.source.Raster = function(options) { * @private * @type {ol.TileQueue} */ - this.tileQueue_ = new ol.TileQueue( + this.tileQueue_ = new _ol_TileQueue_( function() { return 1; }, this.changed.bind(this)); - var layerStatesArray = ol.source.Raster.getLayerStatesArray_(this.renderers_); + var layerStatesArray = _ol_source_Raster_.getLayerStatesArray_(this.renderers_); var layerStates = {}; for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) { - layerStates[ol.getUid(layerStatesArray[i].layer)] = layerStatesArray[i]; + layerStates[_ol_.getUid(layerStatesArray[i].layer)] = layerStatesArray[i]; } /** @@ -107,7 +107,7 @@ ol.source.Raster = function(options) { */ this.frameState_ = { animate: false, - coordinateToPixelTransform: ol.transform.create(), + coordinateToPixelTransform: _ol_transform_.create(), extent: null, focus: null, index: 0, @@ -115,7 +115,7 @@ ol.source.Raster = function(options) { layerStatesArray: layerStatesArray, logos: {}, pixelRatio: 1, - pixelToCoordinateTransform: ol.transform.create(), + pixelToCoordinateTransform: _ol_transform_.create(), postRenderFunctions: [], size: [0, 0], skippedFeatureUids: {}, @@ -129,14 +129,15 @@ ol.source.Raster = function(options) { wantedTiles: {} }; - ol.source.Image.call(this, {}); + _ol_source_Image_.call(this, {}); if (options.operation !== undefined) { this.setOperation(options.operation, options.lib); } }; -ol.inherits(ol.source.Raster, ol.source.Image); + +_ol_.inherits(_ol_source_Raster_, _ol_source_Image_); /** @@ -146,10 +147,10 @@ ol.inherits(ol.source.Raster, ol.source.Image); * in a worker. * @api */ -ol.source.Raster.prototype.setOperation = function(operation, opt_lib) { - this.worker_ = new ol.ext.pixelworks.Processor({ +_ol_source_Raster_.prototype.setOperation = function(operation, opt_lib) { + this.worker_ = new _ol_ext_pixelworks_Processor_({ operation: operation, - imageOps: this.operationType_ === ol.source.RasterOperationType.IMAGE, + imageOps: this.operationType_ === _ol_source_RasterOperationType_.IMAGE, queue: 1, lib: opt_lib, threads: this.threads_ @@ -166,20 +167,20 @@ ol.source.Raster.prototype.setOperation = function(operation, opt_lib) { * @return {olx.FrameState} The updated frame state. * @private */ -ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, projection) { +_ol_source_Raster_.prototype.updateFrameState_ = function(extent, resolution, projection) { var frameState = /** @type {olx.FrameState} */ ( - ol.obj.assign({}, this.frameState_)); + _ol_obj_.assign({}, this.frameState_)); frameState.viewState = /** @type {olx.ViewState} */ ( - ol.obj.assign({}, frameState.viewState)); + _ol_obj_.assign({}, frameState.viewState)); - var center = ol.extent.getCenter(extent); + var center = _ol_extent_.getCenter(extent); frameState.extent = extent.slice(); frameState.focus = center; - frameState.size[0] = Math.round(ol.extent.getWidth(extent) / resolution); - frameState.size[1] = Math.round(ol.extent.getHeight(extent) / resolution); + frameState.size[0] = Math.round(_ol_extent_.getWidth(extent) / resolution); + frameState.size[1] = Math.round(_ol_extent_.getHeight(extent) / resolution); frameState.time = Date.now(); frameState.animate = false; @@ -196,12 +197,12 @@ ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, proj * @return {boolean} All sources are ready. * @private */ -ol.source.Raster.prototype.allSourcesReady_ = function() { +_ol_source_Raster_.prototype.allSourcesReady_ = function() { var ready = true; var source; for (var i = 0, ii = this.renderers_.length; i < ii; ++i) { source = this.renderers_[i].getLayer().getSource(); - if (source.getState() !== ol.source.State.READY) { + if (source.getState() !== _ol_source_State_.READY) { ready = false; break; } @@ -213,7 +214,7 @@ ol.source.Raster.prototype.allSourcesReady_ = function() { /** * @inheritDoc */ -ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, projection) { +_ol_source_Raster_.prototype.getImage = function(extent, resolution, pixelRatio, projection) { if (!this.allSourcesReady_()) { return null; } @@ -225,7 +226,7 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p if (this.renderedImageCanvas_) { var renderedResolution = this.renderedImageCanvas_.getResolution(); var renderedExtent = this.renderedImageCanvas_.getExtent(); - if (resolution !== renderedResolution || !ol.extent.equals(extent, renderedExtent)) { + if (resolution !== renderedResolution || !_ol_extent_.equals(extent, renderedExtent)) { this.renderedImageCanvas_ = null; } } @@ -248,12 +249,12 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p * Start processing source data. * @private */ -ol.source.Raster.prototype.processSources_ = function() { +_ol_source_Raster_.prototype.processSources_ = function() { var frameState = this.requestedFrameState_; var len = this.renderers_.length; var imageDatas = new Array(len); for (var i = 0; i < len; ++i) { - var imageData = ol.source.Raster.getImageData_( + var imageData = _ol_source_Raster_.getImageData_( this.renderers_[i], frameState, frameState.layerStatesArray[i]); if (imageData) { imageDatas[i] = imageData; @@ -263,8 +264,8 @@ ol.source.Raster.prototype.processSources_ = function() { } var data = {}; - this.dispatchEvent(new ol.source.Raster.Event( - ol.source.Raster.EventType_.BEFOREOPERATIONS, frameState, data)); + this.dispatchEvent(new _ol_source_Raster_.Event( + _ol_source_Raster_.EventType_.BEFOREOPERATIONS, frameState, data)); this.worker_.process(imageDatas, data, this.onWorkerComplete_.bind(this, frameState)); }; @@ -278,7 +279,7 @@ ol.source.Raster.prototype.processSources_ = function() { * @param {Object} data The user data. * @private */ -ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, data) { +_ol_source_Raster_.prototype.onWorkerComplete_ = function(frameState, err, output, data) { if (err || !output) { return; } @@ -287,7 +288,7 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, var extent = frameState.extent; var resolution = frameState.viewState.resolution; if (resolution !== this.requestedFrameState_.viewState.resolution || - !ol.extent.equals(extent, this.requestedFrameState_.extent)) { + !_ol_extent_.equals(extent, this.requestedFrameState_.extent)) { return; } @@ -295,18 +296,18 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, if (this.renderedImageCanvas_) { context = this.renderedImageCanvas_.getImage().getContext('2d'); } else { - var width = Math.round(ol.extent.getWidth(extent) / resolution); - var height = Math.round(ol.extent.getHeight(extent) / resolution); - context = ol.dom.createCanvasContext2D(width, height); - this.renderedImageCanvas_ = new ol.ImageCanvas(extent, resolution, 1, context.canvas); + var width = Math.round(_ol_extent_.getWidth(extent) / resolution); + var height = Math.round(_ol_extent_.getHeight(extent) / resolution); + context = _ol_dom_.createCanvasContext2D(width, height); + this.renderedImageCanvas_ = new _ol_ImageCanvas_(extent, resolution, 1, context.canvas); } context.putImageData(output, 0, 0); this.changed(); this.renderedRevision_ = this.getRevision(); - this.dispatchEvent(new ol.source.Raster.Event( - ol.source.Raster.EventType_.AFTEROPERATIONS, frameState, data)); + this.dispatchEvent(new _ol_source_Raster_.Event( + _ol_source_Raster_.EventType_.AFTEROPERATIONS, frameState, data)); }; @@ -318,24 +319,24 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, * @return {ImageData} The image data. * @private */ -ol.source.Raster.getImageData_ = function(renderer, frameState, layerState) { +_ol_source_Raster_.getImageData_ = function(renderer, frameState, layerState) { if (!renderer.prepareFrame(frameState, layerState)) { return null; } var width = frameState.size[0]; var height = frameState.size[1]; - if (!ol.source.Raster.context_) { - ol.source.Raster.context_ = ol.dom.createCanvasContext2D(width, height); + if (!_ol_source_Raster_.context_) { + _ol_source_Raster_.context_ = _ol_dom_.createCanvasContext2D(width, height); } else { - var canvas = ol.source.Raster.context_.canvas; + var canvas = _ol_source_Raster_.context_.canvas; if (canvas.width !== width || canvas.height !== height) { - ol.source.Raster.context_ = ol.dom.createCanvasContext2D(width, height); + _ol_source_Raster_.context_ = _ol_dom_.createCanvasContext2D(width, height); } else { - ol.source.Raster.context_.clearRect(0, 0, width, height); + _ol_source_Raster_.context_.clearRect(0, 0, width, height); } } - renderer.composeFrame(frameState, layerState, ol.source.Raster.context_); - return ol.source.Raster.context_.getImageData(0, 0, width, height); + renderer.composeFrame(frameState, layerState, _ol_source_Raster_.context_); + return _ol_source_Raster_.context_.getImageData(0, 0, width, height); }; @@ -344,7 +345,7 @@ ol.source.Raster.getImageData_ = function(renderer, frameState, layerState) { * @type {CanvasRenderingContext2D} * @private */ -ol.source.Raster.context_ = null; +_ol_source_Raster_.context_ = null; /** @@ -353,7 +354,7 @@ ol.source.Raster.context_ = null; * @return {Array.} The layer states. * @private */ -ol.source.Raster.getLayerStatesArray_ = function(renderers) { +_ol_source_Raster_.getLayerStatesArray_ = function(renderers) { return renderers.map(function(renderer) { return renderer.getLayer().getLayerState(); }); @@ -366,11 +367,11 @@ ol.source.Raster.getLayerStatesArray_ = function(renderers) { * @return {Array.} Array of layer renderers. * @private */ -ol.source.Raster.createRenderers_ = function(sources) { +_ol_source_Raster_.createRenderers_ = function(sources) { var len = sources.length; var renderers = new Array(len); for (var i = 0; i < len; ++i) { - renderers[i] = ol.source.Raster.createRenderer_(sources[i]); + renderers[i] = _ol_source_Raster_.createRenderer_(sources[i]); } return renderers; }; @@ -382,12 +383,12 @@ ol.source.Raster.createRenderers_ = function(sources) { * @return {ol.renderer.canvas.Layer} The renderer. * @private */ -ol.source.Raster.createRenderer_ = function(source) { +_ol_source_Raster_.createRenderer_ = function(source) { var renderer = null; - if (source instanceof ol.source.Tile) { - renderer = ol.source.Raster.createTileRenderer_(source); - } else if (source instanceof ol.source.Image) { - renderer = ol.source.Raster.createImageRenderer_(source); + if (source instanceof _ol_source_Tile_) { + renderer = _ol_source_Raster_.createTileRenderer_(source); + } else if (source instanceof _ol_source_Image_) { + renderer = _ol_source_Raster_.createImageRenderer_(source); } return renderer; }; @@ -399,9 +400,9 @@ ol.source.Raster.createRenderer_ = function(source) { * @return {ol.renderer.canvas.Layer} The renderer. * @private */ -ol.source.Raster.createImageRenderer_ = function(source) { - var layer = new ol.layer.Image({source: source}); - return new ol.renderer.canvas.ImageLayer(layer); +_ol_source_Raster_.createImageRenderer_ = function(source) { + var layer = new _ol_layer_Image_({source: source}); + return new _ol_renderer_canvas_ImageLayer_(layer); }; @@ -411,9 +412,9 @@ ol.source.Raster.createImageRenderer_ = function(source) { * @return {ol.renderer.canvas.Layer} The renderer. * @private */ -ol.source.Raster.createTileRenderer_ = function(source) { - var layer = new ol.layer.Tile({source: source}); - return new ol.renderer.canvas.TileLayer(layer); +_ol_source_Raster_.createTileRenderer_ = function(source) { + var layer = new _ol_layer_Tile_({source: source}); + return new _ol_renderer_canvas_TileLayer_(layer); }; @@ -429,8 +430,8 @@ ol.source.Raster.createTileRenderer_ = function(source) { * @param {olx.FrameState} frameState The frame state. * @param {Object} data An object made available to operations. */ -ol.source.Raster.Event = function(type, frameState, data) { - ol.events.Event.call(this, type); +_ol_source_Raster_.Event = function(type, frameState, data) { + _ol_events_Event_.call(this, type); /** * The raster extent. @@ -455,13 +456,13 @@ ol.source.Raster.Event = function(type, frameState, data) { this.data = data; }; -ol.inherits(ol.source.Raster.Event, ol.events.Event); +_ol_.inherits(_ol_source_Raster_.Event, _ol_events_Event_); /** * @override */ -ol.source.Raster.prototype.getImageInternal = function() { +_ol_source_Raster_.prototype.getImageInternal = function() { return null; // not implemented }; @@ -470,7 +471,7 @@ ol.source.Raster.prototype.getImageInternal = function() { * @enum {string} * @private */ -ol.source.Raster.EventType_ = { +_ol_source_Raster_.EventType_ = { /** * Triggered before operations are run. * @event ol.source.Raster.Event#beforeoperations @@ -485,3 +486,4 @@ ol.source.Raster.EventType_ = { */ AFTEROPERATIONS: 'afteroperations' }; +export default _ol_source_Raster_; diff --git a/src/ol/source/RasterOperationType.js b/src/ol/source/RasterOperationType.js index a86611f600..bf6fd88c63 100644 --- a/src/ol/source/RasterOperationType.js +++ b/src/ol/source/RasterOperationType.js @@ -1,10 +1,13 @@ -goog.provide('ol.source.RasterOperationType'); - +/** + * @module ol/source/RasterOperationType + */ /** * Raster operation type. Supported values are `'pixel'` and `'image'`. * @enum {string} */ -ol.source.RasterOperationType = { +var _ol_source_RasterOperationType_ = { PIXEL: 'pixel', IMAGE: 'image' }; + +export default _ol_source_RasterOperationType_; diff --git a/src/ol/source/Source.js b/src/ol/source/Source.js index 9e1fdf1ce3..6c03ba7126 100644 --- a/src/ol/source/Source.js +++ b/src/ol/source/Source.js @@ -1,11 +1,11 @@ -goog.provide('ol.source.Source'); - -goog.require('ol'); -goog.require('ol.Attribution'); -goog.require('ol.Object'); -goog.require('ol.proj'); -goog.require('ol.source.State'); - +/** + * @module ol/source/Source + */ +import _ol_ from '../index.js'; +import _ol_Attribution_ from '../Attribution.js'; +import _ol_Object_ from '../Object.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_State_ from '../source/State.js'; /** * @classdesc @@ -21,15 +21,15 @@ goog.require('ol.source.State'); * @param {ol.SourceSourceOptions} options Source options. * @api */ -ol.source.Source = function(options) { +var _ol_source_Source_ = function(options) { - ol.Object.call(this); + _ol_Object_.call(this); /** * @private * @type {ol.proj.Projection} */ - this.projection_ = ol.proj.get(options.projection); + this.projection_ = _ol_proj_.get(options.projection); /** * @private @@ -54,7 +54,7 @@ ol.source.Source = function(options) { * @type {ol.source.State} */ this.state_ = options.state !== undefined ? - options.state : ol.source.State.READY; + options.state : _ol_source_State_.READY; /** * @private @@ -63,7 +63,8 @@ ol.source.Source = function(options) { this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false; }; -ol.inherits(ol.source.Source, ol.Object); + +_ol_.inherits(_ol_source_Source_, _ol_Object_); /** * Turns the attributions option into an attributions function. @@ -71,11 +72,11 @@ ol.inherits(ol.source.Source, ol.Object); * @param {ol.AttributionLike|undefined} attributionLike The attribution option. * @return {?ol.Attribution2} An attribution function (or null). */ -ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) { +_ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) { if (!attributionLike) { return null; } - if (attributionLike instanceof ol.Attribution) { + if (attributionLike instanceof _ol_Attribution_) { // TODO: remove attributions_ in next major release this.attributions_ = [attributionLike]; @@ -85,7 +86,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) { }; } if (Array.isArray(attributionLike)) { - if (attributionLike[0] instanceof ol.Attribution) { + if (attributionLike[0] instanceof _ol_Attribution_) { // TODO: remove attributions_ in next major release this.attributions_ = attributionLike; @@ -100,7 +101,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) { // TODO: remove attributions_ in next major release this.attributions_ = attributionLike.map(function(attribution) { - return new ol.Attribution({html: attribution}); + return new _ol_Attribution_({html: attribution}); }); return function(frameState) { @@ -114,7 +115,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) { // TODO: remove attributions_ in next major release this.attributions_ = [ - new ol.Attribution({html: attributionLike}) + new _ol_Attribution_({html: attributionLike}) ]; return function(frameState) { @@ -133,7 +134,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) { * @return {T|undefined} Callback result. * @template T */ -ol.source.Source.prototype.forEachFeatureAtCoordinate = ol.nullFunction; +_ol_source_Source_.prototype.forEachFeatureAtCoordinate = _ol_.nullFunction; /** @@ -141,7 +142,7 @@ ol.source.Source.prototype.forEachFeatureAtCoordinate = ol.nullFunction; * @return {Array.} Attributions. * @api */ -ol.source.Source.prototype.getAttributions = function() { +_ol_source_Source_.prototype.getAttributions = function() { return this.attributions_; }; @@ -150,7 +151,7 @@ ol.source.Source.prototype.getAttributions = function() { * Get the attribution function for the source. * @return {?ol.Attribution2} Attribution function. */ -ol.source.Source.prototype.getAttributions2 = function() { +_ol_source_Source_.prototype.getAttributions2 = function() { return this.attributions2_; }; @@ -160,7 +161,7 @@ ol.source.Source.prototype.getAttributions2 = function() { * @return {string|olx.LogoOptions|undefined} Logo. * @api */ -ol.source.Source.prototype.getLogo = function() { +_ol_source_Source_.prototype.getLogo = function() { return this.logo_; }; @@ -170,7 +171,7 @@ ol.source.Source.prototype.getLogo = function() { * @return {ol.proj.Projection} Projection. * @api */ -ol.source.Source.prototype.getProjection = function() { +_ol_source_Source_.prototype.getProjection = function() { return this.projection_; }; @@ -179,7 +180,7 @@ ol.source.Source.prototype.getProjection = function() { * @abstract * @return {Array.|undefined} Resolutions. */ -ol.source.Source.prototype.getResolutions = function() {}; +_ol_source_Source_.prototype.getResolutions = function() {}; /** @@ -187,7 +188,7 @@ ol.source.Source.prototype.getResolutions = function() {}; * @return {ol.source.State} State. * @api */ -ol.source.Source.prototype.getState = function() { +_ol_source_Source_.prototype.getState = function() { return this.state_; }; @@ -195,7 +196,7 @@ ol.source.Source.prototype.getState = function() { /** * @return {boolean|undefined} Wrap X. */ -ol.source.Source.prototype.getWrapX = function() { +_ol_source_Source_.prototype.getWrapX = function() { return this.wrapX_; }; @@ -204,7 +205,7 @@ ol.source.Source.prototype.getWrapX = function() { * Refreshes the source and finally dispatches a 'change' event. * @api */ -ol.source.Source.prototype.refresh = function() { +_ol_source_Source_.prototype.refresh = function() { this.changed(); }; @@ -216,7 +217,7 @@ ol.source.Source.prototype.refresh = function() { * or `undefined`. * @api */ -ol.source.Source.prototype.setAttributions = function(attributions) { +_ol_source_Source_.prototype.setAttributions = function(attributions) { this.attributions2_ = this.adaptAttributions_(attributions); this.changed(); }; @@ -226,7 +227,7 @@ ol.source.Source.prototype.setAttributions = function(attributions) { * Set the logo of the source. * @param {string|olx.LogoOptions|undefined} logo Logo. */ -ol.source.Source.prototype.setLogo = function(logo) { +_ol_source_Source_.prototype.setLogo = function(logo) { this.logo_ = logo; }; @@ -236,7 +237,8 @@ ol.source.Source.prototype.setLogo = function(logo) { * @param {ol.source.State} state State. * @protected */ -ol.source.Source.prototype.setState = function(state) { +_ol_source_Source_.prototype.setState = function(state) { this.state_ = state; this.changed(); }; +export default _ol_source_Source_; diff --git a/src/ol/source/Stamen.js b/src/ol/source/Stamen.js index 673f5a7304..9c62d56607 100644 --- a/src/ol/source/Stamen.js +++ b/src/ol/source/Stamen.js @@ -1,9 +1,9 @@ -goog.provide('ol.source.Stamen'); - -goog.require('ol'); -goog.require('ol.source.OSM'); -goog.require('ol.source.XYZ'); - +/** + * @module ol/source/Stamen + */ +import _ol_ from '../index.js'; +import _ol_source_OSM_ from '../source/OSM.js'; +import _ol_source_XYZ_ from '../source/XYZ.js'; /** * @classdesc @@ -14,19 +14,19 @@ goog.require('ol.source.XYZ'); * @param {olx.source.StamenOptions} options Stamen options. * @api */ -ol.source.Stamen = function(options) { +var _ol_source_Stamen_ = function(options) { var i = options.layer.indexOf('-'); var provider = i == -1 ? options.layer : options.layer.slice(0, i); - var providerConfig = ol.source.Stamen.ProviderConfig[provider]; + var providerConfig = _ol_source_Stamen_.ProviderConfig[provider]; - var layerConfig = ol.source.Stamen.LayerConfig[options.layer]; + var layerConfig = _ol_source_Stamen_.LayerConfig[options.layer]; var url = options.url !== undefined ? options.url : 'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer + '/{z}/{x}/{y}.' + layerConfig.extension; - ol.source.XYZ.call(this, { - attributions: ol.source.Stamen.ATTRIBUTIONS, + _ol_source_XYZ_.call(this, { + attributions: _ol_source_Stamen_.ATTRIBUTIONS, cacheSize: options.cacheSize, crossOrigin: 'anonymous', maxZoom: options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom, @@ -38,24 +38,25 @@ ol.source.Stamen = function(options) { wrapX: options.wrapX }); }; -ol.inherits(ol.source.Stamen, ol.source.XYZ); + +_ol_.inherits(_ol_source_Stamen_, _ol_source_XYZ_); /** * @const * @type {Array.} */ -ol.source.Stamen.ATTRIBUTIONS = [ +_ol_source_Stamen_.ATTRIBUTIONS = [ 'Map tiles by Stamen Design, ' + 'under CC BY' + ' 3.0.', - ol.source.OSM.ATTRIBUTION + _ol_source_OSM_.ATTRIBUTION ]; /** * @type {Object.} */ -ol.source.Stamen.LayerConfig = { +_ol_source_Stamen_.LayerConfig = { 'terrain': { extension: 'jpg', opaque: true @@ -105,7 +106,7 @@ ol.source.Stamen.LayerConfig = { /** * @type {Object.} */ -ol.source.Stamen.ProviderConfig = { +_ol_source_Stamen_.ProviderConfig = { 'terrain': { minZoom: 4, maxZoom: 18 @@ -119,3 +120,4 @@ ol.source.Stamen.ProviderConfig = { maxZoom: 16 } }; +export default _ol_source_Stamen_; diff --git a/src/ol/source/State.js b/src/ol/source/State.js index e53aa054d2..ebf8dd5331 100644 --- a/src/ol/source/State.js +++ b/src/ol/source/State.js @@ -1,14 +1,15 @@ -goog.provide('ol.source.State'); - - +/** + * @module ol/source/State + */ /** * State of the source, one of 'undefined', 'loading', 'ready' or 'error'. * @enum {string} */ -ol.source.State = { +var _ol_source_State_ = { UNDEFINED: 'undefined', LOADING: 'loading', READY: 'ready', ERROR: 'error' }; +export default _ol_source_State_; diff --git a/src/ol/source/Tile.js b/src/ol/source/Tile.js index ddc39273c3..e0fdfa3ecb 100644 --- a/src/ol/source/Tile.js +++ b/src/ol/source/Tile.js @@ -1,15 +1,15 @@ -goog.provide('ol.source.Tile'); - -goog.require('ol'); -goog.require('ol.TileCache'); -goog.require('ol.TileState'); -goog.require('ol.events.Event'); -goog.require('ol.proj'); -goog.require('ol.size'); -goog.require('ol.source.Source'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/Tile + */ +import _ol_ from '../index.js'; +import _ol_TileCache_ from '../TileCache.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_proj_ from '../proj.js'; +import _ol_size_ from '../size.js'; +import _ol_source_Source_ from '../source/Source.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -23,9 +23,9 @@ goog.require('ol.tilegrid'); * @param {ol.SourceTileOptions} options Tile source options. * @api */ -ol.source.Tile = function(options) { +var _ol_source_Tile_ = function(options) { - ol.source.Source.call(this, { + _ol_source_Source_.call(this, { attributions: options.attributions, extent: options.extent, logo: options.logo, @@ -57,7 +57,7 @@ ol.source.Tile = function(options) { * @protected * @type {ol.TileCache} */ - this.tileCache = new ol.TileCache(options.cacheSize); + this.tileCache = new _ol_TileCache_(options.cacheSize); /** * @protected @@ -78,13 +78,14 @@ ol.source.Tile = function(options) { this.tileOptions = {transition: options.transition}; }; -ol.inherits(ol.source.Tile, ol.source.Source); + +_ol_.inherits(_ol_source_Tile_, _ol_source_Source_); /** * @return {boolean} Can expire cache. */ -ol.source.Tile.prototype.canExpireCache = function() { +_ol_source_Tile_.prototype.canExpireCache = function() { return this.tileCache.canExpireCache(); }; @@ -93,7 +94,7 @@ ol.source.Tile.prototype.canExpireCache = function() { * @param {ol.proj.Projection} projection Projection. * @param {Object.} usedTiles Used tiles. */ -ol.source.Tile.prototype.expireCache = function(projection, usedTiles) { +_ol_source_Tile_.prototype.expireCache = function(projection, usedTiles) { var tileCache = this.getTileCacheForProjection(projection); if (tileCache) { tileCache.expireCache(usedTiles); @@ -110,7 +111,7 @@ ol.source.Tile.prototype.expireCache = function(projection, usedTiles) { * considered loaded. * @return {boolean} The tile range is fully covered with loaded tiles. */ -ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange, callback) { +_ol_source_Tile_.prototype.forEachLoadedTile = function(projection, z, tileRange, callback) { var tileCache = this.getTileCacheForProjection(projection); if (!tileCache) { return false; @@ -120,11 +121,11 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange, var tile, tileCoordKey, loaded; for (var x = tileRange.minX; x <= tileRange.maxX; ++x) { for (var y = tileRange.minY; y <= tileRange.maxY; ++y) { - tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); + tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); loaded = false; if (tileCache.containsKey(tileCoordKey)) { tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey)); - loaded = tile.getState() === ol.TileState.LOADED; + loaded = tile.getState() === _ol_TileState_.LOADED; if (loaded) { loaded = (callback(tile) !== false); } @@ -142,7 +143,7 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange, * @param {ol.proj.Projection} projection Projection. * @return {number} Gutter. */ -ol.source.Tile.prototype.getGutter = function(projection) { +_ol_source_Tile_.prototype.getGutter = function(projection) { return 0; }; @@ -152,7 +153,7 @@ ol.source.Tile.prototype.getGutter = function(projection) { * @return {string} The key for all tiles. * @protected */ -ol.source.Tile.prototype.getKey = function() { +_ol_source_Tile_.prototype.getKey = function() { return this.key_; }; @@ -162,7 +163,7 @@ ol.source.Tile.prototype.getKey = function() { * @param {string} key The key for tiles. * @protected */ -ol.source.Tile.prototype.setKey = function(key) { +_ol_source_Tile_.prototype.setKey = function(key) { if (this.key_ !== key) { this.key_ = key; this.changed(); @@ -174,7 +175,7 @@ ol.source.Tile.prototype.setKey = function(key) { * @param {ol.proj.Projection} projection Projection. * @return {boolean} Opaque. */ -ol.source.Tile.prototype.getOpaque = function(projection) { +_ol_source_Tile_.prototype.getOpaque = function(projection) { return this.opaque_; }; @@ -182,7 +183,7 @@ ol.source.Tile.prototype.getOpaque = function(projection) { /** * @inheritDoc */ -ol.source.Tile.prototype.getResolutions = function() { +_ol_source_Tile_.prototype.getResolutions = function() { return this.tileGrid.getResolutions(); }; @@ -196,7 +197,7 @@ ol.source.Tile.prototype.getResolutions = function() { * @param {ol.proj.Projection} projection Projection. * @return {!ol.Tile} Tile. */ -ol.source.Tile.prototype.getTile = function(z, x, y, pixelRatio, projection) {}; +_ol_source_Tile_.prototype.getTile = function(z, x, y, pixelRatio, projection) {}; /** @@ -204,7 +205,7 @@ ol.source.Tile.prototype.getTile = function(z, x, y, pixelRatio, projection) {}; * @return {ol.tilegrid.TileGrid} Tile grid. * @api */ -ol.source.Tile.prototype.getTileGrid = function() { +_ol_source_Tile_.prototype.getTileGrid = function() { return this.tileGrid; }; @@ -213,9 +214,9 @@ ol.source.Tile.prototype.getTileGrid = function() { * @param {ol.proj.Projection} projection Projection. * @return {!ol.tilegrid.TileGrid} Tile grid. */ -ol.source.Tile.prototype.getTileGridForProjection = function(projection) { +_ol_source_Tile_.prototype.getTileGridForProjection = function(projection) { if (!this.tileGrid) { - return ol.tilegrid.getForProjection(projection); + return _ol_tilegrid_.getForProjection(projection); } else { return this.tileGrid; } @@ -227,9 +228,9 @@ ol.source.Tile.prototype.getTileGridForProjection = function(projection) { * @return {ol.TileCache} Tile cache. * @protected */ -ol.source.Tile.prototype.getTileCacheForProjection = function(projection) { +_ol_source_Tile_.prototype.getTileCacheForProjection = function(projection) { var thisProj = this.getProjection(); - if (thisProj && !ol.proj.equivalent(thisProj, projection)) { + if (thisProj && !_ol_proj_.equivalent(thisProj, projection)) { return null; } else { return this.tileCache; @@ -244,7 +245,7 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) { * @param {number} pixelRatio Pixel ratio. * @return {number} Tile pixel ratio. */ -ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) { +_ol_source_Tile_.prototype.getTilePixelRatio = function(pixelRatio) { return this.tilePixelRatio_; }; @@ -255,14 +256,14 @@ ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) { * @param {ol.proj.Projection} projection Projection. * @return {ol.Size} Tile size. */ -ol.source.Tile.prototype.getTilePixelSize = function(z, pixelRatio, projection) { +_ol_source_Tile_.prototype.getTilePixelSize = function(z, pixelRatio, projection) { var tileGrid = this.getTileGridForProjection(projection); var tilePixelRatio = this.getTilePixelRatio(pixelRatio); - var tileSize = ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize); + var tileSize = _ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize); if (tilePixelRatio == 1) { return tileSize; } else { - return ol.size.scale(tileSize, tilePixelRatio, this.tmpSize); + return _ol_size_.scale(tileSize, tilePixelRatio, this.tmpSize); } }; @@ -276,21 +277,21 @@ ol.source.Tile.prototype.getTilePixelSize = function(z, pixelRatio, projection) * @return {ol.TileCoord} Tile coordinate to be passed to the tileUrlFunction or * null if no tile URL should be created for the passed `tileCoord`. */ -ol.source.Tile.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) { +_ol_source_Tile_.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) { var projection = opt_projection !== undefined ? opt_projection : this.getProjection(); var tileGrid = this.getTileGridForProjection(projection); if (this.getWrapX() && projection.isGlobal()) { - tileCoord = ol.tilegrid.wrapX(tileGrid, tileCoord, projection); + tileCoord = _ol_tilegrid_.wrapX(tileGrid, tileCoord, projection); } - return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null; + return _ol_tilecoord_.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null; }; /** * @inheritDoc */ -ol.source.Tile.prototype.refresh = function() { +_ol_source_Tile_.prototype.refresh = function() { this.tileCache.clear(); this.changed(); }; @@ -303,7 +304,7 @@ ol.source.Tile.prototype.refresh = function() { * @param {number} y Tile coordinate y. * @param {ol.proj.Projection} projection Projection. */ -ol.source.Tile.prototype.useTile = ol.nullFunction; +_ol_source_Tile_.prototype.useTile = _ol_.nullFunction; /** @@ -317,9 +318,9 @@ ol.source.Tile.prototype.useTile = ol.nullFunction; * @param {string} type Type. * @param {ol.Tile} tile The tile. */ -ol.source.Tile.Event = function(type, tile) { +_ol_source_Tile_.Event = function(type, tile) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The tile related to the event. @@ -329,4 +330,5 @@ ol.source.Tile.Event = function(type, tile) { this.tile = tile; }; -ol.inherits(ol.source.Tile.Event, ol.events.Event); +_ol_.inherits(_ol_source_Tile_.Event, _ol_events_Event_); +export default _ol_source_Tile_; diff --git a/src/ol/source/TileArcGISRest.js b/src/ol/source/TileArcGISRest.js index 3a504de7a4..cb8031c1f2 100644 --- a/src/ol/source/TileArcGISRest.js +++ b/src/ol/source/TileArcGISRest.js @@ -1,14 +1,14 @@ -goog.provide('ol.source.TileArcGISRest'); - -goog.require('ol'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.obj'); -goog.require('ol.size'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilecoord'); -goog.require('ol.uri'); - +/** + * @module ol/source/TileArcGISRest + */ +import _ol_ from '../index.js'; +import _ol_extent_ from '../extent.js'; +import _ol_math_ from '../math.js'; +import _ol_obj_ from '../obj.js'; +import _ol_size_ from '../size.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -24,11 +24,11 @@ goog.require('ol.uri'); * options. * @api */ -ol.source.TileArcGISRest = function(opt_options) { +var _ol_source_TileArcGISRest_ = function(opt_options) { var options = opt_options || {}; - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -53,18 +53,19 @@ ol.source.TileArcGISRest = function(opt_options) { * @private * @type {ol.Extent} */ - this.tmpExtent_ = ol.extent.createEmpty(); + this.tmpExtent_ = _ol_extent_.createEmpty(); this.setKey(this.getKeyForParams_()); }; -ol.inherits(ol.source.TileArcGISRest, ol.source.TileImage); + +_ol_.inherits(_ol_source_TileArcGISRest_, _ol_source_TileImage_); /** * @private * @return {string} The key for the current params. */ -ol.source.TileArcGISRest.prototype.getKeyForParams_ = function() { +_ol_source_TileArcGISRest_.prototype.getKeyForParams_ = function() { var i = 0; var res = []; for (var key in this.params_) { @@ -80,7 +81,7 @@ ol.source.TileArcGISRest.prototype.getKeyForParams_ = function() { * @return {Object} Params. * @api */ -ol.source.TileArcGISRest.prototype.getParams = function() { +_ol_source_TileArcGISRest_.prototype.getParams = function() { return this.params_; }; @@ -95,7 +96,7 @@ ol.source.TileArcGISRest.prototype.getParams = function() { * @return {string|undefined} Request URL. * @private */ -ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent, +_ol_source_TileArcGISRest_.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent, pixelRatio, projection, params) { var urls = this.urls; @@ -118,21 +119,21 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize if (urls.length == 1) { url = urls[0]; } else { - var index = ol.math.modulo(ol.tilecoord.hash(tileCoord), urls.length); + var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length); url = urls[index]; } var modifiedUrl = url .replace(/MapServer\/?$/, 'MapServer/export') .replace(/ImageServer\/?$/, 'ImageServer/exportImage'); - return ol.uri.appendParams(modifiedUrl, params); + return _ol_uri_.appendParams(modifiedUrl, params); }; /** * @inheritDoc */ -ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) { +_ol_source_TileArcGISRest_.prototype.getTilePixelRatio = function(pixelRatio) { return /** @type {number} */ (pixelRatio); }; @@ -140,7 +141,7 @@ ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) { /** * @inheritDoc */ -ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) { +_ol_source_TileArcGISRest_.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) { var tileGrid = this.getTileGrid(); if (!tileGrid) { @@ -153,11 +154,11 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi var tileExtent = tileGrid.getTileCoordExtent( tileCoord, this.tmpExtent_); - var tileSize = ol.size.toSize( + var tileSize = _ol_size_.toSize( tileGrid.getTileSize(tileCoord[0]), this.tmpSize); if (pixelRatio != 1) { - tileSize = ol.size.scale(tileSize, pixelRatio, this.tmpSize); + tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize); } // Apply default params and override with user specified values. @@ -166,7 +167,7 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi 'FORMAT': 'PNG32', 'TRANSPARENT': true }; - ol.obj.assign(baseParams, this.params_); + _ol_obj_.assign(baseParams, this.params_); return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams); @@ -178,7 +179,8 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi * @param {Object} params Params. * @api */ -ol.source.TileArcGISRest.prototype.updateParams = function(params) { - ol.obj.assign(this.params_, params); +_ol_source_TileArcGISRest_.prototype.updateParams = function(params) { + _ol_obj_.assign(this.params_, params); this.setKey(this.getKeyForParams_()); }; +export default _ol_source_TileArcGISRest_; diff --git a/src/ol/source/TileDebug.js b/src/ol/source/TileDebug.js index 80dfa8013f..51b4d170d8 100644 --- a/src/ol/source/TileDebug.js +++ b/src/ol/source/TileDebug.js @@ -1,13 +1,13 @@ -goog.provide('ol.source.TileDebug'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); -goog.require('ol.dom'); -goog.require('ol.size'); -goog.require('ol.source.Tile'); -goog.require('ol.tilecoord'); - +/** + * @module ol/source/TileDebug + */ +import _ol_ from '../index.js'; +import _ol_Tile_ from '../Tile.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_dom_ from '../dom.js'; +import _ol_size_ from '../size.js'; +import _ol_source_Tile_ from '../source/Tile.js'; +import _ol_tilecoord_ from '../tilecoord.js'; /** * @classdesc @@ -22,9 +22,9 @@ goog.require('ol.tilecoord'); * @param {olx.source.TileDebugOptions} options Debug tile options. * @api */ -ol.source.TileDebug = function(options) { +var _ol_source_TileDebug_ = function(options) { - ol.source.Tile.call(this, { + _ol_source_Tile_.call(this, { opaque: false, projection: options.projection, tileGrid: options.tileGrid, @@ -32,23 +32,24 @@ ol.source.TileDebug = function(options) { }); }; -ol.inherits(ol.source.TileDebug, ol.source.Tile); + +_ol_.inherits(_ol_source_TileDebug_, _ol_source_Tile_); /** * @inheritDoc */ -ol.source.TileDebug.prototype.getTile = function(z, x, y) { - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); +_ol_source_TileDebug_.prototype.getTile = function(z, x, y) { + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey)); } else { - var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z)); + var tileSize = _ol_size_.toSize(this.tileGrid.getTileSize(z)); var tileCoord = [z, x, y]; var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord); var text = !textTileCoord ? '' : this.getTileCoordForTileUrlFunction(textTileCoord).toString(); - var tile = new ol.source.TileDebug.Tile_(tileCoord, tileSize, text); + var tile = new _ol_source_TileDebug_.Tile_(tileCoord, tileSize, text); this.tileCache.set(tileCoordKey, tile); return tile; } @@ -63,9 +64,9 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) { * @param {string} text Text. * @private */ -ol.source.TileDebug.Tile_ = function(tileCoord, tileSize, text) { +_ol_source_TileDebug_.Tile_ = function(tileCoord, tileSize, text) { - ol.Tile.call(this, tileCoord, ol.TileState.LOADED); + _ol_Tile_.call(this, tileCoord, _ol_TileState_.LOADED); /** * @private @@ -86,19 +87,19 @@ ol.source.TileDebug.Tile_ = function(tileCoord, tileSize, text) { this.canvas_ = null; }; -ol.inherits(ol.source.TileDebug.Tile_, ol.Tile); +_ol_.inherits(_ol_source_TileDebug_.Tile_, _ol_Tile_); /** * Get the image element for this tile. * @return {HTMLCanvasElement} Image. */ -ol.source.TileDebug.Tile_.prototype.getImage = function() { +_ol_source_TileDebug_.Tile_.prototype.getImage = function() { if (this.canvas_) { return this.canvas_; } else { var tileSize = this.tileSize_; - var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]); + var context = _ol_dom_.createCanvasContext2D(tileSize[0], tileSize[1]); context.strokeStyle = 'black'; context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5); @@ -118,4 +119,5 @@ ol.source.TileDebug.Tile_.prototype.getImage = function() { /** * @override */ -ol.source.TileDebug.Tile_.prototype.load = function() {}; +_ol_source_TileDebug_.Tile_.prototype.load = function() {}; +export default _ol_source_TileDebug_; diff --git a/src/ol/source/TileEventType.js b/src/ol/source/TileEventType.js index c62ea14bc1..5adae2af05 100644 --- a/src/ol/source/TileEventType.js +++ b/src/ol/source/TileEventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.source.TileEventType'); - +/** + * @module ol/source/TileEventType + */ /** * @enum {string} */ -ol.source.TileEventType = { +var _ol_source_TileEventType_ = { /** * Triggered when a tile starts loading. @@ -28,3 +29,5 @@ ol.source.TileEventType = { TILELOADERROR: 'tileloaderror' }; + +export default _ol_source_TileEventType_; diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index e43769d399..226083f21a 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -1,17 +1,17 @@ -goog.provide('ol.source.TileImage'); - -goog.require('ol'); -goog.require('ol.ImageTile'); -goog.require('ol.TileCache'); -goog.require('ol.TileState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.proj'); -goog.require('ol.reproj.Tile'); -goog.require('ol.source.UrlTile'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/TileImage + */ +import _ol_ from '../index.js'; +import _ol_ImageTile_ from '../ImageTile.js'; +import _ol_TileCache_ from '../TileCache.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_proj_ from '../proj.js'; +import _ol_reproj_Tile_ from '../reproj/Tile.js'; +import _ol_source_UrlTile_ from '../source/UrlTile.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -23,9 +23,9 @@ goog.require('ol.tilegrid'); * @param {olx.source.TileImageOptions} options Image tile options. * @api */ -ol.source.TileImage = function(options) { +var _ol_source_TileImage_ = function(options) { - ol.source.UrlTile.call(this, { + _ol_source_UrlTile_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, extent: options.extent, @@ -35,7 +35,7 @@ ol.source.TileImage = function(options) { state: options.state, tileGrid: options.tileGrid, tileLoadFunction: options.tileLoadFunction ? - options.tileLoadFunction : ol.source.TileImage.defaultTileLoadFunction, + options.tileLoadFunction : _ol_source_TileImage_.defaultTileLoadFunction, tilePixelRatio: options.tilePixelRatio, tileUrlFunction: options.tileUrlFunction, url: options.url, @@ -57,7 +57,7 @@ ol.source.TileImage = function(options) { * ?string, ol.TileLoadFunctionType, olx.TileOptions=)} */ this.tileClass = options.tileClass !== undefined ? - options.tileClass : ol.ImageTile; + options.tileClass : _ol_ImageTile_; /** * @protected @@ -83,15 +83,16 @@ ol.source.TileImage = function(options) { */ this.renderReprojectionEdges_ = false; }; -ol.inherits(ol.source.TileImage, ol.source.UrlTile); + +_ol_.inherits(_ol_source_TileImage_, _ol_source_UrlTile_); /** * @inheritDoc */ -ol.source.TileImage.prototype.canExpireCache = function() { - if (!ol.ENABLE_RASTER_REPROJECTION) { - return ol.source.UrlTile.prototype.canExpireCache.call(this); +_ol_source_TileImage_.prototype.canExpireCache = function() { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { + return _ol_source_UrlTile_.prototype.canExpireCache.call(this); } if (this.tileCache.canExpireCache()) { return true; @@ -109,9 +110,9 @@ ol.source.TileImage.prototype.canExpireCache = function() { /** * @inheritDoc */ -ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) { - if (!ol.ENABLE_RASTER_REPROJECTION) { - ol.source.UrlTile.prototype.expireCache.call(this, projection, usedTiles); +_ol_source_TileImage_.prototype.expireCache = function(projection, usedTiles) { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { + _ol_source_UrlTile_.prototype.expireCache.call(this, projection, usedTiles); return; } var usedTileCache = this.getTileCacheForProjection(projection); @@ -127,10 +128,10 @@ ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) { /** * @inheritDoc */ -ol.source.TileImage.prototype.getGutter = function(projection) { - if (ol.ENABLE_RASTER_REPROJECTION && +_ol_source_TileImage_.prototype.getGutter = function(projection) { + if (_ol_.ENABLE_RASTER_REPROJECTION && this.getProjection() && projection && - !ol.proj.equivalent(this.getProjection(), projection)) { + !_ol_proj_.equivalent(this.getProjection(), projection)) { return 0; } else { return this.getGutterInternal(); @@ -142,7 +143,7 @@ ol.source.TileImage.prototype.getGutter = function(projection) { * @protected * @return {number} Gutter. */ -ol.source.TileImage.prototype.getGutterInternal = function() { +_ol_source_TileImage_.prototype.getGutterInternal = function() { return 0; }; @@ -150,13 +151,13 @@ ol.source.TileImage.prototype.getGutterInternal = function() { /** * @inheritDoc */ -ol.source.TileImage.prototype.getOpaque = function(projection) { - if (ol.ENABLE_RASTER_REPROJECTION && +_ol_source_TileImage_.prototype.getOpaque = function(projection) { + if (_ol_.ENABLE_RASTER_REPROJECTION && this.getProjection() && projection && - !ol.proj.equivalent(this.getProjection(), projection)) { + !_ol_proj_.equivalent(this.getProjection(), projection)) { return false; } else { - return ol.source.UrlTile.prototype.getOpaque.call(this, projection); + return _ol_source_UrlTile_.prototype.getOpaque.call(this, projection); } }; @@ -164,19 +165,19 @@ ol.source.TileImage.prototype.getOpaque = function(projection) { /** * @inheritDoc */ -ol.source.TileImage.prototype.getTileGridForProjection = function(projection) { - if (!ol.ENABLE_RASTER_REPROJECTION) { - return ol.source.UrlTile.prototype.getTileGridForProjection.call(this, projection); +_ol_source_TileImage_.prototype.getTileGridForProjection = function(projection) { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { + return _ol_source_UrlTile_.prototype.getTileGridForProjection.call(this, projection); } var thisProj = this.getProjection(); if (this.tileGrid && - (!thisProj || ol.proj.equivalent(thisProj, projection))) { + (!thisProj || _ol_proj_.equivalent(thisProj, projection))) { return this.tileGrid; } else { - var projKey = ol.getUid(projection).toString(); + var projKey = _ol_.getUid(projection).toString(); if (!(projKey in this.tileGridForProjection)) { this.tileGridForProjection[projKey] = - ol.tilegrid.getForProjection(projection); + _ol_tilegrid_.getForProjection(projection); } return /** @type {!ol.tilegrid.TileGrid} */ (this.tileGridForProjection[projKey]); } @@ -186,17 +187,17 @@ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) { /** * @inheritDoc */ -ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) { - if (!ol.ENABLE_RASTER_REPROJECTION) { - return ol.source.UrlTile.prototype.getTileCacheForProjection.call(this, projection); +_ol_source_TileImage_.prototype.getTileCacheForProjection = function(projection) { + if (!_ol_.ENABLE_RASTER_REPROJECTION) { + return _ol_source_UrlTile_.prototype.getTileCacheForProjection.call(this, projection); } var thisProj = this.getProjection(); - if (!thisProj || ol.proj.equivalent(thisProj, projection)) { + if (!thisProj || _ol_proj_.equivalent(thisProj, projection)) { return this.tileCache; } else { - var projKey = ol.getUid(projection).toString(); + var projKey = _ol_.getUid(projection).toString(); if (!(projKey in this.tileCacheForProjection)) { - this.tileCacheForProjection[projKey] = new ol.TileCache(this.tileCache.highWaterMark); + this.tileCacheForProjection[projKey] = new _ol_TileCache_(this.tileCache.highWaterMark); } return this.tileCacheForProjection[projKey]; } @@ -213,7 +214,7 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) { * @return {!ol.Tile} Tile. * @private */ -ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) { +_ol_source_TileImage_.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) { var tileCoord = [z, x, y]; var urlTileCoord = this.getTileCoordForTileUrlFunction( tileCoord, projection); @@ -221,13 +222,13 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined; var tile = new this.tileClass( tileCoord, - tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY, + tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, tileUrl !== undefined ? tileUrl : '', this.crossOrigin, this.tileLoadFunction, this.tileOptions); tile.key = key; - ol.events.listen(tile, ol.events.EventType.CHANGE, + _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, this.handleTileChange, this); return tile; }; @@ -236,17 +237,17 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec /** * @inheritDoc */ -ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection) { +_ol_source_TileImage_.prototype.getTile = function(z, x, y, pixelRatio, projection) { var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection()); - if (!ol.ENABLE_RASTER_REPROJECTION || + if (!_ol_.ENABLE_RASTER_REPROJECTION || !sourceProjection || !projection || - ol.proj.equivalent(sourceProjection, projection)) { + _ol_proj_.equivalent(sourceProjection, projection)) { return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection); } else { var cache = this.getTileCacheForProjection(projection); var tileCoord = [z, x, y]; var tile; - var tileCoordKey = ol.tilecoord.getKey(tileCoord); + var tileCoordKey = _ol_tilecoord_.getKey(tileCoord); if (cache.containsKey(tileCoordKey)) { tile = /** @type {!ol.Tile} */ (cache.get(tileCoordKey)); } @@ -258,7 +259,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection var targetTileGrid = this.getTileGridForProjection(projection); var wrappedTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection); - var newTile = new ol.reproj.Tile( + var newTile = new _ol_reproj_Tile_( sourceProjection, sourceTileGrid, projection, targetTileGrid, tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio), @@ -291,9 +292,9 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection * @return {!ol.Tile} Tile. * @protected */ -ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) { +_ol_source_TileImage_.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) { var tile = null; - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); var key = this.getKey(); if (!this.tileCache.containsKey(tileCoordKey)) { tile = this.createTile_(z, x, y, pixelRatio, projection, key); @@ -308,7 +309,7 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr tile = this.createTile_(z, x, y, pixelRatio, projection, key); //make the new tile the head of the list, - if (interimTile.getState() == ol.TileState.IDLE) { + if (interimTile.getState() == _ol_TileState_.IDLE) { //the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it tile.interimTile = interimTile.interimTile; } else { @@ -327,8 +328,8 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr * @param {boolean} render Render the edges. * @api */ -ol.source.TileImage.prototype.setRenderReprojectionEdges = function(render) { - if (!ol.ENABLE_RASTER_REPROJECTION || +_ol_source_TileImage_.prototype.setRenderReprojectionEdges = function(render) { + if (!_ol_.ENABLE_RASTER_REPROJECTION || this.renderReprojectionEdges_ == render) { return; } @@ -352,11 +353,11 @@ ol.source.TileImage.prototype.setRenderReprojectionEdges = function(render) { * @param {ol.tilegrid.TileGrid} tilegrid Tile grid to use for the projection. * @api */ -ol.source.TileImage.prototype.setTileGridForProjection = function(projection, tilegrid) { - if (ol.ENABLE_RASTER_REPROJECTION) { - var proj = ol.proj.get(projection); +_ol_source_TileImage_.prototype.setTileGridForProjection = function(projection, tilegrid) { + if (_ol_.ENABLE_RASTER_REPROJECTION) { + var proj = _ol_proj_.get(projection); if (proj) { - var projKey = ol.getUid(proj).toString(); + var projKey = _ol_.getUid(proj).toString(); if (!(projKey in this.tileGridForProjection)) { this.tileGridForProjection[projKey] = tilegrid; } @@ -369,6 +370,7 @@ ol.source.TileImage.prototype.setTileGridForProjection = function(projection, ti * @param {ol.ImageTile} imageTile Image tile. * @param {string} src Source. */ -ol.source.TileImage.defaultTileLoadFunction = function(imageTile, src) { +_ol_source_TileImage_.defaultTileLoadFunction = function(imageTile, src) { imageTile.getImage().src = src; }; +export default _ol_source_TileImage_; diff --git a/src/ol/source/TileJSON.js b/src/ol/source/TileJSON.js index e186c8b579..68f35f941d 100644 --- a/src/ol/source/TileJSON.js +++ b/src/ol/source/TileJSON.js @@ -1,21 +1,21 @@ +/** + * @module ol/source/TileJSON + */ // FIXME check order of async callbacks /** * @see http://mapbox.com/developers/api/ */ -goog.provide('ol.source.TileJSON'); - -goog.require('ol'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.asserts'); -goog.require('ol.extent'); -goog.require('ol.net'); -goog.require('ol.proj'); -goog.require('ol.source.State'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilegrid'); - +import _ol_ from '../index.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_extent_ from '../extent.js'; +import _ol_net_ from '../net.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -26,7 +26,7 @@ goog.require('ol.tilegrid'); * @param {olx.source.TileJSONOptions} options TileJSON options. * @api */ -ol.source.TileJSON = function(options) { +var _ol_source_TileJSON_ = function(options) { /** * @type {TileJSON} @@ -34,13 +34,13 @@ ol.source.TileJSON = function(options) { */ this.tileJSON_ = null; - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, - projection: ol.proj.get('EPSG:3857'), + projection: _ol_proj_.get('EPSG:3857'), reprojectionErrorThreshold: options.reprojectionErrorThreshold, - state: ol.source.State.LOADING, + state: _ol_source_State_.LOADING, tileLoadFunction: options.tileLoadFunction, wrapX: options.wrapX !== undefined ? options.wrapX : true, transition: options.transition @@ -48,7 +48,7 @@ ol.source.TileJSON = function(options) { if (options.url) { if (options.jsonp) { - ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this), + _ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this), this.handleTileJSONError.bind(this)); } else { var client = new XMLHttpRequest(); @@ -60,18 +60,19 @@ ol.source.TileJSON = function(options) { } else if (options.tileJSON) { this.handleTileJSONResponse(options.tileJSON); } else { - ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided + _ol_asserts_.assert(false, 51); // Either `url` or `tileJSON` options must be provided } }; -ol.inherits(ol.source.TileJSON, ol.source.TileImage); + +_ol_.inherits(_ol_source_TileJSON_, _ol_source_TileImage_); /** * @private * @param {Event} event The load event. */ -ol.source.TileJSON.prototype.onXHRLoad_ = function(event) { +_ol_source_TileJSON_.prototype.onXHRLoad_ = function(event) { var client = /** @type {XMLHttpRequest} */ (event.target); // status will be 0 for file:// urls if (!client.status || client.status >= 200 && client.status < 300) { @@ -93,7 +94,7 @@ ol.source.TileJSON.prototype.onXHRLoad_ = function(event) { * @private * @param {Event} event The error event. */ -ol.source.TileJSON.prototype.onXHRError_ = function(event) { +_ol_source_TileJSON_.prototype.onXHRError_ = function(event) { this.handleTileJSONError(); }; @@ -102,7 +103,7 @@ ol.source.TileJSON.prototype.onXHRError_ = function(event) { * @return {TileJSON} The tilejson object. * @api */ -ol.source.TileJSON.prototype.getTileJSON = function() { +_ol_source_TileJSON_.prototype.getTileJSON = function() { return this.tileJSON_; }; @@ -111,36 +112,36 @@ ol.source.TileJSON.prototype.getTileJSON = function() { * @protected * @param {TileJSON} tileJSON Tile JSON. */ -ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { +_ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) { - var epsg4326Projection = ol.proj.get('EPSG:4326'); + var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var sourceProjection = this.getProjection(); var extent; if (tileJSON.bounds !== undefined) { - var transform = ol.proj.getTransformFromProjections( + var transform = _ol_proj_.getTransformFromProjections( epsg4326Projection, sourceProjection); - extent = ol.extent.applyTransform(tileJSON.bounds, transform); + extent = _ol_extent_.applyTransform(tileJSON.bounds, transform); } var minZoom = tileJSON.minzoom || 0; var maxZoom = tileJSON.maxzoom || 22; - var tileGrid = ol.tilegrid.createXYZ({ - extent: ol.tilegrid.extentFromProjection(sourceProjection), + var tileGrid = _ol_tilegrid_.createXYZ({ + extent: _ol_tilegrid_.extentFromProjection(sourceProjection), maxZoom: maxZoom, minZoom: minZoom }); this.tileGrid = tileGrid; this.tileUrlFunction = - ol.TileUrlFunction.createFromTemplates(tileJSON.tiles, tileGrid); + _ol_TileUrlFunction_.createFromTemplates(tileJSON.tiles, tileGrid); if (tileJSON.attribution !== undefined && !this.getAttributions2()) { var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); this.setAttributions(function(frameState) { - if (ol.extent.intersects(attributionExtent, frameState.extent)) { + if (_ol_extent_.intersects(attributionExtent, frameState.extent)) { return [tileJSON.attribution]; } return null; @@ -148,7 +149,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { } this.tileJSON_ = tileJSON; - this.setState(ol.source.State.READY); + this.setState(_ol_source_State_.READY); }; @@ -156,6 +157,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) { /** * @protected */ -ol.source.TileJSON.prototype.handleTileJSONError = function() { - this.setState(ol.source.State.ERROR); +_ol_source_TileJSON_.prototype.handleTileJSONError = function() { + this.setState(_ol_source_State_.ERROR); }; +export default _ol_source_TileJSON_; diff --git a/src/ol/source/TileUTFGrid.js b/src/ol/source/TileUTFGrid.js index 0aa094f028..8fd7e88c5f 100644 --- a/src/ol/source/TileUTFGrid.js +++ b/src/ol/source/TileUTFGrid.js @@ -1,20 +1,20 @@ -goog.provide('ol.source.TileUTFGrid'); - -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.net'); -goog.require('ol.proj'); -goog.require('ol.source.State'); -goog.require('ol.source.Tile'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/TileUTFGrid + */ +import _ol_ from '../index.js'; +import _ol_Tile_ from '../Tile.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_net_ from '../net.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_Tile_ from '../source/Tile.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -25,10 +25,10 @@ goog.require('ol.tilegrid'); * @param {olx.source.TileUTFGridOptions} options Source options. * @api */ -ol.source.TileUTFGrid = function(options) { - ol.source.Tile.call(this, { - projection: ol.proj.get('EPSG:3857'), - state: ol.source.State.LOADING +var _ol_source_TileUTFGrid_ = function(options) { + _ol_source_Tile_.call(this, { + projection: _ol_proj_.get('EPSG:3857'), + state: _ol_source_State_.LOADING }); /** @@ -42,7 +42,7 @@ ol.source.TileUTFGrid = function(options) { * @private * @type {!ol.TileUrlFunctionType} */ - this.tileUrlFunction_ = ol.TileUrlFunction.nullTileUrlFunction; + this.tileUrlFunction_ = _ol_TileUrlFunction_.nullTileUrlFunction; /** * @private @@ -58,7 +58,7 @@ ol.source.TileUTFGrid = function(options) { if (options.url) { if (this.jsonp_) { - ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this), + _ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this), this.handleTileJSONError.bind(this)); } else { var client = new XMLHttpRequest(); @@ -70,17 +70,18 @@ ol.source.TileUTFGrid = function(options) { } else if (options.tileJSON) { this.handleTileJSONResponse(options.tileJSON); } else { - ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided + _ol_asserts_.assert(false, 51); // Either `url` or `tileJSON` options must be provided } }; -ol.inherits(ol.source.TileUTFGrid, ol.source.Tile); + +_ol_.inherits(_ol_source_TileUTFGrid_, _ol_source_Tile_); /** * @private * @param {Event} event The load event. */ -ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) { +_ol_source_TileUTFGrid_.prototype.onXHRLoad_ = function(event) { var client = /** @type {XMLHttpRequest} */ (event.target); // status will be 0 for file:// urls if (!client.status || client.status >= 200 && client.status < 300) { @@ -102,7 +103,7 @@ ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) { * @private * @param {Event} event The error event. */ -ol.source.TileUTFGrid.prototype.onXHRError_ = function(event) { +_ol_source_TileUTFGrid_.prototype.onXHRError_ = function(event) { this.handleTileJSONError(); }; @@ -112,7 +113,7 @@ ol.source.TileUTFGrid.prototype.onXHRError_ = function(event) { * @return {string|undefined} The template from TileJSON. * @api */ -ol.source.TileUTFGrid.prototype.getTemplate = function() { +_ol_source_TileUTFGrid_.prototype.getTemplate = function() { return this.template_; }; @@ -130,7 +131,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() { * @template T * @api */ -ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function( +_ol_source_TileUTFGrid_.prototype.forDataAtCoordinateAndResolution = function( coordinate, resolution, callback, opt_this, opt_request) { if (this.tileGrid) { var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution( @@ -153,8 +154,8 @@ ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function( /** * @protected */ -ol.source.TileUTFGrid.prototype.handleTileJSONError = function() { - this.setState(ol.source.State.ERROR); +_ol_source_TileUTFGrid_.prototype.handleTileJSONError = function() { + this.setState(_ol_source_State_.ERROR); }; @@ -163,22 +164,22 @@ ol.source.TileUTFGrid.prototype.handleTileJSONError = function() { * @protected * @param {TileJSON} tileJSON Tile JSON. */ -ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { +_ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) { - var epsg4326Projection = ol.proj.get('EPSG:4326'); + var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var sourceProjection = this.getProjection(); var extent; if (tileJSON.bounds !== undefined) { - var transform = ol.proj.getTransformFromProjections( + var transform = _ol_proj_.getTransformFromProjections( epsg4326Projection, sourceProjection); - extent = ol.extent.applyTransform(tileJSON.bounds, transform); + extent = _ol_extent_.applyTransform(tileJSON.bounds, transform); } var minZoom = tileJSON.minzoom || 0; var maxZoom = tileJSON.maxzoom || 22; - var tileGrid = ol.tilegrid.createXYZ({ - extent: ol.tilegrid.extentFromProjection(sourceProjection), + var tileGrid = _ol_tilegrid_.createXYZ({ + extent: _ol_tilegrid_.extentFromProjection(sourceProjection), maxZoom: maxZoom, minZoom: minZoom }); @@ -188,26 +189,26 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { var grids = tileJSON.grids; if (!grids) { - this.setState(ol.source.State.ERROR); + this.setState(_ol_source_State_.ERROR); return; } this.tileUrlFunction_ = - ol.TileUrlFunction.createFromTemplates(grids, tileGrid); + _ol_TileUrlFunction_.createFromTemplates(grids, tileGrid); if (tileJSON.attribution !== undefined) { var attributionExtent = extent !== undefined ? extent : epsg4326Projection.getExtent(); this.setAttributions(function(frameState) { - if (ol.extent.intersects(attributionExtent, frameState.extent)) { + if (_ol_extent_.intersects(attributionExtent, frameState.extent)) { return [tileJSON.attribution]; } return null; }); } - this.setState(ol.source.State.READY); + this.setState(_ol_source_State_.READY); }; @@ -215,8 +216,8 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) { /** * @inheritDoc */ -ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) { - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); +_ol_source_TileUTFGrid_.prototype.getTile = function(z, x, y, pixelRatio, projection) { + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey)); } else { @@ -224,9 +225,9 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti var urlTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection); var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection); - var tile = new ol.source.TileUTFGrid.Tile_( + var tile = new _ol_source_TileUTFGrid_.Tile_( tileCoord, - tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY, + tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, tileUrl !== undefined ? tileUrl : '', this.tileGrid.getTileCoordExtent(tileCoord), this.preemptive_, @@ -240,8 +241,8 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti /** * @inheritDoc */ -ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) { - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); +_ol_source_TileUTFGrid_.prototype.useTile = function(z, x, y) { + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { this.tileCache.get(tileCoordKey); } @@ -259,9 +260,9 @@ ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) { * @param {boolean} jsonp Load the tile as a script. * @private */ -ol.source.TileUTFGrid.Tile_ = function(tileCoord, state, src, extent, preemptive, jsonp) { +_ol_source_TileUTFGrid_.Tile_ = function(tileCoord, state, src, extent, preemptive, jsonp) { - ol.Tile.call(this, tileCoord, state); + _ol_Tile_.call(this, tileCoord, state); /** * @private @@ -307,14 +308,14 @@ ol.source.TileUTFGrid.Tile_ = function(tileCoord, state, src, extent, preemptive this.jsonp_ = jsonp; }; -ol.inherits(ol.source.TileUTFGrid.Tile_, ol.Tile); +_ol_.inherits(_ol_source_TileUTFGrid_.Tile_, _ol_Tile_); /** * Get the image element for this tile. * @return {Image} Image. */ -ol.source.TileUTFGrid.Tile_.prototype.getImage = function() { +_ol_source_TileUTFGrid_.Tile_.prototype.getImage = function() { return null; }; @@ -324,7 +325,7 @@ ol.source.TileUTFGrid.Tile_.prototype.getImage = function() { * @param {ol.Coordinate} coordinate Coordinate. * @return {*} The data. */ -ol.source.TileUTFGrid.Tile_.prototype.getData = function(coordinate) { +_ol_source_TileUTFGrid_.Tile_.prototype.getData = function(coordinate) { if (!this.grid_ || !this.keys_) { return null; } @@ -371,9 +372,9 @@ ol.source.TileUTFGrid.Tile_.prototype.getData = function(coordinate) { * The tile data is requested if not yet loaded. * @template T */ -ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) { - if (this.state == ol.TileState.IDLE && opt_request === true) { - ol.events.listenOnce(this, ol.events.EventType.CHANGE, function(e) { +_ol_source_TileUTFGrid_.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) { + if (this.state == _ol_TileState_.IDLE && opt_request === true) { + _ol_events_.listenOnce(this, _ol_events_EventType_.CHANGE, function(e) { callback.call(opt_this, this.getData(coordinate)); }, this); this.loadInternal_(); @@ -392,7 +393,7 @@ ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate, /** * @inheritDoc */ -ol.source.TileUTFGrid.Tile_.prototype.getKey = function() { +_ol_source_TileUTFGrid_.Tile_.prototype.getKey = function() { return this.src_; }; @@ -400,8 +401,8 @@ ol.source.TileUTFGrid.Tile_.prototype.getKey = function() { /** * @private */ -ol.source.TileUTFGrid.Tile_.prototype.handleError_ = function() { - this.state = ol.TileState.ERROR; +_ol_source_TileUTFGrid_.Tile_.prototype.handleError_ = function() { + this.state = _ol_TileState_.ERROR; this.changed(); }; @@ -410,12 +411,12 @@ ol.source.TileUTFGrid.Tile_.prototype.handleError_ = function() { * @param {!UTFGridJSON} json UTFGrid data. * @private */ -ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) { +_ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) { this.grid_ = json.grid; this.keys_ = json.keys; this.data_ = json.data; - this.state = ol.TileState.EMPTY; + this.state = _ol_TileState_.EMPTY; this.changed(); }; @@ -423,11 +424,11 @@ ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) { /** * @private */ -ol.source.TileUTFGrid.Tile_.prototype.loadInternal_ = function() { - if (this.state == ol.TileState.IDLE) { - this.state = ol.TileState.LOADING; +_ol_source_TileUTFGrid_.Tile_.prototype.loadInternal_ = function() { + if (this.state == _ol_TileState_.IDLE) { + this.state = _ol_TileState_.LOADING; if (this.jsonp_) { - ol.net.jsonp(this.src_, this.handleLoad_.bind(this), + _ol_net_.jsonp(this.src_, this.handleLoad_.bind(this), this.handleError_.bind(this)); } else { var client = new XMLHttpRequest(); @@ -444,7 +445,7 @@ ol.source.TileUTFGrid.Tile_.prototype.loadInternal_ = function() { * @private * @param {Event} event The load event. */ -ol.source.TileUTFGrid.Tile_.prototype.onXHRLoad_ = function(event) { +_ol_source_TileUTFGrid_.Tile_.prototype.onXHRLoad_ = function(event) { var client = /** @type {XMLHttpRequest} */ (event.target); // status will be 0 for file:// urls if (!client.status || client.status >= 200 && client.status < 300) { @@ -466,7 +467,7 @@ ol.source.TileUTFGrid.Tile_.prototype.onXHRLoad_ = function(event) { * @private * @param {Event} event The error event. */ -ol.source.TileUTFGrid.Tile_.prototype.onXHRError_ = function(event) { +_ol_source_TileUTFGrid_.Tile_.prototype.onXHRError_ = function(event) { this.handleError_(); }; @@ -474,8 +475,9 @@ ol.source.TileUTFGrid.Tile_.prototype.onXHRError_ = function(event) { /** * @override */ -ol.source.TileUTFGrid.Tile_.prototype.load = function() { +_ol_source_TileUTFGrid_.Tile_.prototype.load = function() { if (this.preemptive_) { this.loadInternal_(); } }; +export default _ol_source_TileUTFGrid_; diff --git a/src/ol/source/TileWMS.js b/src/ol/source/TileWMS.js index f7984d4464..3815ec0016 100644 --- a/src/ol/source/TileWMS.js +++ b/src/ol/source/TileWMS.js @@ -1,22 +1,23 @@ +/** + * @module ol/source/TileWMS + */ // FIXME add minZoom support // FIXME add date line wrap (tile coord transform) // FIXME cannot be shared between maps with different projections -goog.provide('ol.source.TileWMS'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.math'); -goog.require('ol.proj'); -goog.require('ol.reproj'); -goog.require('ol.size'); -goog.require('ol.source.TileImage'); -goog.require('ol.source.WMSServerType'); -goog.require('ol.tilecoord'); -goog.require('ol.string'); -goog.require('ol.uri'); +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; +import _ol_math_ from '../math.js'; +import _ol_proj_ from '../proj.js'; +import _ol_reproj_ from '../reproj.js'; +import _ol_size_ from '../size.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_source_WMSServerType_ from '../source/WMSServerType.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_string_ from '../string.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -27,7 +28,7 @@ goog.require('ol.uri'); * @param {olx.source.TileWMSOptions=} opt_options Tile WMS options. * @api */ -ol.source.TileWMS = function(opt_options) { +var _ol_source_TileWMS_ = function(opt_options) { var options = opt_options || {}; @@ -35,7 +36,7 @@ ol.source.TileWMS = function(opt_options) { var transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true; - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -86,13 +87,14 @@ ol.source.TileWMS = function(opt_options) { * @private * @type {ol.Extent} */ - this.tmpExtent_ = ol.extent.createEmpty(); + this.tmpExtent_ = _ol_extent_.createEmpty(); this.updateV13_(); this.setKey(this.getKeyForParams_()); }; -ol.inherits(ol.source.TileWMS, ol.source.TileImage); + +_ol_.inherits(_ol_source_TileWMS_, _ol_source_TileImage_); /** @@ -109,8 +111,8 @@ ol.inherits(ol.source.TileWMS, ol.source.TileImage); * @return {string|undefined} GetFeatureInfo URL. * @api */ -ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { - var projectionObj = ol.proj.get(projection); +_ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { + var projectionObj = _ol_proj_.get(projection); var sourceProjectionObj = this.getProjection(); var tileGrid = this.getTileGrid(); @@ -126,30 +128,30 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti var tileResolution = tileGrid.getResolution(tileCoord[0]); var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_); - var tileSize = ol.size.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize); + var tileSize = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize); var gutter = this.gutter_; if (gutter !== 0) { - tileSize = ol.size.buffer(tileSize, gutter, this.tmpSize); - tileExtent = ol.extent.buffer(tileExtent, tileResolution * gutter, tileExtent); + tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize); + tileExtent = _ol_extent_.buffer(tileExtent, tileResolution * gutter, tileExtent); } if (sourceProjectionObj && sourceProjectionObj !== projectionObj) { - tileResolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution); - tileExtent = ol.proj.transformExtent(tileExtent, projectionObj, sourceProjectionObj); - coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj); + tileResolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution); + tileExtent = _ol_proj_.transformExtent(tileExtent, projectionObj, sourceProjectionObj); + coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj); } var baseParams = { 'SERVICE': 'WMS', - 'VERSION': ol.DEFAULT_WMS_VERSION, + 'VERSION': _ol_.DEFAULT_WMS_VERSION, 'REQUEST': 'GetFeatureInfo', 'FORMAT': 'image/png', 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'] }; - ol.obj.assign(baseParams, this.params_, params); + _ol_obj_.assign(baseParams, this.params_, params); var x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution); var y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution); @@ -165,7 +167,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti /** * @inheritDoc */ -ol.source.TileWMS.prototype.getGutterInternal = function() { +_ol_source_TileWMS_.prototype.getGutterInternal = function() { return this.gutter_; }; @@ -176,7 +178,7 @@ ol.source.TileWMS.prototype.getGutterInternal = function() { * @return {Object} Params. * @api */ -ol.source.TileWMS.prototype.getParams = function() { +_ol_source_TileWMS_.prototype.getParams = function() { return this.params_; }; @@ -191,7 +193,7 @@ ol.source.TileWMS.prototype.getParams = function() { * @return {string|undefined} Request URL. * @private */ -ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent, +_ol_source_TileWMS_.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent, pixelRatio, projection, params) { var urls = this.urls; @@ -210,7 +212,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE if (pixelRatio != 1) { switch (this.serverType_) { - case ol.source.WMSServerType.GEOSERVER: + case _ol_source_WMSServerType_.GEOSERVER: var dpi = (90 * pixelRatio + 0.5) | 0; if ('FORMAT_OPTIONS' in params) { params['FORMAT_OPTIONS'] += ';dpi:' + dpi; @@ -218,15 +220,15 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE params['FORMAT_OPTIONS'] = 'dpi:' + dpi; } break; - case ol.source.WMSServerType.MAPSERVER: + case _ol_source_WMSServerType_.MAPSERVER: params['MAP_RESOLUTION'] = 90 * pixelRatio; break; - case ol.source.WMSServerType.CARMENTA_SERVER: - case ol.source.WMSServerType.QGIS: + case _ol_source_WMSServerType_.CARMENTA_SERVER: + case _ol_source_WMSServerType_.QGIS: params['DPI'] = 90 * pixelRatio; break; default: - ol.asserts.assert(false, 52); // Unknown `serverType` configured + _ol_asserts_.assert(false, 52); // Unknown `serverType` configured break; } } @@ -248,17 +250,17 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE if (urls.length == 1) { url = urls[0]; } else { - var index = ol.math.modulo(ol.tilecoord.hash(tileCoord), urls.length); + var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length); url = urls[index]; } - return ol.uri.appendParams(url, params); + return _ol_uri_.appendParams(url, params); }; /** * @inheritDoc */ -ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) { +_ol_source_TileWMS_.prototype.getTilePixelRatio = function(pixelRatio) { return (!this.hidpi_ || this.serverType_ === undefined) ? 1 : /** @type {number} */ (pixelRatio); }; @@ -268,7 +270,7 @@ ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) { * @private * @return {string} The key for the current params. */ -ol.source.TileWMS.prototype.getKeyForParams_ = function() { +_ol_source_TileWMS_.prototype.getKeyForParams_ = function() { var i = 0; var res = []; for (var key in this.params_) { @@ -281,7 +283,7 @@ ol.source.TileWMS.prototype.getKeyForParams_ = function() { /** * @inheritDoc */ -ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) { +_ol_source_TileWMS_.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) { var tileGrid = this.getTileGrid(); if (!tileGrid) { @@ -298,28 +300,28 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati var tileResolution = tileGrid.getResolution(tileCoord[0]); var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_); - var tileSize = ol.size.toSize( + var tileSize = _ol_size_.toSize( tileGrid.getTileSize(tileCoord[0]), this.tmpSize); var gutter = this.gutter_; if (gutter !== 0) { - tileSize = ol.size.buffer(tileSize, gutter, this.tmpSize); - tileExtent = ol.extent.buffer(tileExtent, + tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize); + tileExtent = _ol_extent_.buffer(tileExtent, tileResolution * gutter, tileExtent); } if (pixelRatio != 1) { - tileSize = ol.size.scale(tileSize, pixelRatio, this.tmpSize); + tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize); } var baseParams = { 'SERVICE': 'WMS', - 'VERSION': ol.DEFAULT_WMS_VERSION, + 'VERSION': _ol_.DEFAULT_WMS_VERSION, 'REQUEST': 'GetMap', 'FORMAT': 'image/png', 'TRANSPARENT': true }; - ol.obj.assign(baseParams, this.params_); + _ol_obj_.assign(baseParams, this.params_); return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams); @@ -330,8 +332,8 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati * @param {Object} params Params. * @api */ -ol.source.TileWMS.prototype.updateParams = function(params) { - ol.obj.assign(this.params_, params); +_ol_source_TileWMS_.prototype.updateParams = function(params) { + _ol_obj_.assign(this.params_, params); this.updateV13_(); this.setKey(this.getKeyForParams_()); }; @@ -340,7 +342,8 @@ ol.source.TileWMS.prototype.updateParams = function(params) { /** * @private */ -ol.source.TileWMS.prototype.updateV13_ = function() { - var version = this.params_['VERSION'] || ol.DEFAULT_WMS_VERSION; - this.v13_ = ol.string.compareVersions(version, '1.3') >= 0; +_ol_source_TileWMS_.prototype.updateV13_ = function() { + var version = this.params_['VERSION'] || _ol_.DEFAULT_WMS_VERSION; + this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0; }; +export default _ol_source_TileWMS_; diff --git a/src/ol/source/UrlTile.js b/src/ol/source/UrlTile.js index 48e7d77003..c4218954ef 100644 --- a/src/ol/source/UrlTile.js +++ b/src/ol/source/UrlTile.js @@ -1,12 +1,12 @@ -goog.provide('ol.source.UrlTile'); - -goog.require('ol'); -goog.require('ol.TileState'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.source.Tile'); -goog.require('ol.source.TileEventType'); -goog.require('ol.tilecoord'); - +/** + * @module ol/source/UrlTile + */ +import _ol_ from '../index.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_source_Tile_ from '../source/Tile.js'; +import _ol_source_TileEventType_ from '../source/TileEventType.js'; +import _ol_tilecoord_ from '../tilecoord.js'; /** * @classdesc @@ -18,9 +18,9 @@ goog.require('ol.tilecoord'); * @extends {ol.source.Tile} * @param {ol.SourceUrlTileOptions} options Image tile options. */ -ol.source.UrlTile = function(options) { +var _ol_source_UrlTile_ = function(options) { - ol.source.Tile.call(this, { + _ol_source_Tile_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, extent: options.extent, @@ -46,7 +46,7 @@ ol.source.UrlTile = function(options) { */ this.tileUrlFunction = this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - ol.TileUrlFunction.nullTileUrlFunction; + _ol_TileUrlFunction_.nullTileUrlFunction; /** * @protected @@ -70,21 +70,22 @@ ol.source.UrlTile = function(options) { this.tileLoadingKeys_ = {}; }; -ol.inherits(ol.source.UrlTile, ol.source.Tile); + +_ol_.inherits(_ol_source_UrlTile_, _ol_source_Tile_); /** * @type {ol.TileUrlFunctionType|undefined} * @protected */ -ol.source.UrlTile.prototype.fixedTileUrlFunction; +_ol_source_UrlTile_.prototype.fixedTileUrlFunction; /** * Return the tile load function of the source. * @return {ol.TileLoadFunctionType} TileLoadFunction * @api */ -ol.source.UrlTile.prototype.getTileLoadFunction = function() { +_ol_source_UrlTile_.prototype.getTileLoadFunction = function() { return this.tileLoadFunction; }; @@ -94,7 +95,7 @@ ol.source.UrlTile.prototype.getTileLoadFunction = function() { * @return {ol.TileUrlFunctionType} TileUrlFunction * @api */ -ol.source.UrlTile.prototype.getTileUrlFunction = function() { +_ol_source_UrlTile_.prototype.getTileUrlFunction = function() { return this.tileUrlFunction; }; @@ -106,7 +107,7 @@ ol.source.UrlTile.prototype.getTileUrlFunction = function() { * @return {!Array.|null} URLs. * @api */ -ol.source.UrlTile.prototype.getUrls = function() { +_ol_source_UrlTile_.prototype.getUrls = function() { return this.urls; }; @@ -116,22 +117,22 @@ ol.source.UrlTile.prototype.getUrls = function() { * @param {ol.events.Event} event Event. * @protected */ -ol.source.UrlTile.prototype.handleTileChange = function(event) { +_ol_source_UrlTile_.prototype.handleTileChange = function(event) { var tile = /** @type {ol.Tile} */ (event.target); - var uid = ol.getUid(tile); + var uid = _ol_.getUid(tile); var tileState = tile.getState(); var type; - if (tileState == ol.TileState.LOADING) { + if (tileState == _ol_TileState_.LOADING) { this.tileLoadingKeys_[uid] = true; - type = ol.source.TileEventType.TILELOADSTART; + type = _ol_source_TileEventType_.TILELOADSTART; } else if (uid in this.tileLoadingKeys_) { delete this.tileLoadingKeys_[uid]; - type = tileState == ol.TileState.ERROR ? ol.source.TileEventType.TILELOADERROR : - (tileState == ol.TileState.LOADED || tileState == ol.TileState.ABORT) ? - ol.source.TileEventType.TILELOADEND : undefined; + type = tileState == _ol_TileState_.ERROR ? _ol_source_TileEventType_.TILELOADERROR : + (tileState == _ol_TileState_.LOADED || tileState == _ol_TileState_.ABORT) ? + _ol_source_TileEventType_.TILELOADEND : undefined; } if (type != undefined) { - this.dispatchEvent(new ol.source.Tile.Event(type, tile)); + this.dispatchEvent(new _ol_source_Tile_.Event(type, tile)); } }; @@ -141,7 +142,7 @@ ol.source.UrlTile.prototype.handleTileChange = function(event) { * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @api */ -ol.source.UrlTile.prototype.setTileLoadFunction = function(tileLoadFunction) { +_ol_source_UrlTile_.prototype.setTileLoadFunction = function(tileLoadFunction) { this.tileCache.clear(); this.tileLoadFunction = tileLoadFunction; this.changed(); @@ -154,7 +155,7 @@ ol.source.UrlTile.prototype.setTileLoadFunction = function(tileLoadFunction) { * @param {string=} opt_key Optional new tile key for the source. * @api */ -ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction, opt_key) { +_ol_source_UrlTile_.prototype.setTileUrlFunction = function(tileUrlFunction, opt_key) { this.tileUrlFunction = tileUrlFunction; this.tileCache.pruneExceptNewestZ(); if (typeof opt_key !== 'undefined') { @@ -170,11 +171,11 @@ ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction, opt_k * @param {string} url URL. * @api */ -ol.source.UrlTile.prototype.setUrl = function(url) { - var urls = this.urls = ol.TileUrlFunction.expandUrl(url); +_ol_source_UrlTile_.prototype.setUrl = function(url) { + var urls = this.urls = _ol_TileUrlFunction_.expandUrl(url); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid), url); + _ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), url); }; @@ -183,21 +184,22 @@ ol.source.UrlTile.prototype.setUrl = function(url) { * @param {Array.} urls URLs. * @api */ -ol.source.UrlTile.prototype.setUrls = function(urls) { +_ol_source_UrlTile_.prototype.setUrls = function(urls) { this.urls = urls; var key = urls.join('\n'); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid), key); + _ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), key); }; /** * @inheritDoc */ -ol.source.UrlTile.prototype.useTile = function(z, x, y) { - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); +_ol_source_UrlTile_.prototype.useTile = function(z, x, y) { + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { this.tileCache.get(tileCoordKey); } }; +export default _ol_source_UrlTile_; diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index 9d2916eddb..deb34faadb 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -1,27 +1,27 @@ +/** + * @module ol/source/Vector + */ // FIXME bulk feature upload - suppress events // FIXME make change-detection more refined (notably, geometry hint) -goog.provide('ol.source.Vector'); - -goog.require('ol'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); -goog.require('ol.ObjectEventType'); -goog.require('ol.array'); -goog.require('ol.asserts'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventType'); -goog.require('ol.extent'); -goog.require('ol.featureloader'); -goog.require('ol.functions'); -goog.require('ol.loadingstrategy'); -goog.require('ol.obj'); -goog.require('ol.source.Source'); -goog.require('ol.source.State'); -goog.require('ol.source.VectorEventType'); -goog.require('ol.structs.RBush'); - +import _ol_ from '../index.js'; +import _ol_Collection_ from '../Collection.js'; +import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import _ol_array_ from '../array.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_ from '../events.js'; +import _ol_events_Event_ from '../events/Event.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_extent_ from '../extent.js'; +import _ol_featureloader_ from '../featureloader.js'; +import _ol_functions_ from '../functions.js'; +import _ol_loadingstrategy_ from '../loadingstrategy.js'; +import _ol_obj_ from '../obj.js'; +import _ol_source_Source_ from '../source/Source.js'; +import _ol_source_State_ from '../source/State.js'; +import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; +import _ol_structs_RBush_ from '../structs/RBush.js'; /** * @classdesc @@ -35,15 +35,15 @@ goog.require('ol.structs.RBush'); * @param {olx.source.VectorOptions=} opt_options Vector source options. * @api */ -ol.source.Vector = function(opt_options) { +var _ol_source_Vector_ = function(opt_options) { var options = opt_options || {}; - ol.source.Source.call(this, { + _ol_source_Source_.call(this, { attributions: options.attributions, logo: options.logo, projection: undefined, - state: ol.source.State.READY, + state: _ol_source_State_.READY, wrapX: options.wrapX !== undefined ? options.wrapX : true }); @@ -51,7 +51,7 @@ ol.source.Vector = function(opt_options) { * @private * @type {ol.FeatureLoader} */ - this.loader_ = ol.nullFunction; + this.loader_ = _ol_.nullFunction; /** * @private @@ -74,9 +74,9 @@ ol.source.Vector = function(opt_options) { if (options.loader !== undefined) { this.loader_ = options.loader; } else if (this.url_ !== undefined) { - ol.asserts.assert(this.format_, 7); // `format` must be set when `url` is set + _ol_asserts_.assert(this.format_, 7); // `format` must be set when `url` is set // create a XHR feature loader for "url" and "format" - this.loader_ = ol.featureloader.xhr(this.url_, /** @type {ol.format.Feature} */ (this.format_)); + this.loader_ = _ol_featureloader_.xhr(this.url_, /** @type {ol.format.Feature} */ (this.format_)); } /** @@ -84,7 +84,7 @@ ol.source.Vector = function(opt_options) { * @type {ol.LoadingStrategy} */ this.strategy_ = options.strategy !== undefined ? options.strategy : - ol.loadingstrategy.all; + _ol_loadingstrategy_.all; var useSpatialIndex = options.useSpatialIndex !== undefined ? options.useSpatialIndex : true; @@ -93,13 +93,13 @@ ol.source.Vector = function(opt_options) { * @private * @type {ol.structs.RBush.} */ - this.featuresRtree_ = useSpatialIndex ? new ol.structs.RBush() : null; + this.featuresRtree_ = useSpatialIndex ? new _ol_structs_RBush_() : null; /** * @private * @type {ol.structs.RBush.<{extent: ol.Extent}>} */ - this.loadedExtentsRtree_ = new ol.structs.RBush(); + this.loadedExtentsRtree_ = new _ol_structs_RBush_(); /** * @private @@ -134,14 +134,14 @@ ol.source.Vector = function(opt_options) { this.featuresCollection_ = null; var collection, features; - if (options.features instanceof ol.Collection) { + if (options.features instanceof _ol_Collection_) { collection = options.features; features = collection.getArray(); } else if (Array.isArray(options.features)) { features = options.features; } if (!useSpatialIndex && collection === undefined) { - collection = new ol.Collection(features); + collection = new _ol_Collection_(features); } if (features !== undefined) { this.addFeaturesInternal(features); @@ -151,7 +151,8 @@ ol.source.Vector = function(opt_options) { } }; -ol.inherits(ol.source.Vector, ol.source.Source); + +_ol_.inherits(_ol_source_Vector_, _ol_source_Source_); /** @@ -163,7 +164,7 @@ ol.inherits(ol.source.Vector, ol.source.Source); * @param {ol.Feature} feature Feature to add. * @api */ -ol.source.Vector.prototype.addFeature = function(feature) { +_ol_source_Vector_.prototype.addFeature = function(feature) { this.addFeatureInternal(feature); this.changed(); }; @@ -174,8 +175,8 @@ ol.source.Vector.prototype.addFeature = function(feature) { * @param {ol.Feature} feature Feature. * @protected */ -ol.source.Vector.prototype.addFeatureInternal = function(feature) { - var featureKey = ol.getUid(feature).toString(); +_ol_source_Vector_.prototype.addFeatureInternal = function(feature) { + var featureKey = _ol_.getUid(feature).toString(); if (!this.addToIndex_(featureKey, feature)) { return; @@ -194,7 +195,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) { } this.dispatchEvent( - new ol.source.Vector.Event(ol.source.VectorEventType.ADDFEATURE, feature)); + new _ol_source_Vector_.Event(_ol_source_VectorEventType_.ADDFEATURE, feature)); }; @@ -203,11 +204,11 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) { * @param {ol.Feature} feature The feature. * @private */ -ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) { +_ol_source_Vector_.prototype.setupChangeEvents_ = function(featureKey, feature) { this.featureChangeKeys_[featureKey] = [ - ol.events.listen(feature, ol.events.EventType.CHANGE, + _ol_events_.listen(feature, _ol_events_EventType_.CHANGE, this.handleFeatureChange_, this), - ol.events.listen(feature, ol.ObjectEventType.PROPERTYCHANGE, + _ol_events_.listen(feature, _ol_ObjectEventType_.PROPERTYCHANGE, this.handleFeatureChange_, this) ]; }; @@ -220,7 +221,7 @@ ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) { * candidate for insertion into the Rtree. * @private */ -ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) { +_ol_source_Vector_.prototype.addToIndex_ = function(featureKey, feature) { var valid = true; var id = feature.getId(); if (id !== undefined) { @@ -230,7 +231,7 @@ ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) { valid = false; } } else { - ol.asserts.assert(!(featureKey in this.undefIdIndex_), + _ol_asserts_.assert(!(featureKey in this.undefIdIndex_), 30); // The passed `feature` was already added to the source this.undefIdIndex_[featureKey] = feature; } @@ -243,7 +244,7 @@ ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) { * @param {Array.} features Features to add. * @api */ -ol.source.Vector.prototype.addFeatures = function(features) { +_ol_source_Vector_.prototype.addFeatures = function(features) { this.addFeaturesInternal(features); this.changed(); }; @@ -254,7 +255,7 @@ ol.source.Vector.prototype.addFeatures = function(features) { * @param {Array.} features Features. * @protected */ -ol.source.Vector.prototype.addFeaturesInternal = function(features) { +_ol_source_Vector_.prototype.addFeaturesInternal = function(features) { var featureKey, i, length, feature; var extents = []; @@ -263,7 +264,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) { for (i = 0, length = features.length; i < length; i++) { feature = features[i]; - featureKey = ol.getUid(feature).toString(); + featureKey = _ol_.getUid(feature).toString(); if (this.addToIndex_(featureKey, feature)) { newFeatures.push(feature); } @@ -271,7 +272,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) { for (i = 0, length = newFeatures.length; i < length; i++) { feature = newFeatures[i]; - featureKey = ol.getUid(feature).toString(); + featureKey = _ol_.getUid(feature).toString(); this.setupChangeEvents_(featureKey, feature); var geometry = feature.getGeometry(); @@ -288,8 +289,8 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) { } for (i = 0, length = newFeatures.length; i < length; i++) { - this.dispatchEvent(new ol.source.Vector.Event( - ol.source.VectorEventType.ADDFEATURE, newFeatures[i])); + this.dispatchEvent(new _ol_source_Vector_.Event( + _ol_source_VectorEventType_.ADDFEATURE, newFeatures[i])); } }; @@ -298,9 +299,9 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) { * @param {!ol.Collection.} collection Collection. * @private */ -ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { +_ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) { var modifyingCollection = false; - ol.events.listen(this, ol.source.VectorEventType.ADDFEATURE, + _ol_events_.listen(this, _ol_source_VectorEventType_.ADDFEATURE, function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -308,7 +309,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { modifyingCollection = false; } }); - ol.events.listen(this, ol.source.VectorEventType.REMOVEFEATURE, + _ol_events_.listen(this, _ol_source_VectorEventType_.REMOVEFEATURE, function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -316,7 +317,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { modifyingCollection = false; } }); - ol.events.listen(collection, ol.CollectionEventType.ADD, + _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -324,7 +325,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { modifyingCollection = false; } }, this); - ol.events.listen(collection, ol.CollectionEventType.REMOVE, + _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -341,11 +342,11 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { * @param {boolean=} opt_fast Skip dispatching of {@link removefeature} events. * @api */ -ol.source.Vector.prototype.clear = function(opt_fast) { +_ol_source_Vector_.prototype.clear = function(opt_fast) { if (opt_fast) { for (var featureId in this.featureChangeKeys_) { var keys = this.featureChangeKeys_[featureId]; - keys.forEach(ol.events.unlistenByKey); + keys.forEach(_ol_events_.unlistenByKey); } if (!this.featuresCollection_) { this.featureChangeKeys_ = {}; @@ -370,7 +371,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) { this.loadedExtentsRtree_.clear(); this.nullGeometryFeatures_ = {}; - var clearEvent = new ol.source.Vector.Event(ol.source.VectorEventType.CLEAR); + var clearEvent = new _ol_source_Vector_.Event(_ol_source_VectorEventType_.CLEAR); this.dispatchEvent(clearEvent); this.changed(); }; @@ -388,7 +389,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) { * @template T,S * @api */ -ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) { +_ol_source_Vector_.prototype.forEachFeature = function(callback, opt_this) { if (this.featuresRtree_) { return this.featuresRtree_.forEach(callback, opt_this); } else if (this.featuresCollection_) { @@ -410,7 +411,7 @@ ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) { * @return {S|undefined} The return value from the last call to the callback. * @template T,S */ -ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback, opt_this) { +_ol_source_Vector_.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback, opt_this) { var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]]; return this.forEachFeatureInExtent(extent, function(feature) { var geometry = feature.getGeometry(); @@ -444,7 +445,7 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect = function(coordinat * @template T,S * @api */ -ol.source.Vector.prototype.forEachFeatureInExtent = function(extent, callback, opt_this) { +_ol_source_Vector_.prototype.forEachFeatureInExtent = function(extent, callback, opt_this) { if (this.featuresRtree_) { return this.featuresRtree_.forEachInExtent(extent, callback, opt_this); } else if (this.featuresCollection_) { @@ -470,7 +471,7 @@ ol.source.Vector.prototype.forEachFeatureInExtent = function(extent, callback, o * @template T,S * @api */ -ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, callback, opt_this) { +_ol_source_Vector_.prototype.forEachFeatureIntersectingExtent = function(extent, callback, opt_this) { return this.forEachFeatureInExtent(extent, /** * @param {ol.Feature} feature Feature. @@ -496,7 +497,7 @@ ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, c * @return {ol.Collection.} The collection of features. * @api */ -ol.source.Vector.prototype.getFeaturesCollection = function() { +_ol_source_Vector_.prototype.getFeaturesCollection = function() { return this.featuresCollection_; }; @@ -506,15 +507,15 @@ ol.source.Vector.prototype.getFeaturesCollection = function() { * @return {Array.} Features. * @api */ -ol.source.Vector.prototype.getFeatures = function() { +_ol_source_Vector_.prototype.getFeatures = function() { var features; if (this.featuresCollection_) { features = this.featuresCollection_.getArray(); } else if (this.featuresRtree_) { features = this.featuresRtree_.getAll(); - if (!ol.obj.isEmpty(this.nullGeometryFeatures_)) { - ol.array.extend( - features, ol.obj.getValues(this.nullGeometryFeatures_)); + if (!_ol_obj_.isEmpty(this.nullGeometryFeatures_)) { + _ol_array_.extend( + features, _ol_obj_.getValues(this.nullGeometryFeatures_)); } } return /** @type {Array.} */ (features); @@ -527,7 +528,7 @@ ol.source.Vector.prototype.getFeatures = function() { * @return {Array.} Features. * @api */ -ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) { +_ol_source_Vector_.prototype.getFeaturesAtCoordinate = function(coordinate) { var features = []; this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) { features.push(feature); @@ -547,7 +548,7 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) { * @return {Array.} Features. * @api */ -ol.source.Vector.prototype.getFeaturesInExtent = function(extent) { +_ol_source_Vector_.prototype.getFeaturesInExtent = function(extent) { return this.featuresRtree_.getInExtent(extent); }; @@ -564,7 +565,7 @@ ol.source.Vector.prototype.getFeaturesInExtent = function(extent) { * @return {ol.Feature} Closest feature. * @api */ -ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_filter) { +_ol_source_Vector_.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_filter) { // Find the closest feature using branch and bound. We start searching an // infinite extent, and find the distance from the first feature found. This // becomes the closest feature. We then compute a smaller extent which any @@ -578,7 +579,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate, var closestPoint = [NaN, NaN]; var minSquaredDistance = Infinity; var extent = [-Infinity, -Infinity, Infinity, Infinity]; - var filter = opt_filter ? opt_filter : ol.functions.TRUE; + var filter = opt_filter ? opt_filter : _ol_functions_.TRUE; this.featuresRtree_.forEachInExtent(extent, /** * @param {ol.Feature} feature Feature. @@ -617,7 +618,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate, * @return {ol.Extent} Extent. * @api */ -ol.source.Vector.prototype.getExtent = function(opt_extent) { +_ol_source_Vector_.prototype.getExtent = function(opt_extent) { return this.featuresRtree_.getExtent(opt_extent); }; @@ -631,7 +632,7 @@ ol.source.Vector.prototype.getExtent = function(opt_extent) { * @return {ol.Feature} The feature (or `null` if not found). * @api */ -ol.source.Vector.prototype.getFeatureById = function(id) { +_ol_source_Vector_.prototype.getFeatureById = function(id) { var feature = this.idIndex_[id.toString()]; return feature !== undefined ? feature : null; }; @@ -643,7 +644,7 @@ ol.source.Vector.prototype.getFeatureById = function(id) { * @return {ol.format.Feature|undefined} The feature format. * @api */ -ol.source.Vector.prototype.getFormat = function() { +_ol_source_Vector_.prototype.getFormat = function() { return this.format_; }; @@ -651,7 +652,7 @@ ol.source.Vector.prototype.getFormat = function() { /** * @return {boolean} The source can have overlapping geometries. */ -ol.source.Vector.prototype.getOverlaps = function() { +_ol_source_Vector_.prototype.getOverlaps = function() { return this.overlaps_; }; @@ -659,7 +660,7 @@ ol.source.Vector.prototype.getOverlaps = function() { /** * @override */ -ol.source.Vector.prototype.getResolutions = function() {}; +_ol_source_Vector_.prototype.getResolutions = function() {}; /** @@ -668,7 +669,7 @@ ol.source.Vector.prototype.getResolutions = function() {}; * @return {string|ol.FeatureUrlFunction|undefined} The url. * @api */ -ol.source.Vector.prototype.getUrl = function() { +_ol_source_Vector_.prototype.getUrl = function() { return this.url_; }; @@ -677,9 +678,9 @@ ol.source.Vector.prototype.getUrl = function() { * @param {ol.events.Event} event Event. * @private */ -ol.source.Vector.prototype.handleFeatureChange_ = function(event) { +_ol_source_Vector_.prototype.handleFeatureChange_ = function(event) { var feature = /** @type {ol.Feature} */ (event.target); - var featureKey = ol.getUid(feature).toString(); + var featureKey = _ol_.getUid(feature).toString(); var geometry = feature.getGeometry(); if (!geometry) { if (!(featureKey in this.nullGeometryFeatures_)) { @@ -720,17 +721,17 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) { } } this.changed(); - this.dispatchEvent(new ol.source.Vector.Event( - ol.source.VectorEventType.CHANGEFEATURE, feature)); + this.dispatchEvent(new _ol_source_Vector_.Event( + _ol_source_VectorEventType_.CHANGEFEATURE, feature)); }; /** * @return {boolean} Is empty. */ -ol.source.Vector.prototype.isEmpty = function() { +_ol_source_Vector_.prototype.isEmpty = function() { return this.featuresRtree_.isEmpty() && - ol.obj.isEmpty(this.nullGeometryFeatures_); + _ol_obj_.isEmpty(this.nullGeometryFeatures_); }; @@ -739,7 +740,7 @@ ol.source.Vector.prototype.isEmpty = function() { * @param {number} resolution Resolution. * @param {ol.proj.Projection} projection Projection. */ -ol.source.Vector.prototype.loadFeatures = function( +_ol_source_Vector_.prototype.loadFeatures = function( extent, resolution, projection) { var loadedExtentsRtree = this.loadedExtentsRtree_; var extentsToLoad = this.strategy_(extent, resolution); @@ -752,7 +753,7 @@ ol.source.Vector.prototype.loadFeatures = function( * @return {boolean} Contains. */ function(object) { - return ol.extent.containsExtent(object.extent, extentToLoad); + return _ol_extent_.containsExtent(object.extent, extentToLoad); }); if (!alreadyLoaded) { this.loader_.call(this, extentToLoad, resolution, projection); @@ -767,11 +768,11 @@ ol.source.Vector.prototype.loadFeatures = function( * @param {ol.Extent} extent Extent. * @api */ -ol.source.Vector.prototype.removeLoadedExtent = function(extent) { +_ol_source_Vector_.prototype.removeLoadedExtent = function(extent) { var loadedExtentsRtree = this.loadedExtentsRtree_; var obj; loadedExtentsRtree.forEachInExtent(extent, function(object) { - if (ol.extent.equals(object.extent, extent)) { + if (_ol_extent_.equals(object.extent, extent)) { obj = object; return true; } @@ -789,8 +790,8 @@ ol.source.Vector.prototype.removeLoadedExtent = function(extent) { * @param {ol.Feature} feature Feature to remove. * @api */ -ol.source.Vector.prototype.removeFeature = function(feature) { - var featureKey = ol.getUid(feature).toString(); +_ol_source_Vector_.prototype.removeFeature = function(feature) { + var featureKey = _ol_.getUid(feature).toString(); if (featureKey in this.nullGeometryFeatures_) { delete this.nullGeometryFeatures_[featureKey]; } else { @@ -808,9 +809,9 @@ ol.source.Vector.prototype.removeFeature = function(feature) { * @param {ol.Feature} feature Feature. * @protected */ -ol.source.Vector.prototype.removeFeatureInternal = function(feature) { - var featureKey = ol.getUid(feature).toString(); - this.featureChangeKeys_[featureKey].forEach(ol.events.unlistenByKey); +_ol_source_Vector_.prototype.removeFeatureInternal = function(feature) { + var featureKey = _ol_.getUid(feature).toString(); + this.featureChangeKeys_[featureKey].forEach(_ol_events_.unlistenByKey); delete this.featureChangeKeys_[featureKey]; var id = feature.getId(); if (id !== undefined) { @@ -818,8 +819,8 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) { } else { delete this.undefIdIndex_[featureKey]; } - this.dispatchEvent(new ol.source.Vector.Event( - ol.source.VectorEventType.REMOVEFEATURE, feature)); + this.dispatchEvent(new _ol_source_Vector_.Event( + _ol_source_VectorEventType_.REMOVEFEATURE, feature)); }; @@ -830,7 +831,7 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) { * @return {boolean} Removed the feature from the index. * @private */ -ol.source.Vector.prototype.removeFromIdIndex_ = function(feature) { +_ol_source_Vector_.prototype.removeFromIdIndex_ = function(feature) { var removed = false; for (var id in this.idIndex_) { if (this.idIndex_[id] === feature) { @@ -849,7 +850,7 @@ ol.source.Vector.prototype.removeFromIdIndex_ = function(feature) { * @param {ol.FeatureLoader} loader The loader to set. * @api */ -ol.source.Vector.prototype.setLoader = function(loader) { +_ol_source_Vector_.prototype.setLoader = function(loader) { this.loader_ = loader; }; @@ -865,9 +866,9 @@ ol.source.Vector.prototype.setLoader = function(loader) { * @param {string} type Type. * @param {ol.Feature=} opt_feature Feature. */ -ol.source.Vector.Event = function(type, opt_feature) { +_ol_source_Vector_.Event = function(type, opt_feature) { - ol.events.Event.call(this, type); + _ol_events_Event_.call(this, type); /** * The feature being added or removed. @@ -877,4 +878,5 @@ ol.source.Vector.Event = function(type, opt_feature) { this.feature = opt_feature; }; -ol.inherits(ol.source.Vector.Event, ol.events.Event); +_ol_.inherits(_ol_source_Vector_.Event, _ol_events_Event_); +export default _ol_source_Vector_; diff --git a/src/ol/source/VectorEventType.js b/src/ol/source/VectorEventType.js index abf148c97b..796030774e 100644 --- a/src/ol/source/VectorEventType.js +++ b/src/ol/source/VectorEventType.js @@ -1,9 +1,10 @@ -goog.provide('ol.source.VectorEventType'); - +/** + * @module ol/source/VectorEventType + */ /** * @enum {string} */ -ol.source.VectorEventType = { +var _ol_source_VectorEventType_ = { /** * Triggered when a feature is added to the source. * @event ol.source.Vector.Event#addfeature @@ -33,3 +34,5 @@ ol.source.VectorEventType = { */ REMOVEFEATURE: 'removefeature' }; + +export default _ol_source_VectorEventType_; diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 9a1c6976ef..56333441f0 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -1,14 +1,14 @@ -goog.provide('ol.source.VectorTile'); - -goog.require('ol'); -goog.require('ol.TileState'); -goog.require('ol.VectorImageTile'); -goog.require('ol.VectorTile'); -goog.require('ol.size'); -goog.require('ol.source.UrlTile'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/VectorTile + */ +import _ol_ from '../index.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_VectorImageTile_ from '../VectorImageTile.js'; +import _ol_VectorTile_ from '../VectorTile.js'; +import _ol_size_ from '../size.js'; +import _ol_source_UrlTile_ from '../source/UrlTile.js'; +import _ol_tilecoord_ from '../tilecoord.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -26,19 +26,19 @@ goog.require('ol.tilegrid'); * @param {olx.source.VectorTileOptions} options Vector tile options. * @api */ -ol.source.VectorTile = function(options) { +var _ol_source_VectorTile_ = function(options) { var projection = options.projection || 'EPSG:3857'; - var extent = options.extent || ol.tilegrid.extentFromProjection(projection); + var extent = options.extent || _ol_tilegrid_.extentFromProjection(projection); - var tileGrid = options.tileGrid || ol.tilegrid.createXYZ({ + var tileGrid = options.tileGrid || _ol_tilegrid_.createXYZ({ extent: extent, maxZoom: options.maxZoom || 22, minZoom: options.minZoom, tileSize: options.tileSize || 512 }); - ol.source.UrlTile.call(this, { + _ol_source_UrlTile_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize !== undefined ? options.cacheSize : 128, extent: extent, @@ -48,7 +48,7 @@ ol.source.VectorTile = function(options) { state: options.state, tileGrid: tileGrid, tileLoadFunction: options.tileLoadFunction ? - options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction, + options.tileLoadFunction : _ol_VectorImageTile_.defaultLoadFunction, tileUrlFunction: options.tileUrlFunction, url: options.url, urls: options.urls, @@ -79,7 +79,7 @@ ol.source.VectorTile = function(options) { * @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string, * ol.format.Feature, ol.TileLoadFunctionType)} */ - this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile; + this.tileClass = options.tileClass ? options.tileClass : _ol_VectorTile_; /** * @private @@ -88,13 +88,14 @@ ol.source.VectorTile = function(options) { this.tileGrids_ = {}; }; -ol.inherits(ol.source.VectorTile, ol.source.UrlTile); + +_ol_.inherits(_ol_source_VectorTile_, _ol_source_UrlTile_); /** * @return {boolean} The source can have overlapping geometries. */ -ol.source.VectorTile.prototype.getOverlaps = function() { +_ol_source_VectorTile_.prototype.getOverlaps = function() { return this.overlaps_; }; @@ -102,7 +103,7 @@ ol.source.VectorTile.prototype.getOverlaps = function() { * clear {@link ol.TileCache} and delete all source tiles * @api */ -ol.source.VectorTile.prototype.clear = function() { +_ol_source_VectorTile_.prototype.clear = function() { this.tileCache.clear(); this.sourceTiles_ = {}; }; @@ -110,17 +111,17 @@ ol.source.VectorTile.prototype.clear = function() { /** * @inheritDoc */ -ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) { - var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y); +_ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, projection) { + var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey)); } else { var tileCoord = [z, x, y]; var urlTileCoord = this.getTileCoordForTileUrlFunction( tileCoord, projection); - var tile = new ol.VectorImageTile( + var tile = new _ol_VectorImageTile_( tileCoord, - urlTileCoord !== null ? ol.TileState.IDLE : ol.TileState.EMPTY, + urlTileCoord !== null ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, this.getRevision(), this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction, this.tileGrid, this.getTileGridForProjection(projection), @@ -137,14 +138,14 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio /** * @inheritDoc */ -ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) { +_ol_source_VectorTile_.prototype.getTileGridForProjection = function(projection) { var code = projection.getCode(); var tileGrid = this.tileGrids_[code]; if (!tileGrid) { // A tile grid that matches the tile size of the source tile grid is more // likely to have 1:1 relationships between source tiles and rendered tiles. var sourceTileGrid = this.tileGrid; - tileGrid = this.tileGrids_[code] = ol.tilegrid.createForProjection(projection, undefined, + tileGrid = this.tileGrids_[code] = _ol_tilegrid_.createForProjection(projection, undefined, sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined); } return tileGrid; @@ -154,7 +155,7 @@ ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) { /** * @inheritDoc */ -ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) { +_ol_source_VectorTile_.prototype.getTilePixelRatio = function(pixelRatio) { return pixelRatio; }; @@ -162,7 +163,8 @@ ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) { /** * @inheritDoc */ -ol.source.VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) { - var tileSize = ol.size.toSize(this.getTileGridForProjection(projection).getTileSize(z)); +_ol_source_VectorTile_.prototype.getTilePixelSize = function(z, pixelRatio, projection) { + var tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z)); return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)]; }; +export default _ol_source_VectorTile_; diff --git a/src/ol/source/WMSServerType.js b/src/ol/source/WMSServerType.js index deb734ce0c..b23cac049c 100644 --- a/src/ol/source/WMSServerType.js +++ b/src/ol/source/WMSServerType.js @@ -1,15 +1,17 @@ -goog.provide('ol.source.WMSServerType'); - - +/** + * @module ol/source/WMSServerType + */ /** * Available server types: `'carmentaserver'`, `'geoserver'`, `'mapserver'`, * `'qgis'`. These are servers that have vendor parameters beyond the WMS * specification that OpenLayers can make use of. * @enum {string} */ -ol.source.WMSServerType = { +var _ol_source_WMSServerType_ = { CARMENTA_SERVER: 'carmentaserver', GEOSERVER: 'geoserver', MAPSERVER: 'mapserver', QGIS: 'qgis' }; + +export default _ol_source_WMSServerType_; diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index 2b3645b334..15900ce641 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -1,16 +1,16 @@ -goog.provide('ol.source.WMTS'); - -goog.require('ol'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.source.TileImage'); -goog.require('ol.source.WMTSRequestEncoding'); -goog.require('ol.tilegrid.WMTS'); -goog.require('ol.uri'); - +/** + * @module ol/source/WMTS + */ +import _ol_ from '../index.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; +import _ol_proj_ from '../proj.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_source_WMTSRequestEncoding_ from '../source/WMTSRequestEncoding.js'; +import _ol_tilegrid_WMTS_ from '../tilegrid/WMTS.js'; +import _ol_uri_ from '../uri.js'; /** * @classdesc @@ -21,7 +21,7 @@ goog.require('ol.uri'); * @param {olx.source.WMTSOptions} options WMTS options. * @api */ -ol.source.WMTS = function(options) { +var _ol_source_WMTS_ = function(options) { // TODO: add support for TileMatrixLimits @@ -63,7 +63,7 @@ ol.source.WMTS = function(options) { var urls = options.urls; if (urls === undefined && options.url !== undefined) { - urls = ol.TileUrlFunction.expandUrl(options.url); + urls = _ol_TileUrlFunction_.expandUrl(options.url); } // FIXME: should we guess this requestEncoding from options.url(s) @@ -75,7 +75,7 @@ ol.source.WMTS = function(options) { */ this.requestEncoding_ = options.requestEncoding !== undefined ? /** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) : - ol.source.WMTSRequestEncoding.KVP; + _ol_source_WMTSRequestEncoding_.KVP; var requestEncoding = this.requestEncoding_; @@ -91,8 +91,8 @@ ol.source.WMTS = function(options) { 'tilematrixset': this.matrixSet_ }; - if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { - ol.obj.assign(context, { + if (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) { + _ol_obj_.assign(context, { 'Service': 'WMTS', 'Request': 'GetTile', 'Version': this.version_, @@ -113,8 +113,8 @@ ol.source.WMTS = function(options) { // order conforms to wmts spec guidance, and so that we can avoid to escape // special template params - template = (requestEncoding == ol.source.WMTSRequestEncoding.KVP) ? - ol.uri.appendParams(template, context) : + template = (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) ? + _ol_uri_.appendParams(template, context) : template.replace(/\{(\w+?)\}/g, function(m, p) { return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m; }); @@ -135,10 +135,10 @@ ol.source.WMTS = function(options) { 'TileCol': tileCoord[1], 'TileRow': -tileCoord[2] - 1 }; - ol.obj.assign(localContext, dimensions); + _ol_obj_.assign(localContext, dimensions); var url = template; - if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { - url = ol.uri.appendParams(url, localContext); + if (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) { + url = _ol_uri_.appendParams(url, localContext); } else { url = url.replace(/\{(\w+?)\}/g, function(m, p) { return localContext[p]; @@ -146,15 +146,16 @@ ol.source.WMTS = function(options) { } return url; } - }); + } + ); }; var tileUrlFunction = (urls && urls.length > 0) ? - ol.TileUrlFunction.createFromTileUrlFunctions( + _ol_TileUrlFunction_.createFromTileUrlFunctions( urls.map(this.createFromWMTSTemplate_)) : - ol.TileUrlFunction.nullTileUrlFunction; + _ol_TileUrlFunction_.nullTileUrlFunction; - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -174,19 +175,20 @@ ol.source.WMTS = function(options) { this.setKey(this.getKeyForDimensions_()); }; -ol.inherits(ol.source.WMTS, ol.source.TileImage); + +_ol_.inherits(_ol_source_WMTS_, _ol_source_TileImage_); /** * Set the URLs to use for requests. * URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}. * @override */ -ol.source.WMTS.prototype.setUrls = function(urls) { +_ol_source_WMTS_.prototype.setUrls = function(urls) { this.urls = urls; var key = urls.join('\n'); this.setTileUrlFunction(this.fixedTileUrlFunction ? this.fixedTileUrlFunction.bind(this) : - ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key); + _ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key); }; /** @@ -196,7 +198,7 @@ ol.source.WMTS.prototype.setUrls = function(urls) { * @return {!Object} Dimensions. * @api */ -ol.source.WMTS.prototype.getDimensions = function() { +_ol_source_WMTS_.prototype.getDimensions = function() { return this.dimensions_; }; @@ -206,7 +208,7 @@ ol.source.WMTS.prototype.getDimensions = function() { * @return {string} Format. * @api */ -ol.source.WMTS.prototype.getFormat = function() { +_ol_source_WMTS_.prototype.getFormat = function() { return this.format_; }; @@ -216,7 +218,7 @@ ol.source.WMTS.prototype.getFormat = function() { * @return {string} Layer. * @api */ -ol.source.WMTS.prototype.getLayer = function() { +_ol_source_WMTS_.prototype.getLayer = function() { return this.layer_; }; @@ -226,7 +228,7 @@ ol.source.WMTS.prototype.getLayer = function() { * @return {string} MatrixSet. * @api */ -ol.source.WMTS.prototype.getMatrixSet = function() { +_ol_source_WMTS_.prototype.getMatrixSet = function() { return this.matrixSet_; }; @@ -236,7 +238,7 @@ ol.source.WMTS.prototype.getMatrixSet = function() { * @return {ol.source.WMTSRequestEncoding} Request encoding. * @api */ -ol.source.WMTS.prototype.getRequestEncoding = function() { +_ol_source_WMTS_.prototype.getRequestEncoding = function() { return this.requestEncoding_; }; @@ -246,7 +248,7 @@ ol.source.WMTS.prototype.getRequestEncoding = function() { * @return {string} Style. * @api */ -ol.source.WMTS.prototype.getStyle = function() { +_ol_source_WMTS_.prototype.getStyle = function() { return this.style_; }; @@ -256,7 +258,7 @@ ol.source.WMTS.prototype.getStyle = function() { * @return {string} Version. * @api */ -ol.source.WMTS.prototype.getVersion = function() { +_ol_source_WMTS_.prototype.getVersion = function() { return this.version_; }; @@ -265,7 +267,7 @@ ol.source.WMTS.prototype.getVersion = function() { * @private * @return {string} The key for the current dimensions. */ -ol.source.WMTS.prototype.getKeyForDimensions_ = function() { +_ol_source_WMTS_.prototype.getKeyForDimensions_ = function() { var i = 0; var res = []; for (var key in this.dimensions_) { @@ -280,8 +282,8 @@ ol.source.WMTS.prototype.getKeyForDimensions_ = function() { * @param {Object} dimensions Dimensions. * @api */ -ol.source.WMTS.prototype.updateDimensions = function(dimensions) { - ol.obj.assign(this.dimensions_, dimensions); +_ol_source_WMTS_.prototype.updateDimensions = function(dimensions) { + _ol_obj_.assign(this.dimensions_, dimensions); this.setKey(this.getKeyForDimensions_()); }; @@ -310,9 +312,9 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) { * @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found. * @api */ -ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { +_ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) { var layers = wmtsCap['Contents']['Layer']; - var l = ol.array.find(layers, function(elt, index, array) { + var l = _ol_array_.find(layers, function(elt, index, array) { return elt['Identifier'] == config['layer']; }); if (l === null) { @@ -322,23 +324,23 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var idx, matrixSet, matrixLimits; if (l['TileMatrixSetLink'].length > 1) { if ('projection' in config) { - idx = ol.array.findIndex(l['TileMatrixSetLink'], + idx = _ol_array_.findIndex(l['TileMatrixSetLink'], function(elt, index, array) { - var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) { + var tileMatrixSet = _ol_array_.find(tileMatrixSets, function(el) { return el['Identifier'] == elt['TileMatrixSet']; }); var supportedCRS = tileMatrixSet['SupportedCRS']; - var proj1 = ol.proj.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || - ol.proj.get(supportedCRS); - var proj2 = ol.proj.get(config['projection']); + var proj1 = _ol_proj_.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || + _ol_proj_.get(supportedCRS); + var proj2 = _ol_proj_.get(config['projection']); if (proj1 && proj2) { - return ol.proj.equivalent(proj1, proj2); + return _ol_proj_.equivalent(proj1, proj2); } else { return supportedCRS == config['projection']; } }); } else { - idx = ol.array.findIndex(l['TileMatrixSetLink'], + idx = _ol_array_.findIndex(l['TileMatrixSetLink'], function(elt, index, array) { return elt['TileMatrixSet'] == config['matrixSet']; }); @@ -358,7 +360,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { if ('format' in config) { format = config['format']; } - idx = ol.array.findIndex(l['Style'], function(elt, index, array) { + idx = _ol_array_.findIndex(l['Style'], function(elt, index, array) { if ('style' in config) { return elt['Title'] == config['style']; } else { @@ -383,20 +385,20 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { } var matrixSets = wmtsCap['Contents']['TileMatrixSet']; - var matrixSetObj = ol.array.find(matrixSets, function(elt, index, array) { + var matrixSetObj = _ol_array_.find(matrixSets, function(elt, index, array) { return elt['Identifier'] == matrixSet; }); var projection; var code = matrixSetObj['SupportedCRS']; if (code) { - projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || - ol.proj.get(code); + projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || + _ol_proj_.get(code); } if ('projection' in config) { - var projConfig = ol.proj.get(config['projection']); + var projConfig = _ol_proj_.get(config['projection']); if (projConfig) { - if (!projection || ol.proj.equivalent(projConfig, projection)) { + if (!projection || _ol_proj_.equivalent(projConfig, projection)) { projection = projConfig; } } @@ -405,22 +407,22 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { var wgs84BoundingBox = l['WGS84BoundingBox']; var extent, wrapX; if (wgs84BoundingBox !== undefined) { - var wgs84ProjectionExtent = ol.proj.get('EPSG:4326').getExtent(); + var wgs84ProjectionExtent = _ol_proj_.get('EPSG:4326').getExtent(); wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] && wgs84BoundingBox[2] == wgs84ProjectionExtent[2]); - extent = ol.proj.transformExtent( + extent = _ol_proj_.transformExtent( wgs84BoundingBox, 'EPSG:4326', projection); var projectionExtent = projection.getExtent(); if (projectionExtent) { // If possible, do a sanity check on the extent - it should never be // bigger than the validity extent of the projection of a matrix set. - if (!ol.extent.containsExtent(projectionExtent, extent)) { + if (!_ol_extent_.containsExtent(projectionExtent, extent)) { extent = undefined; } } } - var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( + var tileGrid = _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet( matrixSetObj, extent, matrixLimits); /** @type {!Array.} */ @@ -433,7 +435,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { for (var i = 0, ii = gets.length; i < ii; ++i) { if (gets[i]['Constraint']) { - var constraint = ol.array.find(gets[i]['Constraint'], function(element) { + var constraint = _ol_array_.find(gets[i]['Constraint'], function(element) { return element['name'] == 'GetEncoding'; }); var encodings = constraint['AllowedValues']['Value']; @@ -442,21 +444,21 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { // requestEncoding not provided, use the first encoding from the list requestEncoding = encodings[0]; } - if (requestEncoding === ol.source.WMTSRequestEncoding.KVP) { - if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) { + if (requestEncoding === _ol_source_WMTSRequestEncoding_.KVP) { + if (_ol_array_.includes(encodings, _ol_source_WMTSRequestEncoding_.KVP)) { urls.push(/** @type {string} */ (gets[i]['href'])); } } else { break; } } else if (gets[i]['href']) { - requestEncoding = ol.source.WMTSRequestEncoding.KVP; + requestEncoding = _ol_source_WMTSRequestEncoding_.KVP; urls.push(/** @type {string} */ (gets[i]['href'])); } } } if (urls.length === 0) { - requestEncoding = ol.source.WMTSRequestEncoding.REST; + requestEncoding = _ol_source_WMTSRequestEncoding_.REST; l['ResourceURL'].forEach(function(element) { if (element['resourceType'] === 'tile') { format = element['format']; @@ -479,3 +481,4 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { crossOrigin: config['crossOrigin'] }; }; +export default _ol_source_WMTS_; diff --git a/src/ol/source/WMTSRequestEncoding.js b/src/ol/source/WMTSRequestEncoding.js index 27b1fba80d..8a5e95ba9b 100644 --- a/src/ol/source/WMTSRequestEncoding.js +++ b/src/ol/source/WMTSRequestEncoding.js @@ -1,10 +1,13 @@ -goog.provide('ol.source.WMTSRequestEncoding'); - +/** + * @module ol/source/WMTSRequestEncoding + */ /** * Request encoding. One of 'KVP', 'REST'. * @enum {string} */ -ol.source.WMTSRequestEncoding = { +var _ol_source_WMTSRequestEncoding_ = { KVP: 'KVP', // see spec §8 REST: 'REST' // see spec §10 }; + +export default _ol_source_WMTSRequestEncoding_; diff --git a/src/ol/source/XYZ.js b/src/ol/source/XYZ.js index eeee16f8fb..b54e049261 100644 --- a/src/ol/source/XYZ.js +++ b/src/ol/source/XYZ.js @@ -1,9 +1,9 @@ -goog.provide('ol.source.XYZ'); - -goog.require('ol'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilegrid'); - +/** + * @module ol/source/XYZ + */ +import _ol_ from '../index.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_tilegrid_ from '../tilegrid.js'; /** * @classdesc @@ -27,20 +27,20 @@ goog.require('ol.tilegrid'); * @param {olx.source.XYZOptions=} opt_options XYZ options. * @api */ -ol.source.XYZ = function(opt_options) { +var _ol_source_XYZ_ = function(opt_options) { var options = opt_options || {}; var projection = options.projection !== undefined ? options.projection : 'EPSG:3857'; var tileGrid = options.tileGrid !== undefined ? options.tileGrid : - ol.tilegrid.createXYZ({ - extent: ol.tilegrid.extentFromProjection(projection), + _ol_tilegrid_.createXYZ({ + extent: _ol_tilegrid_.extentFromProjection(projection), maxZoom: options.maxZoom, minZoom: options.minZoom, tileSize: options.tileSize }); - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -59,4 +59,6 @@ ol.source.XYZ = function(opt_options) { }); }; -ol.inherits(ol.source.XYZ, ol.source.TileImage); + +_ol_.inherits(_ol_source_XYZ_, _ol_source_TileImage_); +export default _ol_source_XYZ_; diff --git a/src/ol/source/Zoomify.js b/src/ol/source/Zoomify.js index acc6b41a94..1bf571c72a 100644 --- a/src/ol/source/Zoomify.js +++ b/src/ol/source/Zoomify.js @@ -1,16 +1,16 @@ -goog.provide('ol.source.Zoomify'); - -goog.require('ol'); -goog.require('ol.ImageTile'); -goog.require('ol.TileState'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.asserts'); -goog.require('ol.dom'); -goog.require('ol.extent'); -goog.require('ol.size'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilegrid.TileGrid'); - +/** + * @module ol/source/Zoomify + */ +import _ol_ from '../index.js'; +import _ol_ImageTile_ from '../ImageTile.js'; +import _ol_TileState_ from '../TileState.js'; +import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_dom_ from '../dom.js'; +import _ol_extent_ from '../extent.js'; +import _ol_size_ from '../size.js'; +import _ol_source_TileImage_ from '../source/TileImage.js'; +import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js'; /** * @classdesc @@ -22,24 +22,24 @@ goog.require('ol.tilegrid.TileGrid'); * @param {olx.source.ZoomifyOptions=} opt_options Options. * @api */ -ol.source.Zoomify = function(opt_options) { +var _ol_source_Zoomify_ = function(opt_options) { var options = opt_options || {}; var size = options.size; var tierSizeCalculation = options.tierSizeCalculation !== undefined ? options.tierSizeCalculation : - ol.source.Zoomify.TierSizeCalculation_.DEFAULT; + _ol_source_Zoomify_.TierSizeCalculation_.DEFAULT; var imageWidth = size[0]; var imageHeight = size[1]; var extent = options.extent || [0, -size[1], size[0], 0]; var tierSizeInTiles = []; - var tileSize = options.tileSize || ol.DEFAULT_TILE_SIZE; + var tileSize = options.tileSize || _ol_.DEFAULT_TILE_SIZE; var tileSizeForTierSizeCalculation = tileSize; switch (tierSizeCalculation) { - case ol.source.Zoomify.TierSizeCalculation_.DEFAULT: + case _ol_source_Zoomify_.TierSizeCalculation_.DEFAULT: while (imageWidth > tileSizeForTierSizeCalculation || imageHeight > tileSizeForTierSizeCalculation) { tierSizeInTiles.push([ Math.ceil(imageWidth / tileSizeForTierSizeCalculation), @@ -48,7 +48,7 @@ ol.source.Zoomify = function(opt_options) { tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation; } break; - case ol.source.Zoomify.TierSizeCalculation_.TRUNCATED: + case _ol_source_Zoomify_.TierSizeCalculation_.TRUNCATED: var width = imageWidth; var height = imageHeight; while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) { @@ -61,7 +61,7 @@ ol.source.Zoomify = function(opt_options) { } break; default: - ol.asserts.assert(false, 53); // Unknown `tierSizeCalculation` configured + _ol_asserts_.assert(false, 53); // Unknown `tierSizeCalculation` configured break; } @@ -80,10 +80,10 @@ ol.source.Zoomify = function(opt_options) { } resolutions.reverse(); - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ tileSize: tileSize, extent: extent, - origin: ol.extent.getTopLeft(extent), + origin: _ol_extent_.getTopLeft(extent), resolutions: resolutions }); @@ -91,7 +91,7 @@ ol.source.Zoomify = function(opt_options) { if (url && url.indexOf('{TileGroup}') == -1 && url.indexOf('{tileIndex}') == -1) { url += '{TileGroup}/{z}-{x}-{y}.jpg'; } - var urls = ol.TileUrlFunction.expandUrl(url); + var urls = _ol_TileUrlFunction_.expandUrl(url); /** * @param {string} template Template. @@ -132,11 +132,11 @@ ol.source.Zoomify = function(opt_options) { }); } - var tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(createFromTemplate)); + var tileUrlFunction = _ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(createFromTemplate)); - var ZoomifyTileClass = ol.source.Zoomify.Tile_.bind(null, tileGrid); + var ZoomifyTileClass = _ol_source_Zoomify_.Tile_.bind(null, tileGrid); - ol.source.TileImage.call(this, { + _ol_source_TileImage_.call(this, { attributions: options.attributions, cacheSize: options.cacheSize, crossOrigin: options.crossOrigin, @@ -150,7 +150,8 @@ ol.source.Zoomify = function(opt_options) { }); }; -ol.inherits(ol.source.Zoomify, ol.source.TileImage); + +_ol_.inherits(_ol_source_Zoomify_, _ol_source_TileImage_); /** * @constructor @@ -164,10 +165,10 @@ ol.inherits(ol.source.Zoomify, ol.source.TileImage); * @param {olx.TileOptions=} opt_options Tile options. * @private */ -ol.source.Zoomify.Tile_ = function( +_ol_source_Zoomify_.Tile_ = function( tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { - ol.ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options); + _ol_ImageTile_.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options); /** * @private @@ -179,26 +180,26 @@ ol.source.Zoomify.Tile_ = function( * @private * @type {ol.Size} */ - this.tileSize_ = ol.size.toSize(tileGrid.getTileSize(tileCoord[0])); + this.tileSize_ = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0])); }; -ol.inherits(ol.source.Zoomify.Tile_, ol.ImageTile); +_ol_.inherits(_ol_source_Zoomify_.Tile_, _ol_ImageTile_); /** * @inheritDoc */ -ol.source.Zoomify.Tile_.prototype.getImage = function() { +_ol_source_Zoomify_.Tile_.prototype.getImage = function() { if (this.zoomifyImage_) { return this.zoomifyImage_; } - var image = ol.ImageTile.prototype.getImage.call(this); - if (this.state == ol.TileState.LOADED) { + var image = _ol_ImageTile_.prototype.getImage.call(this); + if (this.state == _ol_TileState_.LOADED) { var tileSize = this.tileSize_; if (image.width == tileSize[0] && image.height == tileSize[1]) { this.zoomifyImage_ = image; return image; } else { - var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]); + var context = _ol_dom_.createCanvasContext2D(tileSize[0], tileSize[1]); context.drawImage(image, 0, 0); this.zoomifyImage_ = context.canvas; return context.canvas; @@ -212,7 +213,8 @@ ol.source.Zoomify.Tile_.prototype.getImage = function() { * @enum {string} * @private */ -ol.source.Zoomify.TierSizeCalculation_ = { +_ol_source_Zoomify_.TierSizeCalculation_ = { DEFAULT: 'default', TRUNCATED: 'truncated' }; +export default _ol_source_Zoomify_; diff --git a/src/ol/string.js b/src/ol/string.js index 2c64bf8ee2..b57680b92d 100644 --- a/src/ol/string.js +++ b/src/ol/string.js @@ -1,4 +1,7 @@ -goog.provide('ol.string'); +/** + * @module ol/string + */ +var _ol_string_ = {}; /** * @param {number} number Number to be formatted @@ -6,7 +9,7 @@ goog.provide('ol.string'); * @param {number=} opt_precision Precision of the output string (i.e. number of decimal places) * @returns {string} Formatted string */ -ol.string.padNumber = function(number, width, opt_precision) { +_ol_string_.padNumber = function(number, width, opt_precision) { var numberString = opt_precision !== undefined ? number.toFixed(opt_precision) : '' + number; var decimal = numberString.indexOf('.'); decimal = decimal === -1 ? numberString.length : decimal; @@ -19,7 +22,7 @@ ol.string.padNumber = function(number, width, opt_precision) { * @param {string|number} v2 Second version * @returns {number} Value */ -ol.string.compareVersions = function(v1, v2) { +_ol_string_.compareVersions = function(v1, v2) { var s1 = ('' + v1).split('.'); var s2 = ('' + v2).split('.'); @@ -37,3 +40,4 @@ ol.string.compareVersions = function(v1, v2) { return 0; }; +export default _ol_string_; diff --git a/src/ol/structs/LRUCache.js b/src/ol/structs/LRUCache.js index d86533bc5c..4c7c5cd1a3 100644 --- a/src/ol/structs/LRUCache.js +++ b/src/ol/structs/LRUCache.js @@ -1,10 +1,10 @@ -goog.provide('ol.structs.LRUCache'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.events.EventTarget'); -goog.require('ol.events.EventType'); - +/** + * @module ol/structs/LRUCache + */ +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_events_EventTarget_ from '../events/EventTarget.js'; +import _ol_events_EventType_ from '../events/EventType.js'; /** * Implements a Least-Recently-Used cache where the keys do not conflict with @@ -17,9 +17,9 @@ goog.require('ol.events.EventType'); * @template T * @param {number=} opt_highWaterMark High water mark. */ -ol.structs.LRUCache = function(opt_highWaterMark) { +var _ol_structs_LRUCache_ = function(opt_highWaterMark) { - ol.events.EventTarget.call(this); + _ol_events_EventTarget_.call(this); /** * @type {number} @@ -52,13 +52,13 @@ ol.structs.LRUCache = function(opt_highWaterMark) { }; -ol.inherits(ol.structs.LRUCache, ol.events.EventTarget); +_ol_.inherits(_ol_structs_LRUCache_, _ol_events_EventTarget_); /** * @return {boolean} Can expire cache. */ -ol.structs.LRUCache.prototype.canExpireCache = function() { +_ol_structs_LRUCache_.prototype.canExpireCache = function() { return this.getCount() > this.highWaterMark; }; @@ -66,12 +66,12 @@ ol.structs.LRUCache.prototype.canExpireCache = function() { /** * FIXME empty description for jsdoc */ -ol.structs.LRUCache.prototype.clear = function() { +_ol_structs_LRUCache_.prototype.clear = function() { this.count_ = 0; this.entries_ = {}; this.oldest_ = null; this.newest_ = null; - this.dispatchEvent(ol.events.EventType.CLEAR); + this.dispatchEvent(_ol_events_EventType_.CLEAR); }; @@ -79,7 +79,7 @@ ol.structs.LRUCache.prototype.clear = function() { * @param {string} key Key. * @return {boolean} Contains key. */ -ol.structs.LRUCache.prototype.containsKey = function(key) { +_ol_structs_LRUCache_.prototype.containsKey = function(key) { return this.entries_.hasOwnProperty(key); }; @@ -92,7 +92,7 @@ ol.structs.LRUCache.prototype.containsKey = function(key) { * @param {S=} opt_this The object to use as `this` in `f`. * @template S */ -ol.structs.LRUCache.prototype.forEach = function(f, opt_this) { +_ol_structs_LRUCache_.prototype.forEach = function(f, opt_this) { var entry = this.oldest_; while (entry) { f.call(opt_this, entry.value_, entry.key_, this); @@ -105,9 +105,9 @@ ol.structs.LRUCache.prototype.forEach = function(f, opt_this) { * @param {string} key Key. * @return {T} Value. */ -ol.structs.LRUCache.prototype.get = function(key) { +_ol_structs_LRUCache_.prototype.get = function(key) { var entry = this.entries_[key]; - ol.asserts.assert(entry !== undefined, + _ol_asserts_.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache if (entry === this.newest_) { return entry.value_; @@ -131,9 +131,9 @@ ol.structs.LRUCache.prototype.get = function(key) { * @param {string} key The entry key. * @return {T} The removed entry. */ -ol.structs.LRUCache.prototype.remove = function(key) { +_ol_structs_LRUCache_.prototype.remove = function(key) { var entry = this.entries_[key]; - ol.asserts.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache + _ol_asserts_.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache if (entry === this.newest_) { this.newest_ = /** @type {ol.LRUCacheEntry} */ (entry.older); if (this.newest_) { @@ -157,7 +157,7 @@ ol.structs.LRUCache.prototype.remove = function(key) { /** * @return {number} Count. */ -ol.structs.LRUCache.prototype.getCount = function() { +_ol_structs_LRUCache_.prototype.getCount = function() { return this.count_; }; @@ -165,7 +165,7 @@ ol.structs.LRUCache.prototype.getCount = function() { /** * @return {Array.} Keys. */ -ol.structs.LRUCache.prototype.getKeys = function() { +_ol_structs_LRUCache_.prototype.getKeys = function() { var keys = new Array(this.count_); var i = 0; var entry; @@ -179,7 +179,7 @@ ol.structs.LRUCache.prototype.getKeys = function() { /** * @return {Array.} Values. */ -ol.structs.LRUCache.prototype.getValues = function() { +_ol_structs_LRUCache_.prototype.getValues = function() { var values = new Array(this.count_); var i = 0; var entry; @@ -193,7 +193,7 @@ ol.structs.LRUCache.prototype.getValues = function() { /** * @return {T} Last value. */ -ol.structs.LRUCache.prototype.peekLast = function() { +_ol_structs_LRUCache_.prototype.peekLast = function() { return this.oldest_.value_; }; @@ -201,7 +201,7 @@ ol.structs.LRUCache.prototype.peekLast = function() { /** * @return {string} Last key. */ -ol.structs.LRUCache.prototype.peekLastKey = function() { +_ol_structs_LRUCache_.prototype.peekLastKey = function() { return this.oldest_.key_; }; @@ -210,7 +210,7 @@ ol.structs.LRUCache.prototype.peekLastKey = function() { * Get the key of the newest item in the cache. Throws if the cache is empty. * @return {string} The newest key. */ -ol.structs.LRUCache.prototype.peekFirstKey = function() { +_ol_structs_LRUCache_.prototype.peekFirstKey = function() { return this.newest_.key_; }; @@ -218,7 +218,7 @@ ol.structs.LRUCache.prototype.peekFirstKey = function() { /** * @return {T} value Value. */ -ol.structs.LRUCache.prototype.pop = function() { +_ol_structs_LRUCache_.prototype.pop = function() { var entry = this.oldest_; delete this.entries_[entry.key_]; if (entry.newer) { @@ -237,7 +237,7 @@ ol.structs.LRUCache.prototype.pop = function() { * @param {string} key Key. * @param {T} value Value. */ -ol.structs.LRUCache.prototype.replace = function(key, value) { +_ol_structs_LRUCache_.prototype.replace = function(key, value) { this.get(key); // update `newest_` this.entries_[key].value_ = value; }; @@ -247,8 +247,8 @@ ol.structs.LRUCache.prototype.replace = function(key, value) { * @param {string} key Key. * @param {T} value Value. */ -ol.structs.LRUCache.prototype.set = function(key, value) { - ol.asserts.assert(!(key in this.entries_), +_ol_structs_LRUCache_.prototype.set = function(key, value) { + _ol_asserts_.assert(!(key in this.entries_), 16); // Tried to set a value for a key that is used already var entry = /** @type {ol.LRUCacheEntry} */ ({ key_: key, @@ -270,8 +270,9 @@ ol.structs.LRUCache.prototype.set = function(key, value) { /** * Prune the cache. */ -ol.structs.LRUCache.prototype.prune = function() { +_ol_structs_LRUCache_.prototype.prune = function() { while (this.canExpireCache()) { this.pop(); } }; +export default _ol_structs_LRUCache_; diff --git a/src/ol/structs/LinkedList.js b/src/ol/structs/LinkedList.js index 19fe515550..4a532dbc46 100644 --- a/src/ol/structs/LinkedList.js +++ b/src/ol/structs/LinkedList.js @@ -1,5 +1,6 @@ -goog.provide('ol.structs.LinkedList'); - +/** + * @module ol/structs/LinkedList + */ /** * Creates an empty linked list structure. * @@ -8,7 +9,7 @@ goog.provide('ol.structs.LinkedList'); * @param {boolean=} opt_circular The last item is connected to the first one, * and the first item to the last one. Default is true. */ -ol.structs.LinkedList = function(opt_circular) { +var _ol_structs_LinkedList_ = function(opt_circular) { /** * @private @@ -46,7 +47,7 @@ ol.structs.LinkedList = function(opt_circular) { * * @param {?} data Item data. */ -ol.structs.LinkedList.prototype.insertItem = function(data) { +_ol_structs_LinkedList_.prototype.insertItem = function(data) { /** @type {ol.LinkedListItem} */ var item = { @@ -87,7 +88,7 @@ ol.structs.LinkedList.prototype.insertItem = function(data) { * Removes the current item from the list. Sets the cursor to the next item, * if possible. */ -ol.structs.LinkedList.prototype.removeItem = function() { +_ol_structs_LinkedList_.prototype.removeItem = function() { var head = this.head_; if (head) { var next = head.next; @@ -118,7 +119,7 @@ ol.structs.LinkedList.prototype.removeItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.firstItem = function() { +_ol_structs_LinkedList_.prototype.firstItem = function() { this.head_ = this.first_; if (this.head_) { return this.head_.data; @@ -131,7 +132,7 @@ ol.structs.LinkedList.prototype.firstItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.lastItem = function() { +_ol_structs_LinkedList_.prototype.lastItem = function() { this.head_ = this.last_; if (this.head_) { return this.head_.data; @@ -144,7 +145,7 @@ ol.structs.LinkedList.prototype.lastItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.nextItem = function() { +_ol_structs_LinkedList_.prototype.nextItem = function() { if (this.head_ && this.head_.next) { this.head_ = this.head_.next; return this.head_.data; @@ -157,7 +158,7 @@ ol.structs.LinkedList.prototype.nextItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.getNextItem = function() { +_ol_structs_LinkedList_.prototype.getNextItem = function() { if (this.head_ && this.head_.next) { return this.head_.next.data; } @@ -169,7 +170,7 @@ ol.structs.LinkedList.prototype.getNextItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.prevItem = function() { +_ol_structs_LinkedList_.prototype.prevItem = function() { if (this.head_ && this.head_.prev) { this.head_ = this.head_.prev; return this.head_.data; @@ -182,7 +183,7 @@ ol.structs.LinkedList.prototype.prevItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.getPrevItem = function() { +_ol_structs_LinkedList_.prototype.getPrevItem = function() { if (this.head_ && this.head_.prev) { return this.head_.prev.data; } @@ -194,7 +195,7 @@ ol.structs.LinkedList.prototype.getPrevItem = function() { * * @return {?} Item data. */ -ol.structs.LinkedList.prototype.getCurrItem = function() { +_ol_structs_LinkedList_.prototype.getCurrItem = function() { if (this.head_) { return this.head_.data; } @@ -205,7 +206,7 @@ ol.structs.LinkedList.prototype.getCurrItem = function() { * Sets the first item of the list. This only works for circular lists, and sets * the last item accordingly. */ -ol.structs.LinkedList.prototype.setFirstItem = function() { +_ol_structs_LinkedList_.prototype.setFirstItem = function() { if (this.circular_ && this.head_) { this.first_ = this.head_; this.last_ = this.head_.prev; @@ -216,7 +217,7 @@ ol.structs.LinkedList.prototype.setFirstItem = function() { * Concatenates two lists. * @param {ol.structs.LinkedList} list List to merge into the current list. */ -ol.structs.LinkedList.prototype.concat = function(list) { +_ol_structs_LinkedList_.prototype.concat = function(list) { if (list.head_) { if (this.head_) { var end = this.head_.next; @@ -243,6 +244,7 @@ ol.structs.LinkedList.prototype.concat = function(list) { * * @return {number} Length. */ -ol.structs.LinkedList.prototype.getLength = function() { +_ol_structs_LinkedList_.prototype.getLength = function() { return this.length_; }; +export default _ol_structs_LinkedList_; diff --git a/src/ol/structs/PriorityQueue.js b/src/ol/structs/PriorityQueue.js index e6426f3116..9ccb36c42e 100644 --- a/src/ol/structs/PriorityQueue.js +++ b/src/ol/structs/PriorityQueue.js @@ -1,8 +1,8 @@ -goog.provide('ol.structs.PriorityQueue'); - -goog.require('ol.asserts'); -goog.require('ol.obj'); - +/** + * @module ol/structs/PriorityQueue + */ +import _ol_asserts_ from '../asserts.js'; +import _ol_obj_ from '../obj.js'; /** * Priority queue. @@ -19,7 +19,7 @@ goog.require('ol.obj'); * @struct * @template T */ -ol.structs.PriorityQueue = function(priorityFunction, keyFunction) { +var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) { /** * @type {function(T): number} @@ -58,16 +58,16 @@ ol.structs.PriorityQueue = function(priorityFunction, keyFunction) { * @const * @type {number} */ -ol.structs.PriorityQueue.DROP = Infinity; +_ol_structs_PriorityQueue_.DROP = Infinity; /** * FIXME empty description for jsdoc */ -ol.structs.PriorityQueue.prototype.clear = function() { +_ol_structs_PriorityQueue_.prototype.clear = function() { this.elements_.length = 0; this.priorities_.length = 0; - ol.obj.clear(this.queuedElements_); + _ol_obj_.clear(this.queuedElements_); }; @@ -75,7 +75,7 @@ ol.structs.PriorityQueue.prototype.clear = function() { * Remove and return the highest-priority element. O(log N). * @return {T} Element. */ -ol.structs.PriorityQueue.prototype.dequeue = function() { +_ol_structs_PriorityQueue_.prototype.dequeue = function() { var elements = this.elements_; var priorities = this.priorities_; var element = elements[0]; @@ -98,11 +98,11 @@ ol.structs.PriorityQueue.prototype.dequeue = function() { * @param {T} element Element. * @return {boolean} The element was added to the queue. */ -ol.structs.PriorityQueue.prototype.enqueue = function(element) { - ol.asserts.assert(!(this.keyFunction_(element) in this.queuedElements_), +_ol_structs_PriorityQueue_.prototype.enqueue = function(element) { + _ol_asserts_.assert(!(this.keyFunction_(element) in this.queuedElements_), 31); // Tried to enqueue an `element` that was already added to the queue var priority = this.priorityFunction_(element); - if (priority != ol.structs.PriorityQueue.DROP) { + if (priority != _ol_structs_PriorityQueue_.DROP) { this.elements_.push(element); this.priorities_.push(priority); this.queuedElements_[this.keyFunction_(element)] = true; @@ -116,7 +116,7 @@ ol.structs.PriorityQueue.prototype.enqueue = function(element) { /** * @return {number} Count. */ -ol.structs.PriorityQueue.prototype.getCount = function() { +_ol_structs_PriorityQueue_.prototype.getCount = function() { return this.elements_.length; }; @@ -127,7 +127,7 @@ ol.structs.PriorityQueue.prototype.getCount = function() { * @return {number} The index of the left child. * @private */ -ol.structs.PriorityQueue.prototype.getLeftChildIndex_ = function(index) { +_ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) { return index * 2 + 1; }; @@ -138,7 +138,7 @@ ol.structs.PriorityQueue.prototype.getLeftChildIndex_ = function(index) { * @return {number} The index of the right child. * @private */ -ol.structs.PriorityQueue.prototype.getRightChildIndex_ = function(index) { +_ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) { return index * 2 + 2; }; @@ -149,7 +149,7 @@ ol.structs.PriorityQueue.prototype.getRightChildIndex_ = function(index) { * @return {number} The index of the parent. * @private */ -ol.structs.PriorityQueue.prototype.getParentIndex_ = function(index) { +_ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) { return (index - 1) >> 1; }; @@ -158,7 +158,7 @@ ol.structs.PriorityQueue.prototype.getParentIndex_ = function(index) { * Make this a heap. O(N). * @private */ -ol.structs.PriorityQueue.prototype.heapify_ = function() { +_ol_structs_PriorityQueue_.prototype.heapify_ = function() { var i; for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) { this.siftUp_(i); @@ -169,7 +169,7 @@ ol.structs.PriorityQueue.prototype.heapify_ = function() { /** * @return {boolean} Is empty. */ -ol.structs.PriorityQueue.prototype.isEmpty = function() { +_ol_structs_PriorityQueue_.prototype.isEmpty = function() { return this.elements_.length === 0; }; @@ -178,7 +178,7 @@ ol.structs.PriorityQueue.prototype.isEmpty = function() { * @param {string} key Key. * @return {boolean} Is key queued. */ -ol.structs.PriorityQueue.prototype.isKeyQueued = function(key) { +_ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) { return key in this.queuedElements_; }; @@ -187,7 +187,7 @@ ol.structs.PriorityQueue.prototype.isKeyQueued = function(key) { * @param {T} element Element. * @return {boolean} Is queued. */ -ol.structs.PriorityQueue.prototype.isQueued = function(element) { +_ol_structs_PriorityQueue_.prototype.isQueued = function(element) { return this.isKeyQueued(this.keyFunction_(element)); }; @@ -196,7 +196,7 @@ ol.structs.PriorityQueue.prototype.isQueued = function(element) { * @param {number} index The index of the node to move down. * @private */ -ol.structs.PriorityQueue.prototype.siftUp_ = function(index) { +_ol_structs_PriorityQueue_.prototype.siftUp_ = function(index) { var elements = this.elements_; var priorities = this.priorities_; var count = elements.length; @@ -228,7 +228,7 @@ ol.structs.PriorityQueue.prototype.siftUp_ = function(index) { * @param {number} index The index of the node to move up. * @private */ -ol.structs.PriorityQueue.prototype.siftDown_ = function(startIndex, index) { +_ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) { var elements = this.elements_; var priorities = this.priorities_; var element = elements[index]; @@ -252,7 +252,7 @@ ol.structs.PriorityQueue.prototype.siftDown_ = function(startIndex, index) { /** * FIXME empty description for jsdoc */ -ol.structs.PriorityQueue.prototype.reprioritize = function() { +_ol_structs_PriorityQueue_.prototype.reprioritize = function() { var priorityFunction = this.priorityFunction_; var elements = this.elements_; var priorities = this.priorities_; @@ -262,7 +262,7 @@ ol.structs.PriorityQueue.prototype.reprioritize = function() { for (i = 0; i < n; ++i) { element = elements[i]; priority = priorityFunction(element); - if (priority == ol.structs.PriorityQueue.DROP) { + if (priority == _ol_structs_PriorityQueue_.DROP) { delete this.queuedElements_[this.keyFunction_(element)]; } else { priorities[index] = priority; @@ -273,3 +273,4 @@ ol.structs.PriorityQueue.prototype.reprioritize = function() { priorities.length = index; this.heapify_(); }; +export default _ol_structs_PriorityQueue_; diff --git a/src/ol/structs/RBush.js b/src/ol/structs/RBush.js index d279bd40c1..586236d0a1 100644 --- a/src/ol/structs/RBush.js +++ b/src/ol/structs/RBush.js @@ -1,10 +1,10 @@ -goog.provide('ol.structs.RBush'); - -goog.require('ol'); -goog.require('ol.ext.rbush'); -goog.require('ol.extent'); -goog.require('ol.obj'); - +/** + * @module ol/structs/RBush + */ +import _ol_ from '../index.js'; +import _ol_ext_rbush_ from 'rbush'; +import _ol_extent_ from '../extent.js'; +import _ol_obj_ from '../obj.js'; /** * Wrapper around the RBush by Vladimir Agafonkin. @@ -15,12 +15,12 @@ goog.require('ol.obj'); * @struct * @template T */ -ol.structs.RBush = function(opt_maxEntries) { +var _ol_structs_RBush_ = function(opt_maxEntries) { /** * @private */ - this.rbush_ = ol.ext.rbush(opt_maxEntries); + this.rbush_ = _ol_ext_rbush_(opt_maxEntries); /** * A mapping between the objects added to this rbush wrapper @@ -38,7 +38,7 @@ ol.structs.RBush = function(opt_maxEntries) { * @param {ol.Extent} extent Extent. * @param {T} value Value. */ -ol.structs.RBush.prototype.insert = function(extent, value) { +_ol_structs_RBush_.prototype.insert = function(extent, value) { /** @type {ol.RBushEntry} */ var item = { minX: extent[0], @@ -49,7 +49,7 @@ ol.structs.RBush.prototype.insert = function(extent, value) { }; this.rbush_.insert(item); - this.items_[ol.getUid(value)] = item; + this.items_[_ol_.getUid(value)] = item; }; @@ -58,7 +58,7 @@ ol.structs.RBush.prototype.insert = function(extent, value) { * @param {Array.} extents Extents. * @param {Array.} values Values. */ -ol.structs.RBush.prototype.load = function(extents, values) { +_ol_structs_RBush_.prototype.load = function(extents, values) { var items = new Array(values.length); for (var i = 0, l = values.length; i < l; i++) { var extent = extents[i]; @@ -73,7 +73,7 @@ ol.structs.RBush.prototype.load = function(extents, values) { value: value }; items[i] = item; - this.items_[ol.getUid(value)] = item; + this.items_[_ol_.getUid(value)] = item; } this.rbush_.load(items); }; @@ -84,8 +84,8 @@ ol.structs.RBush.prototype.load = function(extents, values) { * @param {T} value Value. * @return {boolean} Removed. */ -ol.structs.RBush.prototype.remove = function(value) { - var uid = ol.getUid(value); +_ol_structs_RBush_.prototype.remove = function(value) { + var uid = _ol_.getUid(value); // get the object in which the value was wrapped when adding to the // internal rbush. then use that object to do the removal. @@ -100,10 +100,10 @@ ol.structs.RBush.prototype.remove = function(value) { * @param {ol.Extent} extent Extent. * @param {T} value Value. */ -ol.structs.RBush.prototype.update = function(extent, value) { - var item = this.items_[ol.getUid(value)]; +_ol_structs_RBush_.prototype.update = function(extent, value) { + var item = this.items_[_ol_.getUid(value)]; var bbox = [item.minX, item.minY, item.maxX, item.maxY]; - if (!ol.extent.equals(bbox, extent)) { + if (!_ol_extent_.equals(bbox, extent)) { this.remove(value); this.insert(extent, value); } @@ -114,7 +114,7 @@ ol.structs.RBush.prototype.update = function(extent, value) { * Return all values in the RBush. * @return {Array.} All. */ -ol.structs.RBush.prototype.getAll = function() { +_ol_structs_RBush_.prototype.getAll = function() { var items = this.rbush_.all(); return items.map(function(item) { return item.value; @@ -127,7 +127,7 @@ ol.structs.RBush.prototype.getAll = function() { * @param {ol.Extent} extent Extent. * @return {Array.} All in extent. */ -ol.structs.RBush.prototype.getInExtent = function(extent) { +_ol_structs_RBush_.prototype.getInExtent = function(extent) { /** @type {ol.RBushEntry} */ var bbox = { minX: extent[0], @@ -151,7 +151,7 @@ ol.structs.RBush.prototype.getInExtent = function(extent) { * @return {*} Callback return value. * @template S */ -ol.structs.RBush.prototype.forEach = function(callback, opt_this) { +_ol_structs_RBush_.prototype.forEach = function(callback, opt_this) { return this.forEach_(this.getAll(), callback, opt_this); }; @@ -164,7 +164,7 @@ ol.structs.RBush.prototype.forEach = function(callback, opt_this) { * @return {*} Callback return value. * @template S */ -ol.structs.RBush.prototype.forEachInExtent = function(extent, callback, opt_this) { +_ol_structs_RBush_.prototype.forEachInExtent = function(extent, callback, opt_this) { return this.forEach_(this.getInExtent(extent), callback, opt_this); }; @@ -177,7 +177,7 @@ ol.structs.RBush.prototype.forEachInExtent = function(extent, callback, opt_this * @return {*} Callback return value. * @template S */ -ol.structs.RBush.prototype.forEach_ = function(values, callback, opt_this) { +_ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) { var result; for (var i = 0, l = values.length; i < l; i++) { result = callback.call(opt_this, values[i]); @@ -192,15 +192,15 @@ ol.structs.RBush.prototype.forEach_ = function(values, callback, opt_this) { /** * @return {boolean} Is empty. */ -ol.structs.RBush.prototype.isEmpty = function() { - return ol.obj.isEmpty(this.items_); +_ol_structs_RBush_.prototype.isEmpty = function() { + return _ol_obj_.isEmpty(this.items_); }; /** * Remove all values from the RBush. */ -ol.structs.RBush.prototype.clear = function() { +_ol_structs_RBush_.prototype.clear = function() { this.rbush_.clear(); this.items_ = {}; }; @@ -210,19 +210,20 @@ ol.structs.RBush.prototype.clear = function() { * @param {ol.Extent=} opt_extent Extent. * @return {ol.Extent} Extent. */ -ol.structs.RBush.prototype.getExtent = function(opt_extent) { +_ol_structs_RBush_.prototype.getExtent = function(opt_extent) { // FIXME add getExtent() to rbush var data = this.rbush_.data; - return ol.extent.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent); + return _ol_extent_.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent); }; /** * @param {ol.structs.RBush} rbush R-Tree. */ -ol.structs.RBush.prototype.concat = function(rbush) { +_ol_structs_RBush_.prototype.concat = function(rbush) { this.rbush_.load(rbush.rbush_.all()); for (var i in rbush.items_) { this.items_[i | 0] = rbush.items_[i | 0]; } }; +export default _ol_structs_RBush_; diff --git a/src/ol/style.js b/src/ol/style.js index 8639a72651..744ffc2474 100644 --- a/src/ol/style.js +++ b/src/ol/style.js @@ -1,9 +1,12 @@ -goog.provide('ol.style'); - -goog.require('ol.style.IconImageCache'); +/** + * @module ol/style + */ +import _ol_style_IconImageCache_ from './style/IconImageCache.js'; +var _ol_style_ = {}; /** * The {@link ol.style.IconImageCache} for {@link ol.style.Icon} images. * @api */ -ol.style.iconImageCache = new ol.style.IconImageCache(); +_ol_style_.iconImageCache = new _ol_style_IconImageCache_(); +export default _ol_style_; diff --git a/src/ol/style/Atlas.js b/src/ol/style/Atlas.js index b1a6e844c3..a23d71e264 100644 --- a/src/ol/style/Atlas.js +++ b/src/ol/style/Atlas.js @@ -1,7 +1,7 @@ -goog.provide('ol.style.Atlas'); - -goog.require('ol.dom'); - +/** + * @module ol/style/Atlas + */ +import _ol_dom_ from '../dom.js'; /** * This class facilitates the creation of image atlases. @@ -20,7 +20,7 @@ goog.require('ol.dom'); * edges overlap when being rendered). To avoid this we add a * padding around each image. */ -ol.style.Atlas = function(size, space) { +var _ol_style_Atlas_ = function(size, space) { /** * @private @@ -44,7 +44,7 @@ ol.style.Atlas = function(size, space) { * @private * @type {CanvasRenderingContext2D} */ - this.context_ = ol.dom.createCanvasContext2D(size, size); + this.context_ = _ol_dom_.createCanvasContext2D(size, size); /** * @private @@ -58,7 +58,7 @@ ol.style.Atlas = function(size, space) { * @param {string} id The identifier of the entry to check. * @return {?ol.AtlasInfo} The atlas info. */ -ol.style.Atlas.prototype.get = function(id) { +_ol_style_Atlas_.prototype.get = function(id) { return this.entries_[id] || null; }; @@ -73,7 +73,7 @@ ol.style.Atlas.prototype.get = function(id) { * `renderCallback`. * @return {?ol.AtlasInfo} The position and atlas image for the entry. */ -ol.style.Atlas.prototype.add = function(id, width, height, renderCallback, opt_this) { +_ol_style_Atlas_.prototype.add = function(id, width, height, renderCallback, opt_this) { var block, i, ii; for (i = 0, ii = this.emptyBlocks_.length; i < ii; ++i) { block = this.emptyBlocks_[i]; @@ -110,7 +110,7 @@ ol.style.Atlas.prototype.add = function(id, width, height, renderCallback, opt_t * @param {number} width The width of the entry to insert. * @param {number} height The height of the entry to insert. */ -ol.style.Atlas.prototype.split_ = function(index, block, width, height) { +_ol_style_Atlas_.prototype.split_ = function(index, block, width, height) { var deltaWidth = block.width - width; var deltaHeight = block.height - height; @@ -168,7 +168,7 @@ ol.style.Atlas.prototype.split_ = function(index, block, width, height) { * @param {ol.AtlasBlock} newBlock1 The 1st block to add. * @param {ol.AtlasBlock} newBlock2 The 2nd block to add. */ -ol.style.Atlas.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { +_ol_style_Atlas_.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { var args = [index, 1]; if (newBlock1.width > 0 && newBlock1.height > 0) { args.push(newBlock1); @@ -178,3 +178,4 @@ ol.style.Atlas.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { } this.emptyBlocks_.splice.apply(this.emptyBlocks_, args); }; +export default _ol_style_Atlas_; diff --git a/src/ol/style/AtlasManager.js b/src/ol/style/AtlasManager.js index 597146e10e..9601c0c497 100644 --- a/src/ol/style/AtlasManager.js +++ b/src/ol/style/AtlasManager.js @@ -1,8 +1,8 @@ -goog.provide('ol.style.AtlasManager'); - -goog.require('ol'); -goog.require('ol.style.Atlas'); - +/** + * @module ol/style/AtlasManager + */ +import _ol_ from '../index.js'; +import _ol_style_Atlas_ from '../style/Atlas.js'; /** * Manages the creation of image atlases. @@ -21,7 +21,7 @@ goog.require('ol.style.Atlas'); * @api * @param {olx.style.AtlasManagerOptions=} opt_options Options. */ -ol.style.AtlasManager = function(opt_options) { +var _ol_style_AtlasManager_ = function(opt_options) { var options = opt_options || {}; @@ -31,7 +31,7 @@ ol.style.AtlasManager = function(opt_options) { * @type {number} */ this.currentSize_ = options.initialSize !== undefined ? - options.initialSize : ol.INITIAL_ATLAS_SIZE; + options.initialSize : _ol_.INITIAL_ATLAS_SIZE; /** * The maximum size in pixels of atlas images. @@ -39,9 +39,9 @@ ol.style.AtlasManager = function(opt_options) { * @type {number} */ this.maxSize_ = options.maxSize !== undefined ? - options.maxSize : ol.MAX_ATLAS_SIZE != -1 ? - ol.MAX_ATLAS_SIZE : ol.WEBGL_MAX_TEXTURE_SIZE !== undefined ? - ol.WEBGL_MAX_TEXTURE_SIZE : 2048; + options.maxSize : _ol_.MAX_ATLAS_SIZE != -1 ? + _ol_.MAX_ATLAS_SIZE : _ol_.WEBGL_MAX_TEXTURE_SIZE !== undefined ? + _ol_.WEBGL_MAX_TEXTURE_SIZE : 2048; /** * The size in pixels between images. @@ -54,7 +54,7 @@ ol.style.AtlasManager = function(opt_options) { * @private * @type {Array.} */ - this.atlases_ = [new ol.style.Atlas(this.currentSize_, this.space_)]; + this.atlases_ = [new _ol_style_Atlas_(this.currentSize_, this.space_)]; /** * The size in pixels of the latest atlas image for hit-detection images. @@ -67,7 +67,7 @@ ol.style.AtlasManager = function(opt_options) { * @private * @type {Array.} */ - this.hitAtlases_ = [new ol.style.Atlas(this.currentHitSize_, this.space_)]; + this.hitAtlases_ = [new _ol_style_Atlas_(this.currentHitSize_, this.space_)]; }; @@ -76,7 +76,7 @@ ol.style.AtlasManager = function(opt_options) { * @return {?ol.AtlasManagerInfo} The position and atlas image for the * entry, or `null` if the entry is not part of the atlas manager. */ -ol.style.AtlasManager.prototype.getInfo = function(id) { +_ol_style_AtlasManager_.prototype.getInfo = function(id) { /** @type {?ol.AtlasInfo} */ var info = this.getInfo_(this.atlases_, id); @@ -96,7 +96,7 @@ ol.style.AtlasManager.prototype.getInfo = function(id) { * @return {?ol.AtlasInfo} The position and atlas image for the entry, * or `null` if the entry is not part of the atlases. */ -ol.style.AtlasManager.prototype.getInfo_ = function(atlases, id) { +_ol_style_AtlasManager_.prototype.getInfo_ = function(atlases, id) { var atlas, info, i, ii; for (i = 0, ii = atlases.length; i < ii; ++i) { atlas = atlases[i]; @@ -117,7 +117,7 @@ ol.style.AtlasManager.prototype.getInfo_ = function(atlases, id) { * @return {?ol.AtlasManagerInfo} The position and atlas image for the * entry, or `null` if the entry is not part of the atlases. */ -ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) { +_ol_style_AtlasManager_.prototype.mergeInfos_ = function(info, hitInfo) { return /** @type {ol.AtlasManagerInfo} */ ({ offsetX: info.offsetX, offsetY: info.offsetY, @@ -149,7 +149,7 @@ ol.style.AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) { * @return {?ol.AtlasManagerInfo} The position and atlas image for the * entry, or `null` if the image is too big. */ -ol.style.AtlasManager.prototype.add = function(id, width, height, +_ol_style_AtlasManager_.prototype.add = function(id, width, height, renderCallback, opt_renderHitCallback, opt_this) { if (width + this.space_ > this.maxSize_ || height + this.space_ > this.maxSize_) { @@ -167,7 +167,7 @@ ol.style.AtlasManager.prototype.add = function(id, width, height, // the hit-detection atlas, to make sure that the offset is the same for // the original image and the hit-detection image. var renderHitCallback = opt_renderHitCallback !== undefined ? - opt_renderHitCallback : ol.nullFunction; + opt_renderHitCallback : _ol_.nullFunction; var hitInfo = /** @type {ol.AtlasInfo} */ (this.add_(true, id, width, height, renderHitCallback, opt_this)); @@ -189,7 +189,7 @@ ol.style.AtlasManager.prototype.add = function(id, width, height, * @return {?ol.AtlasInfo} The position and atlas image for the entry, * or `null` if the image is too big. */ -ol.style.AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height, +_ol_style_AtlasManager_.prototype.add_ = function(isHitAtlas, id, width, height, renderCallback, opt_this) { var atlases = (isHitAtlas) ? this.hitAtlases_ : this.atlases_; var atlas, info, i, ii; @@ -209,7 +209,7 @@ ol.style.AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height, size = Math.min(this.currentSize_ * 2, this.maxSize_); this.currentSize_ = size; } - atlas = new ol.style.Atlas(size, this.space_); + atlas = new _ol_style_Atlas_(size, this.space_); atlases.push(atlas); // run the loop another time ++ii; @@ -217,3 +217,4 @@ ol.style.AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height, } return null; }; +export default _ol_style_AtlasManager_; diff --git a/src/ol/style/Circle.js b/src/ol/style/Circle.js index acf8512ce5..03d59f9423 100644 --- a/src/ol/style/Circle.js +++ b/src/ol/style/Circle.js @@ -1,8 +1,8 @@ -goog.provide('ol.style.Circle'); - -goog.require('ol'); -goog.require('ol.style.RegularShape'); - +/** + * @module ol/style/Circle + */ +import _ol_ from '../index.js'; +import _ol_style_RegularShape_ from '../style/RegularShape.js'; /** * @classdesc @@ -13,11 +13,11 @@ goog.require('ol.style.RegularShape'); * @extends {ol.style.RegularShape} * @api */ -ol.style.Circle = function(opt_options) { +var _ol_style_Circle_ = function(opt_options) { var options = opt_options || {}; - ol.style.RegularShape.call(this, { + _ol_style_RegularShape_.call(this, { points: Infinity, fill: options.fill, radius: options.radius, @@ -27,7 +27,8 @@ ol.style.Circle = function(opt_options) { }); }; -ol.inherits(ol.style.Circle, ol.style.RegularShape); + +_ol_.inherits(_ol_style_Circle_, _ol_style_RegularShape_); /** @@ -36,8 +37,8 @@ ol.inherits(ol.style.Circle, ol.style.RegularShape); * @override * @api */ -ol.style.Circle.prototype.clone = function() { - var style = new ol.style.Circle({ +_ol_style_Circle_.prototype.clone = function() { + var style = new _ol_style_Circle_({ fill: this.getFill() ? this.getFill().clone() : undefined, stroke: this.getStroke() ? this.getStroke().clone() : undefined, radius: this.getRadius(), @@ -56,7 +57,8 @@ ol.style.Circle.prototype.clone = function() { * @param {number} radius Circle radius. * @api */ -ol.style.Circle.prototype.setRadius = function(radius) { +_ol_style_Circle_.prototype.setRadius = function(radius) { this.radius_ = radius; this.render_(this.atlasManager_); }; +export default _ol_style_Circle_; diff --git a/src/ol/style/Fill.js b/src/ol/style/Fill.js index 924ef73264..f6555d1ea5 100644 --- a/src/ol/style/Fill.js +++ b/src/ol/style/Fill.js @@ -1,8 +1,8 @@ -goog.provide('ol.style.Fill'); - -goog.require('ol'); -goog.require('ol.color'); - +/** + * @module ol/style/Fill + */ +import _ol_ from '../index.js'; +import _ol_color_ from '../color.js'; /** * @classdesc @@ -12,7 +12,7 @@ goog.require('ol.color'); * @param {olx.style.FillOptions=} opt_options Options. * @api */ -ol.style.Fill = function(opt_options) { +var _ol_style_Fill_ = function(opt_options) { var options = opt_options || {}; @@ -35,9 +35,9 @@ ol.style.Fill = function(opt_options) { * @return {ol.style.Fill} The cloned style. * @api */ -ol.style.Fill.prototype.clone = function() { +_ol_style_Fill_.prototype.clone = function() { var color = this.getColor(); - return new ol.style.Fill({ + return new _ol_style_Fill_({ color: (color && color.slice) ? color.slice() : color || undefined }); }; @@ -48,7 +48,7 @@ ol.style.Fill.prototype.clone = function() { * @return {ol.Color|ol.ColorLike} Color. * @api */ -ol.style.Fill.prototype.getColor = function() { +_ol_style_Fill_.prototype.getColor = function() { return this.color_; }; @@ -59,7 +59,7 @@ ol.style.Fill.prototype.getColor = function() { * @param {ol.Color|ol.ColorLike} color Color. * @api */ -ol.style.Fill.prototype.setColor = function(color) { +_ol_style_Fill_.prototype.setColor = function(color) { this.color_ = color; this.checksum_ = undefined; }; @@ -68,18 +68,19 @@ ol.style.Fill.prototype.setColor = function(color) { /** * @return {string} The checksum. */ -ol.style.Fill.prototype.getChecksum = function() { +_ol_style_Fill_.prototype.getChecksum = function() { if (this.checksum_ === undefined) { if ( this.color_ instanceof CanvasPattern || this.color_ instanceof CanvasGradient ) { - this.checksum_ = ol.getUid(this.color_).toString(); + this.checksum_ = _ol_.getUid(this.color_).toString(); } else { this.checksum_ = 'f' + (this.color_ ? - ol.color.asString(this.color_) : '-'); + _ol_color_.asString(this.color_) : '-'); } } return this.checksum_; }; +export default _ol_style_Fill_; diff --git a/src/ol/style/Icon.js b/src/ol/style/Icon.js index 14cd073cd0..cec4b495c0 100644 --- a/src/ol/style/Icon.js +++ b/src/ol/style/Icon.js @@ -1,16 +1,16 @@ -goog.provide('ol.style.Icon'); - -goog.require('ol'); -goog.require('ol.ImageState'); -goog.require('ol.asserts'); -goog.require('ol.color'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.style.IconAnchorUnits'); -goog.require('ol.style.IconImage'); -goog.require('ol.style.IconOrigin'); -goog.require('ol.style.Image'); - +/** + * @module ol/style/Icon + */ +import _ol_ from '../index.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_color_ from '../color.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; +import _ol_style_IconImage_ from '../style/IconImage.js'; +import _ol_style_IconOrigin_ from '../style/IconOrigin.js'; +import _ol_style_Image_ from '../style/Image.js'; /** * @classdesc @@ -21,7 +21,7 @@ goog.require('ol.style.Image'); * @extends {ol.style.Image} * @api */ -ol.style.Icon = function(opt_options) { +var _ol_style_Icon_ = function(opt_options) { var options = opt_options || {}; @@ -42,21 +42,21 @@ ol.style.Icon = function(opt_options) { * @type {ol.style.IconOrigin} */ this.anchorOrigin_ = options.anchorOrigin !== undefined ? - options.anchorOrigin : ol.style.IconOrigin.TOP_LEFT; + options.anchorOrigin : _ol_style_IconOrigin_.TOP_LEFT; /** * @private * @type {ol.style.IconAnchorUnits} */ this.anchorXUnits_ = options.anchorXUnits !== undefined ? - options.anchorXUnits : ol.style.IconAnchorUnits.FRACTION; + options.anchorXUnits : _ol_style_IconAnchorUnits_.FRACTION; /** * @private * @type {ol.style.IconAnchorUnits} */ this.anchorYUnits_ = options.anchorYUnits !== undefined ? - options.anchorYUnits : ol.style.IconAnchorUnits.FRACTION; + options.anchorYUnits : _ol_style_IconAnchorUnits_.FRACTION; /** * @private @@ -80,35 +80,35 @@ ol.style.Icon = function(opt_options) { */ var src = options.src; - ol.asserts.assert(!(src !== undefined && image), + _ol_asserts_.assert(!(src !== undefined && image), 4); // `image` and `src` cannot be provided at the same time - ol.asserts.assert(!image || (image && imgSize), + _ol_asserts_.assert(!image || (image && imgSize), 5); // `imgSize` must be set when `image` is provided if ((src === undefined || src.length === 0) && image) { - src = image.src || ol.getUid(image).toString(); + src = image.src || _ol_.getUid(image).toString(); } - ol.asserts.assert(src !== undefined && src.length > 0, + _ol_asserts_.assert(src !== undefined && src.length > 0, 6); // A defined and non-empty `src` or `image` must be provided /** * @type {ol.ImageState} */ var imageState = options.src !== undefined ? - ol.ImageState.IDLE : ol.ImageState.LOADED; + _ol_ImageState_.IDLE : _ol_ImageState_.LOADED; /** * @private * @type {ol.Color} */ - this.color_ = options.color !== undefined ? ol.color.asArray(options.color) : + this.color_ = options.color !== undefined ? _ol_color_.asArray(options.color) : null; /** * @private * @type {ol.style.IconImage} */ - this.iconImage_ = ol.style.IconImage.get( + this.iconImage_ = _ol_style_IconImage_.get( image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_); /** @@ -122,7 +122,7 @@ ol.style.Icon = function(opt_options) { * @type {ol.style.IconOrigin} */ this.offsetOrigin_ = options.offsetOrigin !== undefined ? - options.offsetOrigin : ol.style.IconOrigin.TOP_LEFT; + options.offsetOrigin : _ol_style_IconOrigin_.TOP_LEFT; /** * @private @@ -163,7 +163,7 @@ ol.style.Icon = function(opt_options) { var snapToPixel = options.snapToPixel !== undefined ? options.snapToPixel : true; - ol.style.Image.call(this, { + _ol_style_Image_.call(this, { opacity: opacity, rotation: rotation, scale: scale, @@ -172,7 +172,8 @@ ol.style.Icon = function(opt_options) { }); }; -ol.inherits(ol.style.Icon, ol.style.Image); + +_ol_.inherits(_ol_style_Icon_, _ol_style_Image_); /** @@ -180,8 +181,8 @@ ol.inherits(ol.style.Icon, ol.style.Image); * @return {ol.style.Icon} The cloned style. * @api */ -ol.style.Icon.prototype.clone = function() { - return new ol.style.Icon({ +_ol_style_Icon_.prototype.clone = function() { + return new _ol_style_Icon_({ anchor: this.anchor_.slice(), anchorOrigin: this.anchorOrigin_, anchorXUnits: this.anchorXUnits_, @@ -205,39 +206,39 @@ ol.style.Icon.prototype.clone = function() { * @inheritDoc * @api */ -ol.style.Icon.prototype.getAnchor = function() { +_ol_style_Icon_.prototype.getAnchor = function() { if (this.normalizedAnchor_) { return this.normalizedAnchor_; } var anchor = this.anchor_; var size = this.getSize(); - if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION || - this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) { + if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION || + this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { if (!size) { return null; } anchor = this.anchor_.slice(); - if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION) { + if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { anchor[0] *= size[0]; } - if (this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) { + if (this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { anchor[1] *= size[1]; } } - if (this.anchorOrigin_ != ol.style.IconOrigin.TOP_LEFT) { + if (this.anchorOrigin_ != _ol_style_IconOrigin_.TOP_LEFT) { if (!size) { return null; } if (anchor === this.anchor_) { anchor = this.anchor_.slice(); } - if (this.anchorOrigin_ == ol.style.IconOrigin.TOP_RIGHT || - this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) { + if (this.anchorOrigin_ == _ol_style_IconOrigin_.TOP_RIGHT || + this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { anchor[0] = -anchor[0] + size[0]; } - if (this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_LEFT || - this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) { + if (this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_LEFT || + this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { anchor[1] = -anchor[1] + size[1]; } } @@ -251,7 +252,7 @@ ol.style.Icon.prototype.getAnchor = function() { * @return {ol.Color} Color. * @api */ -ol.style.Icon.prototype.getColor = function() { +_ol_style_Icon_.prototype.getColor = function() { return this.color_; }; @@ -263,7 +264,7 @@ ol.style.Icon.prototype.getColor = function() { * @override * @api */ -ol.style.Icon.prototype.getImage = function(pixelRatio) { +_ol_style_Icon_.prototype.getImage = function(pixelRatio) { return this.iconImage_.getImage(pixelRatio); }; @@ -271,7 +272,7 @@ ol.style.Icon.prototype.getImage = function(pixelRatio) { /** * @override */ -ol.style.Icon.prototype.getImageSize = function() { +_ol_style_Icon_.prototype.getImageSize = function() { return this.iconImage_.getSize(); }; @@ -279,7 +280,7 @@ ol.style.Icon.prototype.getImageSize = function() { /** * @override */ -ol.style.Icon.prototype.getHitDetectionImageSize = function() { +_ol_style_Icon_.prototype.getHitDetectionImageSize = function() { return this.getImageSize(); }; @@ -287,7 +288,7 @@ ol.style.Icon.prototype.getHitDetectionImageSize = function() { /** * @override */ -ol.style.Icon.prototype.getImageState = function() { +_ol_style_Icon_.prototype.getImageState = function() { return this.iconImage_.getImageState(); }; @@ -295,7 +296,7 @@ ol.style.Icon.prototype.getImageState = function() { /** * @override */ -ol.style.Icon.prototype.getHitDetectionImage = function(pixelRatio) { +_ol_style_Icon_.prototype.getHitDetectionImage = function(pixelRatio) { return this.iconImage_.getHitDetectionImage(pixelRatio); }; @@ -304,25 +305,25 @@ ol.style.Icon.prototype.getHitDetectionImage = function(pixelRatio) { * @inheritDoc * @api */ -ol.style.Icon.prototype.getOrigin = function() { +_ol_style_Icon_.prototype.getOrigin = function() { if (this.origin_) { return this.origin_; } var offset = this.offset_; - if (this.offsetOrigin_ != ol.style.IconOrigin.TOP_LEFT) { + if (this.offsetOrigin_ != _ol_style_IconOrigin_.TOP_LEFT) { var size = this.getSize(); var iconImageSize = this.iconImage_.getSize(); if (!size || !iconImageSize) { return null; } offset = offset.slice(); - if (this.offsetOrigin_ == ol.style.IconOrigin.TOP_RIGHT || - this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) { + if (this.offsetOrigin_ == _ol_style_IconOrigin_.TOP_RIGHT || + this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { offset[0] = iconImageSize[0] - size[0] - offset[0]; } - if (this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_LEFT || - this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) { + if (this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_LEFT || + this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { offset[1] = iconImageSize[1] - size[1] - offset[1]; } } @@ -336,7 +337,7 @@ ol.style.Icon.prototype.getOrigin = function() { * @return {string|undefined} Image src. * @api */ -ol.style.Icon.prototype.getSrc = function() { +_ol_style_Icon_.prototype.getSrc = function() { return this.iconImage_.getSrc(); }; @@ -345,7 +346,7 @@ ol.style.Icon.prototype.getSrc = function() { * @inheritDoc * @api */ -ol.style.Icon.prototype.getSize = function() { +_ol_style_Icon_.prototype.getSize = function() { return !this.size_ ? this.iconImage_.getSize() : this.size_; }; @@ -353,8 +354,8 @@ ol.style.Icon.prototype.getSize = function() { /** * @override */ -ol.style.Icon.prototype.listenImageChange = function(listener, thisArg) { - return ol.events.listen(this.iconImage_, ol.events.EventType.CHANGE, +_ol_style_Icon_.prototype.listenImageChange = function(listener, thisArg) { + return _ol_events_.listen(this.iconImage_, _ol_events_EventType_.CHANGE, listener, thisArg); }; @@ -367,7 +368,7 @@ ol.style.Icon.prototype.listenImageChange = function(listener, thisArg) { * @override * @api */ -ol.style.Icon.prototype.load = function() { +_ol_style_Icon_.prototype.load = function() { this.iconImage_.load(); }; @@ -375,7 +376,8 @@ ol.style.Icon.prototype.load = function() { /** * @override */ -ol.style.Icon.prototype.unlistenImageChange = function(listener, thisArg) { - ol.events.unlisten(this.iconImage_, ol.events.EventType.CHANGE, +_ol_style_Icon_.prototype.unlistenImageChange = function(listener, thisArg) { + _ol_events_.unlisten(this.iconImage_, _ol_events_EventType_.CHANGE, listener, thisArg); }; +export default _ol_style_Icon_; diff --git a/src/ol/style/IconAnchorUnits.js b/src/ol/style/IconAnchorUnits.js index 4d18ca034f..703c8771a9 100644 --- a/src/ol/style/IconAnchorUnits.js +++ b/src/ol/style/IconAnchorUnits.js @@ -1,10 +1,13 @@ -goog.provide('ol.style.IconAnchorUnits'); - +/** + * @module ol/style/IconAnchorUnits + */ /** * Icon anchor units. One of 'fraction', 'pixels'. * @enum {string} */ -ol.style.IconAnchorUnits = { +var _ol_style_IconAnchorUnits_ = { FRACTION: 'fraction', PIXELS: 'pixels' }; + +export default _ol_style_IconAnchorUnits_; diff --git a/src/ol/style/IconImage.js b/src/ol/style/IconImage.js index 61a7903631..aeb141881e 100644 --- a/src/ol/style/IconImage.js +++ b/src/ol/style/IconImage.js @@ -1,13 +1,13 @@ -goog.provide('ol.style.IconImage'); - -goog.require('ol'); -goog.require('ol.dom'); -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); -goog.require('ol.events.EventType'); -goog.require('ol.ImageState'); -goog.require('ol.style'); - +/** + * @module ol/style/IconImage + */ +import _ol_ from '../index.js'; +import _ol_dom_ from '../dom.js'; +import _ol_events_ from '../events.js'; +import _ol_events_EventTarget_ from '../events/EventTarget.js'; +import _ol_events_EventType_ from '../events/EventType.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_style_ from '../style.js'; /** * @constructor @@ -19,10 +19,10 @@ goog.require('ol.style'); * @param {ol.Color} color Color. * @extends {ol.events.EventTarget} */ -ol.style.IconImage = function(image, src, size, crossOrigin, imageState, +var _ol_style_IconImage_ = function(image, src, size, crossOrigin, imageState, color) { - ol.events.EventTarget.call(this); + _ol_events_EventTarget_.call(this); /** * @private @@ -83,12 +83,13 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState, * @type {boolean} */ this.tainting_ = false; - if (this.imageState_ == ol.ImageState.LOADED) { + if (this.imageState_ == _ol_ImageState_.LOADED) { this.determineTainting_(); } }; -ol.inherits(ol.style.IconImage, ol.events.EventTarget); + +_ol_.inherits(_ol_style_IconImage_, _ol_events_EventTarget_); /** @@ -100,12 +101,12 @@ ol.inherits(ol.style.IconImage, ol.events.EventTarget); * @param {ol.Color} color Color. * @return {ol.style.IconImage} Icon image. */ -ol.style.IconImage.get = function(image, src, size, crossOrigin, imageState, +_ol_style_IconImage_.get = function(image, src, size, crossOrigin, imageState, color) { - var iconImageCache = ol.style.iconImageCache; + var iconImageCache = _ol_style_.iconImageCache; var iconImage = iconImageCache.get(src, crossOrigin, color); if (!iconImage) { - iconImage = new ol.style.IconImage( + iconImage = new _ol_style_IconImage_( image, src, size, crossOrigin, imageState, color); iconImageCache.set(src, crossOrigin, color, iconImage); } @@ -116,8 +117,8 @@ ol.style.IconImage.get = function(image, src, size, crossOrigin, imageState, /** * @private */ -ol.style.IconImage.prototype.determineTainting_ = function() { - var context = ol.dom.createCanvasContext2D(1, 1); +_ol_style_IconImage_.prototype.determineTainting_ = function() { + var context = _ol_dom_.createCanvasContext2D(1, 1); try { context.drawImage(this.image_, 0, 0); context.getImageData(0, 0, 1, 1); @@ -130,16 +131,16 @@ ol.style.IconImage.prototype.determineTainting_ = function() { /** * @private */ -ol.style.IconImage.prototype.dispatchChangeEvent_ = function() { - this.dispatchEvent(ol.events.EventType.CHANGE); +_ol_style_IconImage_.prototype.dispatchChangeEvent_ = function() { + this.dispatchEvent(_ol_events_EventType_.CHANGE); }; /** * @private */ -ol.style.IconImage.prototype.handleImageError_ = function() { - this.imageState_ = ol.ImageState.ERROR; +_ol_style_IconImage_.prototype.handleImageError_ = function() { + this.imageState_ = _ol_ImageState_.ERROR; this.unlistenImage_(); this.dispatchChangeEvent_(); }; @@ -148,8 +149,8 @@ ol.style.IconImage.prototype.handleImageError_ = function() { /** * @private */ -ol.style.IconImage.prototype.handleImageLoad_ = function() { - this.imageState_ = ol.ImageState.LOADED; +_ol_style_IconImage_.prototype.handleImageLoad_ = function() { + this.imageState_ = _ol_ImageState_.LOADED; if (this.size_) { this.image_.width = this.size_[0]; this.image_.height = this.size_[1]; @@ -166,7 +167,7 @@ ol.style.IconImage.prototype.handleImageLoad_ = function() { * @param {number} pixelRatio Pixel ratio. * @return {Image|HTMLCanvasElement} Image or Canvas element. */ -ol.style.IconImage.prototype.getImage = function(pixelRatio) { +_ol_style_IconImage_.prototype.getImage = function(pixelRatio) { return this.canvas_ ? this.canvas_ : this.image_; }; @@ -174,7 +175,7 @@ ol.style.IconImage.prototype.getImage = function(pixelRatio) { /** * @return {ol.ImageState} Image state. */ -ol.style.IconImage.prototype.getImageState = function() { +_ol_style_IconImage_.prototype.getImageState = function() { return this.imageState_; }; @@ -183,12 +184,12 @@ ol.style.IconImage.prototype.getImageState = function() { * @param {number} pixelRatio Pixel ratio. * @return {Image|HTMLCanvasElement} Image element. */ -ol.style.IconImage.prototype.getHitDetectionImage = function(pixelRatio) { +_ol_style_IconImage_.prototype.getHitDetectionImage = function(pixelRatio) { if (!this.hitDetectionImage_) { if (this.tainting_) { var width = this.size_[0]; var height = this.size_[1]; - var context = ol.dom.createCanvasContext2D(width, height); + var context = _ol_dom_.createCanvasContext2D(width, height); context.fillRect(0, 0, width, height); this.hitDetectionImage_ = context.canvas; } else { @@ -202,7 +203,7 @@ ol.style.IconImage.prototype.getHitDetectionImage = function(pixelRatio) { /** * @return {ol.Size} Image size. */ -ol.style.IconImage.prototype.getSize = function() { +_ol_style_IconImage_.prototype.getSize = function() { return this.size_; }; @@ -210,7 +211,7 @@ ol.style.IconImage.prototype.getSize = function() { /** * @return {string|undefined} Image src. */ -ol.style.IconImage.prototype.getSrc = function() { +_ol_style_IconImage_.prototype.getSrc = function() { return this.src_; }; @@ -218,13 +219,13 @@ ol.style.IconImage.prototype.getSrc = function() { /** * Load not yet loaded URI. */ -ol.style.IconImage.prototype.load = function() { - if (this.imageState_ == ol.ImageState.IDLE) { - this.imageState_ = ol.ImageState.LOADING; +_ol_style_IconImage_.prototype.load = function() { + if (this.imageState_ == _ol_ImageState_.IDLE) { + this.imageState_ = _ol_ImageState_.LOADING; this.imageListenerKeys_ = [ - ol.events.listenOnce(this.image_, ol.events.EventType.ERROR, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.ERROR, this.handleImageError_, this), - ol.events.listenOnce(this.image_, ol.events.EventType.LOAD, + _ol_events_.listenOnce(this.image_, _ol_events_EventType_.LOAD, this.handleImageLoad_, this) ]; try { @@ -239,7 +240,7 @@ ol.style.IconImage.prototype.load = function() { /** * @private */ -ol.style.IconImage.prototype.replaceColor_ = function() { +_ol_style_IconImage_.prototype.replaceColor_ = function() { if (this.tainting_ || this.color_ === null) { return; } @@ -270,7 +271,8 @@ ol.style.IconImage.prototype.replaceColor_ = function() { * * @private */ -ol.style.IconImage.prototype.unlistenImage_ = function() { - this.imageListenerKeys_.forEach(ol.events.unlistenByKey); +_ol_style_IconImage_.prototype.unlistenImage_ = function() { + this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey); this.imageListenerKeys_ = null; }; +export default _ol_style_IconImage_; diff --git a/src/ol/style/IconImageCache.js b/src/ol/style/IconImageCache.js index 7966e7bdc6..14935640f4 100644 --- a/src/ol/style/IconImageCache.js +++ b/src/ol/style/IconImageCache.js @@ -1,13 +1,13 @@ -goog.provide('ol.style.IconImageCache'); - -goog.require('ol.color'); - +/** + * @module ol/style/IconImageCache + */ +import _ol_color_ from '../color.js'; /** * Singleton class. Available through {@link ol.style.iconImageCache}. * @constructor */ -ol.style.IconImageCache = function() { +var _ol_style_IconImageCache_ = function() { /** * @type {Object.} @@ -35,8 +35,8 @@ ol.style.IconImageCache = function() { * @param {ol.Color} color Color. * @return {string} Cache key. */ -ol.style.IconImageCache.getKey = function(src, crossOrigin, color) { - var colorString = color ? ol.color.asString(color) : 'null'; +_ol_style_IconImageCache_.getKey = function(src, crossOrigin, color) { + var colorString = color ? _ol_color_.asString(color) : 'null'; return crossOrigin + ':' + src + ':' + colorString; }; @@ -44,7 +44,7 @@ ol.style.IconImageCache.getKey = function(src, crossOrigin, color) { /** * FIXME empty description for jsdoc */ -ol.style.IconImageCache.prototype.clear = function() { +_ol_style_IconImageCache_.prototype.clear = function() { this.cache_ = {}; this.cacheSize_ = 0; }; @@ -53,7 +53,7 @@ ol.style.IconImageCache.prototype.clear = function() { /** * FIXME empty description for jsdoc */ -ol.style.IconImageCache.prototype.expire = function() { +_ol_style_IconImageCache_.prototype.expire = function() { if (this.cacheSize_ > this.maxCacheSize_) { var i = 0; var key, iconImage; @@ -74,8 +74,8 @@ ol.style.IconImageCache.prototype.expire = function() { * @param {ol.Color} color Color. * @return {ol.style.IconImage} Icon image. */ -ol.style.IconImageCache.prototype.get = function(src, crossOrigin, color) { - var key = ol.style.IconImageCache.getKey(src, crossOrigin, color); +_ol_style_IconImageCache_.prototype.get = function(src, crossOrigin, color) { + var key = _ol_style_IconImageCache_.getKey(src, crossOrigin, color); return key in this.cache_ ? this.cache_[key] : null; }; @@ -86,8 +86,8 @@ ol.style.IconImageCache.prototype.get = function(src, crossOrigin, color) { * @param {ol.Color} color Color. * @param {ol.style.IconImage} iconImage Icon image. */ -ol.style.IconImageCache.prototype.set = function(src, crossOrigin, color, iconImage) { - var key = ol.style.IconImageCache.getKey(src, crossOrigin, color); +_ol_style_IconImageCache_.prototype.set = function(src, crossOrigin, color, iconImage) { + var key = _ol_style_IconImageCache_.getKey(src, crossOrigin, color); this.cache_[key] = iconImage; ++this.cacheSize_; }; @@ -100,7 +100,8 @@ ol.style.IconImageCache.prototype.set = function(src, crossOrigin, color, iconIm * @param {number} maxCacheSize Cache max size. * @api */ -ol.style.IconImageCache.prototype.setSize = function(maxCacheSize) { +_ol_style_IconImageCache_.prototype.setSize = function(maxCacheSize) { this.maxCacheSize_ = maxCacheSize; this.expire(); }; +export default _ol_style_IconImageCache_; diff --git a/src/ol/style/IconOrigin.js b/src/ol/style/IconOrigin.js index 8acff2f9ab..1c473ba59c 100644 --- a/src/ol/style/IconOrigin.js +++ b/src/ol/style/IconOrigin.js @@ -1,12 +1,15 @@ -goog.provide('ol.style.IconOrigin'); - +/** + * @module ol/style/IconOrigin + */ /** * Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'. * @enum {string} */ -ol.style.IconOrigin = { +var _ol_style_IconOrigin_ = { BOTTOM_LEFT: 'bottom-left', BOTTOM_RIGHT: 'bottom-right', TOP_LEFT: 'top-left', TOP_RIGHT: 'top-right' }; + +export default _ol_style_IconOrigin_; diff --git a/src/ol/style/Image.js b/src/ol/style/Image.js index 9ba000d07e..0a680147b2 100644 --- a/src/ol/style/Image.js +++ b/src/ol/style/Image.js @@ -1,6 +1,6 @@ -goog.provide('ol.style.Image'); - - +/** + * @module ol/style/Image + */ /** * @classdesc * A base class used for creating subclasses and not instantiated in @@ -12,7 +12,7 @@ goog.provide('ol.style.Image'); * @param {ol.StyleImageOptions} options Options. * @api */ -ol.style.Image = function(options) { +var _ol_style_Image_ = function(options) { /** * @private @@ -52,7 +52,7 @@ ol.style.Image = function(options) { * @return {number} Opacity. * @api */ -ol.style.Image.prototype.getOpacity = function() { +_ol_style_Image_.prototype.getOpacity = function() { return this.opacity_; }; @@ -62,7 +62,7 @@ ol.style.Image.prototype.getOpacity = function() { * @return {boolean} Rotate with map. * @api */ -ol.style.Image.prototype.getRotateWithView = function() { +_ol_style_Image_.prototype.getRotateWithView = function() { return this.rotateWithView_; }; @@ -72,7 +72,7 @@ ol.style.Image.prototype.getRotateWithView = function() { * @return {number} Rotation. * @api */ -ol.style.Image.prototype.getRotation = function() { +_ol_style_Image_.prototype.getRotation = function() { return this.rotation_; }; @@ -82,7 +82,7 @@ ol.style.Image.prototype.getRotation = function() { * @return {number} Scale. * @api */ -ol.style.Image.prototype.getScale = function() { +_ol_style_Image_.prototype.getScale = function() { return this.scale_; }; @@ -92,7 +92,7 @@ ol.style.Image.prototype.getScale = function() { * @return {boolean} The symbolizer should snap to a pixel. * @api */ -ol.style.Image.prototype.getSnapToPixel = function() { +_ol_style_Image_.prototype.getSnapToPixel = function() { return this.snapToPixel_; }; @@ -103,7 +103,7 @@ ol.style.Image.prototype.getSnapToPixel = function() { * @abstract * @return {Array.} Anchor. */ -ol.style.Image.prototype.getAnchor = function() {}; +_ol_style_Image_.prototype.getAnchor = function() {}; /** @@ -112,7 +112,7 @@ ol.style.Image.prototype.getAnchor = function() {}; * @param {number} pixelRatio Pixel ratio. * @return {HTMLCanvasElement|HTMLVideoElement|Image} Image element. */ -ol.style.Image.prototype.getImage = function(pixelRatio) {}; +_ol_style_Image_.prototype.getImage = function(pixelRatio) {}; /** @@ -120,28 +120,28 @@ ol.style.Image.prototype.getImage = function(pixelRatio) {}; * @param {number} pixelRatio Pixel ratio. * @return {HTMLCanvasElement|HTMLVideoElement|Image} Image element. */ -ol.style.Image.prototype.getHitDetectionImage = function(pixelRatio) {}; +_ol_style_Image_.prototype.getHitDetectionImage = function(pixelRatio) {}; /** * @abstract * @return {ol.ImageState} Image state. */ -ol.style.Image.prototype.getImageState = function() {}; +_ol_style_Image_.prototype.getImageState = function() {}; /** * @abstract * @return {ol.Size} Image size. */ -ol.style.Image.prototype.getImageSize = function() {}; +_ol_style_Image_.prototype.getImageSize = function() {}; /** * @abstract * @return {ol.Size} Size of the hit-detection image. */ -ol.style.Image.prototype.getHitDetectionImageSize = function() {}; +_ol_style_Image_.prototype.getHitDetectionImageSize = function() {}; /** @@ -149,7 +149,7 @@ ol.style.Image.prototype.getHitDetectionImageSize = function() {}; * @abstract * @return {Array.} Origin. */ -ol.style.Image.prototype.getOrigin = function() {}; +_ol_style_Image_.prototype.getOrigin = function() {}; /** @@ -157,7 +157,7 @@ ol.style.Image.prototype.getOrigin = function() {}; * @abstract * @return {ol.Size} Size. */ -ol.style.Image.prototype.getSize = function() {}; +_ol_style_Image_.prototype.getSize = function() {}; /** @@ -166,7 +166,7 @@ ol.style.Image.prototype.getSize = function() {}; * @param {number} opacity Opacity. * @api */ -ol.style.Image.prototype.setOpacity = function(opacity) { +_ol_style_Image_.prototype.setOpacity = function(opacity) { this.opacity_ = opacity; }; @@ -176,7 +176,7 @@ ol.style.Image.prototype.setOpacity = function(opacity) { * * @param {boolean} rotateWithView Rotate with map. */ -ol.style.Image.prototype.setRotateWithView = function(rotateWithView) { +_ol_style_Image_.prototype.setRotateWithView = function(rotateWithView) { this.rotateWithView_ = rotateWithView; }; @@ -187,7 +187,7 @@ ol.style.Image.prototype.setRotateWithView = function(rotateWithView) { * @param {number} rotation Rotation. * @api */ -ol.style.Image.prototype.setRotation = function(rotation) { +_ol_style_Image_.prototype.setRotation = function(rotation) { this.rotation_ = rotation; }; @@ -198,7 +198,7 @@ ol.style.Image.prototype.setRotation = function(rotation) { * @param {number} scale Scale. * @api */ -ol.style.Image.prototype.setScale = function(scale) { +_ol_style_Image_.prototype.setScale = function(scale) { this.scale_ = scale; }; @@ -208,7 +208,7 @@ ol.style.Image.prototype.setScale = function(scale) { * * @param {boolean} snapToPixel Snap to pixel? */ -ol.style.Image.prototype.setSnapToPixel = function(snapToPixel) { +_ol_style_Image_.prototype.setSnapToPixel = function(snapToPixel) { this.snapToPixel_ = snapToPixel; }; @@ -220,14 +220,14 @@ ol.style.Image.prototype.setSnapToPixel = function(snapToPixel) { * @return {ol.EventsKey|undefined} Listener key. * @template T */ -ol.style.Image.prototype.listenImageChange = function(listener, thisArg) {}; +_ol_style_Image_.prototype.listenImageChange = function(listener, thisArg) {}; /** * Load not yet loaded URI. * @abstract */ -ol.style.Image.prototype.load = function() {}; +_ol_style_Image_.prototype.load = function() {}; /** @@ -236,4 +236,5 @@ ol.style.Image.prototype.load = function() {}; * @param {T} thisArg Value to use as `this` when executing `listener`. * @template T */ -ol.style.Image.prototype.unlistenImageChange = function(listener, thisArg) {}; +_ol_style_Image_.prototype.unlistenImageChange = function(listener, thisArg) {}; +export default _ol_style_Image_; diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index 08f0a80e36..28166b4f33 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -1,13 +1,13 @@ -goog.provide('ol.style.RegularShape'); - -goog.require('ol'); -goog.require('ol.colorlike'); -goog.require('ol.dom'); -goog.require('ol.has'); -goog.require('ol.ImageState'); -goog.require('ol.render.canvas'); -goog.require('ol.style.Image'); - +/** + * @module ol/style/RegularShape + */ +import _ol_ from '../index.js'; +import _ol_colorlike_ from '../colorlike.js'; +import _ol_dom_ from '../dom.js'; +import _ol_has_ from '../has.js'; +import _ol_ImageState_ from '../ImageState.js'; +import _ol_render_canvas_ from '../render/canvas.js'; +import _ol_style_Image_ from '../style/Image.js'; /** * @classdesc @@ -20,7 +20,7 @@ goog.require('ol.style.Image'); * @extends {ol.style.Image} * @api */ -ol.style.RegularShape = function(options) { +var _ol_style_RegularShape_ = function(options) { /** * @private * @type {Array.} @@ -126,7 +126,7 @@ ol.style.RegularShape = function(options) { var rotateWithView = options.rotateWithView !== undefined ? options.rotateWithView : false; - ol.style.Image.call(this, { + _ol_style_Image_.call(this, { opacity: 1, rotateWithView: rotateWithView, rotation: options.rotation !== undefined ? options.rotation : 0, @@ -134,7 +134,8 @@ ol.style.RegularShape = function(options) { snapToPixel: snapToPixel }); }; -ol.inherits(ol.style.RegularShape, ol.style.Image); + +_ol_.inherits(_ol_style_RegularShape_, _ol_style_Image_); /** @@ -142,8 +143,8 @@ ol.inherits(ol.style.RegularShape, ol.style.Image); * @return {ol.style.RegularShape} The cloned style. * @api */ -ol.style.RegularShape.prototype.clone = function() { - var style = new ol.style.RegularShape({ +_ol_style_RegularShape_.prototype.clone = function() { + var style = new _ol_style_RegularShape_({ fill: this.getFill() ? this.getFill().clone() : undefined, points: this.getPoints(), radius: this.getRadius(), @@ -165,7 +166,7 @@ ol.style.RegularShape.prototype.clone = function() { * @inheritDoc * @api */ -ol.style.RegularShape.prototype.getAnchor = function() { +_ol_style_RegularShape_.prototype.getAnchor = function() { return this.anchor_; }; @@ -175,7 +176,7 @@ ol.style.RegularShape.prototype.getAnchor = function() { * @return {number} Shape's rotation in radians. * @api */ -ol.style.RegularShape.prototype.getAngle = function() { +_ol_style_RegularShape_.prototype.getAngle = function() { return this.angle_; }; @@ -185,7 +186,7 @@ ol.style.RegularShape.prototype.getAngle = function() { * @return {ol.style.Fill} Fill style. * @api */ -ol.style.RegularShape.prototype.getFill = function() { +_ol_style_RegularShape_.prototype.getFill = function() { return this.fill_; }; @@ -193,7 +194,7 @@ ol.style.RegularShape.prototype.getFill = function() { /** * @inheritDoc */ -ol.style.RegularShape.prototype.getHitDetectionImage = function(pixelRatio) { +_ol_style_RegularShape_.prototype.getHitDetectionImage = function(pixelRatio) { return this.hitDetectionCanvas_; }; @@ -202,7 +203,7 @@ ol.style.RegularShape.prototype.getHitDetectionImage = function(pixelRatio) { * @inheritDoc * @api */ -ol.style.RegularShape.prototype.getImage = function(pixelRatio) { +_ol_style_RegularShape_.prototype.getImage = function(pixelRatio) { return this.canvas_; }; @@ -210,7 +211,7 @@ ol.style.RegularShape.prototype.getImage = function(pixelRatio) { /** * @inheritDoc */ -ol.style.RegularShape.prototype.getImageSize = function() { +_ol_style_RegularShape_.prototype.getImageSize = function() { return this.imageSize_; }; @@ -218,7 +219,7 @@ ol.style.RegularShape.prototype.getImageSize = function() { /** * @inheritDoc */ -ol.style.RegularShape.prototype.getHitDetectionImageSize = function() { +_ol_style_RegularShape_.prototype.getHitDetectionImageSize = function() { return this.hitDetectionImageSize_; }; @@ -226,8 +227,8 @@ ol.style.RegularShape.prototype.getHitDetectionImageSize = function() { /** * @inheritDoc */ -ol.style.RegularShape.prototype.getImageState = function() { - return ol.ImageState.LOADED; +_ol_style_RegularShape_.prototype.getImageState = function() { + return _ol_ImageState_.LOADED; }; @@ -235,7 +236,7 @@ ol.style.RegularShape.prototype.getImageState = function() { * @inheritDoc * @api */ -ol.style.RegularShape.prototype.getOrigin = function() { +_ol_style_RegularShape_.prototype.getOrigin = function() { return this.origin_; }; @@ -245,7 +246,7 @@ ol.style.RegularShape.prototype.getOrigin = function() { * @return {number} Number of points for stars and regular polygons. * @api */ -ol.style.RegularShape.prototype.getPoints = function() { +_ol_style_RegularShape_.prototype.getPoints = function() { return this.points_; }; @@ -255,7 +256,7 @@ ol.style.RegularShape.prototype.getPoints = function() { * @return {number} Radius. * @api */ -ol.style.RegularShape.prototype.getRadius = function() { +_ol_style_RegularShape_.prototype.getRadius = function() { return this.radius_; }; @@ -265,7 +266,7 @@ ol.style.RegularShape.prototype.getRadius = function() { * @return {number|undefined} Radius2. * @api */ -ol.style.RegularShape.prototype.getRadius2 = function() { +_ol_style_RegularShape_.prototype.getRadius2 = function() { return this.radius2_; }; @@ -274,7 +275,7 @@ ol.style.RegularShape.prototype.getRadius2 = function() { * @inheritDoc * @api */ -ol.style.RegularShape.prototype.getSize = function() { +_ol_style_RegularShape_.prototype.getSize = function() { return this.size_; }; @@ -284,7 +285,7 @@ ol.style.RegularShape.prototype.getSize = function() { * @return {ol.style.Stroke} Stroke style. * @api */ -ol.style.RegularShape.prototype.getStroke = function() { +_ol_style_RegularShape_.prototype.getStroke = function() { return this.stroke_; }; @@ -292,26 +293,26 @@ ol.style.RegularShape.prototype.getStroke = function() { /** * @inheritDoc */ -ol.style.RegularShape.prototype.listenImageChange = function(listener, thisArg) {}; +_ol_style_RegularShape_.prototype.listenImageChange = function(listener, thisArg) {}; /** * @inheritDoc */ -ol.style.RegularShape.prototype.load = function() {}; +_ol_style_RegularShape_.prototype.load = function() {}; /** * @inheritDoc */ -ol.style.RegularShape.prototype.unlistenImageChange = function(listener, thisArg) {}; +_ol_style_RegularShape_.prototype.unlistenImageChange = function(listener, thisArg) {}; /** * @protected * @param {ol.style.AtlasManager|undefined} atlasManager An atlas manager. */ -ol.style.RegularShape.prototype.render_ = function(atlasManager) { +_ol_style_RegularShape_.prototype.render_ = function(atlasManager) { var imageSize; var lineCap = ''; var lineJoin = ''; @@ -324,30 +325,30 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { if (this.stroke_) { strokeStyle = this.stroke_.getColor(); if (strokeStyle === null) { - strokeStyle = ol.render.canvas.defaultStrokeStyle; + strokeStyle = _ol_render_canvas_.defaultStrokeStyle; } - strokeStyle = ol.colorlike.asColorLike(strokeStyle); + strokeStyle = _ol_colorlike_.asColorLike(strokeStyle); strokeWidth = this.stroke_.getWidth(); if (strokeWidth === undefined) { - strokeWidth = ol.render.canvas.defaultLineWidth; + strokeWidth = _ol_render_canvas_.defaultLineWidth; } lineDash = this.stroke_.getLineDash(); lineDashOffset = this.stroke_.getLineDashOffset(); - if (!ol.has.CANVAS_LINE_DASH) { + if (!_ol_has_.CANVAS_LINE_DASH) { lineDash = null; lineDashOffset = 0; } lineJoin = this.stroke_.getLineJoin(); if (lineJoin === undefined) { - lineJoin = ol.render.canvas.defaultLineJoin; + lineJoin = _ol_render_canvas_.defaultLineJoin; } lineCap = this.stroke_.getLineCap(); if (lineCap === undefined) { - lineCap = ol.render.canvas.defaultLineCap; + lineCap = _ol_render_canvas_.defaultLineCap; } miterLimit = this.stroke_.getMiterLimit(); if (miterLimit === undefined) { - miterLimit = ol.render.canvas.defaultMiterLimit; + miterLimit = _ol_render_canvas_.defaultMiterLimit; } } @@ -367,7 +368,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { if (atlasManager === undefined) { // no atlas manager is used, create a new canvas - var context = ol.dom.createCanvasContext2D(size, size); + var context = _ol_dom_.createCanvasContext2D(size, size); this.canvas_ = context.canvas; // canvas.width and height are rounded to the closest integer @@ -421,7 +422,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). */ -ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) { +_ol_style_RegularShape_.prototype.draw_ = function(renderOptions, context, x, y) { var i, angle0, radiusC; // reset transform context.setTransform(1, 0, 0, 1, 0, 0); @@ -454,9 +455,9 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) { if (this.fill_) { var color = this.fill_.getColor(); if (color === null) { - color = ol.render.canvas.defaultFillStyle; + color = _ol_render_canvas_.defaultFillStyle; } - context.fillStyle = ol.colorlike.asColorLike(color); + context.fillStyle = _ol_colorlike_.asColorLike(color); context.fill(); } if (this.stroke_) { @@ -479,7 +480,7 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) { * @private * @param {ol.RegularShapeRenderOptions} renderOptions Render options. */ -ol.style.RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptions) { +_ol_style_RegularShape_.prototype.createHitDetectionCanvas_ = function(renderOptions) { this.hitDetectionImageSize_ = [renderOptions.size, renderOptions.size]; if (this.fill_) { this.hitDetectionCanvas_ = this.canvas_; @@ -488,7 +489,7 @@ ol.style.RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptio // if no fill style is set, create an extra hit-detection image with a // default fill style - var context = ol.dom.createCanvasContext2D(renderOptions.size, renderOptions.size); + var context = _ol_dom_.createCanvasContext2D(renderOptions.size, renderOptions.size); this.hitDetectionCanvas_ = context.canvas; this.drawHitDetectionCanvas_(renderOptions, context, 0, 0); @@ -502,7 +503,7 @@ ol.style.RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptio * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). */ -ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions, context, x, y) { +_ol_style_RegularShape_.prototype.drawHitDetectionCanvas_ = function(renderOptions, context, x, y) { // reset transform context.setTransform(1, 0, 0, 1, 0, 0); @@ -531,7 +532,7 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions } } - context.fillStyle = ol.render.canvas.defaultFillStyle; + context.fillStyle = _ol_render_canvas_.defaultFillStyle; context.fill(); if (this.stroke_) { context.strokeStyle = renderOptions.strokeStyle; @@ -549,7 +550,7 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions /** * @return {string} The checksum. */ -ol.style.RegularShape.prototype.getChecksum = function() { +_ol_style_RegularShape_.prototype.getChecksum = function() { var strokeChecksum = this.stroke_ ? this.stroke_.getChecksum() : '-'; var fillChecksum = this.fill_ ? @@ -575,3 +576,4 @@ ol.style.RegularShape.prototype.getChecksum = function() { return this.checksums_[0]; }; +export default _ol_style_RegularShape_; diff --git a/src/ol/style/Stroke.js b/src/ol/style/Stroke.js index 73b3645dd9..0ff0f6041e 100644 --- a/src/ol/style/Stroke.js +++ b/src/ol/style/Stroke.js @@ -1,7 +1,7 @@ -goog.provide('ol.style.Stroke'); - -goog.require('ol'); - +/** + * @module ol/style/Stroke + */ +import _ol_ from '../index.js'; /** * @classdesc @@ -14,7 +14,7 @@ goog.require('ol'); * @param {olx.style.StrokeOptions=} opt_options Options. * @api */ -ol.style.Stroke = function(opt_options) { +var _ol_style_Stroke_ = function(opt_options) { var options = opt_options || {}; @@ -73,9 +73,9 @@ ol.style.Stroke = function(opt_options) { * @return {ol.style.Stroke} The cloned style. * @api */ -ol.style.Stroke.prototype.clone = function() { +_ol_style_Stroke_.prototype.clone = function() { var color = this.getColor(); - return new ol.style.Stroke({ + return new _ol_style_Stroke_({ color: (color && color.slice) ? color.slice() : color || undefined, lineCap: this.getLineCap(), lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined, @@ -92,7 +92,7 @@ ol.style.Stroke.prototype.clone = function() { * @return {ol.Color|ol.ColorLike} Color. * @api */ -ol.style.Stroke.prototype.getColor = function() { +_ol_style_Stroke_.prototype.getColor = function() { return this.color_; }; @@ -102,7 +102,7 @@ ol.style.Stroke.prototype.getColor = function() { * @return {string|undefined} Line cap. * @api */ -ol.style.Stroke.prototype.getLineCap = function() { +_ol_style_Stroke_.prototype.getLineCap = function() { return this.lineCap_; }; @@ -112,7 +112,7 @@ ol.style.Stroke.prototype.getLineCap = function() { * @return {Array.} Line dash. * @api */ -ol.style.Stroke.prototype.getLineDash = function() { +_ol_style_Stroke_.prototype.getLineDash = function() { return this.lineDash_; }; @@ -122,7 +122,7 @@ ol.style.Stroke.prototype.getLineDash = function() { * @return {number|undefined} Line dash offset. * @api */ -ol.style.Stroke.prototype.getLineDashOffset = function() { +_ol_style_Stroke_.prototype.getLineDashOffset = function() { return this.lineDashOffset_; }; @@ -132,7 +132,7 @@ ol.style.Stroke.prototype.getLineDashOffset = function() { * @return {string|undefined} Line join. * @api */ -ol.style.Stroke.prototype.getLineJoin = function() { +_ol_style_Stroke_.prototype.getLineJoin = function() { return this.lineJoin_; }; @@ -142,7 +142,7 @@ ol.style.Stroke.prototype.getLineJoin = function() { * @return {number|undefined} Miter limit. * @api */ -ol.style.Stroke.prototype.getMiterLimit = function() { +_ol_style_Stroke_.prototype.getMiterLimit = function() { return this.miterLimit_; }; @@ -152,7 +152,7 @@ ol.style.Stroke.prototype.getMiterLimit = function() { * @return {number|undefined} Width. * @api */ -ol.style.Stroke.prototype.getWidth = function() { +_ol_style_Stroke_.prototype.getWidth = function() { return this.width_; }; @@ -163,7 +163,7 @@ ol.style.Stroke.prototype.getWidth = function() { * @param {ol.Color|ol.ColorLike} color Color. * @api */ -ol.style.Stroke.prototype.setColor = function(color) { +_ol_style_Stroke_.prototype.setColor = function(color) { this.color_ = color; this.checksum_ = undefined; }; @@ -175,7 +175,7 @@ ol.style.Stroke.prototype.setColor = function(color) { * @param {string|undefined} lineCap Line cap. * @api */ -ol.style.Stroke.prototype.setLineCap = function(lineCap) { +_ol_style_Stroke_.prototype.setLineCap = function(lineCap) { this.lineCap_ = lineCap; this.checksum_ = undefined; }; @@ -193,7 +193,7 @@ ol.style.Stroke.prototype.setLineCap = function(lineCap) { * @param {Array.} lineDash Line dash. * @api */ -ol.style.Stroke.prototype.setLineDash = function(lineDash) { +_ol_style_Stroke_.prototype.setLineDash = function(lineDash) { this.lineDash_ = lineDash; this.checksum_ = undefined; }; @@ -205,7 +205,7 @@ ol.style.Stroke.prototype.setLineDash = function(lineDash) { * @param {number|undefined} lineDashOffset Line dash offset. * @api */ -ol.style.Stroke.prototype.setLineDashOffset = function(lineDashOffset) { +_ol_style_Stroke_.prototype.setLineDashOffset = function(lineDashOffset) { this.lineDashOffset_ = lineDashOffset; this.checksum_ = undefined; }; @@ -217,7 +217,7 @@ ol.style.Stroke.prototype.setLineDashOffset = function(lineDashOffset) { * @param {string|undefined} lineJoin Line join. * @api */ -ol.style.Stroke.prototype.setLineJoin = function(lineJoin) { +_ol_style_Stroke_.prototype.setLineJoin = function(lineJoin) { this.lineJoin_ = lineJoin; this.checksum_ = undefined; }; @@ -229,7 +229,7 @@ ol.style.Stroke.prototype.setLineJoin = function(lineJoin) { * @param {number|undefined} miterLimit Miter limit. * @api */ -ol.style.Stroke.prototype.setMiterLimit = function(miterLimit) { +_ol_style_Stroke_.prototype.setMiterLimit = function(miterLimit) { this.miterLimit_ = miterLimit; this.checksum_ = undefined; }; @@ -241,7 +241,7 @@ ol.style.Stroke.prototype.setMiterLimit = function(miterLimit) { * @param {number|undefined} width Width. * @api */ -ol.style.Stroke.prototype.setWidth = function(width) { +_ol_style_Stroke_.prototype.setWidth = function(width) { this.width_ = width; this.checksum_ = undefined; }; @@ -250,14 +250,14 @@ ol.style.Stroke.prototype.setWidth = function(width) { /** * @return {string} The checksum. */ -ol.style.Stroke.prototype.getChecksum = function() { +_ol_style_Stroke_.prototype.getChecksum = function() { if (this.checksum_ === undefined) { this.checksum_ = 's'; if (this.color_) { if (typeof this.color_ === 'string') { this.checksum_ += this.color_; } else { - this.checksum_ += ol.getUid(this.color_).toString(); + this.checksum_ += _ol_.getUid(this.color_).toString(); } } else { this.checksum_ += '-'; @@ -279,3 +279,4 @@ ol.style.Stroke.prototype.getChecksum = function() { return this.checksum_; }; +export default _ol_style_Stroke_; diff --git a/src/ol/style/Style.js b/src/ol/style/Style.js index 09dd93407f..5cca865250 100644 --- a/src/ol/style/Style.js +++ b/src/ol/style/Style.js @@ -1,11 +1,11 @@ -goog.provide('ol.style.Style'); - -goog.require('ol.asserts'); -goog.require('ol.geom.GeometryType'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); - +/** + * @module ol/style/Style + */ +import _ol_asserts_ from '../asserts.js'; +import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; +import _ol_style_Circle_ from '../style/Circle.js'; +import _ol_style_Fill_ from '../style/Fill.js'; +import _ol_style_Stroke_ from '../style/Stroke.js'; /** * @classdesc @@ -18,7 +18,7 @@ goog.require('ol.style.Stroke'); * @param {olx.style.StyleOptions=} opt_options Style options. * @api */ -ol.style.Style = function(opt_options) { +var _ol_style_Style_ = function(opt_options) { var options = opt_options || {}; @@ -32,7 +32,7 @@ ol.style.Style = function(opt_options) { * @private * @type {!ol.StyleGeometryFunction} */ - this.geometryFunction_ = ol.style.Style.defaultGeometryFunction; + this.geometryFunction_ = _ol_style_Style_.defaultGeometryFunction; if (options.geometry !== undefined) { this.setGeometry(options.geometry); @@ -82,12 +82,12 @@ ol.style.Style = function(opt_options) { * @return {ol.style.Style} The cloned style. * @api */ -ol.style.Style.prototype.clone = function() { +_ol_style_Style_.prototype.clone = function() { var geometry = this.getGeometry(); if (geometry && geometry.clone) { geometry = geometry.clone(); } - return new ol.style.Style({ + return new _ol_style_Style_({ geometry: geometry, fill: this.getFill() ? this.getFill().clone() : undefined, image: this.getImage() ? this.getImage().clone() : undefined, @@ -104,7 +104,7 @@ ol.style.Style.prototype.clone = function() { * @return {ol.StyleRenderFunction|null} Custom renderer function. * @api */ -ol.style.Style.prototype.getRenderer = function() { +_ol_style_Style_.prototype.getRenderer = function() { return this.renderer_; }; @@ -115,7 +115,7 @@ ol.style.Style.prototype.getRenderer = function() { * @param {ol.StyleRenderFunction|null} renderer Custom renderer function. * @api */ -ol.style.Style.prototype.setRenderer = function(renderer) { +_ol_style_Style_.prototype.setRenderer = function(renderer) { this.renderer_ = renderer; }; @@ -127,7 +127,7 @@ ol.style.Style.prototype.setRenderer = function(renderer) { * be rendered with this style. * @api */ -ol.style.Style.prototype.getGeometry = function() { +_ol_style_Style_.prototype.getGeometry = function() { return this.geometry_; }; @@ -138,7 +138,7 @@ ol.style.Style.prototype.getGeometry = function() { * and returns the geometry to render instead of the feature's geometry. * @api */ -ol.style.Style.prototype.getGeometryFunction = function() { +_ol_style_Style_.prototype.getGeometryFunction = function() { return this.geometryFunction_; }; @@ -148,7 +148,7 @@ ol.style.Style.prototype.getGeometryFunction = function() { * @return {ol.style.Fill} Fill style. * @api */ -ol.style.Style.prototype.getFill = function() { +_ol_style_Style_.prototype.getFill = function() { return this.fill_; }; @@ -158,7 +158,7 @@ ol.style.Style.prototype.getFill = function() { * @param {ol.style.Fill} fill Fill style. * @api */ -ol.style.Style.prototype.setFill = function(fill) { +_ol_style_Style_.prototype.setFill = function(fill) { this.fill_ = fill; }; @@ -168,7 +168,7 @@ ol.style.Style.prototype.setFill = function(fill) { * @return {ol.style.Image} Image style. * @api */ -ol.style.Style.prototype.getImage = function() { +_ol_style_Style_.prototype.getImage = function() { return this.image_; }; @@ -178,7 +178,7 @@ ol.style.Style.prototype.getImage = function() { * @param {ol.style.Image} image Image style. * @api */ -ol.style.Style.prototype.setImage = function(image) { +_ol_style_Style_.prototype.setImage = function(image) { this.image_ = image; }; @@ -188,7 +188,7 @@ ol.style.Style.prototype.setImage = function(image) { * @return {ol.style.Stroke} Stroke style. * @api */ -ol.style.Style.prototype.getStroke = function() { +_ol_style_Style_.prototype.getStroke = function() { return this.stroke_; }; @@ -198,7 +198,7 @@ ol.style.Style.prototype.getStroke = function() { * @param {ol.style.Stroke} stroke Stroke style. * @api */ -ol.style.Style.prototype.setStroke = function(stroke) { +_ol_style_Style_.prototype.setStroke = function(stroke) { this.stroke_ = stroke; }; @@ -208,7 +208,7 @@ ol.style.Style.prototype.setStroke = function(stroke) { * @return {ol.style.Text} Text style. * @api */ -ol.style.Style.prototype.getText = function() { +_ol_style_Style_.prototype.getText = function() { return this.text_; }; @@ -218,7 +218,7 @@ ol.style.Style.prototype.getText = function() { * @param {ol.style.Text} text Text style. * @api */ -ol.style.Style.prototype.setText = function(text) { +_ol_style_Style_.prototype.setText = function(text) { this.text_ = text; }; @@ -228,7 +228,7 @@ ol.style.Style.prototype.setText = function(text) { * @return {number|undefined} ZIndex. * @api */ -ol.style.Style.prototype.getZIndex = function() { +_ol_style_Style_.prototype.getZIndex = function() { return this.zIndex_; }; @@ -241,7 +241,7 @@ ol.style.Style.prototype.getZIndex = function() { * for this style. * @api */ -ol.style.Style.prototype.setGeometry = function(geometry) { +_ol_style_Style_.prototype.setGeometry = function(geometry) { if (typeof geometry === 'function') { this.geometryFunction_ = geometry; } else if (typeof geometry === 'string') { @@ -249,7 +249,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) { return /** @type {ol.geom.Geometry} */ (feature.get(geometry)); }; } else if (!geometry) { - this.geometryFunction_ = ol.style.Style.defaultGeometryFunction; + this.geometryFunction_ = _ol_style_Style_.defaultGeometryFunction; } else if (geometry !== undefined) { this.geometryFunction_ = function() { return /** @type {ol.geom.Geometry} */ (geometry); @@ -265,7 +265,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) { * @param {number|undefined} zIndex ZIndex. * @api */ -ol.style.Style.prototype.setZIndex = function(zIndex) { +_ol_style_Style_.prototype.setZIndex = function(zIndex) { this.zIndex_ = zIndex; }; @@ -278,7 +278,7 @@ ol.style.Style.prototype.setZIndex = function(zIndex) { * A style function, a single style, or an array of styles. * @return {ol.StyleFunction} A style function. */ -ol.style.Style.createFunction = function(obj) { +_ol_style_Style_.createFunction = function(obj) { var styleFunction; if (typeof obj === 'function') { @@ -291,7 +291,7 @@ ol.style.Style.createFunction = function(obj) { if (Array.isArray(obj)) { styles = obj; } else { - ol.asserts.assert(obj instanceof ol.style.Style, + _ol_asserts_.assert(obj instanceof _ol_style_Style_, 41); // Expected an `ol.style.Style` or an array of `ol.style.Style` styles = [obj]; } @@ -307,7 +307,7 @@ ol.style.Style.createFunction = function(obj) { * @type {Array.} * @private */ -ol.style.Style.default_ = null; +_ol_style_Style_.default_ = null; /** @@ -315,23 +315,23 @@ ol.style.Style.default_ = null; * @param {number} resolution Resolution. * @return {Array.} Style. */ -ol.style.Style.defaultFunction = function(feature, resolution) { +_ol_style_Style_.defaultFunction = function(feature, resolution) { // We don't use an immediately-invoked function // and a closure so we don't get an error at script evaluation time in // browsers that do not support Canvas. (ol.style.Circle does // canvas.getContext('2d') at construction time, which will cause an.error // in such browsers.) - if (!ol.style.Style.default_) { - var fill = new ol.style.Fill({ + if (!_ol_style_Style_.default_) { + var fill = new _ol_style_Fill_({ color: 'rgba(255,255,255,0.4)' }); - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: '#3399CC', width: 1.25 }); - ol.style.Style.default_ = [ - new ol.style.Style({ - image: new ol.style.Circle({ + _ol_style_Style_.default_ = [ + new _ol_style_Style_({ + image: new _ol_style_Circle_({ fill: fill, stroke: stroke, radius: 5 @@ -341,7 +341,7 @@ ol.style.Style.defaultFunction = function(feature, resolution) { }) ]; } - return ol.style.Style.default_; + return _ol_style_Style_.default_; }; @@ -349,53 +349,53 @@ ol.style.Style.defaultFunction = function(feature, resolution) { * Default styles for editing features. * @return {Object.>} Styles */ -ol.style.Style.createDefaultEditing = function() { +_ol_style_Style_.createDefaultEditing = function() { /** @type {Object.>} */ var styles = {}; var white = [255, 255, 255, 1]; var blue = [0, 153, 255, 1]; var width = 3; - styles[ol.geom.GeometryType.POLYGON] = [ - new ol.style.Style({ - fill: new ol.style.Fill({ + styles[_ol_geom_GeometryType_.POLYGON] = [ + new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: [255, 255, 255, 0.5] }) }) ]; - styles[ol.geom.GeometryType.MULTI_POLYGON] = - styles[ol.geom.GeometryType.POLYGON]; + styles[_ol_geom_GeometryType_.MULTI_POLYGON] = + styles[_ol_geom_GeometryType_.POLYGON]; - styles[ol.geom.GeometryType.LINE_STRING] = [ - new ol.style.Style({ - stroke: new ol.style.Stroke({ + styles[_ol_geom_GeometryType_.LINE_STRING] = [ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: white, width: width + 2 }) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({ + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: blue, width: width }) }) ]; - styles[ol.geom.GeometryType.MULTI_LINE_STRING] = - styles[ol.geom.GeometryType.LINE_STRING]; + styles[_ol_geom_GeometryType_.MULTI_LINE_STRING] = + styles[_ol_geom_GeometryType_.LINE_STRING]; - styles[ol.geom.GeometryType.CIRCLE] = - styles[ol.geom.GeometryType.POLYGON].concat( - styles[ol.geom.GeometryType.LINE_STRING] + styles[_ol_geom_GeometryType_.CIRCLE] = + styles[_ol_geom_GeometryType_.POLYGON].concat( + styles[_ol_geom_GeometryType_.LINE_STRING] ); - styles[ol.geom.GeometryType.POINT] = [ - new ol.style.Style({ - image: new ol.style.Circle({ + styles[_ol_geom_GeometryType_.POINT] = [ + new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: width * 2, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: blue }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: white, width: width / 2 }) @@ -403,13 +403,13 @@ ol.style.Style.createDefaultEditing = function() { zIndex: Infinity }) ]; - styles[ol.geom.GeometryType.MULTI_POINT] = - styles[ol.geom.GeometryType.POINT]; + styles[_ol_geom_GeometryType_.MULTI_POINT] = + styles[_ol_geom_GeometryType_.POINT]; - styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] = - styles[ol.geom.GeometryType.POLYGON].concat( - styles[ol.geom.GeometryType.LINE_STRING], - styles[ol.geom.GeometryType.POINT] + styles[_ol_geom_GeometryType_.GEOMETRY_COLLECTION] = + styles[_ol_geom_GeometryType_.POLYGON].concat( + styles[_ol_geom_GeometryType_.LINE_STRING], + styles[_ol_geom_GeometryType_.POINT] ); return styles; @@ -422,6 +422,7 @@ ol.style.Style.createDefaultEditing = function() { * for. * @return {ol.geom.Geometry|ol.render.Feature|undefined} Geometry to render. */ -ol.style.Style.defaultGeometryFunction = function(feature) { +_ol_style_Style_.defaultGeometryFunction = function(feature) { return feature.getGeometry(); }; +export default _ol_style_Style_; diff --git a/src/ol/style/Text.js b/src/ol/style/Text.js index 0a8ee5c9b5..13b90f1ca0 100644 --- a/src/ol/style/Text.js +++ b/src/ol/style/Text.js @@ -1,9 +1,8 @@ -goog.provide('ol.style.Text'); - - -goog.require('ol.style.Fill'); -goog.require('ol.style.TextPlacement'); - +/** + * @module ol/style/Text + */ +import _ol_style_Fill_ from '../style/Fill.js'; +import _ol_style_TextPlacement_ from '../style/TextPlacement.js'; /** * @classdesc @@ -13,7 +12,7 @@ goog.require('ol.style.TextPlacement'); * @param {olx.style.TextOptions=} opt_options Options. * @api */ -ol.style.Text = function(opt_options) { +var _ol_style_Text_ = function(opt_options) { var options = opt_options || {}; @@ -64,7 +63,7 @@ ol.style.Text = function(opt_options) { * @type {ol.style.Fill} */ this.fill_ = options.fill !== undefined ? options.fill : - new ol.style.Fill({color: ol.style.Text.DEFAULT_FILL_COLOR_}); + new _ol_style_Fill_({color: _ol_style_Text_.DEFAULT_FILL_COLOR_}); /** * @private @@ -76,7 +75,7 @@ ol.style.Text = function(opt_options) { * @private * @type {ol.style.TextPlacement|string} */ - this.placement_ = options.placement !== undefined ? options.placement : ol.style.TextPlacement.POINT; + this.placement_ = options.placement !== undefined ? options.placement : _ol_style_TextPlacement_.POINT; //TODO Use options.overflow directly after removing @deprecated exceedLength var overflow = options.overflow === undefined ? options.exceedLength : options.overflow; @@ -132,7 +131,7 @@ ol.style.Text = function(opt_options) { * @const {string} * @private */ -ol.style.Text.DEFAULT_FILL_COLOR_ = '#333'; +_ol_style_Text_.DEFAULT_FILL_COLOR_ = '#333'; /** @@ -140,8 +139,8 @@ ol.style.Text.DEFAULT_FILL_COLOR_ = '#333'; * @return {ol.style.Text} The cloned style. * @api */ -ol.style.Text.prototype.clone = function() { - return new ol.style.Text({ +_ol_style_Text_.prototype.clone = function() { + return new _ol_style_Text_({ font: this.getFont(), placement: this.getPlacement(), maxAngle: this.getMaxAngle(), @@ -165,7 +164,7 @@ ol.style.Text.prototype.clone = function() { * @return {boolean} Let text overflow the length of the path they follow. * @api */ -ol.style.Text.prototype.getOverflow = function() { +_ol_style_Text_.prototype.getOverflow = function() { return this.overflow_; }; @@ -175,7 +174,7 @@ ol.style.Text.prototype.getOverflow = function() { * @return {string|undefined} Font. * @api */ -ol.style.Text.prototype.getFont = function() { +_ol_style_Text_.prototype.getFont = function() { return this.font_; }; @@ -185,7 +184,7 @@ ol.style.Text.prototype.getFont = function() { * @return {number} Angle in radians. * @api */ -ol.style.Text.prototype.getMaxAngle = function() { +_ol_style_Text_.prototype.getMaxAngle = function() { return this.maxAngle_; }; @@ -195,7 +194,7 @@ ol.style.Text.prototype.getMaxAngle = function() { * @return {ol.style.TextPlacement|string} Text placement. * @api */ -ol.style.Text.prototype.getPlacement = function() { +_ol_style_Text_.prototype.getPlacement = function() { return this.placement_; }; @@ -205,7 +204,7 @@ ol.style.Text.prototype.getPlacement = function() { * @return {number} Horizontal text offset. * @api */ -ol.style.Text.prototype.getOffsetX = function() { +_ol_style_Text_.prototype.getOffsetX = function() { return this.offsetX_; }; @@ -215,7 +214,7 @@ ol.style.Text.prototype.getOffsetX = function() { * @return {number} Vertical text offset. * @api */ -ol.style.Text.prototype.getOffsetY = function() { +_ol_style_Text_.prototype.getOffsetY = function() { return this.offsetY_; }; @@ -225,7 +224,7 @@ ol.style.Text.prototype.getOffsetY = function() { * @return {ol.style.Fill} Fill style. * @api */ -ol.style.Text.prototype.getFill = function() { +_ol_style_Text_.prototype.getFill = function() { return this.fill_; }; @@ -235,7 +234,7 @@ ol.style.Text.prototype.getFill = function() { * @return {boolean|undefined} Rotate with map. * @api */ -ol.style.Text.prototype.getRotateWithView = function() { +_ol_style_Text_.prototype.getRotateWithView = function() { return this.rotateWithView_; }; @@ -245,7 +244,7 @@ ol.style.Text.prototype.getRotateWithView = function() { * @return {number|undefined} Rotation. * @api */ -ol.style.Text.prototype.getRotation = function() { +_ol_style_Text_.prototype.getRotation = function() { return this.rotation_; }; @@ -255,7 +254,7 @@ ol.style.Text.prototype.getRotation = function() { * @return {number|undefined} Scale. * @api */ -ol.style.Text.prototype.getScale = function() { +_ol_style_Text_.prototype.getScale = function() { return this.scale_; }; @@ -265,7 +264,7 @@ ol.style.Text.prototype.getScale = function() { * @return {ol.style.Stroke} Stroke style. * @api */ -ol.style.Text.prototype.getStroke = function() { +_ol_style_Text_.prototype.getStroke = function() { return this.stroke_; }; @@ -275,7 +274,7 @@ ol.style.Text.prototype.getStroke = function() { * @return {string|undefined} Text. * @api */ -ol.style.Text.prototype.getText = function() { +_ol_style_Text_.prototype.getText = function() { return this.text_; }; @@ -285,7 +284,7 @@ ol.style.Text.prototype.getText = function() { * @return {string|undefined} Text align. * @api */ -ol.style.Text.prototype.getTextAlign = function() { +_ol_style_Text_.prototype.getTextAlign = function() { return this.textAlign_; }; @@ -295,7 +294,7 @@ ol.style.Text.prototype.getTextAlign = function() { * @return {string|undefined} Text baseline. * @api */ -ol.style.Text.prototype.getTextBaseline = function() { +_ol_style_Text_.prototype.getTextBaseline = function() { return this.textBaseline_; }; @@ -305,7 +304,7 @@ ol.style.Text.prototype.getTextBaseline = function() { * @return {ol.style.Fill} Fill style. * @api */ -ol.style.Text.prototype.getBackgroundFill = function() { +_ol_style_Text_.prototype.getBackgroundFill = function() { return this.backgroundFill_; }; @@ -315,7 +314,7 @@ ol.style.Text.prototype.getBackgroundFill = function() { * @return {ol.style.Stroke} Stroke style. * @api */ -ol.style.Text.prototype.getBackgroundStroke = function() { +_ol_style_Text_.prototype.getBackgroundStroke = function() { return this.backgroundStroke_; }; @@ -325,7 +324,7 @@ ol.style.Text.prototype.getBackgroundStroke = function() { * @return {Array.} Padding. * @api */ -ol.style.Text.prototype.getPadding = function() { +_ol_style_Text_.prototype.getPadding = function() { return this.padding_; }; @@ -336,7 +335,7 @@ ol.style.Text.prototype.getPadding = function() { * @param {boolean} overflow Let text overflow the path that it follows. * @api */ -ol.style.Text.prototype.setOverflow = function(overflow) { +_ol_style_Text_.prototype.setOverflow = function(overflow) { this.overflow_ = overflow; }; @@ -347,7 +346,7 @@ ol.style.Text.prototype.setOverflow = function(overflow) { * @param {string|undefined} font Font. * @api */ -ol.style.Text.prototype.setFont = function(font) { +_ol_style_Text_.prototype.setFont = function(font) { this.font_ = font; }; @@ -358,7 +357,7 @@ ol.style.Text.prototype.setFont = function(font) { * @param {number} maxAngle Angle in radians. * @api */ -ol.style.Text.prototype.setMaxAngle = function(maxAngle) { +_ol_style_Text_.prototype.setMaxAngle = function(maxAngle) { this.maxAngle_ = maxAngle; }; @@ -369,7 +368,7 @@ ol.style.Text.prototype.setMaxAngle = function(maxAngle) { * @param {number} offsetX Horizontal text offset. * @api */ -ol.style.Text.prototype.setOffsetX = function(offsetX) { +_ol_style_Text_.prototype.setOffsetX = function(offsetX) { this.offsetX_ = offsetX; }; @@ -380,7 +379,7 @@ ol.style.Text.prototype.setOffsetX = function(offsetX) { * @param {number} offsetY Vertical text offset. * @api */ -ol.style.Text.prototype.setOffsetY = function(offsetY) { +_ol_style_Text_.prototype.setOffsetY = function(offsetY) { this.offsetY_ = offsetY; }; @@ -391,7 +390,7 @@ ol.style.Text.prototype.setOffsetY = function(offsetY) { * @param {ol.style.TextPlacement|string} placement Placement. * @api */ -ol.style.Text.prototype.setPlacement = function(placement) { +_ol_style_Text_.prototype.setPlacement = function(placement) { this.placement_ = placement; }; @@ -402,7 +401,7 @@ ol.style.Text.prototype.setPlacement = function(placement) { * @param {ol.style.Fill} fill Fill style. * @api */ -ol.style.Text.prototype.setFill = function(fill) { +_ol_style_Text_.prototype.setFill = function(fill) { this.fill_ = fill; }; @@ -413,7 +412,7 @@ ol.style.Text.prototype.setFill = function(fill) { * @param {number|undefined} rotation Rotation. * @api */ -ol.style.Text.prototype.setRotation = function(rotation) { +_ol_style_Text_.prototype.setRotation = function(rotation) { this.rotation_ = rotation; }; @@ -424,7 +423,7 @@ ol.style.Text.prototype.setRotation = function(rotation) { * @param {number|undefined} scale Scale. * @api */ -ol.style.Text.prototype.setScale = function(scale) { +_ol_style_Text_.prototype.setScale = function(scale) { this.scale_ = scale; }; @@ -435,7 +434,7 @@ ol.style.Text.prototype.setScale = function(scale) { * @param {ol.style.Stroke} stroke Stroke style. * @api */ -ol.style.Text.prototype.setStroke = function(stroke) { +_ol_style_Text_.prototype.setStroke = function(stroke) { this.stroke_ = stroke; }; @@ -446,7 +445,7 @@ ol.style.Text.prototype.setStroke = function(stroke) { * @param {string|undefined} text Text. * @api */ -ol.style.Text.prototype.setText = function(text) { +_ol_style_Text_.prototype.setText = function(text) { this.text_ = text; }; @@ -457,7 +456,7 @@ ol.style.Text.prototype.setText = function(text) { * @param {string|undefined} textAlign Text align. * @api */ -ol.style.Text.prototype.setTextAlign = function(textAlign) { +_ol_style_Text_.prototype.setTextAlign = function(textAlign) { this.textAlign_ = textAlign; }; @@ -468,7 +467,7 @@ ol.style.Text.prototype.setTextAlign = function(textAlign) { * @param {string|undefined} textBaseline Text baseline. * @api */ -ol.style.Text.prototype.setTextBaseline = function(textBaseline) { +_ol_style_Text_.prototype.setTextBaseline = function(textBaseline) { this.textBaseline_ = textBaseline; }; @@ -479,7 +478,7 @@ ol.style.Text.prototype.setTextBaseline = function(textBaseline) { * @param {ol.style.Fill} fill Fill style. * @api */ -ol.style.Text.prototype.setBackgroundFill = function(fill) { +_ol_style_Text_.prototype.setBackgroundFill = function(fill) { this.backgroundFill_ = fill; }; @@ -490,7 +489,7 @@ ol.style.Text.prototype.setBackgroundFill = function(fill) { * @param {ol.style.Stroke} stroke Stroke style. * @api */ -ol.style.Text.prototype.setBackgroundStroke = function(stroke) { +_ol_style_Text_.prototype.setBackgroundStroke = function(stroke) { this.backgroundStroke_ = stroke; }; @@ -501,6 +500,7 @@ ol.style.Text.prototype.setBackgroundStroke = function(stroke) { * @param {!Array.} padding Padding. * @api */ -ol.style.Text.prototype.setPadding = function(padding) { +_ol_style_Text_.prototype.setPadding = function(padding) { this.padding_ = padding; }; +export default _ol_style_Text_; diff --git a/src/ol/style/TextPlacement.js b/src/ol/style/TextPlacement.js index 39c45e06b4..636863f8e0 100644 --- a/src/ol/style/TextPlacement.js +++ b/src/ol/style/TextPlacement.js @@ -1,6 +1,6 @@ -goog.provide('ol.style.TextPlacement'); - - +/** + * @module ol/style/TextPlacement + */ /** * Text placement. One of `'point'`, `'line'`. Default is `'point'`. Note that * `'line'` requires the underlying geometry to be a {@link ol.geom.LineString}, @@ -8,7 +8,9 @@ goog.provide('ol.style.TextPlacement'); * {@link ol.geom.MultiPolygon}. * @enum {string} */ -ol.style.TextPlacement = { +var _ol_style_TextPlacement_ = { POINT: 'point', LINE: 'line' }; + +export default _ol_style_TextPlacement_; diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index 63740f7535..d9d100e5c6 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -1,4 +1,7 @@ -goog.provide('ol.tilecoord'); +/** + * @module ol/tilecoord + */ +var _ol_tilecoord_ = {}; /** @@ -8,7 +11,7 @@ goog.provide('ol.tilecoord'); * @param {ol.TileCoord=} opt_tileCoord Tile coordinate. * @return {ol.TileCoord} Tile coordinate. */ -ol.tilecoord.createOrUpdate = function(z, x, y, opt_tileCoord) { +_ol_tilecoord_.createOrUpdate = function(z, x, y, opt_tileCoord) { if (opt_tileCoord !== undefined) { opt_tileCoord[0] = z; opt_tileCoord[1] = x; @@ -26,7 +29,7 @@ ol.tilecoord.createOrUpdate = function(z, x, y, opt_tileCoord) { * @param {number} y Y. * @return {string} Key. */ -ol.tilecoord.getKeyZXY = function(z, x, y) { +_ol_tilecoord_.getKeyZXY = function(z, x, y) { return z + '/' + x + '/' + y; }; @@ -36,8 +39,8 @@ ol.tilecoord.getKeyZXY = function(z, x, y) { * @param {ol.TileCoord} tileCoord The tile coord. * @return {string} Key. */ -ol.tilecoord.getKey = function(tileCoord) { - return ol.tilecoord.getKeyZXY(tileCoord[0], tileCoord[1], tileCoord[2]); +_ol_tilecoord_.getKey = function(tileCoord) { + return _ol_tilecoord_.getKeyZXY(tileCoord[0], tileCoord[1], tileCoord[2]); }; @@ -46,7 +49,7 @@ ol.tilecoord.getKey = function(tileCoord) { * @param {string} key The tile coord key. * @return {ol.TileCoord} The tile coord. */ -ol.tilecoord.fromKey = function(key) { +_ol_tilecoord_.fromKey = function(key) { return key.split('/').map(Number); }; @@ -55,7 +58,7 @@ ol.tilecoord.fromKey = function(key) { * @param {ol.TileCoord} tileCoord Tile coord. * @return {number} Hash. */ -ol.tilecoord.hash = function(tileCoord) { +_ol_tilecoord_.hash = function(tileCoord) { return (tileCoord[1] << tileCoord[0]) + tileCoord[2]; }; @@ -64,7 +67,7 @@ ol.tilecoord.hash = function(tileCoord) { * @param {ol.TileCoord} tileCoord Tile coord. * @return {string} Quad key. */ -ol.tilecoord.quadKey = function(tileCoord) { +_ol_tilecoord_.quadKey = function(tileCoord) { var z = tileCoord[0]; var digits = new Array(z); var mask = 1 << (z - 1); @@ -90,7 +93,7 @@ ol.tilecoord.quadKey = function(tileCoord) { * @param {!ol.tilegrid.TileGrid} tileGrid Tile grid. * @return {boolean} Tile coordinate is within extent and zoom level range. */ -ol.tilecoord.withinExtentAndZ = function(tileCoord, tileGrid) { +_ol_tilecoord_.withinExtentAndZ = function(tileCoord, tileGrid) { var z = tileCoord[0]; var x = tileCoord[1]; var y = tileCoord[2]; @@ -111,3 +114,4 @@ ol.tilecoord.withinExtentAndZ = function(tileCoord, tileGrid) { return tileRange.containsXY(x, y); } }; +export default _ol_tilecoord_; diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index fe5aa7397d..7b4edccbec 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -1,23 +1,25 @@ -goog.provide('ol.tilegrid'); - -goog.require('ol'); -goog.require('ol.size'); -goog.require('ol.extent'); -goog.require('ol.extent.Corner'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.proj.Units'); -goog.require('ol.tilegrid.TileGrid'); +/** + * @module ol/tilegrid + */ +import _ol_ from './index.js'; +import _ol_size_ from './size.js'; +import _ol_extent_ from './extent.js'; +import _ol_extent_Corner_ from './extent/Corner.js'; +import _ol_obj_ from './obj.js'; +import _ol_proj_ from './proj.js'; +import _ol_proj_Units_ from './proj/Units.js'; +import _ol_tilegrid_TileGrid_ from './tilegrid/TileGrid.js'; +var _ol_tilegrid_ = {}; /** * @param {ol.proj.Projection} projection Projection. * @return {!ol.tilegrid.TileGrid} Default tile grid for the passed projection. */ -ol.tilegrid.getForProjection = function(projection) { +_ol_tilegrid_.getForProjection = function(projection) { var tileGrid = projection.getDefaultTileGrid(); if (!tileGrid) { - tileGrid = ol.tilegrid.createForProjection(projection); + tileGrid = _ol_tilegrid_.createForProjection(projection); projection.setDefaultTileGrid(tileGrid); } return tileGrid; @@ -30,12 +32,12 @@ ol.tilegrid.getForProjection = function(projection) { * @param {ol.proj.Projection} projection Projection. * @return {ol.TileCoord} Tile coordinate. */ -ol.tilegrid.wrapX = function(tileGrid, tileCoord, projection) { +_ol_tilegrid_.wrapX = function(tileGrid, tileCoord, projection) { var z = tileCoord[0]; var center = tileGrid.getTileCoordCenter(tileCoord); - var projectionExtent = ol.tilegrid.extentFromProjection(projection); - if (!ol.extent.containsCoordinate(projectionExtent, center)) { - var worldWidth = ol.extent.getWidth(projectionExtent); + var projectionExtent = _ol_tilegrid_.extentFromProjection(projection); + if (!_ol_extent_.containsCoordinate(projectionExtent, center)) { + var worldWidth = _ol_extent_.getWidth(projectionExtent); var worldsAway = Math.ceil((projectionExtent[0] - center[0]) / worldWidth); center[0] += worldWidth * worldsAway; return tileGrid.getTileCoordForCoordAndZ(center, z); @@ -55,16 +57,16 @@ ol.tilegrid.wrapX = function(tileGrid, tileCoord, projection) { * ol.extent.Corner.TOP_LEFT). * @return {!ol.tilegrid.TileGrid} TileGrid instance. */ -ol.tilegrid.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_corner) { +_ol_tilegrid_.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_corner) { var corner = opt_corner !== undefined ? - opt_corner : ol.extent.Corner.TOP_LEFT; + opt_corner : _ol_extent_Corner_.TOP_LEFT; - var resolutions = ol.tilegrid.resolutionsFromExtent( + var resolutions = _ol_tilegrid_.resolutionsFromExtent( extent, opt_maxZoom, opt_tileSize); - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ extent: extent, - origin: ol.extent.getCorner(extent, corner), + origin: _ol_extent_.getCorner(extent, corner), resolutions: resolutions, tileSize: opt_tileSize }); @@ -77,18 +79,18 @@ ol.tilegrid.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_co * @return {!ol.tilegrid.TileGrid} Tile grid instance. * @api */ -ol.tilegrid.createXYZ = function(opt_options) { +_ol_tilegrid_.createXYZ = function(opt_options) { var options = /** @type {olx.tilegrid.TileGridOptions} */ ({}); - ol.obj.assign(options, opt_options !== undefined ? + _ol_obj_.assign(options, opt_options !== undefined ? opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); if (options.extent === undefined) { - options.extent = ol.proj.get('EPSG:3857').getExtent(); + options.extent = _ol_proj_.get('EPSG:3857').getExtent(); } - options.resolutions = ol.tilegrid.resolutionsFromExtent( + options.resolutions = _ol_tilegrid_.resolutionsFromExtent( options.extent, options.maxZoom, options.tileSize); delete options.maxZoom; - return new ol.tilegrid.TileGrid(options); + return new _ol_tilegrid_TileGrid_(options); }; @@ -101,15 +103,15 @@ ol.tilegrid.createXYZ = function(opt_options) { * ol.DEFAULT_TILE_SIZE). * @return {!Array.} Resolutions array. */ -ol.tilegrid.resolutionsFromExtent = function(extent, opt_maxZoom, opt_tileSize) { +_ol_tilegrid_.resolutionsFromExtent = function(extent, opt_maxZoom, opt_tileSize) { var maxZoom = opt_maxZoom !== undefined ? - opt_maxZoom : ol.DEFAULT_MAX_ZOOM; + opt_maxZoom : _ol_.DEFAULT_MAX_ZOOM; - var height = ol.extent.getHeight(extent); - var width = ol.extent.getWidth(extent); + var height = _ol_extent_.getHeight(extent); + var width = _ol_extent_.getWidth(extent); - var tileSize = ol.size.toSize(opt_tileSize !== undefined ? - opt_tileSize : ol.DEFAULT_TILE_SIZE); + var tileSize = _ol_size_.toSize(opt_tileSize !== undefined ? + opt_tileSize : _ol_.DEFAULT_TILE_SIZE); var maxResolution = Math.max( width / tileSize[0], height / tileSize[1]); @@ -132,9 +134,9 @@ ol.tilegrid.resolutionsFromExtent = function(extent, opt_maxZoom, opt_tileSize) * ol.extent.Corner.BOTTOM_LEFT). * @return {!ol.tilegrid.TileGrid} TileGrid instance. */ -ol.tilegrid.createForProjection = function(projection, opt_maxZoom, opt_tileSize, opt_corner) { - var extent = ol.tilegrid.extentFromProjection(projection); - return ol.tilegrid.createForExtent( +_ol_tilegrid_.createForProjection = function(projection, opt_maxZoom, opt_tileSize, opt_corner) { + var extent = _ol_tilegrid_.extentFromProjection(projection); + return _ol_tilegrid_.createForExtent( extent, opt_maxZoom, opt_tileSize, opt_corner); }; @@ -145,13 +147,14 @@ ol.tilegrid.createForProjection = function(projection, opt_maxZoom, opt_tileSize * @param {ol.ProjectionLike} projection Projection. * @return {ol.Extent} Extent. */ -ol.tilegrid.extentFromProjection = function(projection) { - projection = ol.proj.get(projection); +_ol_tilegrid_.extentFromProjection = function(projection) { + projection = _ol_proj_.get(projection); var extent = projection.getExtent(); if (!extent) { - var half = 180 * ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES] / + var half = 180 * _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES] / projection.getMetersPerUnit(); - extent = ol.extent.createOrUpdate(-half, -half, half, half); + extent = _ol_extent_.createOrUpdate(-half, -half, half, half); } return extent; }; +export default _ol_tilegrid_; diff --git a/src/ol/tilegrid/TileGrid.js b/src/ol/tilegrid/TileGrid.js index bc933cf28c..8c83add519 100644 --- a/src/ol/tilegrid/TileGrid.js +++ b/src/ol/tilegrid/TileGrid.js @@ -1,14 +1,14 @@ -goog.provide('ol.tilegrid.TileGrid'); - -goog.require('ol'); -goog.require('ol.asserts'); -goog.require('ol.TileRange'); -goog.require('ol.array'); -goog.require('ol.extent'); -goog.require('ol.math'); -goog.require('ol.size'); -goog.require('ol.tilecoord'); - +/** + * @module ol/tilegrid/TileGrid + */ +import _ol_ from '../index.js'; +import _ol_asserts_ from '../asserts.js'; +import _ol_TileRange_ from '../TileRange.js'; +import _ol_array_ from '../array.js'; +import _ol_extent_ from '../extent.js'; +import _ol_math_ from '../math.js'; +import _ol_size_ from '../size.js'; +import _ol_tilecoord_ from '../tilecoord.js'; /** * @classdesc @@ -20,7 +20,7 @@ goog.require('ol.tilecoord'); * @struct * @api */ -ol.tilegrid.TileGrid = function(options) { +var _ol_tilegrid_TileGrid_ = function(options) { /** * @protected @@ -33,7 +33,7 @@ ol.tilegrid.TileGrid = function(options) { * @type {!Array.} */ this.resolutions_ = options.resolutions; - ol.asserts.assert(ol.array.isSorted(this.resolutions_, function(a, b) { + _ol_asserts_.assert(_ol_array_.isSorted(this.resolutions_, function(a, b) { return b - a; }, true), 17); // `resolutions` must be sorted in descending order @@ -80,7 +80,7 @@ ol.tilegrid.TileGrid = function(options) { this.origins_ = null; if (options.origins !== undefined) { this.origins_ = options.origins; - ol.asserts.assert(this.origins_.length == this.resolutions_.length, + _ol_asserts_.assert(this.origins_.length == this.resolutions_.length, 20); // Number of `origins` and `resolutions` must be equal } @@ -88,10 +88,10 @@ ol.tilegrid.TileGrid = function(options) { if (extent !== undefined && !this.origin_ && !this.origins_) { - this.origin_ = ol.extent.getTopLeft(extent); + this.origin_ = _ol_extent_.getTopLeft(extent); } - ol.asserts.assert( + _ol_asserts_.assert( (!this.origin_ && this.origins_) || (this.origin_ && !this.origins_), 18); // Either `origin` or `origins` must be configured, never both @@ -102,7 +102,7 @@ ol.tilegrid.TileGrid = function(options) { this.tileSizes_ = null; if (options.tileSizes !== undefined) { this.tileSizes_ = options.tileSizes; - ol.asserts.assert(this.tileSizes_.length == this.resolutions_.length, + _ol_asserts_.assert(this.tileSizes_.length == this.resolutions_.length, 19); // Number of `tileSizes` and `resolutions` must be equal } @@ -112,8 +112,8 @@ ol.tilegrid.TileGrid = function(options) { */ this.tileSize_ = options.tileSize !== undefined ? options.tileSize : - !this.tileSizes_ ? ol.DEFAULT_TILE_SIZE : null; - ol.asserts.assert( + !this.tileSizes_ ? _ol_.DEFAULT_TILE_SIZE : null; + _ol_asserts_.assert( (!this.tileSize_ && this.tileSizes_) || (this.tileSize_ && !this.tileSizes_), 22); // Either `tileSize` or `tileSizes` must be configured, never both @@ -139,7 +139,7 @@ ol.tilegrid.TileGrid = function(options) { if (options.sizes !== undefined) { this.fullTileRanges_ = options.sizes.map(function(size, z) { - var tileRange = new ol.TileRange( + var tileRange = new _ol_TileRange_( Math.min(0, size[0]), Math.max(size[0] - 1, -1), Math.min(0, size[1]), Math.max(size[1] - 1, -1)); return tileRange; @@ -155,7 +155,7 @@ ol.tilegrid.TileGrid = function(options) { * @private * @type {ol.TileCoord} */ -ol.tilegrid.TileGrid.tmpTileCoord_ = [0, 0, 0]; +_ol_tilegrid_TileGrid_.tmpTileCoord_ = [0, 0, 0]; /** @@ -166,7 +166,7 @@ ol.tilegrid.TileGrid.tmpTileCoord_ = [0, 0, 0]; * @param {function(ol.TileCoord)} callback Function called with each tile coordinate. * @api */ -ol.tilegrid.TileGrid.prototype.forEachTileCoord = function(extent, zoom, callback) { +_ol_tilegrid_TileGrid_.prototype.forEachTileCoord = function(extent, zoom, callback) { var tileRange = this.getTileRangeForExtentAndZ(extent, zoom); for (var i = tileRange.minX, ii = tileRange.maxX; i <= ii; ++i) { for (var j = tileRange.minY, jj = tileRange.maxY; j <= jj; ++j) { @@ -185,7 +185,7 @@ ol.tilegrid.TileGrid.prototype.forEachTileCoord = function(extent, zoom, callbac * @return {boolean} Callback succeeded. * @template T */ -ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCoord, callback, opt_this, opt_tileRange, opt_extent) { +_ol_tilegrid_TileGrid_.prototype.forEachTileCoordParentTileRange = function(tileCoord, callback, opt_this, opt_tileRange, opt_extent) { var tileRange, x, y; var tileCoordExtent = null; var z = tileCoord[0] - 1; @@ -199,7 +199,7 @@ ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCo if (this.zoomFactor_ === 2) { x = Math.floor(x / 2); y = Math.floor(y / 2); - tileRange = ol.TileRange.createOrUpdate(x, x, y, y, opt_tileRange); + tileRange = _ol_TileRange_.createOrUpdate(x, x, y, y, opt_tileRange); } else { tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange); } @@ -216,7 +216,7 @@ ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCo * Get the extent for this tile grid, if it was configured. * @return {ol.Extent} Extent. */ -ol.tilegrid.TileGrid.prototype.getExtent = function() { +_ol_tilegrid_TileGrid_.prototype.getExtent = function() { return this.extent_; }; @@ -226,7 +226,7 @@ ol.tilegrid.TileGrid.prototype.getExtent = function() { * @return {number} Max zoom. * @api */ -ol.tilegrid.TileGrid.prototype.getMaxZoom = function() { +_ol_tilegrid_TileGrid_.prototype.getMaxZoom = function() { return this.maxZoom; }; @@ -236,7 +236,7 @@ ol.tilegrid.TileGrid.prototype.getMaxZoom = function() { * @return {number} Min zoom. * @api */ -ol.tilegrid.TileGrid.prototype.getMinZoom = function() { +_ol_tilegrid_TileGrid_.prototype.getMinZoom = function() { return this.minZoom; }; @@ -247,7 +247,7 @@ ol.tilegrid.TileGrid.prototype.getMinZoom = function() { * @return {ol.Coordinate} Origin. * @api */ -ol.tilegrid.TileGrid.prototype.getOrigin = function(z) { +_ol_tilegrid_TileGrid_.prototype.getOrigin = function(z) { if (this.origin_) { return this.origin_; } else { @@ -262,7 +262,7 @@ ol.tilegrid.TileGrid.prototype.getOrigin = function(z) { * @return {number} Resolution. * @api */ -ol.tilegrid.TileGrid.prototype.getResolution = function(z) { +_ol_tilegrid_TileGrid_.prototype.getResolution = function(z) { return this.resolutions_[z]; }; @@ -272,7 +272,7 @@ ol.tilegrid.TileGrid.prototype.getResolution = function(z) { * @return {Array.} Resolutions. * @api */ -ol.tilegrid.TileGrid.prototype.getResolutions = function() { +_ol_tilegrid_TileGrid_.prototype.getResolutions = function() { return this.resolutions_; }; @@ -283,12 +283,12 @@ ol.tilegrid.TileGrid.prototype.getResolutions = function() { * @param {ol.Extent=} opt_extent Temporary ol.Extent object. * @return {ol.TileRange} Tile range. */ -ol.tilegrid.TileGrid.prototype.getTileCoordChildTileRange = function(tileCoord, opt_tileRange, opt_extent) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordChildTileRange = function(tileCoord, opt_tileRange, opt_extent) { if (tileCoord[0] < this.maxZoom) { if (this.zoomFactor_ === 2) { var minX = tileCoord[1] * 2; var minY = tileCoord[2] * 2; - return ol.TileRange.createOrUpdate(minX, minX + 1, minY, minY + 1, opt_tileRange); + return _ol_TileRange_.createOrUpdate(minX, minX + 1, minY, minY + 1, opt_tileRange); } var tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent); return this.getTileRangeForExtentAndZ( @@ -305,15 +305,15 @@ ol.tilegrid.TileGrid.prototype.getTileCoordChildTileRange = function(tileCoord, * @param {ol.Extent=} opt_extent Temporary ol.Extent object. * @return {ol.Extent} Extent. */ -ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange, opt_extent) { +_ol_tilegrid_TileGrid_.prototype.getTileRangeExtent = function(z, tileRange, opt_extent) { var origin = this.getOrigin(z); var resolution = this.getResolution(z); - var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_); + var tileSize = _ol_size_.toSize(this.getTileSize(z), this.tmpSize_); var minX = origin[0] + tileRange.minX * tileSize[0] * resolution; var maxX = origin[0] + (tileRange.maxX + 1) * tileSize[0] * resolution; var minY = origin[1] + tileRange.minY * tileSize[1] * resolution; var maxY = origin[1] + (tileRange.maxY + 1) * tileSize[1] * resolution; - return ol.extent.createOrUpdate(minX, minY, maxX, maxY, opt_extent); + return _ol_extent_.createOrUpdate(minX, minY, maxX, maxY, opt_extent); }; @@ -324,13 +324,13 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange, opt_e * @param {ol.TileRange=} opt_tileRange Temporary tile range object. * @return {ol.TileRange} Tile range. */ -ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z, opt_tileRange) { - var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_; +_ol_tilegrid_TileGrid_.prototype.getTileRangeForExtentAndZ = function(extent, z, opt_tileRange) { + var tileCoord = _ol_tilegrid_TileGrid_.tmpTileCoord_; this.getTileCoordForXYAndZ_(extent[0], extent[1], z, false, tileCoord); var minX = tileCoord[1]; var minY = tileCoord[2]; this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord); - return ol.TileRange.createOrUpdate( + return _ol_TileRange_.createOrUpdate( minX, tileCoord[1], minY, tileCoord[2], opt_tileRange); }; @@ -339,10 +339,10 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z, o * @param {ol.TileCoord} tileCoord Tile coordinate. * @return {ol.Coordinate} Tile center. */ -ol.tilegrid.TileGrid.prototype.getTileCoordCenter = function(tileCoord) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordCenter = function(tileCoord) { var origin = this.getOrigin(tileCoord[0]); var resolution = this.getResolution(tileCoord[0]); - var tileSize = ol.size.toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); + var tileSize = _ol_size_.toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); return [ origin[0] + (tileCoord[1] + 0.5) * tileSize[0] * resolution, origin[1] + (tileCoord[2] + 0.5) * tileSize[1] * resolution @@ -358,15 +358,15 @@ ol.tilegrid.TileGrid.prototype.getTileCoordCenter = function(tileCoord) { * @return {ol.Extent} Extent. * @api */ -ol.tilegrid.TileGrid.prototype.getTileCoordExtent = function(tileCoord, opt_extent) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordExtent = function(tileCoord, opt_extent) { var origin = this.getOrigin(tileCoord[0]); var resolution = this.getResolution(tileCoord[0]); - var tileSize = ol.size.toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); + var tileSize = _ol_size_.toSize(this.getTileSize(tileCoord[0]), this.tmpSize_); var minX = origin[0] + tileCoord[1] * tileSize[0] * resolution; var minY = origin[1] + tileCoord[2] * tileSize[1] * resolution; var maxX = minX + tileSize[0] * resolution; var maxY = minY + tileSize[1] * resolution; - return ol.extent.createOrUpdate(minX, minY, maxX, maxY, opt_extent); + return _ol_extent_.createOrUpdate(minX, minY, maxX, maxY, opt_extent); }; @@ -381,7 +381,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent = function(tileCoord, opt_exte * @return {ol.TileCoord} Tile coordinate. * @api */ -ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(coordinate, resolution, opt_tileCoord) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordForCoordAndResolution = function(coordinate, resolution, opt_tileCoord) { return this.getTileCoordForXYAndResolution_( coordinate[0], coordinate[1], resolution, false, opt_tileCoord); }; @@ -400,12 +400,12 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(coor * @return {ol.TileCoord} Tile coordinate. * @private */ -ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function( +_ol_tilegrid_TileGrid_.prototype.getTileCoordForXYAndResolution_ = function( x, y, resolution, reverseIntersectionPolicy, opt_tileCoord) { var z = this.getZForResolution(resolution); var scale = resolution / this.getResolution(z); var origin = this.getOrigin(z); - var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_); + var tileSize = _ol_size_.toSize(this.getTileSize(z), this.tmpSize_); var adjustX = reverseIntersectionPolicy ? 0.5 : 0; var adjustY = reverseIntersectionPolicy ? 0 : 0.5; @@ -422,7 +422,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function( tileCoordY = Math.floor(tileCoordY); } - return ol.tilecoord.createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord); + return _ol_tilecoord_.createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord); }; @@ -441,10 +441,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function( * @return {ol.TileCoord} Tile coordinate. * @private */ -ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndZ_ = function(x, y, z, reverseIntersectionPolicy, opt_tileCoord) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordForXYAndZ_ = function(x, y, z, reverseIntersectionPolicy, opt_tileCoord) { var origin = this.getOrigin(z); var resolution = this.getResolution(z); - var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_); + var tileSize = _ol_size_.toSize(this.getTileSize(z), this.tmpSize_); var adjustX = reverseIntersectionPolicy ? 0.5 : 0; var adjustY = reverseIntersectionPolicy ? 0 : 0.5; @@ -461,7 +461,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndZ_ = function(x, y, z, revers tileCoordY = Math.floor(tileCoordY); } - return ol.tilecoord.createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord); + return _ol_tilecoord_.createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord); }; @@ -473,7 +473,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndZ_ = function(x, y, z, revers * @return {ol.TileCoord} Tile coordinate. * @api */ -ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ = function(coordinate, z, opt_tileCoord) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordForCoordAndZ = function(coordinate, z, opt_tileCoord) { return this.getTileCoordForXYAndZ_( coordinate[0], coordinate[1], z, false, opt_tileCoord); }; @@ -483,7 +483,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ = function(coordinate, z * @param {ol.TileCoord} tileCoord Tile coordinate. * @return {number} Tile resolution. */ -ol.tilegrid.TileGrid.prototype.getTileCoordResolution = function(tileCoord) { +_ol_tilegrid_TileGrid_.prototype.getTileCoordResolution = function(tileCoord) { return this.resolutions_[tileCoord[0]]; }; @@ -496,7 +496,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordResolution = function(tileCoord) { * @return {number|ol.Size} Tile size. * @api */ -ol.tilegrid.TileGrid.prototype.getTileSize = function(z) { +_ol_tilegrid_TileGrid_.prototype.getTileSize = function(z) { if (this.tileSize_) { return this.tileSize_; } else { @@ -509,7 +509,7 @@ ol.tilegrid.TileGrid.prototype.getTileSize = function(z) { * @param {number} z Zoom level. * @return {ol.TileRange} Extent tile range for the specified zoom level. */ -ol.tilegrid.TileGrid.prototype.getFullTileRange = function(z) { +_ol_tilegrid_TileGrid_.prototype.getFullTileRange = function(z) { if (!this.fullTileRanges_) { return null; } else { @@ -526,11 +526,11 @@ ol.tilegrid.TileGrid.prototype.getFullTileRange = function(z) { * @return {number} Z. * @api */ -ol.tilegrid.TileGrid.prototype.getZForResolution = function( +_ol_tilegrid_TileGrid_.prototype.getZForResolution = function( resolution, opt_direction) { - var z = ol.array.linearFindNearest(this.resolutions_, resolution, + var z = _ol_array_.linearFindNearest(this.resolutions_, resolution, opt_direction || 0); - return ol.math.clamp(z, this.minZoom, this.maxZoom); + return _ol_math_.clamp(z, this.minZoom, this.maxZoom); }; @@ -538,7 +538,7 @@ ol.tilegrid.TileGrid.prototype.getZForResolution = function( * @param {!ol.Extent} extent Extent for this tile grid. * @private */ -ol.tilegrid.TileGrid.prototype.calculateTileRanges_ = function(extent) { +_ol_tilegrid_TileGrid_.prototype.calculateTileRanges_ = function(extent) { var length = this.resolutions_.length; var fullTileRanges = new Array(length); for (var z = this.minZoom; z < length; ++z) { @@ -546,3 +546,4 @@ ol.tilegrid.TileGrid.prototype.calculateTileRanges_ = function(extent) { } this.fullTileRanges_ = fullTileRanges; }; +export default _ol_tilegrid_TileGrid_; diff --git a/src/ol/tilegrid/WMTS.js b/src/ol/tilegrid/WMTS.js index c67ff01f18..80ed2fc946 100644 --- a/src/ol/tilegrid/WMTS.js +++ b/src/ol/tilegrid/WMTS.js @@ -1,10 +1,10 @@ -goog.provide('ol.tilegrid.WMTS'); - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.proj'); -goog.require('ol.tilegrid.TileGrid'); - +/** + * @module ol/tilegrid/WMTS + */ +import _ol_ from '../index.js'; +import _ol_array_ from '../array.js'; +import _ol_proj_ from '../proj.js'; +import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js'; /** * @classdesc @@ -16,7 +16,7 @@ goog.require('ol.tilegrid.TileGrid'); * @struct * @api */ -ol.tilegrid.WMTS = function(options) { +var _ol_tilegrid_WMTS_ = function(options) { /** * @private * @type {!Array.} @@ -24,7 +24,7 @@ ol.tilegrid.WMTS = function(options) { this.matrixIds_ = options.matrixIds; // FIXME: should the matrixIds become optional? - ol.tilegrid.TileGrid.call(this, { + _ol_tilegrid_TileGrid_.call(this, { extent: options.extent, origin: options.origin, origins: options.origins, @@ -34,14 +34,15 @@ ol.tilegrid.WMTS = function(options) { sizes: options.sizes }); }; -ol.inherits(ol.tilegrid.WMTS, ol.tilegrid.TileGrid); + +_ol_.inherits(_ol_tilegrid_WMTS_, _ol_tilegrid_TileGrid_); /** * @param {number} z Z. * @return {string} MatrixId.. */ -ol.tilegrid.WMTS.prototype.getMatrixId = function(z) { +_ol_tilegrid_WMTS_.prototype.getMatrixId = function(z) { return this.matrixIds_[z]; }; @@ -51,7 +52,7 @@ ol.tilegrid.WMTS.prototype.getMatrixId = function(z) { * @return {Array.} MatrixIds. * @api */ -ol.tilegrid.WMTS.prototype.getMatrixIds = function() { +_ol_tilegrid_WMTS_.prototype.getMatrixIds = function() { return this.matrixIds_; }; @@ -68,7 +69,7 @@ ol.tilegrid.WMTS.prototype.getMatrixIds = function() { * @return {ol.tilegrid.WMTS} WMTS tileGrid instance. * @api */ -ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_extent, +_ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet = function(matrixSet, opt_extent, opt_matrixLimits) { /** @type {!Array.} */ @@ -93,8 +94,8 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten var tileHeightPropName = 'TileHeight'; var code = matrixSet[supportedCRSPropName]; - var projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || - ol.proj.get(code); + var projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || + _ol_proj_.get(code); var metersPerUnit = projection.getMetersPerUnit(); // swap origin x and y coordinates if axis orientation is lat/long var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne'; @@ -109,7 +110,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten // use of matrixLimits to filter TileMatrices from GetCapabilities // TileMatrixSet from unavailable matrix levels. if (matrixLimits.length > 0) { - matrixAvailable = ol.array.find(matrixLimits, + matrixAvailable = _ol_array_.find(matrixLimits, function(elt_ml, index_ml, array_ml) { return elt[identifierPropName] == elt_ml[matrixIdsPropName]; }); @@ -136,7 +137,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten } }); - return new ol.tilegrid.WMTS({ + return new _ol_tilegrid_WMTS_({ extent: opt_extent, origins: origins, resolutions: resolutions, @@ -145,3 +146,4 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten sizes: sizes }); }; +export default _ol_tilegrid_WMTS_; diff --git a/src/ol/transform.js b/src/ol/transform.js index 356aae0392..54dbb3d9b9 100644 --- a/src/ol/transform.js +++ b/src/ol/transform.js @@ -1,6 +1,8 @@ -goog.provide('ol.transform'); - -goog.require('ol.asserts'); +/** + * @module ol/transform + */ +import _ol_asserts_ from './asserts.js'; +var _ol_transform_ = {}; /** @@ -20,14 +22,14 @@ goog.require('ol.asserts'); * @private * @type {ol.Transform} */ -ol.transform.tmp_ = new Array(6); +_ol_transform_.tmp_ = new Array(6); /** * Create an identity transform. * @return {!ol.Transform} Identity transform. */ -ol.transform.create = function() { +_ol_transform_.create = function() { return [1, 0, 0, 1, 0, 0]; }; @@ -37,8 +39,8 @@ ol.transform.create = function() { * @param {!ol.Transform} transform Transform. * @return {!ol.Transform} Transform. */ -ol.transform.reset = function(transform) { - return ol.transform.set(transform, 1, 0, 0, 1, 0, 0); +_ol_transform_.reset = function(transform) { + return _ol_transform_.set(transform, 1, 0, 0, 1, 0, 0); }; @@ -49,7 +51,7 @@ ol.transform.reset = function(transform) { * @param {!ol.Transform} transform2 Transform parameters of matrix 2. * @return {!ol.Transform} transform1 multiplied with transform2. */ -ol.transform.multiply = function(transform1, transform2) { +_ol_transform_.multiply = function(transform1, transform2) { var a1 = transform1[0]; var b1 = transform1[1]; var c1 = transform1[2]; @@ -84,7 +86,7 @@ ol.transform.multiply = function(transform1, transform2) { * @param {number} f The f component of the transform. * @return {!ol.Transform} Matrix with transform applied. */ -ol.transform.set = function(transform, a, b, c, d, e, f) { +_ol_transform_.set = function(transform, a, b, c, d, e, f) { transform[0] = a; transform[1] = b; transform[2] = c; @@ -101,7 +103,7 @@ ol.transform.set = function(transform, a, b, c, d, e, f) { * @param {!ol.Transform} transform2 Matrix to set transform from. * @return {!ol.Transform} transform1 with transform from transform2 applied. */ -ol.transform.setFromArray = function(transform1, transform2) { +_ol_transform_.setFromArray = function(transform1, transform2) { transform1[0] = transform2[0]; transform1[1] = transform2[1]; transform1[2] = transform2[2]; @@ -121,7 +123,7 @@ ol.transform.setFromArray = function(transform1, transform2) { * @return {ol.Coordinate|ol.Pixel} return coordinate so that operations can be * chained together. */ -ol.transform.apply = function(transform, coordinate) { +_ol_transform_.apply = function(transform, coordinate) { var x = coordinate[0], y = coordinate[1]; coordinate[0] = transform[0] * x + transform[2] * y + transform[4]; coordinate[1] = transform[1] * x + transform[3] * y + transform[5]; @@ -135,11 +137,11 @@ ol.transform.apply = function(transform, coordinate) { * @param {number} angle Angle in radians. * @return {!ol.Transform} The rotated transform. */ -ol.transform.rotate = function(transform, angle) { +_ol_transform_.rotate = function(transform, angle) { var cos = Math.cos(angle); var sin = Math.sin(angle); - return ol.transform.multiply(transform, - ol.transform.set(ol.transform.tmp_, cos, sin, -sin, cos, 0, 0)); + return _ol_transform_.multiply(transform, + _ol_transform_.set(_ol_transform_.tmp_, cos, sin, -sin, cos, 0, 0)); }; @@ -150,9 +152,9 @@ ol.transform.rotate = function(transform, angle) { * @param {number} y Scale factor y. * @return {!ol.Transform} The scaled transform. */ -ol.transform.scale = function(transform, x, y) { - return ol.transform.multiply(transform, - ol.transform.set(ol.transform.tmp_, x, 0, 0, y, 0, 0)); +_ol_transform_.scale = function(transform, x, y) { + return _ol_transform_.multiply(transform, + _ol_transform_.set(_ol_transform_.tmp_, x, 0, 0, y, 0, 0)); }; @@ -163,9 +165,9 @@ ol.transform.scale = function(transform, x, y) { * @param {number} dy Translation y. * @return {!ol.Transform} The translated transform. */ -ol.transform.translate = function(transform, dx, dy) { - return ol.transform.multiply(transform, - ol.transform.set(ol.transform.tmp_, 1, 0, 0, 1, dx, dy)); +_ol_transform_.translate = function(transform, dx, dy) { + return _ol_transform_.multiply(transform, + _ol_transform_.set(_ol_transform_.tmp_, 1, 0, 0, 1, dx, dy)); }; @@ -182,7 +184,7 @@ ol.transform.translate = function(transform, dx, dy) { * @param {number} dy2 Final translation y. * @return {!ol.Transform} The composite transform. */ -ol.transform.compose = function(transform, dx1, dy1, sx, sy, angle, dx2, dy2) { +_ol_transform_.compose = function(transform, dx1, dy1, sx, sy, angle, dx2, dy2) { var sin = Math.sin(angle); var cos = Math.cos(angle); transform[0] = sx * cos; @@ -200,9 +202,9 @@ ol.transform.compose = function(transform, dx1, dy1, sx, sy, angle, dx2, dy2) { * @param {!ol.Transform} transform Transform. * @return {!ol.Transform} Inverse of the transform. */ -ol.transform.invert = function(transform) { - var det = ol.transform.determinant(transform); - ol.asserts.assert(det !== 0, 32); // Transformation matrix cannot be inverted +_ol_transform_.invert = function(transform) { + var det = _ol_transform_.determinant(transform); + _ol_asserts_.assert(det !== 0, 32); // Transformation matrix cannot be inverted var a = transform[0]; var b = transform[1]; @@ -227,6 +229,7 @@ ol.transform.invert = function(transform) { * @param {!ol.Transform} mat Matrix. * @return {number} Determinant. */ -ol.transform.determinant = function(mat) { +_ol_transform_.determinant = function(mat) { return mat[0] * mat[3] - mat[1] * mat[2]; }; +export default _ol_transform_; diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 69aa608ff5..7163d6b873 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -1,3 +1,30 @@ +/** + * @module ol/typedefs + */ +/* eslint-disable openlayers-internal/no-missing-requires */ + +/** + * File for all typedefs used by the compiler, and referenced by JSDoc. + * + * These look like vars (or var properties), but in fact are simply identifiers + * for the Closure compiler. Originally they were included in the appropriate + * namespace file, but with the move away from Closure namespaces and towards + * self-contained standard modules are now all in this file. + * Unlike the other type definitions - enums and constructor functions - they + * are not code and so are not imported or exported. They are only referred to + * in type-defining comments used by the Closure compiler, and so should not + * appear in module code. + * + * They are now all in the `ol` namespace. + */ + + +/** + * @typedef {{x: number, y: number, width: number, height: number}} + */ +/** + * @module ol/typedefs + */ /* eslint-disable openlayers-internal/no-missing-requires */ /** diff --git a/src/ol/uri.js b/src/ol/uri.js index 387d4f5e96..b96f27a8c2 100644 --- a/src/ol/uri.js +++ b/src/ol/uri.js @@ -1,4 +1,7 @@ -goog.provide('ol.uri'); +/** + * @module ol/uri + */ +var _ol_uri_ = {}; /** @@ -9,7 +12,7 @@ goog.provide('ol.uri'); * and the values are arbitrary types or arrays. * @return {string} The new URI. */ -ol.uri.appendParams = function(uri, params) { +_ol_uri_.appendParams = function(uri, params) { var keyParams = []; // Skip any null or undefined parameter values Object.keys(params).forEach(function(k) { @@ -24,3 +27,4 @@ ol.uri.appendParams = function(uri, params) { uri = uri.indexOf('?') === -1 ? uri + '?' : uri + '&'; return uri + qs; }; +export default _ol_uri_; diff --git a/src/ol/vec/Mat4.js b/src/ol/vec/Mat4.js index 65dd22f1e4..dd662b3528 100644 --- a/src/ol/vec/Mat4.js +++ b/src/ol/vec/Mat4.js @@ -1,10 +1,13 @@ -goog.provide('ol.vec.Mat4'); +/** + * @module ol/vec/Mat4 + */ +var _ol_vec_Mat4_ = {}; /** * @return {Array.} 4x4 matrix representing a 3D identity transform. */ -ol.vec.Mat4.create = function() { +_ol_vec_Mat4_.create = function() { return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; }; @@ -14,7 +17,7 @@ ol.vec.Mat4.create = function() { * @param {ol.Transform} transform Transformation matrix. * @return {Array.} 2D transformation matrix as flattened 4x4 matrix. */ -ol.vec.Mat4.fromTransform = function(mat4, transform) { +_ol_vec_Mat4_.fromTransform = function(mat4, transform) { mat4[0] = transform[0]; mat4[1] = transform[1]; mat4[4] = transform[2]; @@ -23,3 +26,4 @@ ol.vec.Mat4.fromTransform = function(mat4, transform) { mat4[13] = transform[5]; return mat4; }; +export default _ol_vec_Mat4_; diff --git a/src/ol/webgl.js b/src/ol/webgl.js index 65580ce580..8b35027b6b 100644 --- a/src/ol/webgl.js +++ b/src/ol/webgl.js @@ -1,4 +1,7 @@ -goog.provide('ol.webgl'); +/** + * @module ol/webgl + */ +var _ol_webgl_ = {}; /** * Constants taken from goog.webgl @@ -9,245 +12,245 @@ goog.provide('ol.webgl'); * @const * @type {number} */ -ol.webgl.ONE = 1; +_ol_webgl_.ONE = 1; /** * @const * @type {number} */ -ol.webgl.SRC_ALPHA = 0x0302; +_ol_webgl_.SRC_ALPHA = 0x0302; /** * @const * @type {number} */ -ol.webgl.COLOR_ATTACHMENT0 = 0x8CE0; +_ol_webgl_.COLOR_ATTACHMENT0 = 0x8CE0; /** * @const * @type {number} */ -ol.webgl.COLOR_BUFFER_BIT = 0x00004000; +_ol_webgl_.COLOR_BUFFER_BIT = 0x00004000; /** * @const * @type {number} */ -ol.webgl.TRIANGLES = 0x0004; +_ol_webgl_.TRIANGLES = 0x0004; /** * @const * @type {number} */ -ol.webgl.TRIANGLE_STRIP = 0x0005; +_ol_webgl_.TRIANGLE_STRIP = 0x0005; /** * @const * @type {number} */ -ol.webgl.ONE_MINUS_SRC_ALPHA = 0x0303; +_ol_webgl_.ONE_MINUS_SRC_ALPHA = 0x0303; /** * @const * @type {number} */ -ol.webgl.ARRAY_BUFFER = 0x8892; +_ol_webgl_.ARRAY_BUFFER = 0x8892; /** * @const * @type {number} */ -ol.webgl.ELEMENT_ARRAY_BUFFER = 0x8893; +_ol_webgl_.ELEMENT_ARRAY_BUFFER = 0x8893; /** * @const * @type {number} */ -ol.webgl.STREAM_DRAW = 0x88E0; +_ol_webgl_.STREAM_DRAW = 0x88E0; /** * @const * @type {number} */ -ol.webgl.STATIC_DRAW = 0x88E4; +_ol_webgl_.STATIC_DRAW = 0x88E4; /** * @const * @type {number} */ -ol.webgl.DYNAMIC_DRAW = 0x88E8; +_ol_webgl_.DYNAMIC_DRAW = 0x88E8; /** * @const * @type {number} */ -ol.webgl.CULL_FACE = 0x0B44; +_ol_webgl_.CULL_FACE = 0x0B44; /** * @const * @type {number} */ -ol.webgl.BLEND = 0x0BE2; +_ol_webgl_.BLEND = 0x0BE2; /** * @const * @type {number} */ -ol.webgl.STENCIL_TEST = 0x0B90; +_ol_webgl_.STENCIL_TEST = 0x0B90; /** * @const * @type {number} */ -ol.webgl.DEPTH_TEST = 0x0B71; +_ol_webgl_.DEPTH_TEST = 0x0B71; /** * @const * @type {number} */ -ol.webgl.SCISSOR_TEST = 0x0C11; +_ol_webgl_.SCISSOR_TEST = 0x0C11; /** * @const * @type {number} */ -ol.webgl.UNSIGNED_BYTE = 0x1401; +_ol_webgl_.UNSIGNED_BYTE = 0x1401; /** * @const * @type {number} */ -ol.webgl.UNSIGNED_SHORT = 0x1403; +_ol_webgl_.UNSIGNED_SHORT = 0x1403; /** * @const * @type {number} */ -ol.webgl.UNSIGNED_INT = 0x1405; +_ol_webgl_.UNSIGNED_INT = 0x1405; /** * @const * @type {number} */ -ol.webgl.FLOAT = 0x1406; +_ol_webgl_.FLOAT = 0x1406; /** * @const * @type {number} */ -ol.webgl.RGBA = 0x1908; +_ol_webgl_.RGBA = 0x1908; /** * @const * @type {number} */ -ol.webgl.FRAGMENT_SHADER = 0x8B30; +_ol_webgl_.FRAGMENT_SHADER = 0x8B30; /** * @const * @type {number} */ -ol.webgl.VERTEX_SHADER = 0x8B31; +_ol_webgl_.VERTEX_SHADER = 0x8B31; /** * @const * @type {number} */ -ol.webgl.LINK_STATUS = 0x8B82; +_ol_webgl_.LINK_STATUS = 0x8B82; /** * @const * @type {number} */ -ol.webgl.LINEAR = 0x2601; +_ol_webgl_.LINEAR = 0x2601; /** * @const * @type {number} */ -ol.webgl.TEXTURE_MAG_FILTER = 0x2800; +_ol_webgl_.TEXTURE_MAG_FILTER = 0x2800; /** * @const * @type {number} */ -ol.webgl.TEXTURE_MIN_FILTER = 0x2801; +_ol_webgl_.TEXTURE_MIN_FILTER = 0x2801; /** * @const * @type {number} */ -ol.webgl.TEXTURE_WRAP_S = 0x2802; +_ol_webgl_.TEXTURE_WRAP_S = 0x2802; /** * @const * @type {number} */ -ol.webgl.TEXTURE_WRAP_T = 0x2803; +_ol_webgl_.TEXTURE_WRAP_T = 0x2803; /** * @const * @type {number} */ -ol.webgl.TEXTURE_2D = 0x0DE1; +_ol_webgl_.TEXTURE_2D = 0x0DE1; /** * @const * @type {number} */ -ol.webgl.TEXTURE0 = 0x84C0; +_ol_webgl_.TEXTURE0 = 0x84C0; /** * @const * @type {number} */ -ol.webgl.CLAMP_TO_EDGE = 0x812F; +_ol_webgl_.CLAMP_TO_EDGE = 0x812F; /** * @const * @type {number} */ -ol.webgl.COMPILE_STATUS = 0x8B81; +_ol_webgl_.COMPILE_STATUS = 0x8B81; /** * @const * @type {number} */ -ol.webgl.FRAMEBUFFER = 0x8D40; +_ol_webgl_.FRAMEBUFFER = 0x8D40; /** end of goog.webgl constants @@ -259,7 +262,7 @@ ol.webgl.FRAMEBUFFER = 0x8D40; * @private * @type {Array.} */ -ol.webgl.CONTEXT_IDS_ = [ +_ol_webgl_.CONTEXT_IDS_ = [ 'experimental-webgl', 'webgl', 'webkit-3d', @@ -272,11 +275,11 @@ ol.webgl.CONTEXT_IDS_ = [ * @param {Object=} opt_attributes Attributes. * @return {WebGLRenderingContext} WebGL rendering context. */ -ol.webgl.getContext = function(canvas, opt_attributes) { - var context, i, ii = ol.webgl.CONTEXT_IDS_.length; +_ol_webgl_.getContext = function(canvas, opt_attributes) { + var context, i, ii = _ol_webgl_.CONTEXT_IDS_.length; for (i = 0; i < ii; ++i) { try { - context = canvas.getContext(ol.webgl.CONTEXT_IDS_[i], opt_attributes); + context = canvas.getContext(_ol_webgl_.CONTEXT_IDS_[i], opt_attributes); if (context) { return /** @type {!WebGLRenderingContext} */ (context); } @@ -286,3 +289,4 @@ ol.webgl.getContext = function(canvas, opt_attributes) { } return null; }; +export default _ol_webgl_; diff --git a/src/ol/webgl/Buffer.js b/src/ol/webgl/Buffer.js index 01d624f948..d56f2c1a2d 100644 --- a/src/ol/webgl/Buffer.js +++ b/src/ol/webgl/Buffer.js @@ -1,7 +1,7 @@ -goog.provide('ol.webgl.Buffer'); - -goog.require('ol.webgl'); - +/** + * @module ol/webgl/Buffer + */ +import _ol_webgl_ from '../webgl.js'; /** * @constructor @@ -9,7 +9,7 @@ goog.require('ol.webgl'); * @param {number=} opt_usage Usage. * @struct */ -ol.webgl.Buffer = function(opt_arr, opt_usage) { +var _ol_webgl_Buffer_ = function(opt_arr, opt_usage) { /** * @private @@ -22,7 +22,7 @@ ol.webgl.Buffer = function(opt_arr, opt_usage) { * @type {number} */ this.usage_ = opt_usage !== undefined ? - opt_usage : ol.webgl.Buffer.Usage_.STATIC_DRAW; + opt_usage : _ol_webgl_Buffer_.Usage_.STATIC_DRAW; }; @@ -30,7 +30,7 @@ ol.webgl.Buffer = function(opt_arr, opt_usage) { /** * @return {Array.} Array. */ -ol.webgl.Buffer.prototype.getArray = function() { +_ol_webgl_Buffer_.prototype.getArray = function() { return this.arr_; }; @@ -38,7 +38,7 @@ ol.webgl.Buffer.prototype.getArray = function() { /** * @return {number} Usage. */ -ol.webgl.Buffer.prototype.getUsage = function() { +_ol_webgl_Buffer_.prototype.getUsage = function() { return this.usage_; }; @@ -47,8 +47,9 @@ ol.webgl.Buffer.prototype.getUsage = function() { * @enum {number} * @private */ -ol.webgl.Buffer.Usage_ = { - STATIC_DRAW: ol.webgl.STATIC_DRAW, - STREAM_DRAW: ol.webgl.STREAM_DRAW, - DYNAMIC_DRAW: ol.webgl.DYNAMIC_DRAW +_ol_webgl_Buffer_.Usage_ = { + STATIC_DRAW: _ol_webgl_.STATIC_DRAW, + STREAM_DRAW: _ol_webgl_.STREAM_DRAW, + DYNAMIC_DRAW: _ol_webgl_.DYNAMIC_DRAW }; +export default _ol_webgl_Buffer_; diff --git a/src/ol/webgl/Context.js b/src/ol/webgl/Context.js index f851c14e9b..880a1d4ede 100644 --- a/src/ol/webgl/Context.js +++ b/src/ol/webgl/Context.js @@ -1,13 +1,13 @@ -goog.provide('ol.webgl.Context'); - -goog.require('ol'); -goog.require('ol.Disposable'); -goog.require('ol.array'); -goog.require('ol.events'); -goog.require('ol.obj'); -goog.require('ol.webgl'); -goog.require('ol.webgl.ContextEventType'); - +/** + * @module ol/webgl/Context + */ +import _ol_ from '../index.js'; +import _ol_Disposable_ from '../Disposable.js'; +import _ol_array_ from '../array.js'; +import _ol_events_ from '../events.js'; +import _ol_obj_ from '../obj.js'; +import _ol_webgl_ from '../webgl.js'; +import _ol_webgl_ContextEventType_ from '../webgl/ContextEventType.js'; /** * @classdesc @@ -18,7 +18,7 @@ goog.require('ol.webgl.ContextEventType'); * @param {HTMLCanvasElement} canvas Canvas. * @param {WebGLRenderingContext} gl GL. */ -ol.webgl.Context = function(canvas, gl) { +var _ol_webgl_Context_ = function(canvas, gl) { /** * @private @@ -77,21 +77,22 @@ ol.webgl.Context = function(canvas, gl) { /** * @type {boolean} */ - this.hasOESElementIndexUint = ol.array.includes( - ol.WEBGL_EXTENSIONS, 'OES_element_index_uint'); + this.hasOESElementIndexUint = _ol_array_.includes( + _ol_.WEBGL_EXTENSIONS, 'OES_element_index_uint'); // use the OES_element_index_uint extension if available if (this.hasOESElementIndexUint) { gl.getExtension('OES_element_index_uint'); } - ol.events.listen(this.canvas_, ol.webgl.ContextEventType.LOST, + _ol_events_.listen(this.canvas_, _ol_webgl_ContextEventType_.LOST, this.handleWebGLContextLost, this); - ol.events.listen(this.canvas_, ol.webgl.ContextEventType.RESTORED, + _ol_events_.listen(this.canvas_, _ol_webgl_ContextEventType_.RESTORED, this.handleWebGLContextRestored, this); }; -ol.inherits(ol.webgl.Context, ol.Disposable); + +_ol_.inherits(_ol_webgl_Context_, _ol_Disposable_); /** @@ -101,10 +102,10 @@ ol.inherits(ol.webgl.Context, ol.Disposable); * @param {number} target Target. * @param {ol.webgl.Buffer} buf Buffer. */ -ol.webgl.Context.prototype.bindBuffer = function(target, buf) { +_ol_webgl_Context_.prototype.bindBuffer = function(target, buf) { var gl = this.getGL(); var arr = buf.getArray(); - var bufferKey = String(ol.getUid(buf)); + var bufferKey = String(_ol_.getUid(buf)); if (bufferKey in this.bufferCache_) { var bufferCacheEntry = this.bufferCache_[bufferKey]; gl.bindBuffer(target, bufferCacheEntry.buffer); @@ -112,9 +113,9 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) { var buffer = gl.createBuffer(); gl.bindBuffer(target, buffer); var /** @type {ArrayBufferView} */ arrayBuffer; - if (target == ol.webgl.ARRAY_BUFFER) { + if (target == _ol_webgl_.ARRAY_BUFFER) { arrayBuffer = new Float32Array(arr); - } else if (target == ol.webgl.ELEMENT_ARRAY_BUFFER) { + } else if (target == _ol_webgl_.ELEMENT_ARRAY_BUFFER) { arrayBuffer = this.hasOESElementIndexUint ? new Uint32Array(arr) : new Uint16Array(arr); } @@ -130,9 +131,9 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) { /** * @param {ol.webgl.Buffer} buf Buffer. */ -ol.webgl.Context.prototype.deleteBuffer = function(buf) { +_ol_webgl_Context_.prototype.deleteBuffer = function(buf) { var gl = this.getGL(); - var bufferKey = String(ol.getUid(buf)); + var bufferKey = String(_ol_.getUid(buf)); var bufferCacheEntry = this.bufferCache_[bufferKey]; if (!gl.isContextLost()) { gl.deleteBuffer(bufferCacheEntry.buffer); @@ -144,8 +145,8 @@ ol.webgl.Context.prototype.deleteBuffer = function(buf) { /** * @inheritDoc */ -ol.webgl.Context.prototype.disposeInternal = function() { - ol.events.unlistenAll(this.canvas_); +_ol_webgl_Context_.prototype.disposeInternal = function() { + _ol_events_.unlistenAll(this.canvas_); var gl = this.getGL(); if (!gl.isContextLost()) { var key; @@ -169,7 +170,7 @@ ol.webgl.Context.prototype.disposeInternal = function() { /** * @return {HTMLCanvasElement} Canvas. */ -ol.webgl.Context.prototype.getCanvas = function() { +_ol_webgl_Context_.prototype.getCanvas = function() { return this.canvas_; }; @@ -179,7 +180,7 @@ ol.webgl.Context.prototype.getCanvas = function() { * @return {WebGLRenderingContext} The rendering context. * @api */ -ol.webgl.Context.prototype.getGL = function() { +_ol_webgl_Context_.prototype.getGL = function() { return this.gl_; }; @@ -188,7 +189,7 @@ ol.webgl.Context.prototype.getGL = function() { * Get the frame buffer for hit detection. * @return {WebGLFramebuffer} The hit detection frame buffer. */ -ol.webgl.Context.prototype.getHitDetectionFramebuffer = function() { +_ol_webgl_Context_.prototype.getHitDetectionFramebuffer = function() { if (!this.hitDetectionFramebuffer_) { this.initHitDetectionFramebuffer_(); } @@ -202,8 +203,8 @@ ol.webgl.Context.prototype.getHitDetectionFramebuffer = function() { * @param {ol.webgl.Shader} shaderObject Shader object. * @return {WebGLShader} Shader. */ -ol.webgl.Context.prototype.getShader = function(shaderObject) { - var shaderKey = String(ol.getUid(shaderObject)); +_ol_webgl_Context_.prototype.getShader = function(shaderObject) { + var shaderKey = String(_ol_.getUid(shaderObject)); if (shaderKey in this.shaderCache_) { return this.shaderCache_[shaderKey]; } else { @@ -225,10 +226,10 @@ ol.webgl.Context.prototype.getShader = function(shaderObject) { * @param {ol.webgl.Vertex} vertexShaderObject Vertex shader. * @return {WebGLProgram} Program. */ -ol.webgl.Context.prototype.getProgram = function( +_ol_webgl_Context_.prototype.getProgram = function( fragmentShaderObject, vertexShaderObject) { var programKey = - ol.getUid(fragmentShaderObject) + '/' + ol.getUid(vertexShaderObject); + _ol_.getUid(fragmentShaderObject) + '/' + _ol_.getUid(vertexShaderObject); if (programKey in this.programCache_) { return this.programCache_[programKey]; } else { @@ -246,10 +247,10 @@ ol.webgl.Context.prototype.getProgram = function( /** * FIXME empy description for jsdoc */ -ol.webgl.Context.prototype.handleWebGLContextLost = function() { - ol.obj.clear(this.bufferCache_); - ol.obj.clear(this.shaderCache_); - ol.obj.clear(this.programCache_); +_ol_webgl_Context_.prototype.handleWebGLContextLost = function() { + _ol_obj_.clear(this.bufferCache_); + _ol_obj_.clear(this.shaderCache_); + _ol_obj_.clear(this.programCache_); this.currentProgram_ = null; this.hitDetectionFramebuffer_ = null; this.hitDetectionTexture_ = null; @@ -260,7 +261,7 @@ ol.webgl.Context.prototype.handleWebGLContextLost = function() { /** * FIXME empy description for jsdoc */ -ol.webgl.Context.prototype.handleWebGLContextRestored = function() { +_ol_webgl_Context_.prototype.handleWebGLContextRestored = function() { }; @@ -268,12 +269,12 @@ ol.webgl.Context.prototype.handleWebGLContextRestored = function() { * Creates a 1x1 pixel framebuffer for the hit-detection. * @private */ -ol.webgl.Context.prototype.initHitDetectionFramebuffer_ = function() { +_ol_webgl_Context_.prototype.initHitDetectionFramebuffer_ = function() { var gl = this.gl_; var framebuffer = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - var texture = ol.webgl.Context.createEmptyTexture(gl, 1, 1); + var texture = _ol_webgl_Context_.createEmptyTexture(gl, 1, 1); var renderbuffer = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 1, 1); @@ -298,7 +299,7 @@ ol.webgl.Context.prototype.initHitDetectionFramebuffer_ = function() { * @return {boolean} Changed. * @api */ -ol.webgl.Context.prototype.useProgram = function(program) { +_ol_webgl_Context_.prototype.useProgram = function(program) { if (program == this.currentProgram_) { return false; } else { @@ -317,7 +318,7 @@ ol.webgl.Context.prototype.useProgram = function(program) { * @return {WebGLTexture} The texture. * @private */ -ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { +_ol_webgl_Context_.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { var texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); @@ -325,11 +326,11 @@ ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { if (opt_wrapS !== undefined) { gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_WRAP_S, opt_wrapS); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S, opt_wrapS); } if (opt_wrapT !== undefined) { gl.texParameteri( - ol.webgl.TEXTURE_2D, ol.webgl.TEXTURE_WRAP_T, opt_wrapT); + _ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T, opt_wrapT); } return texture; @@ -344,9 +345,9 @@ ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) { * @param {number=} opt_wrapT wrapT. * @return {WebGLTexture} The texture. */ -ol.webgl.Context.createEmptyTexture = function( +_ol_webgl_Context_.createEmptyTexture = function( gl, width, height, opt_wrapS, opt_wrapT) { - var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT); + var texture = _ol_webgl_Context_.createTexture_(gl, opt_wrapS, opt_wrapT); gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); @@ -362,10 +363,11 @@ ol.webgl.Context.createEmptyTexture = function( * @param {number=} opt_wrapT wrapT. * @return {WebGLTexture} The texture. */ -ol.webgl.Context.createTexture = function(gl, image, opt_wrapS, opt_wrapT) { - var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT); +_ol_webgl_Context_.createTexture = function(gl, image, opt_wrapS, opt_wrapT) { + var texture = _ol_webgl_Context_.createTexture_(gl, opt_wrapS, opt_wrapT); gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); return texture; }; +export default _ol_webgl_Context_; diff --git a/src/ol/webgl/ContextEventType.js b/src/ol/webgl/ContextEventType.js index db41dcee97..4b9b3bb6c9 100644 --- a/src/ol/webgl/ContextEventType.js +++ b/src/ol/webgl/ContextEventType.js @@ -1,10 +1,12 @@ -goog.provide('ol.webgl.ContextEventType'); - - +/** + * @module ol/webgl/ContextEventType + */ /** * @enum {string} */ -ol.webgl.ContextEventType = { +var _ol_webgl_ContextEventType_ = { LOST: 'webglcontextlost', RESTORED: 'webglcontextrestored' }; + +export default _ol_webgl_ContextEventType_; diff --git a/src/ol/webgl/Fragment.js b/src/ol/webgl/Fragment.js index 49bb0f0445..4a3eb1e11a 100644 --- a/src/ol/webgl/Fragment.js +++ b/src/ol/webgl/Fragment.js @@ -1,9 +1,9 @@ -goog.provide('ol.webgl.Fragment'); - -goog.require('ol'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Shader'); - +/** + * @module ol/webgl/Fragment + */ +import _ol_ from '../index.js'; +import _ol_webgl_ from '../webgl.js'; +import _ol_webgl_Shader_ from '../webgl/Shader.js'; /** * @constructor @@ -11,15 +11,17 @@ goog.require('ol.webgl.Shader'); * @param {string} source Source. * @struct */ -ol.webgl.Fragment = function(source) { - ol.webgl.Shader.call(this, source); +var _ol_webgl_Fragment_ = function(source) { + _ol_webgl_Shader_.call(this, source); }; -ol.inherits(ol.webgl.Fragment, ol.webgl.Shader); + +_ol_.inherits(_ol_webgl_Fragment_, _ol_webgl_Shader_); /** * @inheritDoc */ -ol.webgl.Fragment.prototype.getType = function() { - return ol.webgl.FRAGMENT_SHADER; +_ol_webgl_Fragment_.prototype.getType = function() { + return _ol_webgl_.FRAGMENT_SHADER; }; +export default _ol_webgl_Fragment_; diff --git a/src/ol/webgl/Shader.js b/src/ol/webgl/Shader.js index 59a02afad7..74dd40cf70 100644 --- a/src/ol/webgl/Shader.js +++ b/src/ol/webgl/Shader.js @@ -1,7 +1,7 @@ -goog.provide('ol.webgl.Shader'); - -goog.require('ol.functions'); - +/** + * @module ol/webgl/Shader + */ +import _ol_functions_ from '../functions.js'; /** * @constructor @@ -9,7 +9,7 @@ goog.require('ol.functions'); * @param {string} source Source. * @struct */ -ol.webgl.Shader = function(source) { +var _ol_webgl_Shader_ = function(source) { /** * @private @@ -24,13 +24,13 @@ ol.webgl.Shader = function(source) { * @abstract * @return {number} Type. */ -ol.webgl.Shader.prototype.getType = function() {}; +_ol_webgl_Shader_.prototype.getType = function() {}; /** * @return {string} Source. */ -ol.webgl.Shader.prototype.getSource = function() { +_ol_webgl_Shader_.prototype.getSource = function() { return this.source_; }; @@ -38,4 +38,5 @@ ol.webgl.Shader.prototype.getSource = function() { /** * @return {boolean} Is animated? */ -ol.webgl.Shader.prototype.isAnimated = ol.functions.FALSE; +_ol_webgl_Shader_.prototype.isAnimated = _ol_functions_.FALSE; +export default _ol_webgl_Shader_; diff --git a/src/ol/webgl/Vertex.js b/src/ol/webgl/Vertex.js index 024c7dc012..d71f7d55a8 100644 --- a/src/ol/webgl/Vertex.js +++ b/src/ol/webgl/Vertex.js @@ -1,9 +1,9 @@ -goog.provide('ol.webgl.Vertex'); - -goog.require('ol'); -goog.require('ol.webgl'); -goog.require('ol.webgl.Shader'); - +/** + * @module ol/webgl/Vertex + */ +import _ol_ from '../index.js'; +import _ol_webgl_ from '../webgl.js'; +import _ol_webgl_Shader_ from '../webgl/Shader.js'; /** * @constructor @@ -11,15 +11,17 @@ goog.require('ol.webgl.Shader'); * @param {string} source Source. * @struct */ -ol.webgl.Vertex = function(source) { - ol.webgl.Shader.call(this, source); +var _ol_webgl_Vertex_ = function(source) { + _ol_webgl_Shader_.call(this, source); }; -ol.inherits(ol.webgl.Vertex, ol.webgl.Shader); + +_ol_.inherits(_ol_webgl_Vertex_, _ol_webgl_Shader_); /** * @inheritDoc */ -ol.webgl.Vertex.prototype.getType = function() { - return ol.webgl.VERTEX_SHADER; +_ol_webgl_Vertex_.prototype.getType = function() { + return _ol_webgl_.VERTEX_SHADER; }; +export default _ol_webgl_Vertex_; diff --git a/src/ol/xml.js b/src/ol/xml.js index 8172942a8c..53baa8a249 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -1,6 +1,8 @@ -goog.provide('ol.xml'); - -goog.require('ol.array'); +/** + * @module ol/xml + */ +import _ol_array_ from './array.js'; +var _ol_xml_ = {}; /** @@ -10,7 +12,7 @@ goog.require('ol.array'); * @const * @type {Document} */ -ol.xml.DOCUMENT = document.implementation.createDocument('', '', null); +_ol_xml_.DOCUMENT = document.implementation.createDocument('', '', null); /** @@ -18,8 +20,8 @@ ol.xml.DOCUMENT = document.implementation.createDocument('', '', null); * @param {string} qualifiedName Qualified name. * @return {Node} Node. */ -ol.xml.createElementNS = function(namespaceURI, qualifiedName) { - return ol.xml.DOCUMENT.createElementNS(namespaceURI, qualifiedName); +_ol_xml_.createElementNS = function(namespaceURI, qualifiedName) { + return _ol_xml_.DOCUMENT.createElementNS(namespaceURI, qualifiedName); }; @@ -31,8 +33,8 @@ ol.xml.createElementNS = function(namespaceURI, qualifiedName) { * @return {string} All text content. * @api */ -ol.xml.getAllTextContent = function(node, normalizeWhitespace) { - return ol.xml.getAllTextContent_(node, normalizeWhitespace, []).join(''); +_ol_xml_.getAllTextContent = function(node, normalizeWhitespace) { + return _ol_xml_.getAllTextContent_(node, normalizeWhitespace, []).join(''); }; @@ -45,7 +47,7 @@ ol.xml.getAllTextContent = function(node, normalizeWhitespace) { * @private * @return {Array.} Accumulator. */ -ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) { +_ol_xml_.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) { if (node.nodeType == Node.CDATA_SECTION_NODE || node.nodeType == Node.TEXT_NODE) { if (normalizeWhitespace) { @@ -56,7 +58,7 @@ ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) { } else { var n; for (n = node.firstChild; n; n = n.nextSibling) { - ol.xml.getAllTextContent_(n, normalizeWhitespace, accumulator); + _ol_xml_.getAllTextContent_(n, normalizeWhitespace, accumulator); } } return accumulator; @@ -67,7 +69,7 @@ ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) { * @param {?} value Value. * @return {boolean} Is document. */ -ol.xml.isDocument = function(value) { +_ol_xml_.isDocument = function(value) { return value instanceof Document; }; @@ -76,7 +78,7 @@ ol.xml.isDocument = function(value) { * @param {?} value Value. * @return {boolean} Is node. */ -ol.xml.isNode = function(value) { +_ol_xml_.isNode = function(value) { return value instanceof Node; }; @@ -87,7 +89,7 @@ ol.xml.isNode = function(value) { * @param {string} name Attribute name. * @return {string} Value */ -ol.xml.getAttributeNS = function(node, namespaceURI, name) { +_ol_xml_.getAttributeNS = function(node, namespaceURI, name) { return node.getAttributeNS(namespaceURI, name) || ''; }; @@ -98,7 +100,7 @@ ol.xml.getAttributeNS = function(node, namespaceURI, name) { * @param {string} name Attribute name. * @param {string|number} value Value. */ -ol.xml.setAttributeNS = function(node, namespaceURI, name, value) { +_ol_xml_.setAttributeNS = function(node, namespaceURI, name, value) { node.setAttributeNS(namespaceURI, name, value); }; @@ -109,7 +111,7 @@ ol.xml.setAttributeNS = function(node, namespaceURI, name, value) { * @return {Document} Document. * @api */ -ol.xml.parse = function(xml) { +_ol_xml_.parse = function(xml) { return new DOMParser().parseFromString(xml, 'application/xml'); }; @@ -123,7 +125,7 @@ ol.xml.parse = function(xml) { * @return {ol.XmlParser} Parser. * @template T */ -ol.xml.makeArrayExtender = function(valueReader, opt_this) { +_ol_xml_.makeArrayExtender = function(valueReader, opt_this) { return ( /** * @param {Node} node Node. @@ -134,9 +136,10 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) { if (value !== undefined) { var array = /** @type {Array.<*>} */ (objectStack[objectStack.length - 1]); - ol.array.extend(array, value); + _ol_array_.extend(array, value); } - }); + } + ); }; @@ -148,7 +151,7 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) { * @return {ol.XmlParser} Parser. * @template T */ -ol.xml.makeArrayPusher = function(valueReader, opt_this) { +_ol_xml_.makeArrayPusher = function(valueReader, opt_this) { return ( /** * @param {Node} node Node. @@ -173,7 +176,7 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) { * @return {ol.XmlParser} Parser. * @template T */ -ol.xml.makeReplacer = function(valueReader, opt_this) { +_ol_xml_.makeReplacer = function(valueReader, opt_this) { return ( /** * @param {Node} node Node. @@ -198,7 +201,7 @@ ol.xml.makeReplacer = function(valueReader, opt_this) { * @return {ol.XmlParser} Parser. * @template T */ -ol.xml.makeObjectPropertyPusher = function(valueReader, opt_property, opt_this) { +_ol_xml_.makeObjectPropertyPusher = function(valueReader, opt_property, opt_this) { return ( /** * @param {Node} node Node. @@ -232,7 +235,7 @@ ol.xml.makeObjectPropertyPusher = function(valueReader, opt_property, opt_this) * @return {ol.XmlParser} Parser. * @template T */ -ol.xml.makeObjectPropertySetter = function(valueReader, opt_property, opt_this) { +_ol_xml_.makeObjectPropertySetter = function(valueReader, opt_property, opt_this) { return ( /** * @param {Node} node Node. @@ -262,7 +265,7 @@ ol.xml.makeObjectPropertySetter = function(valueReader, opt_property, opt_this) * @return {ol.XmlSerializer} Serializer. * @template T, V */ -ol.xml.makeChildAppender = function(nodeWriter, opt_this) { +_ol_xml_.makeChildAppender = function(nodeWriter, opt_this) { return function(node, value, objectStack) { nodeWriter.call(opt_this !== undefined ? opt_this : this, node, value, objectStack); @@ -286,7 +289,7 @@ ol.xml.makeChildAppender = function(nodeWriter, opt_this) { * @return {ol.XmlSerializer} Serializer. * @template T, V */ -ol.xml.makeArraySerializer = function(nodeWriter, opt_this) { +_ol_xml_.makeArraySerializer = function(nodeWriter, opt_this) { var serializersNS, nodeFactory; return function(node, value, objectStack) { if (serializersNS === undefined) { @@ -294,9 +297,9 @@ ol.xml.makeArraySerializer = function(nodeWriter, opt_this) { var serializers = {}; serializers[node.localName] = nodeWriter; serializersNS[node.namespaceURI] = serializers; - nodeFactory = ol.xml.makeSimpleNodeFactory(node.localName); + nodeFactory = _ol_xml_.makeSimpleNodeFactory(node.localName); } - ol.xml.serialize(serializersNS, nodeFactory, value, objectStack); + _ol_xml_.serialize(serializersNS, nodeFactory, value, objectStack); }; }; @@ -314,7 +317,7 @@ ol.xml.makeArraySerializer = function(nodeWriter, opt_this) { * be used. * @return {function(*, Array.<*>, string=): (Node|undefined)} Node factory. */ -ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { +_ol_xml_.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { var fixedNodeName = opt_nodeName; return ( /** @@ -334,7 +337,7 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { if (opt_namespaceURI === undefined) { namespaceURI = node.namespaceURI; } - return ol.xml.createElementNS(namespaceURI, /** @type {string} */ (nodeName)); + return _ol_xml_.createElementNS(namespaceURI, /** @type {string} */ (nodeName)); } ); }; @@ -347,7 +350,7 @@ ol.xml.makeSimpleNodeFactory = function(opt_nodeName, opt_namespaceURI) { * @const * @type {function(*, Array.<*>, string=): (Node|undefined)} */ -ol.xml.OBJECT_PROPERTY_NODE_FACTORY = ol.xml.makeSimpleNodeFactory(); +_ol_xml_.OBJECT_PROPERTY_NODE_FACTORY = _ol_xml_.makeSimpleNodeFactory(); /** @@ -362,7 +365,7 @@ ol.xml.OBJECT_PROPERTY_NODE_FACTORY = ol.xml.makeSimpleNodeFactory(); * present in `object` will be `undefined` in the resulting array. * @template V */ -ol.xml.makeSequence = function(object, orderedKeys) { +_ol_xml_.makeSequence = function(object, orderedKeys) { var length = orderedKeys.length; var sequence = new Array(length); for (var i = 0; i < length; ++i) { @@ -382,7 +385,7 @@ ol.xml.makeSequence = function(object, orderedKeys) { * @return {Object.} Namespaced structure. * @template T */ -ol.xml.makeStructureNS = function(namespaceURIs, structure, opt_structureNS) { +_ol_xml_.makeStructureNS = function(namespaceURIs, structure, opt_structureNS) { /** * @type {Object.} */ @@ -403,7 +406,7 @@ ol.xml.makeStructureNS = function(namespaceURIs, structure, opt_structureNS) { * @param {Array.<*>} objectStack Object stack. * @param {*=} opt_this The object to use as `this`. */ -ol.xml.parseNode = function(parsersNS, node, objectStack, opt_this) { +_ol_xml_.parseNode = function(parsersNS, node, objectStack, opt_this) { var n; for (n = node.firstElementChild; n; n = n.nextElementSibling) { var parsers = parsersNS[n.namespaceURI]; @@ -428,10 +431,10 @@ ol.xml.parseNode = function(parsersNS, node, objectStack, opt_this) { * @return {T} Object. * @template T */ -ol.xml.pushParseAndPop = function( +_ol_xml_.pushParseAndPop = function( object, parsersNS, node, objectStack, opt_this) { objectStack.push(object); - ol.xml.parseNode(parsersNS, node, objectStack, opt_this); + _ol_xml_.parseNode(parsersNS, node, objectStack, opt_this); return objectStack.pop(); }; @@ -458,7 +461,7 @@ ol.xml.pushParseAndPop = function( * serializers. * @template T */ -ol.xml.serialize = function( +_ol_xml_.serialize = function( serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) { var length = (opt_keys !== undefined ? opt_keys : values).length; var value, node; @@ -499,10 +502,11 @@ ol.xml.serialize = function( * @return {O|undefined} Object. * @template O, T */ -ol.xml.pushSerializeAndPop = function(object, +_ol_xml_.pushSerializeAndPop = function(object, serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) { objectStack.push(object); - ol.xml.serialize( + _ol_xml_.serialize( serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this); return objectStack.pop(); }; +export default _ol_xml_; diff --git a/test/rendering/ol/layer/clip.test.js b/test/rendering/ol/layer/clip.test.js index eb09be1e40..9f1315bdbd 100644 --- a/test/rendering/ol/layer/clip.test.js +++ b/test/rendering/ol/layer/clip.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.XYZ'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; describe('layer clipping', function() { @@ -40,10 +38,10 @@ describe('layer clipping', function() { var map = null; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(256, 256), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -57,22 +55,22 @@ describe('layer clipping', function() { it('clips to all parts of the MultiPolygon', function(done) { - var source = new ol.source.XYZ({ + var source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); - var layer = new ol.layer.Tile({ + var layer = new _ol_layer_Tile_({ source: source }); - var geometry = new ol.geom.MultiPolygon([ + var geometry = new _ol_geom_MultiPolygon_([ [[[-80, -40], [-40, 0], [-80, 40], [-120, 0], [-80, -40]]], [[[80, -40], [120, 0], [80, 40], [40, 0], [80, -40]]] ]).transform('EPSG:4326', 'EPSG:3857'); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ width: 2, color: 'blue' }) diff --git a/test/rendering/ol/layer/image.test.js b/test/rendering/ol/layer/image.test.js index 17abfe5f13..8f5a8c2c23 100644 --- a/test/rendering/ol/layer/image.test.js +++ b/test/rendering/ol/layer/image.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.source.ImageStatic'); -goog.require('ol.tilegrid'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; +import _ol_obj_ from '../../../../src/ol/obj.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.rendering.layer.Image', function() { @@ -14,12 +12,12 @@ describe('ol.rendering.layer.Image', function() { var map; function createMap(renderer) { - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(50, 50), renderer: renderer, - view: new ol.View({ - center: ol.proj.transform( + view: new _ol_View_({ + center: _ol_proj_.transform( [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), zoom: 5 }) @@ -58,8 +56,8 @@ describe('ol.rendering.layer.Image', function() { var options = { source: source }; - ol.obj.assign(options, layerOptions); - map.addLayer(new ol.layer.Image(options)); + _ol_obj_.assign(options, layerOptions); + map.addLayer(new _ol_layer_Image_(options)); }); } @@ -67,11 +65,11 @@ describe('ol.rendering.layer.Image', function() { var source; beforeEach(function() { - source = new ol.source.ImageStatic({ + source = new _ol_source_ImageStatic_({ url: 'rendering/ol/data/tiles/osm/5/5/12.png', - imageExtent: ol.tilegrid.createXYZ().getTileCoordExtent( + imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent( [5, 5, -12 - 1]), - projection: ol.proj.get('EPSG:3857') + projection: _ol_proj_.get('EPSG:3857') }); }); @@ -97,9 +95,9 @@ describe('ol.rendering.layer.Image', function() { var source; beforeEach(function() { - source = new ol.source.ImageStatic({ + source = new _ol_source_ImageStatic_({ url: 'rendering/ol/data/tiles/osm/5/5/12.png', - imageExtent: ol.proj.transformExtent( + imageExtent: _ol_proj_.transformExtent( [-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857') }); }); diff --git a/test/rendering/ol/layer/tile.test.js b/test/rendering/ol/layer/tile.test.js index 3ff6468064..aaa55a870d 100644 --- a/test/rendering/ol/layer/tile.test.js +++ b/test/rendering/ol/layer/tile.test.js @@ -1,18 +1,16 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.source.TileImage'); -goog.require('ol.source.XYZ'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.tilegrid'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_obj_ from '../../../../src/ol/obj.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.rendering.layer.Tile', function() { @@ -22,12 +20,12 @@ describe('ol.rendering.layer.Tile', function() { function createMap(renderer, opt_center, opt_size, opt_pixelRatio, opt_resolutions) { var size = opt_size !== undefined ? opt_size : [50, 50]; - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: opt_pixelRatio || 1, target: createMapDiv(size[0], size[1]), renderer: renderer, - view: new ol.View({ - center: opt_center !== undefined ? opt_center : ol.proj.transform( + view: new _ol_View_({ + center: opt_center !== undefined ? opt_center : _ol_proj_.transform( [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), resolutions: opt_resolutions, zoom: 5 @@ -67,15 +65,15 @@ describe('ol.rendering.layer.Tile', function() { var options = { source: source }; - ol.obj.assign(options, layerOptions[i] || layerOptions); - map.addLayer(new ol.layer.Tile(options)); + _ol_obj_.assign(options, layerOptions[i] || layerOptions); + map.addLayer(new _ol_layer_Tile_(options)); }); } describe('with tile transition', function() { it('renders correctly after the transition', function(done) { createMap('canvas'); - var source = new ol.source.XYZ({ + var source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png' }); waitForTiles([source], {}, function() { @@ -91,7 +89,7 @@ describe('ol.rendering.layer.Tile', function() { var source; beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); @@ -119,11 +117,11 @@ describe('ol.rendering.layer.Tile', function() { var source1, source2; beforeEach(function() { - source1 = new ol.source.XYZ({ + source1 = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); - source2 = new ol.source.XYZ({ + source2 = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/stamen-labels/{z}/{x}/{y}.png', transition: 0 }); @@ -148,8 +146,8 @@ describe('ol.rendering.layer.Tile', function() { function centerExtent(map) { var c = map.getView().calculateExtent(map.getSize()); - var qw = ol.extent.getSize(c)[0] / 4; - var qh = ol.extent.getSize(c)[1] / 4; + var qw = _ol_extent_.getSize(c)[0] / 4; + var qh = _ol_extent_.getSize(c)[1] / 4; return [c[0] + qw, c[1] + qh, c[2] - qw, c[3] - qh]; } @@ -193,7 +191,7 @@ describe('ol.rendering.layer.Tile', function() { var source; beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); @@ -220,9 +218,9 @@ describe('ol.rendering.layer.Tile', function() { describe('tile layer with non-square tiles', function() { function createSource(tileSize) { - return new ol.source.TileImage({ + return new _ol_source_TileImage_({ url: 'rendering/ol/data/tiles/' + tileSize + '/{z}/{x}/{y}.png', - tileGrid: ol.tilegrid.createXYZ({ + tileGrid: _ol_tilegrid_.createXYZ({ tileSize: tileSize.split('x') }), transition: 0 @@ -274,20 +272,20 @@ describe('ol.rendering.layer.Tile', function() { var source, onAddLayer; beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); onAddLayer = function(evt) { evt.element.on('render', function(e) { - e.vectorContext.setImageStyle(new ol.style.Circle({ + e.vectorContext.setImageStyle(new _ol_style_Circle_({ radius: 5, snapToPixel: false, - fill: new ol.style.Fill({color: 'yellow'}), - stroke: new ol.style.Stroke({color: 'red', width: 1}) + fill: new _ol_style_Fill_({color: 'yellow'}), + stroke: new _ol_style_Stroke_({color: 'red', width: 1}) })); - e.vectorContext.drawPoint(new ol.geom.Point( - ol.proj.transform([-123, 38], 'EPSG:4326', 'EPSG:3857'))); + e.vectorContext.drawPoint(new _ol_geom_Point_( + _ol_proj_.transform([-123, 38], 'EPSG:4326', 'EPSG:3857'))); }); }; }); diff --git a/test/rendering/ol/layer/vector.test.js b/test/rendering/ol/layer/vector.test.js index 4ceeeee2af..6ef5a64478 100644 --- a/test/rendering/ol/layer/vector.test.js +++ b/test/rendering/ol/layer/vector.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; describe('ol.rendering.layer.Vector', function() { @@ -23,11 +21,11 @@ describe('ol.rendering.layer.Vector', function() { var map; function createMap(renderer) { - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(80, 80), renderer: renderer, - view: new ol.View({ + view: new _ol_View_({ center: center, zoom: 13 }) @@ -44,11 +42,11 @@ describe('ol.rendering.layer.Vector', function() { var source; function addCircle(r) { - source.addFeature(new ol.Feature(new ol.geom.Circle(center, r))); + source.addFeature(new _ol_Feature_(new _ol_geom_Circle_(center, r))); } function addPolygon(r) { - source.addFeature(new ol.Feature(new ol.geom.Polygon([ + source.addFeature(new _ol_Feature_(new _ol_geom_Polygon_([ [ [center[0] - r, center[1] - r], [center[0] + r, center[1] - r], @@ -60,7 +58,7 @@ describe('ol.rendering.layer.Vector', function() { } function addLineString(r) { - source.addFeature(new ol.Feature(new ol.geom.LineString([ + source.addFeature(new _ol_Feature_(new _ol_geom_LineString_([ [center[0] - r, center[1] - r], [center[0] + r, center[1] - r], [center[0] + r, center[1] + r], @@ -72,18 +70,18 @@ describe('ol.rendering.layer.Vector', function() { describe('vector layer', function() { beforeEach(function() { - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('renders opacity correctly with the canvas renderer', function(done) { createMap('canvas'); - var smallLine = new ol.Feature(new ol.geom.LineString([ + var smallLine = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1], [center[0], center[1] + 1] ])); - smallLine.setStyle(new ol.style.Style({ + smallLine.setStyle(new _ol_style_Style_({ zIndex: -99, - stroke: new ol.style.Stroke({width: 75, color: 'red'}) + stroke: new _ol_style_Stroke_({width: 75, color: 'red'}) })); source.addFeature(smallLine); addPolygon(100); @@ -92,7 +90,7 @@ describe('ol.rendering.layer.Vector', function() { addCircle(500); addPolygon(600); addPolygon(720); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: source })); map.once('postrender', function() { @@ -103,13 +101,13 @@ describe('ol.rendering.layer.Vector', function() { it('renders opacity correctly with renderMode: \'image\'', function(done) { createMap('canvas'); - var smallLine = new ol.Feature(new ol.geom.LineString([ + var smallLine = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1], [center[0], center[1] + 1] ])); - smallLine.setStyle(new ol.style.Style({ + smallLine.setStyle(new _ol_style_Style_({ zIndex: -99, - stroke: new ol.style.Stroke({width: 75, color: 'red'}) + stroke: new _ol_style_Stroke_({width: 75, color: 'red'}) })); source.addFeature(smallLine); addPolygon(100); @@ -118,7 +116,7 @@ describe('ol.rendering.layer.Vector', function() { addCircle(500); addPolygon(600); addPolygon(720); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ renerMode: 'image', source: source })); @@ -130,34 +128,34 @@ describe('ol.rendering.layer.Vector', function() { it('renders transparent layers correctly with the canvas renderer', function(done) { createMap('canvas'); - var smallLine = new ol.Feature(new ol.geom.LineString([ + var smallLine = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1], [center[0], center[1] + 1] ])); smallLine.setStyle([ - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 75, color: 'red'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 75, color: 'red'}) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 45, color: 'white'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 45, color: 'white'}) }) ]); source.addFeature(smallLine); - var smallLine2 = new ol.Feature(new ol.geom.LineString([ + var smallLine2 = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1000], [center[0], center[1] + 1000] ])); smallLine2.setStyle([ - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 35, color: 'blue'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 35, color: 'blue'}) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 15, color: 'green'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 15, color: 'green'}) }) ]); source.addFeature(smallLine2); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: source, opacity: 0.5 })); @@ -169,34 +167,34 @@ describe('ol.rendering.layer.Vector', function() { it('renders transparent layers correctly with renderMode: \'image\'', function(done) { createMap('canvas'); - var smallLine = new ol.Feature(new ol.geom.LineString([ + var smallLine = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1], [center[0], center[1] + 1] ])); smallLine.setStyle([ - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 75, color: 'red'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 75, color: 'red'}) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 45, color: 'white'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 45, color: 'white'}) }) ]); source.addFeature(smallLine); - var smallLine2 = new ol.Feature(new ol.geom.LineString([ + var smallLine2 = new _ol_Feature_(new _ol_geom_LineString_([ [center[0], center[1] - 1000], [center[0], center[1] + 1000] ])); smallLine2.setStyle([ - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 35, color: 'blue'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 35, color: 'blue'}) }), - new ol.style.Style({ - stroke: new ol.style.Stroke({width: 15, color: 'green'}) + new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({width: 15, color: 'green'}) }) ]); source.addFeature(smallLine2); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ renderMode: 'image', source: source, opacity: 0.5 @@ -212,10 +210,10 @@ describe('ol.rendering.layer.Vector', function() { map.getView().setRotation(Math.PI + Math.PI / 4); addPolygon(300); addCircle(500); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: source, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ width: 2, color: 'black' }) @@ -232,11 +230,11 @@ describe('ol.rendering.layer.Vector', function() { map.getView().setRotation(Math.PI + Math.PI / 4); addPolygon(300); addCircle(500); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ renderMode: 'image', source: source, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ width: 2, color: 'black' }) @@ -253,14 +251,14 @@ describe('ol.rendering.layer.Vector', function() { addCircle(500); addPolygon(300); map.skipFeature(source.getFeatures()[1]); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ renderMode: 'image', source: source, - style: new ol.style.Style({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(255,0,0,0.5)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ width: 2, color: 'black' }) @@ -276,7 +274,7 @@ describe('ol.rendering.layer.Vector', function() { it('renders fill/stroke batches correctly with the canvas renderer', function(done) { createMap('canvas'); - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ overlaps: false }); addPolygon(100); @@ -285,10 +283,10 @@ describe('ol.rendering.layer.Vector', function() { addCircle(500); addPolygon(600); addPolygon(720); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: source, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#3399CC', width: 1.25 }) @@ -302,17 +300,17 @@ describe('ol.rendering.layer.Vector', function() { it('renders stroke batches correctly with the canvas renderer', function(done) { createMap('canvas'); - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ overlaps: false }); addLineString(100); addLineString(250); addLineString(600); addLineString(720); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ source: source, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ + style: new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#3399CC', width: 1.25 }) @@ -329,7 +327,7 @@ describe('ol.rendering.layer.Vector', function() { var color; function createSource(overlaps) { color = '#3399CC'; - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ overlaps: overlaps }); addPolygon(720); @@ -348,16 +346,16 @@ describe('ol.rendering.layer.Vector', function() { } return color; } - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: createSource(true), style: function(feature) { alternateColor(); - return new ol.style.Style({ - stroke: new ol.style.Stroke({ + return new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: alternateColor(), width: 1.25 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: alternateColor() }) }); @@ -382,7 +380,7 @@ describe('ol.rendering.layer.Vector', function() { var color; function createSource(overlaps) { color = '#3399CC'; - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ overlaps: overlaps }); addLineString(720); @@ -399,16 +397,16 @@ describe('ol.rendering.layer.Vector', function() { } return color; } - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: createSource(true), style: function(feature) { alternateColor(); - return new ol.style.Style({ - stroke: new ol.style.Stroke({ + return new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: alternateColor(), width: 1.25 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: alternateColor() }) }); @@ -433,10 +431,10 @@ describe('ol.rendering.layer.Vector', function() { var map2; beforeEach(function() { - map2 = new ol.Map({ + map2 = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(128, 128), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -465,15 +463,15 @@ describe('ol.rendering.layer.Vector', function() { properties: {} }; - var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'}); + var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'}); var feature = format.readFeature(json); - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }), - style: new ol.style.Style({ - fill: new ol.style.Fill({ + style: new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'blue' }) }) @@ -494,16 +492,16 @@ describe('ol.rendering.layer.Vector', function() { var layer, map3; beforeEach(function() { - var src = new ol.source.Vector({ + var src = new _ol_source_Vector_({ features: [ - new ol.Feature(new ol.geom.Polygon([[ + new _ol_Feature_(new _ol_geom_Polygon_([[ [-22, 58], [-22, 78], [-9, 78], [-9, 58], [-22, 58] ]])), - new ol.Feature(new ol.geom.Polygon([[ + new _ol_Feature_(new _ol_geom_Polygon_([[ [-9, 58], [-9, 78], [4, 78], @@ -512,17 +510,17 @@ describe('ol.rendering.layer.Vector', function() { ]])) ] }); - layer = new ol.layer.Vector({ + layer = new _ol_layer_Vector_({ renderBuffer: 0, source: src }); - var view = new ol.View({ + var view = new _ol_View_({ center: [-9.5, 78], zoom: 2, projection: 'EPSG:4326' }); - map3 = new ol.Map({ + map3 = new _ol_Map_({ pixelRatio: 1, layers: [layer], target: createMapDiv(100, 100), @@ -536,12 +534,12 @@ describe('ol.rendering.layer.Vector', function() { }); it('renders partially out-of-view polygons with a fill and stroke', function(done) { - layer.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + layer.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [0, 0, 0, 1], width: 2 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: [255, 0, 0, 1] }) })); @@ -552,8 +550,8 @@ describe('ol.rendering.layer.Vector', function() { }); it('renders partially out-of-view polygons with a fill', function(done) { - layer.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({ + layer.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: [0, 0, 0, 1] }) })); @@ -564,8 +562,8 @@ describe('ol.rendering.layer.Vector', function() { }); it('renders partially out-of-view polygons with a stroke', function(done) { - layer.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + layer.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: [0, 0, 0, 1], width: 2 }) @@ -581,34 +579,34 @@ describe('ol.rendering.layer.Vector', function() { describe('decluttering', function() { beforeEach(function() { - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('declutters text', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - var centerFeature = new ol.Feature({ - geometry: new ol.geom.Point(center), + var centerFeature = new _ol_Feature_({ + geometry: new _ol_geom_Point_(center), text: 'center' }); source.addFeature(centerFeature); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]), text: 'west' })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]), text: 'east' })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ - text: new ol.style.Text({ + return new _ol_style_Style_({ + text: new _ol_style_Text_({ text: feature.get('text'), font: '12px sans-serif' }) @@ -626,30 +624,30 @@ describe('ol.rendering.layer.Vector', function() { it('declutters text with renderMode: \'image\'', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ renderMode: 'image', source: source }); map.addLayer(layer); - var centerFeature = new ol.Feature({ - geometry: new ol.geom.Point(center), + var centerFeature = new _ol_Feature_({ + geometry: new _ol_geom_Point_(center), text: 'center' }); source.addFeature(centerFeature); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]), text: 'west' })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]), text: 'east' })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ - text: new ol.style.Text({ + return new _ol_style_Style_({ + text: new _ol_style_Text_({ text: feature.get('text'), font: '12px sans-serif' }) @@ -667,32 +665,32 @@ describe('ol.rendering.layer.Vector', function() { it('declutters text and respects z-index', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point(center), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_(center), text: 'center', zIndex: 2 })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]), text: 'west', zIndex: 3 })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]), text: 'east', zIndex: 1 })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ + return new _ol_style_Style_({ zIndex: feature.get('zIndex'), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: feature.get('text'), font: '12px sans-serif' }) @@ -707,28 +705,28 @@ describe('ol.rendering.layer.Vector', function() { it('declutters images', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - var centerFeature = new ol.Feature({ - geometry: new ol.geom.Point(center) + var centerFeature = new _ol_Feature_({ + geometry: new _ol_geom_Point_(center) }); source.addFeature(centerFeature); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]) + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]) })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]) + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]) })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ - image: new ol.style.Circle({ + return new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 15, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) @@ -746,29 +744,29 @@ describe('ol.rendering.layer.Vector', function() { it('declutters images with renderMode: \'image\'', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ renderMode: 'image', source: source }); map.addLayer(layer); - var centerFeature = new ol.Feature({ - geometry: new ol.geom.Point(center) + var centerFeature = new _ol_Feature_({ + geometry: new _ol_geom_Point_(center) }); source.addFeature(centerFeature); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]) + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]) })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]) + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]) })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ - image: new ol.style.Circle({ + return new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 15, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) @@ -786,31 +784,31 @@ describe('ol.rendering.layer.Vector', function() { it('declutters images and respects z-index', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point(center), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_(center), zIndex: 2 })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]), zIndex: 3 })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]), zIndex: 1 })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ + return new _ol_style_Style_({ zIndex: feature.get('zIndex'), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 15, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) @@ -825,34 +823,34 @@ describe('ol.rendering.layer.Vector', function() { it('declutters image & text groups', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point(center), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_(center), text: 'center' })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] - 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] - 540, center[1]]), text: 'west' })); - source.addFeature(new ol.Feature({ - geometry: new ol.geom.Point([center[0] + 540, center[1]]), + source.addFeature(new _ol_Feature_({ + geometry: new _ol_geom_Point_([center[0] + 540, center[1]]), text: 'east' })); layer.setDeclutter(true); layer.setStyle(function(feature) { - return new ol.style.Style({ - image: new ol.style.Circle({ + return new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: feature.get('text'), font: '12px sans-serif', textBaseline: 'bottom', @@ -869,30 +867,30 @@ describe('ol.rendering.layer.Vector', function() { it('declutters text along lines and images', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - var point = new ol.Feature(new ol.geom.Point(center)); - point.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + var point = new _ol_Feature_(new _ol_geom_Point_(center)); + point.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 8, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) })); - var line = new ol.Feature(new ol.geom.LineString([ + var line = new _ol_Feature_(new _ol_geom_LineString_([ [center[0] - 650, center[1] - 200], [center[0] + 650, center[1] - 200] ])); - line.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + line.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#CCC', width: 12 }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ placement: 'line', text: 'east-west', font: '12px sans-serif' @@ -912,30 +910,30 @@ describe('ol.rendering.layer.Vector', function() { it('declutters text along lines and images with renderMode: \'image\'', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - var point = new ol.Feature(new ol.geom.Point(center)); - point.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + var point = new _ol_Feature_(new _ol_geom_Point_(center)); + point.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 8, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) })); - var line = new ol.Feature(new ol.geom.LineString([ + var line = new _ol_Feature_(new _ol_geom_LineString_([ [center[0] - 650, center[1] - 200], [center[0] + 650, center[1] - 200] ])); - line.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + line.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#CCC', width: 12 }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ placement: 'line', text: 'east-west', font: '12px sans-serif' @@ -955,32 +953,32 @@ describe('ol.rendering.layer.Vector', function() { it('declutters text along lines and images with z-index', function(done) { createMap('canvas'); - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); map.addLayer(layer); - var point = new ol.Feature(new ol.geom.Point(center)); - point.setStyle(new ol.style.Style({ + var point = new _ol_Feature_(new _ol_geom_Point_(center)); + point.setStyle(new _ol_style_Style_({ zIndex: 2, - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 8, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: 'blue' }) }) })); - var line = new ol.Feature(new ol.geom.LineString([ + var line = new _ol_Feature_(new _ol_geom_LineString_([ [center[0] - 650, center[1] - 200], [center[0] + 650, center[1] - 200] ])); - line.setStyle(new ol.style.Style({ + line.setStyle(new _ol_style_Style_({ zIndex: 1, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#CCC', width: 12 }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ placement: 'line', text: 'east-west', font: '12px sans-serif' diff --git a/test/rendering/ol/layer/vectortile.test.js b/test/rendering/ol/layer/vectortile.test.js index c0a7a1f9a6..427b650e36 100644 --- a/test/rendering/ol/layer/vectortile.test.js +++ b/test/rendering/ol/layer/vectortile.test.js @@ -1,18 +1,18 @@ -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.format.MVT'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.obj'); -goog.require('ol.source.Vector'); -goog.require('ol.source.VectorTile'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); -goog.require('ol.tilegrid'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; +import _ol_obj_ from '../../../../src/ol/obj.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.rendering.layer.VectorTile', function() { @@ -21,11 +21,11 @@ describe('ol.rendering.layer.VectorTile', function() { function createMap(renderer, opt_pixelRatio, opt_size) { var size = opt_size || 50; - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: opt_pixelRatio || 1, target: createMapDiv(size, size), renderer: renderer, - view: new ol.View({ + view: new _ol_View_({ center: [1825927.7316762917, 6143091.089223046], zoom: 14 }) @@ -61,17 +61,17 @@ describe('ol.rendering.layer.VectorTile', function() { var options = { source: source }; - ol.obj.assign(options, layerOptions); - map.addLayer(new ol.layer.VectorTile(options)); + _ol_obj_.assign(options, layerOptions); + map.addLayer(new _ol_layer_VectorTile_(options)); } describe('vector tile layer', function() { var source; beforeEach(function() { - source = new ol.source.VectorTile({ - format: new ol.format.MVT(), - tileGrid: ol.tilegrid.createXYZ(), + source = new _ol_source_VectorTile_({ + format: new _ol_format_MVT_(), + tileGrid: _ol_tilegrid_.createXYZ(), url: 'rendering/ol/data/tiles/mvt/{z}-{x}-{y}.vector.pbf', transition: 0 }); @@ -96,18 +96,18 @@ describe('ol.rendering.layer.VectorTile', function() { it('renders rotated view correctly with vector layer on top', function(done) { createMap('canvas'); - var vectorSource = new ol.source.Vector({ + var vectorSource = new _ol_source_Vector_({ features: [ - new ol.Feature(new ol.geom.Point([1825727.7316762917, 6143091.089223046])) + new _ol_Feature_(new _ol_geom_Point_([1825727.7316762917, 6143091.089223046])) ] }); - map.addLayer(new ol.layer.Vector({ + map.addLayer(new _ol_layer_Vector_({ zIndex: 1, source: vectorSource, - style: new ol.style.Style({ - image: new ol.style.Circle({ + style: new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 10, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'red' }) }) @@ -143,14 +143,14 @@ describe('ol.rendering.layer.VectorTile', function() { var style = function(feature, resolution) { var geom = feature.getGeometry(); if (geom.getType() == 'Point') { - return new ol.style.Style({ - image: new ol.style.Circle({ + return new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 7, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'red' }) }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: feature.get('name_en'), font: '12px sans-serif', textBaseline: 'bottom', diff --git a/test/rendering/ol/map.test.js b/test/rendering/ol/map.test.js index f27723545c..66496d5081 100644 --- a/test/rendering/ol/map.test.js +++ b/test/rendering/ol/map.test.js @@ -1,31 +1,29 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); +import _ol_Feature_ from '../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_View_ from '../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../src/ol/source/Vector.js'; describe('ol.rendering.Map', function() { var map; function createMap(renderer) { - var vectorLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: [new ol.Feature({ - geometry: new ol.geom.Point([0, 0]) + var vectorLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ + features: [new _ol_Feature_({ + geometry: new _ol_geom_Point_([0, 0]) })] }) }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(50, 50), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 diff --git a/test/rendering/ol/render.test.js b/test/rendering/ol/render.test.js index 81e0cbd60a..cf6ac405c6 100644 --- a/test/rendering/ol/render.test.js +++ b/test/rendering/ol/render.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render'); -goog.require('ol.render.VectorContext'); -goog.require('ol.render.canvas.Immediate'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_geom_LineString_ from '../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../src/ol/geom/Polygon.js'; +import _ol_render_ from '../../../src/ol/render.js'; +import _ol_render_VectorContext_ from '../../../src/ol/render/VectorContext.js'; +import _ol_render_canvas_Immediate_ from '../../../src/ol/render/canvas/Immediate.js'; +import _ol_style_Circle_ from '../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../src/ol/style/Style.js'; function getContext() { return document.createElement('canvas').getContext('2d'); @@ -20,24 +18,24 @@ describe('ol.render', function() { describe('ol.render.toContext()', function() { it('creates a vector context from a Canvas 2d context', function() { - var vectorContext = ol.render.toContext(getContext(), { + var vectorContext = _ol_render_.toContext(getContext(), { pixelRatio: 1, size: [100, 100] }); - expect(vectorContext).to.be.a(ol.render.VectorContext); - expect(vectorContext).to.be.a(ol.render.canvas.Immediate); + expect(vectorContext).to.be.a(_ol_render_VectorContext_); + expect(vectorContext).to.be.a(_ol_render_canvas_Immediate_); }); it('can be used to render a point geometry', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ + var style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: 'green' }), radius: 10 @@ -45,7 +43,7 @@ describe('ol.render', function() { }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.Point([50, 50])); + vectorContext.drawGeometry(new _ol_geom_Point_([50, 50])); resembleCanvas(context.canvas, 'rendering/ol/expected/render-point.png', IMAGE_TOLERANCE, done); @@ -54,20 +52,20 @@ describe('ol.render', function() { it('can be used to render a linestring geometry', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'red', width: 14 }) }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.LineString([ + vectorContext.drawGeometry(new _ol_geom_LineString_([ [10, 60], [30, 40], [50, 60], [70, 40], [90, 60] ])); @@ -78,13 +76,13 @@ describe('ol.render', function() { it('respects lineCap for linestring', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ lineCap: 'butt', color: 'red', width: 14 @@ -92,7 +90,7 @@ describe('ol.render', function() { }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.LineString([ + vectorContext.drawGeometry(new _ol_geom_LineString_([ [10, 60], [30, 40], [50, 60], [70, 40], [90, 60] ])); @@ -103,13 +101,13 @@ describe('ol.render', function() { it('respects lineJoin for linestring', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ lineJoin: 'bevel', color: 'red', width: 14 @@ -117,7 +115,7 @@ describe('ol.render', function() { }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.LineString([ + vectorContext.drawGeometry(new _ol_geom_LineString_([ [10, 60], [30, 40], [50, 60], [70, 40], [90, 60] ])); @@ -128,24 +126,24 @@ describe('ol.render', function() { it('can be used to render a polygon geometry', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'blue', width: 8 }), - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0,0,255,0.5)' }) }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.Polygon([ + vectorContext.drawGeometry(new _ol_geom_Polygon_([ [[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]], [[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]] ])); @@ -157,20 +155,20 @@ describe('ol.render', function() { it('supports lineDash styles', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ lineDash: [10, 5] }) }); vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.Polygon([ + vectorContext.drawGeometry(new _ol_geom_Polygon_([ [[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]], [[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]] ])); @@ -182,13 +180,13 @@ describe('ol.render', function() { it('supports lineDashOffset', function(done) { var context = getContext(); - var vectorContext = ol.render.toContext(context, { + var vectorContext = _ol_render_.toContext(context, { pixelRatio: 1, size: [100, 100] }); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ lineDash: [10, 5], lineDashOffset: 5 }) @@ -196,7 +194,7 @@ describe('ol.render', function() { vectorContext.setStyle(style); - vectorContext.drawGeometry(new ol.geom.Polygon([ + vectorContext.drawGeometry(new _ol_geom_Polygon_([ [[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]], [[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]] ])); diff --git a/test/rendering/ol/reproj/image.test.js b/test/rendering/ol/reproj/image.test.js index 7b80daaaff..f42c3a99dc 100644 --- a/test/rendering/ol/reproj/image.test.js +++ b/test/rendering/ol/reproj/image.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.proj.EPSG3857'); -goog.require('ol.reproj.Image'); -goog.require('ol.source.ImageStatic'); -goog.require('ol.tilegrid'); +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; +import _ol_reproj_Image_ from '../../../../src/ol/reproj/Image.js'; +import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.rendering.reproj.Image', function() { @@ -16,14 +14,14 @@ describe('ol.rendering.reproj.Image', function() { var imagesRequested = 0; - var image = new ol.reproj.Image(sourceProj, ol.proj.get(targetProj), + var image = new _ol_reproj_Image_(sourceProj, _ol_proj_.get(targetProj), targetExtent, targetResolution, pixelRatio, function(extent, resolution, pixelRatio) { imagesRequested++; return source.getImage(extent, resolution, pixelRatio, sourceProj); }); if (image.getState() == 0) { // IDLE - ol.events.listen(image, 'change', function(e) { + _ol_events_.listen(image, 'change', function(e) { if (image.getState() == 2) { // LOADED expect(imagesRequested).to.be(1); resembleCanvas(image.getImage(), expectedUrl, IMAGE_TOLERANCE, done); @@ -37,23 +35,23 @@ describe('ol.rendering.reproj.Image', function() { describe('image reprojections from EPSG:3857', function() { beforeEach(function() { - source = new ol.source.ImageStatic({ + source = new _ol_source_ImageStatic_({ url: 'rendering/ol/data/tiles/osm/5/5/12.png', - imageExtent: ol.tilegrid.createXYZ().getTileCoordExtent([5, 5, -13]), - projection: ol.proj.get('EPSG:3857') + imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]), + projection: _ol_proj_.get('EPSG:3857') }); }); it('works for identity reprojection', function(done) { testSingleImage(source, 'EPSG:3857', - ol.tilegrid.createXYZ().getTileCoordExtent([5, 5, -13]), - 2 * ol.proj.EPSG3857.HALF_SIZE / (256 * (1 << 5)), 1, + _ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]), + 2 * _ol_proj_EPSG3857_.HALF_SIZE / (256 * (1 << 5)), 1, 'rendering/ol/data/tiles/osm/5/5/12.png', done); }); it('to EPSG:4326', function(done) { testSingleImage(source, 'EPSG:4326', - ol.tilegrid.createForProjection('EPSG:4326'). + _ol_tilegrid_.createForProjection('EPSG:4326'). getTileCoordExtent([6, 10, -10]), 360 / (256 * (1 << 4)), 1, 'rendering/ol/reproj/expected/image-3857-to-4326.png', done); diff --git a/test/rendering/ol/reproj/tile.test.js b/test/rendering/ol/reproj/tile.test.js index e21a27a6e2..dc78c88c7f 100644 --- a/test/rendering/ol/reproj/tile.test.js +++ b/test/rendering/ol/reproj/tile.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.TileState'); -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.reproj.Tile'); -goog.require('ol.source.XYZ'); -goog.require('ol.tilegrid'); +import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.rendering.reproj.Tile', function() { @@ -17,16 +15,16 @@ describe('ol.rendering.reproj.Tile', function() { var tilesRequested = 0; - var tile = new ol.reproj.Tile(sourceProjection, source.getTileGrid(), - ol.proj.get(targetProjection), targetTileGrid, + var tile = new _ol_reproj_Tile_(sourceProjection, source.getTileGrid(), + _ol_proj_.get(targetProjection), targetTileGrid, [z, x, y], null, pixelRatio, sourceGutter, function(z, x, y, pixelRatio) { tilesRequested++; return source.getTile(z, x, y, pixelRatio, sourceProjection); }); - if (tile.getState() == ol.TileState.IDLE) { - ol.events.listen(tile, 'change', function(e) { - if (tile.getState() == ol.TileState.LOADED) { + if (tile.getState() == _ol_TileState_.IDLE) { + _ol_events_.listen(tile, 'change', function(e) { + if (tile.getState() == _ol_TileState_.LOADED) { expect(tilesRequested).to.be(expectedRequests); resembleCanvas(tile.getImage(), expectedUrl, 7.5, done); } @@ -39,7 +37,7 @@ describe('ol.rendering.reproj.Tile', function() { describe('single tile reprojections from EPSG:3857', function() { beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ projection: 'EPSG:3857', url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png' }); @@ -51,7 +49,7 @@ describe('ol.rendering.reproj.Tile', function() { }); it('to EPSG:4326', function(done) { - var tileGrid = ol.tilegrid.createForProjection('EPSG:4326', 7, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]); testSingleTile(source, 'EPSG:4326', tileGrid, 7, 21, -20, 1, 'rendering/ol/reproj/expected/osm4326.png', 1, done); }); @@ -60,10 +58,10 @@ describe('ol.rendering.reproj.Tile', function() { proj4.defs('EPSG:5070', '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' + '+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); - var proj5070 = ol.proj.get('EPSG:5070'); + var proj5070 = _ol_proj_.get('EPSG:5070'); proj5070.setExtent([-6e6, 0, 4e6, 6e6]); - var tileGrid = ol.tilegrid.createForProjection('EPSG:5070', 5, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:5070', 5, [64, 64]); testSingleTile(source, 'EPSG:5070', tileGrid, 5, 13, -15, 1, 'rendering/ol/reproj/expected/osm5070.png', 1, done); }); @@ -71,10 +69,10 @@ describe('ol.rendering.reproj.Tile', function() { it('to ESRI:54009', function(done) { proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); - var proj54009 = ol.proj.get('ESRI:54009'); + var proj54009 = _ol_proj_.get('ESRI:54009'); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); - var tileGrid = ol.tilegrid.createForProjection('ESRI:54009', 7, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('ESRI:54009', 7, [64, 64]); testSingleTile(source, 'ESRI:54009', tileGrid, 7, 27, -16, 1, 'rendering/ol/reproj/expected/osm54009.png', 1, done); }); @@ -82,14 +80,14 @@ describe('ol.rendering.reproj.Tile', function() { describe('stitching several tiles from EPSG:3857', function() { beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ projection: 'EPSG:3857', url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png' }); }); it('to EPSG:4326', function(done) { - var tileGrid = ol.tilegrid.createForProjection('EPSG:4326', 7, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 64]); testSingleTile(source, 'EPSG:4326', tileGrid, 7, 23, -21, 1, 'rendering/ol/reproj/expected/stitch-osm4326.png', 2, done); }); @@ -98,10 +96,10 @@ describe('ol.rendering.reproj.Tile', function() { proj4.defs('EPSG:3740', '+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' + '+units=m +no_defs'); - var proj3740 = ol.proj.get('EPSG:3740'); + var proj3740 = _ol_proj_.get('EPSG:3740'); proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]); - var tileGrid = ol.tilegrid.createForProjection('EPSG:3740', 4, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3740', 4, [64, 64]); testSingleTile(source, 'EPSG:3740', tileGrid, 4, 4, -13, 1, 'rendering/ol/reproj/expected/stitch-osm3740.png', 4, done); }); @@ -109,7 +107,7 @@ describe('ol.rendering.reproj.Tile', function() { describe('tile projection from EPSG:4326', function() { beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ projection: 'EPSG:4326', maxZoom: 0, url: 'rendering/ol/data/tiles/4326/{z}/{x}/{y}.png' @@ -122,7 +120,7 @@ describe('ol.rendering.reproj.Tile', function() { }); it('to EPSG:3857', function(done) { - var tileGrid = ol.tilegrid.createForProjection('EPSG:3857', 0, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3857', 0, [64, 64]); testSingleTile(source, 'EPSG:3857', tileGrid, 0, 0, -1, 1, 'rendering/ol/reproj/expected/4326-to-3857.png', 1, done); }); @@ -130,7 +128,7 @@ describe('ol.rendering.reproj.Tile', function() { describe('non-square source tiles', function() { beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ projection: 'EPSG:3857', url: 'rendering/ol/data/tiles/osm-512x256/{z}/{x}/{y}.png', tileSize: [512, 256] @@ -143,7 +141,7 @@ describe('ol.rendering.reproj.Tile', function() { }); it('to 64x128 EPSG:4326', function(done) { - var tileGrid = ol.tilegrid.createForProjection('EPSG:4326', 7, [64, 128]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 7, [64, 128]); testSingleTile(source, 'EPSG:4326', tileGrid, 7, 27, -10, 1, 'rendering/ol/reproj/expected/512x256-to-64x128.png', 1, done); }); @@ -151,7 +149,7 @@ describe('ol.rendering.reproj.Tile', function() { describe('dateline wrapping', function() { beforeEach(function() { - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ projection: 'EPSG:4326', maxZoom: 0, url: 'rendering/ol/data/tiles/4326/{z}/{x}/{y}.png' @@ -160,10 +158,10 @@ describe('ol.rendering.reproj.Tile', function() { it('wraps X when prime meridian is shifted', function(done) { proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs'); - var proj_ = ol.proj.get('merc_180'); + var proj_ = _ol_proj_.get('merc_180'); proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]); - var tileGrid = ol.tilegrid.createForProjection('merc_180', 0, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('merc_180', 0, [64, 64]); testSingleTile(source, 'merc_180', tileGrid, 0, 0, -1, 1, 'rendering/ol/reproj/expected/dateline-merc-180.png', 2, done); }); @@ -171,10 +169,10 @@ describe('ol.rendering.reproj.Tile', function() { it('displays north pole correctly (EPSG:3413)', function(done) { proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' + '+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); - var proj3413 = ol.proj.get('EPSG:3413'); + var proj3413 = _ol_proj_.get('EPSG:3413'); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); - var tileGrid = ol.tilegrid.createForProjection('EPSG:3413', 0, [64, 64]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3413', 0, [64, 64]); testSingleTile(source, 'EPSG:3413', tileGrid, 0, 0, -1, 1, 'rendering/ol/reproj/expected/dateline-pole.png', 2, done); }); diff --git a/test/rendering/ol/source/raster.test.js b/test/rendering/ol/source/raster.test.js index 2f650ca481..053edb178a 100644 --- a/test/rendering/ol/source/raster.test.js +++ b/test/rendering/ol/source/raster.test.js @@ -1,8 +1,8 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.source.Raster'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; +import _ol_source_Raster_ from '../../../../src/ol/source/Raster.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() { @@ -28,11 +28,11 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() { var map; function createMap(renderer, pixelRatio) { - map = new ol.Map({ + map = new _ol_Map_({ target: createMapDiv(200, 200), pixelRatio: pixelRatio, renderer: renderer, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -50,12 +50,12 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() { it('renders the result of an operation', function(done) { createMap('canvas', 1); - var source = new ol.source.XYZ({ + var source = new _ol_source_XYZ_({ url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png', transition: 0 }); - var raster = new ol.source.Raster({ + var raster = new _ol_source_Raster_({ sources: [source], operation: function(pixels) { var pixel = pixels[0]; @@ -75,7 +75,7 @@ where('Uint8ClampedArray').describe('ol.rendering.source.Raster', function() { expectResemble(map, 'rendering/ol/source/expected/raster-1.png', IMAGE_TOLERANCE, done); }); - var layer = new ol.layer.Image({source: raster}); + var layer = new _ol_layer_Image_({source: raster}); map.addLayer(layer); }); diff --git a/test/rendering/ol/source/tilewms.test.js b/test/rendering/ol/source/tilewms.test.js index 4c2972c434..bff0c67b60 100644 --- a/test/rendering/ol/source/tilewms.test.js +++ b/test/rendering/ol/source/tilewms.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.TileWMS'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_source_TileWMS_ from '../../../../src/ol/source/TileWMS.js'; describe('ol.rendering.source.TileWMS', function() { @@ -27,11 +25,11 @@ describe('ol.rendering.source.TileWMS', function() { var map; function createMap(renderer, pixelRatio) { - map = new ol.Map({ + map = new _ol_Map_({ target: createMapDiv(200, 200), pixelRatio: pixelRatio, renderer: renderer, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 5 }) @@ -46,7 +44,7 @@ describe('ol.rendering.source.TileWMS', function() { }); function createSource(gutter) { - return new ol.source.TileWMS({ + return new _ol_source_TileWMS_({ params: { 'LAYERS': 'layer' }, @@ -64,7 +62,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/0_1.canvas.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -76,7 +74,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/0_1.webgl.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -89,7 +87,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/0_2.canvas.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -101,7 +99,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/0_2.webgl.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -115,7 +113,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/20_1.canvas.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -127,7 +125,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/20_1.webgl.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -140,7 +138,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/20_2.canvas.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); @@ -152,7 +150,7 @@ describe('ol.rendering.source.TileWMS', function() { tilesLoaded(source, function() { expectResemble(map, 'rendering/ol/source/expected/20_2.webgl.png', IMAGE_TOLERANCE, done); }); - map.addLayer(new ol.layer.Tile({ + map.addLayer(new _ol_layer_Tile_({ source: source })); }); diff --git a/test/rendering/ol/style/circle.test.js b/test/rendering/ol/style/circle.test.js index aff53000d5..af396f7a50 100644 --- a/test/rendering/ol/style/circle.test.js +++ b/test/rendering/ol/style/circle.test.js @@ -1,16 +1,14 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.rendering.style.Circle', function() { @@ -18,17 +16,17 @@ describe('ol.rendering.style.Circle', function() { var map, vectorSource; function createMap(renderer) { - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(50, 50), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -47,55 +45,55 @@ describe('ol.rendering.style.Circle', function() { function createFeatures(multi) { var feature; - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-20, 18]]) : new ol.geom.Point([-20, 18]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-20, 18]]) : new _ol_geom_Point_([-20, 18]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 2, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#91E339' }) }) })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-10, 18]]) : new ol.geom.Point([-10, 18]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-10, 18]]) : new _ol_geom_Point_([-10, 18]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 4, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#5447E6' }) }) })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[4, 18]]) : new ol.geom.Point([4, 18]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[4, 18]]) : new _ol_geom_Point_([4, 18]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 6, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#92A8A6' }) }) })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-20, 3]]) : new ol.geom.Point([-20, 3]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-20, 3]]) : new _ol_geom_Point_([-20, 3]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 2, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#91E339' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#000000', width: 1 }) @@ -103,16 +101,16 @@ describe('ol.rendering.style.Circle', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-10, 3]]) : new ol.geom.Point([-10, 3]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-10, 3]]) : new _ol_geom_Point_([-10, 3]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 4, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#5447E6' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#000000', width: 2 }) @@ -120,16 +118,16 @@ describe('ol.rendering.style.Circle', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[4, 3]]) : new ol.geom.Point([4, 3]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[4, 3]]) : new _ol_geom_Point_([4, 3]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 6, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#92A8A6' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#000000', width: 3 }) @@ -137,13 +135,13 @@ describe('ol.rendering.style.Circle', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-20, -15]]) : new ol.geom.Point([-20, -15]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-20, -15]]) : new _ol_geom_Point_([-20, -15]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 2, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#256308', width: 1 }) @@ -151,16 +149,16 @@ describe('ol.rendering.style.Circle', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[-10, -15]]) : new ol.geom.Point([-10, -15]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[-10, -15]]) : new _ol_geom_Point_([-10, -15]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 4, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(0, 0, 255, 0.3)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#256308', width: 2 }) @@ -168,16 +166,16 @@ describe('ol.rendering.style.Circle', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: multi ? new ol.geom.MultiPoint([[4, -15]]) : new ol.geom.Point([4, -15]) + feature = new _ol_Feature_({ + geometry: multi ? new _ol_geom_MultiPoint_([[4, -15]]) : new _ol_geom_Point_([4, -15]) }); - feature.setStyle(new ol.style.Style({ - image: new ol.style.Circle({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 6, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgba(235, 45, 70, 0.6)' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#256308', width: 3 }) diff --git a/test/rendering/ol/style/icon.test.js b/test/rendering/ol/style/icon.test.js index c786f06ac0..d3dd5a8bde 100644 --- a/test/rendering/ol/style/icon.test.js +++ b/test/rendering/ol/style/icon.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; describe('ol.rendering.style.Icon', function() { @@ -24,17 +22,17 @@ describe('ol.rendering.style.Icon', function() { }; function createMap(renderer, width, height) { - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(width ? width : 50, height ? height : 50), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -53,15 +51,15 @@ describe('ol.rendering.style.Icon', function() { function createFeatures(src, imgInfo, callback) { var feature; - feature = new ol.Feature({ - geometry: new ol.geom.Point([0, 0]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([0, 0]) }); var img = new Image(); img.onload = function() { imgInfo.img = img; - feature.setStyle(new ol.style.Style({ - image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ (imgInfo)) + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_Icon_(/** @type {olx.style.IconOptions} */ (imgInfo)) })); vectorSource.addFeature(feature); callback(); diff --git a/test/rendering/ol/style/linestring.test.js b/test/rendering/ol/style/linestring.test.js index 6a179c8634..bddc0bc444 100644 --- a/test/rendering/ol/style/linestring.test.js +++ b/test/rendering/ol/style/linestring.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.LineString'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.rendering.style.LineString', function() { @@ -15,17 +13,17 @@ describe('ol.rendering.style.LineString', function() { var map, vectorSource; function createMap(renderer, opt_pixelRatio) { - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: opt_pixelRatio || 1, target: createMapDiv(50, 50), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -45,45 +43,45 @@ describe('ol.rendering.style.LineString', function() { function createFeatures() { var feature; - feature = new ol.Feature({ - geometry: new ol.geom.LineString( + feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[-20, 20], [15, 20]] ) }); - feature.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({color: '#DE213A', width: 3}) + feature.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({color: '#DE213A', width: 3}) })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.LineString( + feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[-20, 15], [15, 15]] ) }); - feature.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({color: '#9696EB', width: 1}) + feature.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({color: '#9696EB', width: 1}) })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.LineString( + feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[-20, 10], [15, 10]] ) }); - feature.setStyle([new ol.style.Style({ - stroke: new ol.style.Stroke({color: '#F2F211', width: 5}) - }), new ol.style.Style({ - stroke: new ol.style.Stroke({color: '#292921', width: 1}) + feature.setStyle([new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({color: '#F2F211', width: 5}) + }), new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({color: '#292921', width: 1}) })]); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.LineString( + feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[-20, -20], [-2, 0], [15, -20]] ) }); - feature.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + feature.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#000000', width: 2, lineCap: 'square', @@ -93,13 +91,13 @@ describe('ol.rendering.style.LineString', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.LineString( + feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[-20, -15], [-2, 5], [15, -15]] ) }); - feature.setStyle(new ol.style.Style({ - stroke: new ol.style.Stroke({ + feature.setStyle(new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#000000', width: 2, lineCap: 'square', diff --git a/test/rendering/ol/style/polygon.test.js b/test/rendering/ol/style/polygon.test.js index 127332726e..1614ac1a8f 100644 --- a/test/rendering/ol/style/polygon.test.js +++ b/test/rendering/ol/style/polygon.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Polygon'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.rendering.style.Polygon', function() { @@ -18,17 +16,17 @@ describe('ol.rendering.style.Polygon', function() { function createMap(renderer, opt_size) { var size = opt_size || 50; - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(size, size), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -46,43 +44,43 @@ describe('ol.rendering.style.Polygon', function() { describe('different types', function() { function createFeatures() { - var fill = new ol.style.Fill({color: 'red'}); + var fill = new _ol_style_Fill_({color: 'red'}); var feature; // rectangle - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, 10], [-20, 20], [-5, 20], [-5, 10], [-20, 10]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ fill: fill })); vectorSource.addFeature(feature); // rectangle with 1 hole - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[0, 10], [0, 20], [15, 20], [15, 10], [0, 10]], [[5, 13], [10, 13], [10, 17], [5, 17], [5, 13]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ fill: fill })); vectorSource.addFeature(feature); // rectangle with 2 holes - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, -20], [-20, 5], [15, 5], [15, -20], [-20, -20]], [[-18, -18], [-12, -18], [-12, -12], [-18, -12], [-18, -18]], [[5, -18], [12, -18], [12, -12], [5, -12], [5, -18]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ fill: fill })); vectorSource.addFeature(feature); @@ -106,7 +104,7 @@ describe('ol.rendering.style.Polygon', function() { describe('different types with stroke', function() { function createFeatures() { - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ width: 10, color: '#000', lineJoin: 'round', @@ -115,39 +113,39 @@ describe('ol.rendering.style.Polygon', function() { var feature; // rectangle - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, 10], [-20, 20], [-5, 20], [-5, 10], [-20, 10]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ stroke: stroke })); vectorSource.addFeature(feature); // rectangle with 1 hole - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[0, 10], [0, 20], [20, 20], [20, 10], [0, 10]], [[5, 13], [10, 13], [10, 17], [5, 17], [5, 13]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ stroke: stroke })); vectorSource.addFeature(feature); // rectangle with 2 holes - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, -20], [-20, 5], [20, 5], [20, -20], [-20, -20]], [[-12, -3], [-12, -12], [-8, -12], [-8, -3], [-12, -3]], [[0, -12], [13, -12], [13, -3], [0, -3], [0, -12]] ]) }); - feature.setStyle(new ol.style.Style({ + feature.setStyle(new _ol_style_Style_({ stroke: stroke })); vectorSource.addFeature(feature); @@ -175,37 +173,37 @@ describe('ol.rendering.style.Polygon', function() { function createFeatures() { var feature; // rectangle with z-index 2 - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, 10], [-20, 20], [-0, 20], [-0, 10], [-20, 10]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: '#E31E10'}), + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: '#E31E10'}), zIndex: 2 })); vectorSource.addFeature(feature); // rectangle with z-index 3 - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-15, 5], [-15, 15], [5, 15], [5, 5], [-15, 5]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: '#1A5E42'}), + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: '#1A5E42'}), zIndex: 3 })); vectorSource.addFeature(feature); // rectangle with z-index 1 - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-10, 0], [-10, 10], [10, 10], [10, 0], [-10, 0]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: '#DEDE21'}), + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: '#DEDE21'}), zIndex: 1 })); vectorSource.addFeature(feature); @@ -232,38 +230,38 @@ describe('ol.rendering.style.Polygon', function() { function createFeatures() { var feature; // rectangle - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, 10], [-20, 20], [-5, 20], [-5, 10], [-20, 10]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: '#9696EB'}), - stroke: new ol.style.Stroke({color: '#9696EB', width: 1}) + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: '#9696EB'}), + stroke: new _ol_style_Stroke_({color: '#9696EB', width: 1}) })); vectorSource.addFeature(feature); // rectangle with 1 hole - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[0, 10], [0, 20], [15, 20], [15, 10], [0, 10]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: 'rgba(255, 0, 0, 0.1)'}), - stroke: new ol.style.Stroke({color: '#DE213A', width: 3}) + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'rgba(255, 0, 0, 0.1)'}), + stroke: new _ol_style_Stroke_({color: '#DE213A', width: 3}) })); vectorSource.addFeature(feature); // rectangle with 2 holes - feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, -20], [-20, 5], [15, 5], [15, -20], [-20, -20]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: 'rgba(18, 204, 105, 0.3)'}), - stroke: new ol.style.Stroke({color: '#032E17', width: 2}) + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'rgba(18, 204, 105, 0.3)'}), + stroke: new _ol_style_Stroke_({color: '#032E17', width: 2}) })); vectorSource.addFeature(feature); } @@ -318,14 +316,14 @@ describe('ol.rendering.style.Polygon', function() { } function createFeatures() { - var feature = new ol.Feature({ - geometry: new ol.geom.Polygon([ + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[-20, -20], [-20, 20], [18, 20], [-20, -20]] ]) }); - feature.setStyle(new ol.style.Style({ - fill: new ol.style.Fill({color: createPattern()}), - stroke: new ol.style.Stroke({color: createRainbowGradient(), width: 3}) + feature.setStyle(new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: createPattern()}), + stroke: new _ol_style_Stroke_({color: createRainbowGradient(), width: 3}) })); vectorSource.addFeature(feature); } diff --git a/test/rendering/ol/style/regularshape.test.js b/test/rendering/ol/style/regularshape.test.js index c386ee90ca..1875c8f12a 100644 --- a/test/rendering/ol/style/regularshape.test.js +++ b/test/rendering/ol/style/regularshape.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.rendering.style.RegularShape', function() { @@ -17,17 +15,17 @@ describe('ol.rendering.style.RegularShape', function() { var map, vectorSource; function createMap(renderer) { - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: createMapDiv(50, 50), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -44,12 +42,12 @@ describe('ol.rendering.style.RegularShape', function() { function createFeatures(stroke, fill) { var feature; - feature = new ol.Feature({ - geometry: new ol.geom.Point([-15, 15]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([-15, 15]) }); // square - feature.setStyle(new ol.style.Style({ - image: new ol.style.RegularShape({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 4, @@ -59,12 +57,12 @@ describe('ol.rendering.style.RegularShape', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.Point([8, 15]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([8, 15]) }); // triangle - feature.setStyle(new ol.style.Style({ - image: new ol.style.RegularShape({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 3, @@ -75,12 +73,12 @@ describe('ol.rendering.style.RegularShape', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.Point([-10, -8]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([-10, -8]) }); // star - feature.setStyle(new ol.style.Style({ - image: new ol.style.RegularShape({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 5, @@ -91,12 +89,12 @@ describe('ol.rendering.style.RegularShape', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.Point([12, -8]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([12, -8]) }); // cross - feature.setStyle(new ol.style.Style({ - image: new ol.style.RegularShape({ + feature.setStyle(new _ol_style_Style_({ + image: new _ol_style_RegularShape_({ fill: fill, stroke: stroke, points: 4, @@ -110,8 +108,8 @@ describe('ol.rendering.style.RegularShape', function() { describe('#render', function() { - var stroke = new ol.style.Stroke({width: 2}); - var fill = new ol.style.Fill({color: 'red'}); + var stroke = new _ol_style_Stroke_({width: 2}); + var fill = new _ol_style_Fill_({color: 'red'}); it('tests the canvas renderer', function(done) { createMap('canvas'); @@ -121,7 +119,7 @@ describe('ol.rendering.style.RegularShape', function() { it('supports lineDash', function(done) { createMap('canvas'); - createFeatures(new ol.style.Stroke({ + createFeatures(new _ol_style_Stroke_({ lineDash: [10, 5] })); expectResemble(map, 'rendering/ol/style/expected/regularshape-canvas-linedash.png', 5, done); @@ -129,7 +127,7 @@ describe('ol.rendering.style.RegularShape', function() { it('supports lineDashOffset', function(done) { createMap('canvas'); - createFeatures(new ol.style.Stroke({ + createFeatures(new _ol_style_Stroke_({ lineDash: [10, 5], lineDashOffset: 5 })); @@ -145,8 +143,8 @@ describe('ol.rendering.style.RegularShape', function() { }); describe('uses the default fill and stroke color', function() { - var stroke = new ol.style.Stroke(); - var fill = new ol.style.Fill(); + var stroke = new _ol_style_Stroke_(); + var fill = new _ol_style_Fill_(); it('tests the canvas renderer', function(done) { createMap('canvas'); diff --git a/test/rendering/ol/style/text.test.js b/test/rendering/ol/style/text.test.js index 6c267e4834..7832825d2c 100644 --- a/test/rendering/ol/style/text.test.js +++ b/test/rendering/ol/style/text.test.js @@ -1,17 +1,17 @@ -goog.require('ol.Feature'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Text'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Style'); -goog.require('ol.style.Stroke'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.rendering.style.Text', function() { @@ -19,17 +19,17 @@ describe('ol.rendering.style.Text', function() { function createMap(renderer, opt_pixelRatio) { var pixelRatio = opt_pixelRatio || 1; - vectorSource = new ol.source.Vector(); - var vectorLayer = new ol.layer.Vector({ + vectorSource = new _ol_source_Vector_(); + var vectorLayer = new _ol_layer_Vector_({ source: vectorSource }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: pixelRatio, target: createMapDiv(200 / pixelRatio, 200 / pixelRatio), renderer: renderer, layers: [vectorLayer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -49,11 +49,11 @@ describe('ol.rendering.style.Text', function() { function createFeatures(opt_scale) { var scale = opt_scale || 1; var feature; - feature = new ol.Feature({ - geometry: new ol.geom.Point([-20, 18]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([-20, 18]) }); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ scale: scale, text: 'hello', font: '10px sans-serif' @@ -61,18 +61,18 @@ describe('ol.rendering.style.Text', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.Point([-10, 0]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([-10, 0]) }); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ scale: scale, text: 'hello', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'red', font: '12px sans-serif' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#000', width: 3 }) @@ -80,16 +80,16 @@ describe('ol.rendering.style.Text', function() { })); vectorSource.addFeature(feature); - feature = new ol.Feature({ - geometry: new ol.geom.Point([20, 10]) + feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([20, 10]) }); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ scale: scale, rotateWithView: true, text: 'hello', font: '10px sans-serif', - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: [10, 10, 10, 0.5] }) }) @@ -105,32 +105,32 @@ describe('ol.rendering.style.Text', function() { var polygon = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17]; function createLineString(coords, textAlign, maxAngle, strokeColor, strokeWidth, scale) { - var geom = new ol.geom.LineString(); + var geom = new _ol_geom_LineString_(); geom.setFlatCoordinates('XY', coords); - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: 'red' }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: 'Hello world', font: 'bold 14px sans-serif', scale: scale || 1, textAlign: textAlign, maxAngle: maxAngle, placement: 'line', - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: strokeColor || 'white', width: strokeWidth }) }) }); - var feature = new ol.Feature(geom); + var feature = new _ol_Feature_(geom); feature.setStyle(style); vectorSource.addFeature(feature); geom = geom.clone(); geom.translate(0, 5); - feature = new ol.Feature(geom); + feature = new _ol_Feature_(geom); style = style.clone(); style.getText().setTextBaseline('top'); feature.setStyle(style); @@ -138,7 +138,7 @@ describe('ol.rendering.style.Text', function() { geom = geom.clone(); geom.translate(0, -10); - feature = new ol.Feature(geom); + feature = new _ol_Feature_(geom); style = style.clone(); style.getText().setTextBaseline('bottom'); feature.setStyle(style); @@ -175,36 +175,36 @@ describe('ol.rendering.style.Text', function() { it('renders multiline text with alignment options', function(done) { createMap('canvas'); var feature; - feature = new ol.Feature(new ol.geom.Point([25, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([25, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nleft', font: 'bold 14px sans-serif', textAlign: 'left' }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([-25, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([-25, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nright', font: 'bold 14px sans-serif', textAlign: 'right' }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([0, 25])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, 25])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nbottom', font: 'bold 14px sans-serif', textBaseline: 'bottom' }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([0, -25])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, -25])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'top\nHello world', font: 'bold 14px sans-serif', textBaseline: 'top' @@ -217,9 +217,9 @@ describe('ol.rendering.style.Text', function() { it('renders multiline text with positioning options', function(done) { createMap('canvas'); var feature; - feature = new ol.Feature(new ol.geom.Point([0, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nleft', font: 'bold 14px sans-serif', textAlign: 'left', @@ -227,9 +227,9 @@ describe('ol.rendering.style.Text', function() { }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([0, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nright', font: 'bold 14px sans-serif', textAlign: 'right', @@ -237,9 +237,9 @@ describe('ol.rendering.style.Text', function() { }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([0, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world\nbottom', font: 'bold 14px sans-serif', textBaseline: 'bottom', @@ -247,9 +247,9 @@ describe('ol.rendering.style.Text', function() { }) })); vectorSource.addFeature(feature); - feature = new ol.Feature(new ol.geom.Point([0, 0])); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'top\nHello world', font: 'bold 14px sans-serif', textBaseline: 'top', @@ -262,9 +262,9 @@ describe('ol.rendering.style.Text', function() { it('renders text along a MultiLineString', function(done) { createMap('canvas'); - var line = new ol.geom.LineString(); + var line = new _ol_geom_LineString_(); line.setFlatCoordinates('XY', nicePath); - var geom = new ol.geom.MultiLineString(null); + var geom = new _ol_geom_MultiLineString_(null); geom.appendLineString(line); line = line.clone(); line.translate(0, 50); @@ -272,9 +272,9 @@ describe('ol.rendering.style.Text', function() { line = line.clone(); line.translate(0, -100); geom.appendLineString(line); - var feature = new ol.Feature(geom); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + var feature = new _ol_Feature_(geom); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world', placement: 'line', font: 'bold 30px sans-serif' @@ -287,11 +287,11 @@ describe('ol.rendering.style.Text', function() { it('renders text along a Polygon', function(done) { createMap('canvas'); - var geom = new ol.geom.Polygon(null); + var geom = new _ol_geom_Polygon_(null); geom.setFlatCoordinates('XY', polygon, [polygon.length]); - var feature = new ol.Feature(geom); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + var feature = new _ol_Feature_(geom); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world', font: 'bold 24px sans-serif', placement: 'line', @@ -305,9 +305,9 @@ describe('ol.rendering.style.Text', function() { it('renders text along a MultiPolygon', function(done) { createMap('canvas'); - var geom = new ol.geom.Polygon(null); + var geom = new _ol_geom_Polygon_(null); geom.setFlatCoordinates('XY', polygon, [polygon.length]); - var multiPolygon = new ol.geom.MultiPolygon(null); + var multiPolygon = new _ol_geom_MultiPolygon_(null); multiPolygon.appendPolygon(geom); geom = geom.clone(); geom.translate(0, 30); @@ -315,9 +315,9 @@ describe('ol.rendering.style.Text', function() { geom = geom.clone(); geom.translate(0, -60); multiPolygon.appendPolygon(geom); - var feature = new ol.Feature(multiPolygon); - feature.setStyle(new ol.style.Style({ - text: new ol.style.Text({ + var feature = new _ol_Feature_(multiPolygon); + feature.setStyle(new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'Hello world', font: 'bold 24px sans-serif', placement: 'line', @@ -333,20 +333,20 @@ describe('ol.rendering.style.Text', function() { createMap('canvas'); createFeatures(); var features = vectorSource.getFeatures(); - features[0].getStyle().getText().setBackgroundFill(new ol.style.Fill({ + features[0].getStyle().getText().setBackgroundFill(new _ol_style_Fill_({ color: 'red' })); - features[1].getStyle().getText().setBackgroundFill(new ol.style.Fill({ + features[1].getStyle().getText().setBackgroundFill(new _ol_style_Fill_({ color: 'red' })); - features[1].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({ + features[1].getStyle().getText().setBackgroundStroke(new _ol_style_Stroke_({ color: 'blue', width: 3 })); - features[2].getStyle().getText().setBackgroundFill(new ol.style.Fill({ + features[2].getStyle().getText().setBackgroundFill(new _ol_style_Fill_({ color: 'red' })); - features[2].getStyle().getText().setBackgroundStroke(new ol.style.Stroke({ + features[2].getStyle().getText().setBackgroundStroke(new _ol_style_Stroke_({ color: 'blue', width: 3 })); diff --git a/test/spec/ol/array.test.js b/test/spec/ol/array.test.js index d79e691ed5..8efac8d7a7 100644 --- a/test/spec/ol/array.test.js +++ b/test/spec/ol/array.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.array'); +import _ol_array_ from '../../../src/ol/array.js'; describe('ol.array', function() { @@ -22,43 +20,43 @@ describe('ol.array', function() { ]; it('should find \'1000\' at index 0', function() { - expect(ol.array.binarySearch(a, '1000')).to.be(0); + expect(_ol_array_.binarySearch(a, '1000')).to.be(0); }); it('should find \'zzz\' at index ' + (a.length - 1), function() { - expect(ol.array.binarySearch(a, 'zzz')).to.be(a.length - 1); + expect(_ol_array_.binarySearch(a, 'zzz')).to.be(a.length - 1); }); it('should find \'C\' at index 10', function() { - expect(ol.array.binarySearch(a, 'C')).to.be(10); + expect(_ol_array_.binarySearch(a, 'C')).to.be(10); }); it('should find \'B\' at index 7 || 8 || 9', function() { - var pos = ol.array.binarySearch(a, 'B'); + var pos = _ol_array_.binarySearch(a, 'B'); expect(pos == 7 || pos == 8 || pos == 9).to.be.ok(); }); it('should not find \'100\'', function() { - var pos = ol.array.binarySearch(a, '100'); + var pos = _ol_array_.binarySearch(a, '100'); expect(pos < 0).to.be.ok(); }); it('should have an insertion point of 0 for \'100\'', function() { - var pos = ol.array.binarySearch(a, '100'); + var pos = _ol_array_.binarySearch(a, '100'); expect(insertionPoint(pos)).to.be(0); }); it('should not find \'zzz0\'', function() { - var pos = ol.array.binarySearch(a, 'zzz0'); + var pos = _ol_array_.binarySearch(a, 'zzz0'); expect(pos < 0).to.be.ok(); }); it('should have an insertion point of ' + (a.length) + ' for \'zzz0\'', function() { - var pos = ol.array.binarySearch(a, 'zzz0'); + var pos = _ol_array_.binarySearch(a, 'zzz0'); expect(insertionPoint(pos)).to.be(a.length); } ); it('should not find \'BA\'', function() { - var pos = ol.array.binarySearch(a, 'zzz0'); + var pos = _ol_array_.binarySearch(a, 'zzz0'); expect(pos < 0).to.be.ok(); }); it('should have an insertion point of 10 for \'BA\'', function() { - var pos = ol.array.binarySearch(a, 'BA'); + var pos = _ol_array_.binarySearch(a, 'BA'); expect(insertionPoint(pos)).to.be(10); } ); @@ -67,11 +65,11 @@ describe('ol.array', function() { describe('0 length array with default comparison', function() { var b = []; it('should not find \'a\'', function() { - expect(ol.array.binarySearch(b, 'a') < 0).to.be.ok(); + expect(_ol_array_.binarySearch(b, 'a') < 0).to.be.ok(); }); it('should have an insertion point of 0 for \'a\'', function() { - var pos = ol.array.binarySearch(b, 'a'); + var pos = _ol_array_.binarySearch(b, 'a'); expect(insertionPoint(pos)).to.be(0); } ); @@ -81,23 +79,23 @@ describe('ol.array', function() { function() { var c = ['only item']; it('should find \'only item\' at index 0', function() { - expect(ol.array.binarySearch(c, 'only item')).to.be(0); + expect(_ol_array_.binarySearch(c, 'only item')).to.be(0); }); it('should not find \'a\'', function() { - expect(ol.array.binarySearch(c, 'a') < 0).to.be.ok(); + expect(_ol_array_.binarySearch(c, 'a') < 0).to.be.ok(); }); it('should have an insertion point of 0 for \'a\'', function() { - var pos = ol.array.binarySearch(c, 'a'); + var pos = _ol_array_.binarySearch(c, 'a'); expect(insertionPoint(pos)).to.be(0); } ); it('should not find \'z\'', function() { - expect(ol.array.binarySearch(c, 'z') < 0).to.be.ok(); + expect(_ol_array_.binarySearch(c, 'z') < 0).to.be.ok(); }); it('should have an insertion point of 1 for \'z\'', function() { - var pos = ol.array.binarySearch(c, 'z'); + var pos = _ol_array_.binarySearch(c, 'z'); expect(insertionPoint(pos)).to.be(1); } ); @@ -110,42 +108,42 @@ describe('ol.array', function() { 0.31255, 5, 142.88888708, 334, 342, 453, 54254 ]; it('should find -897123.9 at index 0', function() { - expect(ol.array.binarySearch(d, -897123.9)).to.be(0); + expect(_ol_array_.binarySearch(d, -897123.9)).to.be(0); }); it('should find 54254 at index ' + (d.length - 1), function() { - expect(ol.array.binarySearch(d, 54254)).to.be(d.length - 1); + expect(_ol_array_.binarySearch(d, 54254)).to.be(d.length - 1); }); it('should find -3 at index 5', function() { - expect(ol.array.binarySearch(d, -3)).to.be(5); + expect(_ol_array_.binarySearch(d, -3)).to.be(5); }); it('should find 0 at index 6 || 7 || 8', function() { - var pos = ol.array.binarySearch(d, 0); + var pos = _ol_array_.binarySearch(d, 0); expect(pos == 6 || pos == 7 || pos == 8).to.be(true); }); it('should not find -900000', function() { - var pos = ol.array.binarySearch(d, -900000); + var pos = _ol_array_.binarySearch(d, -900000); expect(pos < 0).to.be(true); }); it('should have an insertion point of 0 for -900000', function() { - var pos = ol.array.binarySearch(d, -900000); + var pos = _ol_array_.binarySearch(d, -900000); expect(insertionPoint(pos)).to.be(0); }); it('should not find 54255', function() { - var pos = ol.array.binarySearch(d, 54255); + var pos = _ol_array_.binarySearch(d, 54255); expect(pos < 0).to.be(true); }); it('should have an insertion point of ' + (d.length) + ' for 54255', function() { - var pos = ol.array.binarySearch(d, 54255); + var pos = _ol_array_.binarySearch(d, 54255); expect(insertionPoint(pos)).to.be(d.length); } ); it('should not find 1.1', function() { - var pos = ol.array.binarySearch(d, 1.1); + var pos = _ol_array_.binarySearch(d, 1.1); expect(pos < 0).to.be(true); }); it('should have an insertion point of 10 for 1.1', function() { - var pos = ol.array.binarySearch(d, 1.1); + var pos = _ol_array_.binarySearch(d, 1.1); expect(insertionPoint(pos)).to.be(10); }); }); @@ -157,45 +155,45 @@ describe('ol.array', function() { -9, -324, -1321.3124, -321434.58758, -897123.9 ]; it('should find 54254 at index 0', function() { - var pos = ol.array.binarySearch(e, 54254, revNumCompare); + var pos = _ol_array_.binarySearch(e, 54254, revNumCompare); expect(pos).to.be(0); }); it('should find -897123.9 at index ' + (e.length - 1), function() { - var pos = ol.array.binarySearch(e, -897123.9, revNumCompare); + var pos = _ol_array_.binarySearch(e, -897123.9, revNumCompare); expect(pos).to.be(e.length - 1); }); it('should find -3 at index 10', function() { - var pos = ol.array.binarySearch(e, -3, revNumCompare); + var pos = _ol_array_.binarySearch(e, -3, revNumCompare); expect(pos).to.be(10); }); it('should find 0 at index 7 || 8 || 9', function() { - var pos = ol.array.binarySearch(e, 0, revNumCompare); + var pos = _ol_array_.binarySearch(e, 0, revNumCompare); expect(pos == 7 || pos == 8 || pos == 9).to.be(true); }); it('should not find 54254.1', function() { - var pos = ol.array.binarySearch(e, 54254.1, revNumCompare); + var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of 0 for 54254.1', function() { - var pos = ol.array.binarySearch(e, 54254.1, revNumCompare); + var pos = _ol_array_.binarySearch(e, 54254.1, revNumCompare); expect(insertionPoint(pos)).to.be(0); }); it('should not find -897124', function() { - var pos = ol.array.binarySearch(e, -897124, revNumCompare); + var pos = _ol_array_.binarySearch(e, -897124, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of ' + e.length + ' for -897124', function() { - var pos = ol.array.binarySearch(e, -897124, revNumCompare); + var pos = _ol_array_.binarySearch(e, -897124, revNumCompare); expect(insertionPoint(pos)).to.be(e.length); } ); it('should not find 1.1', function() { - var pos = ol.array.binarySearch(e, 1.1, revNumCompare); + var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of 0 for 1.1', function() { - var pos = ol.array.binarySearch(e, 1.1, revNumCompare); + var pos = _ol_array_.binarySearch(e, 1.1, revNumCompare); expect(insertionPoint(pos)).to.be(6); }); } @@ -204,11 +202,11 @@ describe('ol.array', function() { describe('0 length array with custom comparison function', function() { var f = []; it('should not find 0', function() { - var pos = ol.array.binarySearch(f, 0, revNumCompare); + var pos = _ol_array_.binarySearch(f, 0, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of 0 for 0', function() { - var pos = ol.array.binarySearch(f, 0, revNumCompare); + var pos = _ol_array_.binarySearch(f, 0, revNumCompare); expect(insertionPoint(pos)).to.be(0); }); }); @@ -217,23 +215,23 @@ describe('ol.array', function() { function() { var g = [1]; it('should find 1 at index 0', function() { - var pos = ol.array.binarySearch(g, 1, revNumCompare); + var pos = _ol_array_.binarySearch(g, 1, revNumCompare); expect(pos).to.be(0); }); it('should not find 2', function() { - var pos = ol.array.binarySearch(g, 2, revNumCompare); + var pos = _ol_array_.binarySearch(g, 2, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of 0 for 2', function() { - var pos = ol.array.binarySearch(g, 2, revNumCompare); + var pos = _ol_array_.binarySearch(g, 2, revNumCompare); expect(insertionPoint(pos)).to.be(0); }); it('should not find 0', function() { - var pos = ol.array.binarySearch(g, 0, revNumCompare); + var pos = _ol_array_.binarySearch(g, 0, revNumCompare); expect(pos < 0).to.be(true); }); it('should have an insertion point of 1 for 0', function() { - var pos = ol.array.binarySearch(g, 0, revNumCompare); + var pos = _ol_array_.binarySearch(g, 0, revNumCompare); expect(insertionPoint(pos)).to.be(1); }); } @@ -241,10 +239,10 @@ describe('ol.array', function() { describe('finding first index when multiple candidates', function() { it('should find the index of the first 0', function() { - expect(ol.array.binarySearch([0, 0, 1], 0)).to.be(0); + expect(_ol_array_.binarySearch([0, 0, 1], 0)).to.be(0); }); it('should find the index of the first 1', function() { - expect(ol.array.binarySearch([0, 1, 1], 1)).to.be(1); + expect(_ol_array_.binarySearch([0, 1, 1], 1)).to.be(1); }); }); @@ -277,8 +275,8 @@ describe('ol.array', function() { }; // Now actually call and test the method twice - ol.array.binarySearch(a, 48); - ol.array.binarySearch(a, 13, function(a, b) { + _ol_array_.binarySearch(a, 48); + _ol_array_.binarySearch(a, 13, function(a, b) { return a > b ? 1 : a < b ? -1 : 0; }); @@ -300,61 +298,61 @@ describe('ol.array', function() { var arr = [1, 2, 2, 2, 3, 5, 9]; it('should return the index of where the item would go plus one, negated, if the item is not found', function() { - expect(ol.array.binarySearch(arr, 4)).to.equal(-6); + expect(_ol_array_.binarySearch(arr, 4)).to.equal(-6); }); it('should work even on empty arrays', function() { - expect(ol.array.binarySearch([], 42)).to.equal(-1); + expect(_ol_array_.binarySearch([], 42)).to.equal(-1); }); it('should work even on arrays of doubles', function() { - expect(ol.array.binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4); + expect(_ol_array_.binarySearch([0.0, 0.1, 0.2, 0.3, 0.4], 0.25)).to.equal(-4); }); }); }); describe('equals', function() { it('returns true for [] == []', function() { - expect(ol.array.equals([], [])).to.be(true); + expect(_ol_array_.equals([], [])).to.be(true); }); it('returns true for [1] == [1]', function() { - expect(ol.array.equals([1], [1])).to.be(true); + expect(_ol_array_.equals([1], [1])).to.be(true); }); it('returns true for [\'1\'] == [\'1\']', function() { - expect(ol.array.equals(['1'], ['1'])).to.be(true); + expect(_ol_array_.equals(['1'], ['1'])).to.be(true); }); it('returns false for [1] == [\'1\']', function() { - expect(ol.array.equals([1], ['1'])).to.be(false); + expect(_ol_array_.equals([1], ['1'])).to.be(false); }); it('returns true for [null] == [null]', function() { - expect(ol.array.equals([null], [null])).to.be(true); + expect(_ol_array_.equals([null], [null])).to.be(true); }); it('returns false for [null] == [undefined]', function() { - expect(ol.array.equals([null], [undefined])).to.be(false); + expect(_ol_array_.equals([null], [undefined])).to.be(false); }); it('returns true for [1, 2] == [1, 2]', function() { - expect(ol.array.equals([1, 2], [1, 2])).to.be(true); + expect(_ol_array_.equals([1, 2], [1, 2])).to.be(true); }); it('returns false for [1, 2] == [2, 1]', function() { - expect(ol.array.equals([1, 2], [2, 1])).to.be(false); + expect(_ol_array_.equals([1, 2], [2, 1])).to.be(false); }); it('returns false for [1, 2] == [1]', function() { - expect(ol.array.equals([1, 2], [1])).to.be(false); + expect(_ol_array_.equals([1, 2], [1])).to.be(false); }); it('returns false for [1] == [1, 2]', function() { - expect(ol.array.equals([1], [1, 2])).to.be(false); + expect(_ol_array_.equals([1], [1, 2])).to.be(false); }); it('returns false for [{}] == [{}]', function() { - expect(ol.array.equals([{}], [{}])).to.be(false); + expect(_ol_array_.equals([{}], [{}])).to.be(false); }); }); describe('extend', function() { it('extends an array in place with an array', function() { var a = [0, 1]; - ol.array.extend(a, [2, 3]); + _ol_array_.extend(a, [2, 3]); expect(a).to.eql([0, 1, 2, 3]); }); it('extends an array in place with a number', function() { var a = [0, 1]; - ol.array.extend(a, 2); + _ol_array_.extend(a, 2); expect(a).to.eql([0, 1, 2]); }); it('extends an array in place with a big array', function() { @@ -364,7 +362,7 @@ describe('ol.array', function() { while (i--) { bigArray[i] = i; } - ol.array.extend(a, bigArray); + _ol_array_.extend(a, bigArray); expect(a).to.eql(bigArray); }); }); @@ -372,7 +370,7 @@ describe('ol.array', function() { describe('find', function() { it('finds numbers in an array', function() { var a = [0, 1, 2, 3]; - var b = ol.array.find(a, function(val, index, a2) { + var b = _ol_array_.find(a, function(val, index, a2) { expect(a).to.equal(a2); expect(typeof index).to.be('number'); return val > 1; @@ -382,7 +380,7 @@ describe('ol.array', function() { it('returns null when an item in an array is not found', function() { var a = [0, 1, 2, 3]; - var b = ol.array.find(a, function(val, index, a2) { + var b = _ol_array_.find(a, function(val, index, a2) { return val > 100; }); expect(b).to.be(null); @@ -390,7 +388,7 @@ describe('ol.array', function() { it('finds items in an array-like', function() { var a = 'abCD'; - var b = ol.array.find(a, function(val, index, a2) { + var b = _ol_array_.find(a, function(val, index, a2) { expect(a).to.equal(a2); expect(typeof index).to.be('number'); return val >= 'A' && val <= 'Z'; @@ -400,7 +398,7 @@ describe('ol.array', function() { it('returns null when nothing in an array-like is found', function() { var a = 'abcd'; - var b = ol.array.find(a, function(val, index, a2) { + var b = _ol_array_.find(a, function(val, index, a2) { return val >= 'A' && val <= 'Z'; }); expect(b).to.be(null); @@ -410,7 +408,7 @@ describe('ol.array', function() { describe('findIndex', function() { it('finds index of numbers in an array', function() { var a = [0, 1, 2, 3]; - var b = ol.array.findIndex(a, function(val, index, a2) { + var b = _ol_array_.findIndex(a, function(val, index, a2) { expect(a).to.equal(a2); expect(typeof index).to.be('number'); return val > 1; @@ -420,7 +418,7 @@ describe('ol.array', function() { it('returns -1 when an item in an array is not found', function() { var a = [0, 1, 2, 3]; - var b = ol.array.findIndex(a, function(val, index, a2) { + var b = _ol_array_.findIndex(a, function(val, index, a2) { return val > 100; }); expect(b).to.be(-1); @@ -429,23 +427,23 @@ describe('ol.array', function() { describe('isSorted', function() { it('works with just an array as argument', function() { - expect(ol.array.isSorted([1, 2, 3])).to.be(true); - expect(ol.array.isSorted([1, 2, 2])).to.be(true); - expect(ol.array.isSorted([1, 2, 1])).to.be(false); + expect(_ol_array_.isSorted([1, 2, 3])).to.be(true); + expect(_ol_array_.isSorted([1, 2, 2])).to.be(true); + expect(_ol_array_.isSorted([1, 2, 1])).to.be(false); }); it('works with strict comparison without compare function', function() { - expect(ol.array.isSorted([1, 2, 3], null, true)).to.be(true); - expect(ol.array.isSorted([1, 2, 2], null, true)).to.be(false); - expect(ol.array.isSorted([1, 2, 1], null, true)).to.be(false); + expect(_ol_array_.isSorted([1, 2, 3], null, true)).to.be(true); + expect(_ol_array_.isSorted([1, 2, 2], null, true)).to.be(false); + expect(_ol_array_.isSorted([1, 2, 1], null, true)).to.be(false); }); it('works with a compare function', function() { function compare(a, b) { return b - a; } - expect(ol.array.isSorted([1, 2, 3], compare)).to.be(false); - expect(ol.array.isSorted([3, 2, 2], compare)).to.be(true); + expect(_ol_array_.isSorted([1, 2, 3], compare)).to.be(false); + expect(_ol_array_.isSorted([3, 2, 2], compare)).to.be(true); }); }); @@ -453,49 +451,49 @@ describe('ol.array', function() { it('returns expected value', function() { var arr = [1000, 500, 100]; - expect(ol.array.linearFindNearest(arr, 10000, 0)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 10000, 1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 10000, -1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 10000, 0)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 10000, 1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 10000, -1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 1000, 0)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 1000, 1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 1000, -1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 1000, 0)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 1000, 1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 1000, -1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 900, 0)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 900, 1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 900, -1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 900, 0)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 900, 1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 900, -1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 750, 0)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 750, 1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 750, -1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 750, 0)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 750, 1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 750, -1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 550, 0)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 550, 1)).to.eql(0); - expect(ol.array.linearFindNearest(arr, 550, -1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 550, 0)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 550, 1)).to.eql(0); + expect(_ol_array_.linearFindNearest(arr, 550, -1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 500, 0)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 500, 1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 500, -1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 500, 0)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 500, 1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 500, -1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 450, 0)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 450, 1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 450, -1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 450, 0)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 450, 1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 450, -1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 300, 0)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 300, 1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 300, -1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 300, 0)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 300, 1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 300, -1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 200, 0)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 200, 1)).to.eql(1); - expect(ol.array.linearFindNearest(arr, 200, -1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 200, 0)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 200, 1)).to.eql(1); + expect(_ol_array_.linearFindNearest(arr, 200, -1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 100, 0)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 100, 1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 100, -1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 100, 0)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 100, 1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 100, -1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 50, 0)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 50, 1)).to.eql(2); - expect(ol.array.linearFindNearest(arr, 50, -1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 50, 0)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 50, 1)).to.eql(2); + expect(_ol_array_.linearFindNearest(arr, 50, -1)).to.eql(2); }); }); @@ -503,7 +501,7 @@ describe('ol.array', function() { it('sorts as expected', function() { var arr = [40, 200, 3000]; // default sort would yield [200, 3000, 40] - arr.sort(ol.array.numberSafeCompareFunction); + arr.sort(_ol_array_.numberSafeCompareFunction); expect(arr).to.eql(arr); }); }); @@ -511,9 +509,9 @@ describe('ol.array', function() { describe('remove', function() { it('removes elements from an array', function() { var a = ['a', 'b', 'c', 'd']; - ol.array.remove(a, 'c'); + _ol_array_.remove(a, 'c'); expect(a).to.eql(['a', 'b', 'd']); - ol.array.remove(a, 'x'); + _ol_array_.remove(a, 'x'); expect(a).to.eql(['a', 'b', 'd']); }); }); @@ -524,19 +522,19 @@ describe('ol.array', function() { var expected = [1, 2, 3, 4, 5, 6]; arr = [1, 5, 4, 3, 2, 6]; - ol.array.reverseSubArray(arr, 1, 4); + _ol_array_.reverseSubArray(arr, 1, 4); expect(arr).to.eql(expected); arr = [3, 2, 1, 4, 5, 6]; - ol.array.reverseSubArray(arr, 0, 2); + _ol_array_.reverseSubArray(arr, 0, 2); expect(arr).to.eql(expected); arr = [1, 2, 3, 6, 5, 4]; - ol.array.reverseSubArray(arr, 3, 5); + _ol_array_.reverseSubArray(arr, 3, 5); expect(arr).to.eql(expected); arr = [6, 5, 4, 3, 2, 1]; - ol.array.reverseSubArray(arr, 0, 5); + _ol_array_.reverseSubArray(arr, 0, 5); expect(arr).to.eql(expected); }); }); @@ -554,7 +552,7 @@ describe('ol.array', function() { function comparisonFn(obj1, obj2) { return obj1.key - obj2.key; } - ol.array.stableSort(arr, comparisonFn); + _ol_array_.stableSort(arr, comparisonFn); var sortedValues = []; for (var i = 0; i < arr.length; i++) { sortedValues.push(arr[i].val); diff --git a/test/spec/ol/assertionerror.test.js b/test/spec/ol/assertionerror.test.js index 8b37f3a6a1..1bafb85721 100644 --- a/test/spec/ol/assertionerror.test.js +++ b/test/spec/ol/assertionerror.test.js @@ -1,27 +1,25 @@ - - -goog.require('ol'); -goog.require('ol.AssertionError'); +import _ol_ from '../../../src/ol.js'; +import _ol_AssertionError_ from '../../../src/ol/AssertionError.js'; describe('ol.AssertionError', function() { it('generates an error', function() { - var error = new ol.AssertionError(42); + var error = new _ol_AssertionError_(42); expect(error).to.be.an(Error); }); it('generates a message with a versioned url', function() { - var error = new ol.AssertionError(42); - var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest'; + var error = new _ol_AssertionError_(42); + var path = _ol_.VERSION ? _ol_.VERSION.split('-')[0] : 'latest'; expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/' + path + '/doc/errors/#42 for details.'); }); it('has an error code', function() { - var error = new ol.AssertionError(42); + var error = new _ol_AssertionError_(42); expect(error.code).to.be(42); }); it('has a name', function() { - var error = new ol.AssertionError(42); + var error = new _ol_AssertionError_(42); expect(error.name).to.be('AssertionError'); }); }); diff --git a/test/spec/ol/asserts.test.js b/test/spec/ol/asserts.test.js index 7d2f8ca209..5129141401 100644 --- a/test/spec/ol/asserts.test.js +++ b/test/spec/ol/asserts.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.asserts'); +import _ol_asserts_ from '../../../src/ol/asserts.js'; describe('ol.asserts', function() { @@ -8,7 +6,7 @@ describe('ol.asserts', function() { describe('ol.asserts.assert', function() { it('throws an exception', function() { expect(function() { - ol.asserts.assert(false, 42); + _ol_asserts_.assert(false, 42); }).to.throwException(); }); }); diff --git a/test/spec/ol/collection.test.js b/test/spec/ol/collection.test.js index 4b60698b2a..654bc0f0ac 100644 --- a/test/spec/ol/collection.test.js +++ b/test/spec/ol/collection.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.events'); -goog.require('ol.Collection'); -goog.require('ol.CollectionEventType'); +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_Collection_ from '../../../src/ol/Collection.js'; +import _ol_CollectionEventType_ from '../../../src/ol/CollectionEventType.js'; describe('ol.collection', function() { var collection; beforeEach(function() { - collection = new ol.Collection(); + collection = new _ol_Collection_(); }); describe('create an empty collection', function() { @@ -23,7 +21,7 @@ describe('ol.collection', function() { describe('create a collection from an array', function() { it('creates the expected collection', function() { var array = [0, 1, 2]; - var collection = new ol.Collection(array); + var collection = new _ol_Collection_(array); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(1); expect(collection.item(2)).to.eql(2); @@ -39,7 +37,7 @@ describe('ol.collection', function() { }); it('returns the correct new length of the collection', function() { var length; - ol.events.listen(collection, 'add', function(event) { + _ol_events_.listen(collection, 'add', function(event) { if (event.element === 'remove_me') { collection.remove(event.element); } @@ -63,7 +61,7 @@ describe('ol.collection', function() { describe('insertAt', function() { it('inserts elements at the correct location', function() { - collection = new ol.Collection([0, 2]); + collection = new _ol_Collection_([0, 2]); collection.insertAt(1, 1); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(1); @@ -82,7 +80,7 @@ describe('ol.collection', function() { describe('removeAt', function() { it('removes elements at the correction', function() { - var collection = new ol.Collection([0, 1, 2]); + var collection = new _ol_Collection_([0, 1, 2]); collection.removeAt(1); expect(collection.item(0)).to.eql(0); expect(collection.item(1)).to.eql(2); @@ -110,7 +108,7 @@ describe('ol.collection', function() { }); describe('scope', function() { it('callbacks get the correct scope', function() { - var collection = new ol.Collection([0]); + var collection = new _ol_Collection_([0]); var that; var uniqueObj = {}; collection.forEach(function(elem) { @@ -123,27 +121,27 @@ describe('ol.collection', function() { describe('remove', function() { it('removes the first matching element', function() { - var collection = new ol.Collection([0, 1, 2]); + var collection = new _ol_Collection_([0, 1, 2]); expect(collection.remove(1)).to.eql(1); expect(collection.getArray()).to.eql([0, 2]); expect(collection.getLength()).to.eql(2); }); it('fires a remove event', function() { - var collection = new ol.Collection([0, 1, 2]); + var collection = new _ol_Collection_([0, 1, 2]); var cb = sinon.spy(); - ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb); + _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb); expect(collection.remove(1)).to.eql(1); expect(cb).to.be.called(); expect(cb.lastCall.args[0].element).to.eql(1); }); it('does not remove more than one matching element', function() { - var collection = new ol.Collection([0, 1, 1, 2]); + var collection = new _ol_Collection_([0, 1, 1, 2]); expect(collection.remove(1)).to.eql(1); expect(collection.getArray()).to.eql([0, 1, 2]); expect(collection.getLength()).to.eql(3); }); it('returns undefined if the element is not found', function() { - var collection = new ol.Collection([0, 1, 2]); + var collection = new _ol_Collection_([0, 1, 2]); expect(collection.remove(3)).to.be(undefined); expect(collection.getArray()).to.eql([0, 1, 2]); expect(collection.getLength()).to.eql(3); @@ -152,13 +150,13 @@ describe('ol.collection', function() { describe('setAt and event', function() { it('does dispatch events', function() { - var collection = new ol.Collection(['a', 'b']); + var collection = new _ol_Collection_(['a', 'b']); var added, removed; - ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) { + _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { added = e.element; }); - ol.events.listen( - collection, ol.CollectionEventType.REMOVE, function(e) { + _ol_events_.listen( + collection, _ol_CollectionEventType_.REMOVE, function(e) { removed = e.element; }); collection.setAt(1, 1); @@ -169,10 +167,10 @@ describe('ol.collection', function() { describe('removeAt and event', function() { it('does dispatch events', function() { - var collection = new ol.Collection(['a']); + var collection = new _ol_Collection_(['a']); var removed; - ol.events.listen( - collection, ol.CollectionEventType.REMOVE, function(e) { + _ol_events_.listen( + collection, _ol_CollectionEventType_.REMOVE, function(e) { removed = e.element; }); collection.pop(); @@ -182,10 +180,10 @@ describe('ol.collection', function() { describe('insertAt and event', function() { it('does dispatch events', function() { - var collection = new ol.Collection([0, 2]); + var collection = new _ol_Collection_([0, 2]); var added; - ol.events.listen( - collection, ol.CollectionEventType.ADD, function(e) { + _ol_events_.listen( + collection, _ol_CollectionEventType_.ADD, function(e) { added = e.element; }); collection.insertAt(1, 1); @@ -196,8 +194,8 @@ describe('ol.collection', function() { describe('setAt beyond end', function() { it('triggers events properly', function() { var added = []; - ol.events.listen( - collection, ol.CollectionEventType.ADD, function(e) { + _ol_events_.listen( + collection, _ol_CollectionEventType_.ADD, function(e) { added.push(e.element); }); collection.setAt(2, 0); @@ -215,9 +213,9 @@ describe('ol.collection', function() { describe('change:length event', function() { var collection, cb; beforeEach(function() { - collection = new ol.Collection([0, 1, 2]); + collection = new _ol_Collection_([0, 1, 2]); cb = sinon.spy(); - ol.events.listen(collection, 'change:length', cb); + _ol_events_.listen(collection, 'change:length', cb); }); describe('insertAt', function() { @@ -244,9 +242,9 @@ describe('ol.collection', function() { describe('add event', function() { it('triggers add when pushing', function() { - var collection = new ol.Collection(); + var collection = new _ol_Collection_(); var elem; - ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) { + _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { elem = e.element; }); var length = collection.push(1); @@ -257,14 +255,14 @@ describe('ol.collection', function() { describe('remove event', function() { var collection, cb1, cb2; beforeEach(function() { - collection = new ol.Collection([1]); + collection = new _ol_Collection_([1]); cb1 = sinon.spy(); cb2 = sinon.spy(); }); describe('setAt', function() { it('triggers remove', function() { - ol.events.listen(collection, ol.CollectionEventType.ADD, cb1); - ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb2); + _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, cb1); + _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb2); collection.setAt(0, 2); expect(cb2.lastCall.args[0].element).to.eql(1); expect(cb1.lastCall.args[0].element).to.eql(2); @@ -272,7 +270,7 @@ describe('ol.collection', function() { }); describe('pop', function() { it('triggers remove', function() { - ol.events.listen(collection, ol.CollectionEventType.REMOVE, cb1); + _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb1); collection.pop(); expect(cb1.lastCall.args[0].element).to.eql(1); }); @@ -288,9 +286,9 @@ describe('ol.collection', function() { expect(collection.item(1)).to.eql(2); }); it('fires events', function() { - var collection = new ol.Collection(); + var collection = new _ol_Collection_(); var elems = []; - ol.events.listen(collection, ol.CollectionEventType.ADD, function(e) { + _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { elems.push(e.element); }); collection.extend([1, 2]); @@ -300,25 +298,25 @@ describe('ol.collection', function() { describe('unique collection', function() { it('allows unique items in the constructor', function() { - new ol.Collection([{}, {}, {}], {unique: true}); + new _ol_Collection_([{}, {}, {}], {unique: true}); }); it('throws if duplicate items are passed to the constructor', function() { var item = {}; var call = function() { - new ol.Collection([item, item], {unique: true}); + new _ol_Collection_([item, item], {unique: true}); }; expect(call).to.throwException(); }); it('allows unique items to be added via push', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); unique.push({}); unique.push({}); }); it('throws if duplicate items are added via push', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); var item = {}; unique.push(item); var call = function() { @@ -328,13 +326,13 @@ describe('ol.collection', function() { }); it('allows unique items to be added via insertAt', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); unique.insertAt(0, {}); unique.insertAt(0, {}); }); it('throws if duplicate items are added via insertAt', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); var item = {}; unique.insertAt(0, item); var call = function() { @@ -344,20 +342,20 @@ describe('ol.collection', function() { }); it('allows unique items to be added via setAt', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); unique.setAt(0, {}); unique.setAt(1, {}); }); it('allows items to be reset via setAt', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); var item = {}; unique.setAt(0, item); unique.setAt(0, item); }); it('throws if duplicate items are added via setAt', function() { - var unique = new ol.Collection(undefined, {unique: true}); + var unique = new _ol_Collection_(undefined, {unique: true}); var item = {}; unique.setAt(0, item); var call = function() { diff --git a/test/spec/ol/color.test.js b/test/spec/ol/color.test.js index b9e131f6b5..30c3d74cec 100644 --- a/test/spec/ol/color.test.js +++ b/test/spec/ol/color.test.js @@ -1,5 +1,5 @@ -goog.require('ol.color'); -goog.require('ol'); +import _ol_color_ from '../../../src/ol/color.js'; +import _ol_ from '../../../src/ol.js'; describe('ol.color', function() { @@ -8,27 +8,27 @@ describe('ol.color', function() { it('returns the same for an array', function() { var color = [1, 2, 3, 0.4]; - var got = ol.color.asArray(color); + var got = _ol_color_.asArray(color); expect(got).to.be(color); }); it('returns an array given an rgba string', function() { - var color = ol.color.asArray('rgba(1,2,3,0.4)'); + var color = _ol_color_.asArray('rgba(1,2,3,0.4)'); expect(color).to.eql([1, 2, 3, 0.4]); }); it('returns an array given an rgb string', function() { - var color = ol.color.asArray('rgb(1,2,3)'); + var color = _ol_color_.asArray('rgb(1,2,3)'); expect(color).to.eql([1, 2, 3, 1]); }); it('returns an array given a hex string', function() { - var color = ol.color.asArray('#00ccff'); + var color = _ol_color_.asArray('#00ccff'); expect(color).to.eql([0, 204, 255, 1]); }); it('returns an array given a hex string with alpha', function() { - var color = ol.color.asArray('#00ccffb0'); + var color = _ol_color_.asArray('#00ccffb0'); expect(color).to.eql([0, 204, 255, 176 / 255]); }); @@ -38,17 +38,17 @@ describe('ol.color', function() { it('returns the same for a string', function() { var color = 'rgba(0,1,2,0.3)'; - var got = ol.color.asString(color); + var got = _ol_color_.asString(color); expect(got).to.be(color); }); it('returns a string given an rgba array', function() { - var color = ol.color.asString([1, 2, 3, 0.4]); + var color = _ol_color_.asString([1, 2, 3, 0.4]); expect(color).to.eql('rgba(1,2,3,0.4)'); }); it('returns a string given an rgb array', function() { - var color = ol.color.asString([1, 2, 3]); + var color = _ol_color_.asString([1, 2, 3]); expect(color).to.eql('rgba(1,2,3,1)'); }); @@ -57,86 +57,86 @@ describe('ol.color', function() { describe('fromString()', function() { before(function() { - sinon.spy(ol.color, 'fromStringInternal_'); + sinon.spy(_ol_color_, 'fromStringInternal_'); }); after(function() { - var spy = ol.color.fromStringInternal_; + var spy = _ol_color_.fromStringInternal_; spy.restore(); }); - if (ol.ENABLE_NAMED_COLORS) { + if (_ol_.ENABLE_NAMED_COLORS) { it('can parse named colors', function() { - expect(ol.color.fromString('red')).to.eql([255, 0, 0, 1]); + expect(_ol_color_.fromString('red')).to.eql([255, 0, 0, 1]); }); } it('can parse 3-digit hex colors', function() { - expect(ol.color.fromString('#087')).to.eql([0, 136, 119, 1]); + expect(_ol_color_.fromString('#087')).to.eql([0, 136, 119, 1]); }); it('can parse 4-digit hex colors', function() { - expect(ol.color.fromString('#0876')).to.eql([0, 136, 119, 102 / 255]); + expect(_ol_color_.fromString('#0876')).to.eql([0, 136, 119, 102 / 255]); }); it('can parse 6-digit hex colors', function() { - expect(ol.color.fromString('#56789a')).to.eql([86, 120, 154, 1]); + expect(_ol_color_.fromString('#56789a')).to.eql([86, 120, 154, 1]); }); it('can parse 8-digit hex colors', function() { - expect(ol.color.fromString('#56789acc')).to.eql([86, 120, 154, 204 / 255]); + expect(_ol_color_.fromString('#56789acc')).to.eql([86, 120, 154, 204 / 255]); }); it('can parse rgb colors', function() { - expect(ol.color.fromString('rgb(0, 0, 255)')).to.eql([0, 0, 255, 1]); + expect(_ol_color_.fromString('rgb(0, 0, 255)')).to.eql([0, 0, 255, 1]); }); it('ignores whitespace before, between & after numbers (rgb)', function() { - expect(ol.color.fromString('rgb( \t 0 , 0 \n , 255 )')).to.eql( + expect(_ol_color_.fromString('rgb( \t 0 , 0 \n , 255 )')).to.eql( [0, 0, 255, 1]); }); it('can parse rgba colors', function() { // opacity 0 - expect(ol.color.fromString('rgba(255, 255, 0, 0)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0)')).to.eql( [255, 255, 0, 0]); // opacity 0.0 (simple float) - expect(ol.color.fromString('rgba(255, 255, 0, 0.0)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0.0)')).to.eql( [255, 255, 0, 0]); // opacity 0.0000000000000000 (float with 16 digits) - expect(ol.color.fromString('rgba(255, 255, 0, 0.0000000000000000)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0.0000000000000000)')).to.eql( [255, 255, 0, 0]); // opacity 0.1 (simple float) - expect(ol.color.fromString('rgba(255, 255, 0, 0.1)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0.1)')).to.eql( [255, 255, 0, 0.1]); // opacity 0.1111111111111111 (float with 16 digits) - expect(ol.color.fromString('rgba(255, 255, 0, 0.1111111111111111)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0.1111111111111111)')).to.eql( [255, 255, 0, 0.1111111111111111]); // opacity 1 - expect(ol.color.fromString('rgba(255, 255, 0, 1)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 1)')).to.eql( [255, 255, 0, 1]); // opacity 1.0 - expect(ol.color.fromString('rgba(255, 255, 0, 1.0)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 1.0)')).to.eql( [255, 255, 0, 1]); // opacity 1.0000000000000000 - expect(ol.color.fromString('rgba(255, 255, 0, 1.0000000000000000)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 1.0000000000000000)')).to.eql( [255, 255, 0, 1]); // with 30 decimal digits - expect(ol.color.fromString('rgba(255, 255, 0, 0.123456789012345678901234567890)')).to.eql( + expect(_ol_color_.fromString('rgba(255, 255, 0, 0.123456789012345678901234567890)')).to.eql( [255, 255, 0, 0.123456789012345678901234567890]); }); it('ignores whitespace before, between & after numbers (rgba)', function() { - expect(ol.color.fromString('rgba( \t 0 , 0 \n , 255 , 0.4711 )')).to.eql( + expect(_ol_color_.fromString('rgba( \t 0 , 0 \n , 255 , 0.4711 )')).to.eql( [0, 0, 255, 0.4711]); }); it('caches parsed values', function() { - var spy = ol.color.fromStringInternal_; + var spy = _ol_color_.fromStringInternal_; var count = spy.callCount; - ol.color.fromString('aquamarine'); + _ol_color_.fromString('aquamarine'); expect(spy.callCount).to.be(count + 1); - ol.color.fromString('aquamarine'); + _ol_color_.fromString('aquamarine'); expect(spy.callCount).to.be(count + 1); }); @@ -145,7 +145,7 @@ describe('ol.color', function() { var i, ii; for (i = 0, ii < invalidColors.length; i < ii; ++i) { expect(function() { - ol.color.fromString(invalidColors[i]); + _ol_color_.fromString(invalidColors[i]); }).to.throwException(); } }); @@ -155,11 +155,11 @@ describe('ol.color', function() { describe('normalize()', function() { it('clamps out-of-range channels', function() { - expect(ol.color.normalize([-1, 256, 0, 2])).to.eql([0, 255, 0, 1]); + expect(_ol_color_.normalize([-1, 256, 0, 2])).to.eql([0, 255, 0, 1]); }); it('rounds color channels to integers', function() { - expect(ol.color.normalize([1.2, 2.5, 3.7, 1])).to.eql([1, 3, 4, 1]); + expect(_ol_color_.normalize([1.2, 2.5, 3.7, 1])).to.eql([1, 3, 4, 1]); }); }); @@ -167,15 +167,15 @@ describe('ol.color', function() { describe('toString()', function() { it('converts valid colors', function() { - expect(ol.color.toString([1, 2, 3, 0.4])).to.be('rgba(1,2,3,0.4)'); + expect(_ol_color_.toString([1, 2, 3, 0.4])).to.be('rgba(1,2,3,0.4)'); }); it('rounds to integers if needed', function() { - expect(ol.color.toString([1.2, 2.5, 3.7, 0.4])).to.be('rgba(1,3,4,0.4)'); + expect(_ol_color_.toString([1.2, 2.5, 3.7, 0.4])).to.be('rgba(1,3,4,0.4)'); }); it('sets default alpha value if undefined', function() { - expect(ol.color.toString([0, 0, 0])).to.be('rgba(0,0,0,1)'); + expect(_ol_color_.toString([0, 0, 0])).to.be('rgba(0,0,0,1)'); }); }); diff --git a/test/spec/ol/control/attribution.test.js b/test/spec/ol/control/attribution.test.js index 0c16e1e49b..7d31a45659 100644 --- a/test/spec/ol/control/attribution.test.js +++ b/test/spec/ol/control/attribution.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.Map'); -goog.require('ol.Tile'); -goog.require('ol.View'); -goog.require('ol.control.Attribution'); -goog.require('ol.layer.Tile'); -goog.require('ol.source.Tile'); -goog.require('ol.tilegrid'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_Tile_ from '../../../../src/ol/Tile.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_control_Attribution_ from '../../../../src/ol/control/Attribution.js'; +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.control.Attribution', function() { @@ -15,36 +13,36 @@ describe('ol.control.Attribution', function() { var target = document.createElement('div'); target.style.width = target.style.height = '100px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - controls: [new ol.control.Attribution({ + controls: [new _ol_control_Attribution_({ collapsed: false, collapsible: false })], layers: [ - new ol.layer.Tile({ - source: new ol.source.Tile({ + new _ol_layer_Tile_({ + source: new _ol_source_Tile_({ projection: 'EPSG:3857', - tileGrid: ol.tilegrid.createXYZ(), + tileGrid: _ol_tilegrid_.createXYZ(), attributions: 'foo' }) }), - new ol.layer.Tile({ - source: new ol.source.Tile({ + new _ol_layer_Tile_({ + source: new _ol_source_Tile_({ projection: 'EPSG:3857', - tileGrid: ol.tilegrid.createXYZ(), + tileGrid: _ol_tilegrid_.createXYZ(), attributions: 'bar' }) }), - new ol.layer.Tile({ - source: new ol.source.Tile({ + new _ol_layer_Tile_({ + source: new _ol_source_Tile_({ projection: 'EPSG:3857', - tileGrid: ol.tilegrid.createXYZ(), + tileGrid: _ol_tilegrid_.createXYZ(), attributions: 'foo' }) }) ], - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -52,7 +50,7 @@ describe('ol.control.Attribution', function() { map.getLayers().forEach(function(layer) { var source = layer.getSource(); source.getTile = function() { - var tile = new ol.Tile([0, 0, -1], 2 /* LOADED */); + var tile = new _ol_Tile_([0, 0, -1], 2 /* LOADED */); tile.getImage = function() { var image = new Image(); image.width = 256; diff --git a/test/spec/ol/control/control.test.js b/test/spec/ol/control/control.test.js index 0e13472e38..b3ec77ddfe 100644 --- a/test/spec/ol/control/control.test.js +++ b/test/spec/ol/control/control.test.js @@ -1,17 +1,15 @@ - - -goog.require('ol.Map'); -goog.require('ol.control.Control'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_control_Control_ from '../../../../src/ol/control/Control.js'; describe('ol.control.Control', function() { var map, control; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: document.createElement('div') }); var element = document.createElement('DIV'); - control = new ol.control.Control({element: element}); + control = new _ol_control_Control_({element: element}); control.setMap(map); }); @@ -35,7 +33,7 @@ describe('ol.control.Control\'s target', function() { var target = document.createElement('div'); target.id = 'mycontrol'; document.body.appendChild(target); - var ctrl = new ol.control.Control({target: 'mycontrol'}); + var ctrl = new _ol_control_Control_({target: 'mycontrol'}); expect(ctrl.target_.id).to.equal('mycontrol'); ctrl.dispose(); target.parentNode.removeChild(target); @@ -44,13 +42,13 @@ describe('ol.control.Control\'s target', function() { var target = document.createElement('div'); target.id = 'mycontrol'; document.body.appendChild(target); - var ctrl = new ol.control.Control({target: target}); + var ctrl = new _ol_control_Control_({target: target}); expect(ctrl.target_.id).to.equal('mycontrol'); ctrl.dispose(); target.parentNode.removeChild(target); }); it('ignores non-existing target id', function() { - var ctrl = new ol.control.Control({target: 'doesnotexist'}); + var ctrl = new _ol_control_Control_({target: 'doesnotexist'}); expect(ctrl.target_).to.equal(null); ctrl.dispose(); }); diff --git a/test/spec/ol/control/fullscreen.test.js b/test/spec/ol/control/fullscreen.test.js index 9f563f3616..9dae5d3c67 100644 --- a/test/spec/ol/control/fullscreen.test.js +++ b/test/spec/ol/control/fullscreen.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.control.FullScreen'); +import _ol_control_FullScreen_ from '../../../../src/ol/control/FullScreen.js'; describe('ol.control.FullScreen', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.control.FullScreen(); - expect(instance).to.be.an(ol.control.FullScreen); + var instance = new _ol_control_FullScreen_(); + expect(instance).to.be.an(_ol_control_FullScreen_); }); }); diff --git a/test/spec/ol/control/mouseposition.test.js b/test/spec/ol/control/mouseposition.test.js index f9b7b68de6..ad51e5facc 100644 --- a/test/spec/ol/control/mouseposition.test.js +++ b/test/spec/ol/control/mouseposition.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.control.MousePosition'); +import _ol_control_MousePosition_ from '../../../../src/ol/control/MousePosition.js'; describe('ol.control.MousePosition', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.control.MousePosition(); - expect(instance).to.be.an(ol.control.MousePosition); + var instance = new _ol_control_MousePosition_(); + expect(instance).to.be.an(_ol_control_MousePosition_); expect(instance.element.className).to.be('ol-mouse-position'); }); it('creates the element with the provided class name', function() { var className = 'foobar'; - var instance = new ol.control.MousePosition({ + var instance = new _ol_control_MousePosition_({ className: className }); expect(instance.element.className).to.be(className); diff --git a/test/spec/ol/control/overviewmap.test.js b/test/spec/ol/control/overviewmap.test.js index c8a0bc076a..37a90dde56 100644 --- a/test/spec/ol/control/overviewmap.test.js +++ b/test/spec/ol/control/overviewmap.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control.Control'); -goog.require('ol.control.OverviewMap'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_control_Control_ from '../../../../src/ol/control/Control.js'; +import _ol_control_OverviewMap_ from '../../../../src/ol/control/OverviewMap.js'; describe('ol.control.OverviewMap', function() { var map, target; @@ -11,7 +9,7 @@ describe('ol.control.OverviewMap', function() { beforeEach(function() { target = document.createElement('div'); document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target }); }); @@ -25,23 +23,23 @@ describe('ol.control.OverviewMap', function() { describe('constructor', function() { it('creates an overview map with the default options', function() { - var control = new ol.control.OverviewMap(); - expect(control).to.be.a(ol.control.OverviewMap); - expect(control).to.be.a(ol.control.Control); + var control = new _ol_control_OverviewMap_(); + expect(control).to.be.a(_ol_control_OverviewMap_); + expect(control).to.be.a(_ol_control_Control_); }); }); describe('setMap()', function() { it('keeps ovmap view rotation in sync with map view rotation', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 }); map.setView(view); - var control = new ol.control.OverviewMap(); + var control = new _ol_control_OverviewMap_(); map.addControl(control); var ovView = control.ovmap_.getView(); expect(ovView.getRotation()).to.be(0); @@ -51,12 +49,12 @@ describe('ol.control.OverviewMap', function() { }); it('maintains rotation in sync if view added later', function() { - var control = new ol.control.OverviewMap(); + var control = new _ol_control_OverviewMap_(); map.addControl(control); var ovView = control.ovmap_.getView(); expect(ovView.getRotation()).to.be(0); - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -67,10 +65,10 @@ describe('ol.control.OverviewMap', function() { }); it('stops listening to old maps', function() { - var control = new ol.control.OverviewMap(); + var control = new _ol_control_OverviewMap_(); var ovView = control.ovmap_.getView(); - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -88,7 +86,7 @@ describe('ol.control.OverviewMap', function() { }); it('set target to null', function() { - var control = new ol.control.OverviewMap(); + var control = new _ol_control_OverviewMap_(); map.addControl(control); diff --git a/test/spec/ol/control/rotate.test.js b/test/spec/ol/control/rotate.test.js index 6ed9a5deb3..11ed38e5e0 100644 --- a/test/spec/ol/control/rotate.test.js +++ b/test/spec/ol/control/rotate.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.control.Rotate'); +import _ol_control_Rotate_ from '../../../../src/ol/control/Rotate.js'; describe('ol.control.Rotate', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.control.Rotate(); - expect(instance).to.be.an(ol.control.Rotate); + var instance = new _ol_control_Rotate_(); + expect(instance).to.be.an(_ol_control_Rotate_); }); }); diff --git a/test/spec/ol/control/scaleline.test.js b/test/spec/ol/control/scaleline.test.js index c7cb8e43c6..ad143684a0 100644 --- a/test/spec/ol/control/scaleline.test.js +++ b/test/spec/ol/control/scaleline.test.js @@ -1,15 +1,15 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control.ScaleLine'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_control_ScaleLine_ from '../../../../src/ol/control/ScaleLine.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; describe('ol.control.ScaleLine', function() { var map; beforeEach(function() { var target = document.createElement('div'); document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target }); }); @@ -20,8 +20,8 @@ describe('ol.control.ScaleLine', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var ctrl = new ol.control.ScaleLine(); - expect(ctrl).to.be.an(ol.control.ScaleLine); + var ctrl = new _ol_control_ScaleLine_(); + expect(ctrl).to.be.an(_ol_control_ScaleLine_); }); }); @@ -29,14 +29,14 @@ describe('ol.control.ScaleLine', function() { describe('className', function() { it('defaults to "ol-scale-line"', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); ctrl.setMap(map); var element = document.querySelector('.ol-scale-line', map.getTarget()); expect(element).to.not.be(null); expect(element).to.be.a(HTMLDivElement); }); it('can be configured', function() { - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ className: 'humpty-dumpty' }); ctrl.setMap(map); @@ -53,11 +53,11 @@ describe('ol.control.ScaleLine', function() { describe('minWidth', function() { it('defaults to 64', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); expect(ctrl.minWidth_).to.be(64); }); it('can be configured', function() { - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ minWidth: 4711 }); expect(ctrl.minWidth_).to.be(4711); @@ -66,14 +66,14 @@ describe('ol.control.ScaleLine', function() { describe('render', function() { it('defaults to `ol.control.ScaleLine.render`', function() { - var ctrl = new ol.control.ScaleLine(); - expect(ctrl.render).to.be(ol.control.ScaleLine.render); + var ctrl = new _ol_control_ScaleLine_(); + expect(ctrl.render).to.be(_ol_control_ScaleLine_.render); }); it('can be configured', function() { var myRender = function() { }; - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ render: myRender }); expect(ctrl.render).to.be(myRender); @@ -85,13 +85,13 @@ describe('ol.control.ScaleLine', function() { describe('synchronisation with map view', function() { it('calls `render` as soon as the map is rendered', function(done) { var renderSpy = sinon.spy(); - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ render: renderSpy }); expect(renderSpy.called).to.be(false); ctrl.setMap(map); expect(renderSpy.called).to.be(false); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -104,11 +104,11 @@ describe('ol.control.ScaleLine', function() { }); it('calls `render` as often as the map is rendered', function() { var renderSpy = sinon.spy(); - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ render: renderSpy }); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -121,11 +121,11 @@ describe('ol.control.ScaleLine', function() { }); it('calls `render` as when the view changes', function(done) { var renderSpy = sinon.spy(); - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ render: renderSpy }); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -140,10 +140,10 @@ describe('ol.control.ScaleLine', function() { describe('static method `render`', function() { it('updates the rendered text', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); expect(ctrl.element.innerText).to.be(''); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -154,17 +154,17 @@ describe('ol.control.ScaleLine', function() { describe('#getUnits', function() { it('returns "metric" by default', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); expect(ctrl.getUnits()).to.be('metric'); }); it('returns what is configured via `units` property', function() { - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ units: 'nautical' }); expect(ctrl.getUnits()).to.be('nautical'); }); it('returns what is configured `setUnits` method', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); ctrl.setUnits('nautical'); expect(ctrl.getUnits()).to.be('nautical'); }); @@ -172,8 +172,8 @@ describe('ol.control.ScaleLine', function() { describe('#setUnits', function() { it('triggers rerendering', function() { - var ctrl = new ol.control.ScaleLine(); - map.setView(new ol.View({ + var ctrl = new _ol_control_ScaleLine_(); + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -196,9 +196,9 @@ describe('ol.control.ScaleLine', function() { var imperialHtml; var usHtml; beforeEach(function(done) { - ctrl = new ol.control.ScaleLine(); + ctrl = new _ol_control_ScaleLine_(); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0 })); @@ -246,16 +246,16 @@ describe('ol.control.ScaleLine', function() { describe('projections affect the scaleline', function() { it('is rendered differently for different projections', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); ctrl.setMap(map); - map.setView(new ol.View({ - center: ol.proj.fromLonLat([7, 52]), + map.setView(new _ol_View_({ + center: _ol_proj_.fromLonLat([7, 52]), zoom: 2, projection: 'EPSG:3857' })); map.renderSync(); var innerHtml3857 = ctrl.element_.innerHTML; - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [7, 52], zoom: 2, projection: 'EPSG:4326' @@ -266,13 +266,13 @@ describe('ol.control.ScaleLine', function() { }); it('Projection\'s metersPerUnit affect scale for non-degree units', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0, resolutions: [1], - projection: new ol.proj.Projection({ + projection: new _ol_proj_Projection_({ code: 'METERS', units: 'm', getPointResolution: function(r) { @@ -282,11 +282,11 @@ describe('ol.control.ScaleLine', function() { })); map.renderSync(); expect(ctrl.element_.innerText).to.be('100 m'); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: 0, resolutions: [1], - projection: new ol.proj.Projection({ + projection: new _ol_proj_Projection_({ code: 'PIXELS', units: 'pixels', metersPerUnit: 1 / 1000, @@ -303,10 +303,10 @@ describe('ol.control.ScaleLine', function() { describe('latitude may affect scale line in EPSG:4326', function() { it('is rendered differently at different latitudes for metric', function() { - var ctrl = new ol.control.ScaleLine(); + var ctrl = new _ol_control_ScaleLine_(); ctrl.setMap(map); - map.setView(new ol.View({ - center: ol.proj.fromLonLat([7, 0]), + map.setView(new _ol_View_({ + center: _ol_proj_.fromLonLat([7, 0]), zoom: 2, projection: 'EPSG:4326' })); @@ -319,12 +319,12 @@ describe('ol.control.ScaleLine', function() { }); it('is rendered the same at different latitudes for degrees', function() { - var ctrl = new ol.control.ScaleLine({ + var ctrl = new _ol_control_ScaleLine_({ units: 'degrees' }); ctrl.setMap(map); - map.setView(new ol.View({ - center: ol.proj.fromLonLat([7, 0]), + map.setView(new _ol_View_({ + center: _ol_proj_.fromLonLat([7, 0]), zoom: 2, projection: 'EPSG:4326' })); @@ -359,11 +359,11 @@ describe('ol.control.ScaleLine', function() { beforeEach(function() { currentZoom = 33; renderedHtmls = {}; - ctrl = new ol.control.ScaleLine({ + ctrl = new _ol_control_ScaleLine_({ minWidth: 10 }); ctrl.setMap(map); - map.setView(new ol.View({ + map.setView(new _ol_View_({ center: [0, 0], zoom: currentZoom, maxZoom: currentZoom diff --git a/test/spec/ol/control/zoom.test.js b/test/spec/ol/control/zoom.test.js index 951ec24d83..e38365b7bf 100644 --- a/test/spec/ol/control/zoom.test.js +++ b/test/spec/ol/control/zoom.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.control.Zoom'); +import _ol_control_Zoom_ from '../../../../src/ol/control/Zoom.js'; describe('ol.control.Zoom', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.control.Zoom(); - expect(instance).to.be.an(ol.control.Zoom); + var instance = new _ol_control_Zoom_(); + expect(instance).to.be.an(_ol_control_Zoom_); }); }); diff --git a/test/spec/ol/control/zoomslider.test.js b/test/spec/ol/control/zoomslider.test.js index 76f0998812..4c363852e9 100644 --- a/test/spec/ol/control/zoomslider.test.js +++ b/test/spec/ol/control/zoomslider.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.control.ZoomSlider'); -goog.require('ol.pointer.PointerEvent'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_control_ZoomSlider_ from '../../../../src/ol/control/ZoomSlider.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; describe('ol.control.ZoomSlider', function() { var map, target, zoomslider; @@ -11,8 +9,8 @@ describe('ol.control.ZoomSlider', function() { beforeEach(function() { target = document.createElement('div'); document.body.appendChild(target); - zoomslider = new ol.control.ZoomSlider(); - map = new ol.Map({ + zoomslider = new _ol_control_ZoomSlider_(); + map = new _ol_Map_({ target: target, controls: [zoomslider] }); @@ -61,7 +59,7 @@ describe('ol.control.ZoomSlider', function() { describe('#direction_', function() { it('is horizontal for wide containers', function() { - var control = new ol.control.ZoomSlider({}); + var control = new _ol_control_ZoomSlider_({}); control.element.style.width = '1000px'; control.element.style.height = '10px'; control.setMap(map); @@ -74,7 +72,7 @@ describe('ol.control.ZoomSlider', function() { }); it('is vertical for tall containers', function() { - var control = new ol.control.ZoomSlider({}); + var control = new _ol_control_ZoomSlider_({}); control.element.style.width = '10px'; control.element.style.height = '1000px'; @@ -91,9 +89,9 @@ describe('ol.control.ZoomSlider', function() { var map; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: createMapDiv(500, 100), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], resolutions: [16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625] }) @@ -104,7 +102,7 @@ describe('ol.control.ZoomSlider', function() { }); it('[horizontal] handles a drag sequence', function() { - var control = new ol.control.ZoomSlider(); + var control = new _ol_control_ZoomSlider_(); map.addControl(control); map.getView().setZoom(0); control.element.style.width = '500px'; @@ -113,7 +111,7 @@ describe('ol.control.ZoomSlider', function() { control.element.firstChild.style.height = '10px'; map.renderSync(); var dragger = control.dragger_; - var event = new ol.pointer.PointerEvent('pointerdown', { + var event = new _ol_pointer_PointerEvent_('pointerdown', { target: control.element.firstElementChild }); event.clientX = control.widthLimit_; @@ -136,7 +134,7 @@ describe('ol.control.ZoomSlider', function() { expect(control.dragging_).to.be(false); }); it('[vertical] handles a drag sequence', function() { - var control = new ol.control.ZoomSlider(); + var control = new _ol_control_ZoomSlider_(); control.element.style.width = '10px'; control.element.style.height = '100px'; control.element.firstChild.style.width = '10px'; @@ -145,7 +143,7 @@ describe('ol.control.ZoomSlider', function() { map.getView().setZoom(8); map.renderSync(); var dragger = control.dragger_; - var event = new ol.pointer.PointerEvent('pointerdown', { + var event = new _ol_pointer_PointerEvent_('pointerdown', { target: control.element.firstElementChild }); event.clientX = 0; diff --git a/test/spec/ol/control/zoomtoextent.test.js b/test/spec/ol/control/zoomtoextent.test.js index da10f55224..868cb83280 100644 --- a/test/spec/ol/control/zoomtoextent.test.js +++ b/test/spec/ol/control/zoomtoextent.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.control.ZoomToExtent'); +import _ol_control_ZoomToExtent_ from '../../../../src/ol/control/ZoomToExtent.js'; describe('ol.control.ZoomToExtent', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.control.ZoomToExtent(); - expect(instance).to.be.an(ol.control.ZoomToExtent); + var instance = new _ol_control_ZoomToExtent_(); + expect(instance).to.be.an(_ol_control_ZoomToExtent_); }); }); diff --git a/test/spec/ol/coordinate.test.js b/test/spec/ol/coordinate.test.js index fb977ad18c..a78649415d 100644 --- a/test/spec/ol/coordinate.test.js +++ b/test/spec/ol/coordinate.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.coordinate'); -goog.require('ol.geom.Circle'); +import _ol_coordinate_ from '../../../src/ol/coordinate.js'; +import _ol_geom_Circle_ from '../../../src/ol/geom/Circle.js'; describe('ol.coordinate', function() { @@ -15,19 +13,19 @@ describe('ol.coordinate', function() { }); it('returns a coordinate', function() { - var returnedCoordinate = ol.coordinate.add(coordinate, delta); + var returnedCoordinate = _ol_coordinate_.add(coordinate, delta); expect(returnedCoordinate).to.be.an('array'); expect(returnedCoordinate).to.have.length(2); }); it('adds the delta', function() { - var returnedCoordinate = ol.coordinate.add(coordinate, delta); + var returnedCoordinate = _ol_coordinate_.add(coordinate, delta); expect(returnedCoordinate[0]).to.eql(48.73); expect(returnedCoordinate[1]).to.eql(10.1); }); it('modifies in place', function() { - ol.coordinate.add(coordinate, delta); + _ol_coordinate_.add(coordinate, delta); expect(coordinate[0]).to.eql(48.73); expect(coordinate[1]).to.eql(10.1); }); @@ -39,8 +37,8 @@ describe('ol.coordinate', function() { var bonn2 = [50.73000, 7.10000]; it('compares correctly', function() { - var bonnEqualsBonn = ol.coordinate.equals(bonn1, bonn2); - var bonnEqualsCologne = ol.coordinate.equals(bonn1, cologne); + var bonnEqualsBonn = _ol_coordinate_.equals(bonn1, bonn2); + var bonnEqualsCologne = _ol_coordinate_.equals(bonn1, cologne); expect(bonnEqualsBonn).to.be(true); expect(bonnEqualsCologne).to.be(false); }); @@ -53,12 +51,12 @@ describe('ol.coordinate', function() { }); it('rounds the values', function() { - var string = ol.coordinate.format(coordinate, '{x} {y}', 0); + var string = _ol_coordinate_.format(coordinate, '{x} {y}', 0); expect(string).to.eql('7 47'); }); it('handles the optional fractionDigits param', function() { - var string = ol.coordinate.format(coordinate, '{x} {y}', 3); + var string = _ol_coordinate_.format(coordinate, '{x} {y}', 3); expect(string).to.eql('6.612 46.792'); }); }); @@ -72,7 +70,7 @@ describe('ol.coordinate', function() { }); it('returns a CoordinateFormatType', function() { - created = ol.coordinate.createStringXY(); + created = _ol_coordinate_.createStringXY(); expect(created).to.be.a('function'); formatted = created(coordinate); @@ -81,7 +79,7 @@ describe('ol.coordinate', function() { }); it('respects opt_fractionDigits', function() { - created = ol.coordinate.createStringXY(3); + created = _ol_coordinate_.createStringXY(3); expect(created).to.be.a('function'); formatted = created(coordinate); @@ -92,13 +90,13 @@ describe('ol.coordinate', function() { describe('#closestOnCircle', function() { var center = [5, 10]; - var circle = new ol.geom.Circle(center, 10); + var circle = new _ol_geom_Circle_(center, 10); it('can find the closest point on circle', function() { - expect(ol.coordinate.closestOnCircle([-20, 10], circle)) + expect(_ol_coordinate_.closestOnCircle([-20, 10], circle)) .to.eql([-5, 10]); }); it('can handle coordinate equal circle center', function() { - expect(ol.coordinate.closestOnCircle(center, circle)) + expect(_ol_coordinate_.closestOnCircle(center, circle)) .to.eql([15, 10]); }); }); @@ -108,27 +106,27 @@ describe('ol.coordinate', function() { function() { var point = [2, 5]; var segment = [[-5, 0], [10, 0]]; - expect(ol.coordinate.closestOnSegment(point, segment)) + expect(_ol_coordinate_.closestOnSegment(point, segment)) .to.eql([2, 0]); }); it('can handle points where the foot of the perpendicular is not closest', function() { var point = [0, -6]; var segment = [[-5, 0], [0, -1]]; - expect(ol.coordinate.closestOnSegment(point, segment)) + expect(_ol_coordinate_.closestOnSegment(point, segment)) .to.eql([0, -1]); }); }); describe('#format', function() { it('can deal with undefined coordinate', function() { - expect(ol.coordinate.format()).to.be(''); + expect(_ol_coordinate_.format()).to.be(''); }); it('formats a coordinate into a template (default precision is 0)', function() { var coord = [7.85, 47.983333]; var template = 'Coordinate is ({x}|{y}).'; - var got = ol.coordinate.format(coord, template); + var got = _ol_coordinate_.format(coord, template); var expected = 'Coordinate is (8|48).'; expect(got).to.be(expected); }); @@ -136,7 +134,7 @@ describe('ol.coordinate', function() { function() { var coord = [7.85, 47.983333]; var template = 'Coordinate is ({x}|{y}).'; - var got = ol.coordinate.format(coord, template, 2); + var got = _ol_coordinate_.format(coord, template, 2); var expected = 'Coordinate is (7.85|47.98).'; expect(got).to.be(expected); }); @@ -146,14 +144,14 @@ describe('ol.coordinate', function() { it('can rotate point in place', function() { var coord = [7.85, 47.983333]; var rotateRadians = Math.PI / 2; // 90 degrees - ol.coordinate.rotate(coord, rotateRadians); + _ol_coordinate_.rotate(coord, rotateRadians); expect(coord[0].toFixed(6)).to.eql('-47.983333'); expect(coord[1].toFixed(6)).to.eql('7.850000'); }); it('returns the rotated point', function() { var coord = [7.85, 47.983333]; var rotateRadians = Math.PI / 2; // 90 degrees - var rotated = ol.coordinate.rotate(coord, rotateRadians); + var rotated = _ol_coordinate_.rotate(coord, rotateRadians); expect(rotated[0].toFixed(7)).to.eql('-47.9833330'); expect(rotated[1].toFixed(7)).to.eql('7.8500000'); }); @@ -163,14 +161,14 @@ describe('ol.coordinate', function() { it('can scale point in place', function() { var coord = [7.85, 47.983333]; var scale = 1.2; - ol.coordinate.scale(coord, scale); + _ol_coordinate_.scale(coord, scale); expect(coord[0].toFixed(7)).to.eql('9.4200000'); expect(coord[1].toFixed(7)).to.eql('57.5799996'); }); it('returns the scaled point', function() { var coord = [7.85, 47.983333]; var scale = 1.2; - var scaledCoord = ol.coordinate.scale(coord, scale); + var scaledCoord = _ol_coordinate_.scale(coord, scale); expect(scaledCoord[0].toFixed(7)).to.eql('9.4200000'); expect(scaledCoord[1].toFixed(7)).to.eql('57.5799996'); }); @@ -180,14 +178,14 @@ describe('ol.coordinate', function() { it('can subtract from point in place', function() { var coord = [47, 11]; var delta = [1, -1]; - ol.coordinate.sub(coord, delta); + _ol_coordinate_.sub(coord, delta); expect(coord[0]).to.eql(46); expect(coord[1]).to.eql(12); }); it('can subtract from point in place', function() { var coord = [47, 11]; var delta = [1, -1]; - var subtracted = ol.coordinate.sub(coord, delta); + var subtracted = _ol_coordinate_.sub(coord, delta); expect(subtracted[0]).to.eql(46); expect(subtracted[1]).to.eql(12); }); @@ -198,14 +196,14 @@ describe('ol.coordinate', function() { function() { var point = [2, 5]; var segment = [[-5, 0], [10, 0]]; - expect(ol.coordinate.squaredDistanceToSegment(point, segment)) + expect(_ol_coordinate_.squaredDistanceToSegment(point, segment)) .to.eql(25); }); it('can handle points where the foot of the perpendicular is not closest', function() { var point = [0, -6]; var segment = [[-5, 0], [0, -1]]; - expect(ol.coordinate.squaredDistanceToSegment(point, segment)) + expect(_ol_coordinate_.squaredDistanceToSegment(point, segment)) .to.eql(25); }); @@ -213,19 +211,19 @@ describe('ol.coordinate', function() { describe('#toStringHDMS', function() { it('returns the empty string on undefined input', function() { - var got = ol.coordinate.toStringHDMS(); + var got = _ol_coordinate_.toStringHDMS(); var expected = ''; expect(got).to.be(expected); }); it('formats with zero fractional digits as default', function() { var coord = [7.85, 47.983333]; - var got = ol.coordinate.toStringHDMS(coord); + var got = _ol_coordinate_.toStringHDMS(coord); var expected = '47° 59′ 00″ N 7° 51′ 00″ E'; expect(got).to.be(expected); }); it('formats with given fractional digits, if passed', function() { var coord = [7.85, 47.983333]; - var got = ol.coordinate.toStringHDMS(coord, 3); + var got = _ol_coordinate_.toStringHDMS(coord, 3); var expected = '47° 58′ 59.999″ N 7° 51′ 00.000″ E'; expect(got).to.be(expected); }); @@ -234,13 +232,13 @@ describe('ol.coordinate', function() { describe('#toStringXY', function() { it('formats with zero fractional digits as default', function() { var coord = [7.85, 47.983333]; - var got = ol.coordinate.toStringXY(coord); + var got = _ol_coordinate_.toStringXY(coord); var expected = '8, 48'; expect(got).to.be(expected); }); it('formats with given fractional digits, if passed', function() { var coord = [7.85, 47.983333]; - var got = ol.coordinate.toStringXY(coord, 2); + var got = _ol_coordinate_.toStringXY(coord, 2); var expected = '7.85, 47.98'; expect(got).to.be(expected); }); diff --git a/test/spec/ol/css.test.js b/test/spec/ol/css.test.js index cf5e40f18b..6dea98c67f 100644 --- a/test/spec/ol/css.test.js +++ b/test/spec/ol/css.test.js @@ -1,4 +1,4 @@ -goog.require('ol.css'); +import _ol_css_ from '../../../src/ol/css.js'; describe('ol.css', function() { @@ -25,7 +25,7 @@ describe('ol.css', function() { cases.forEach(function(c, i) { it('works for ' + c.font, function() { - var families = ol.css.getFontFamilies(c.font); + var families = _ol_css_.getFontFamilies(c.font); if (c.families === null) { expect(families).to.be(null); return; diff --git a/test/spec/ol/deviceorientation.test.js b/test/spec/ol/deviceorientation.test.js index bb7f891297..178ce1bcdb 100644 --- a/test/spec/ol/deviceorientation.test.js +++ b/test/spec/ol/deviceorientation.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.DeviceOrientation'); +import _ol_DeviceOrientation_ from '../../../src/ol/DeviceOrientation.js'; describe('ol.DeviceOrientation', function() { @@ -8,8 +6,8 @@ describe('ol.DeviceOrientation', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.DeviceOrientation(); - expect(instance).to.be.an(ol.DeviceOrientation); + var instance = new _ol_DeviceOrientation_(); + expect(instance).to.be.an(_ol_DeviceOrientation_); }); }); diff --git a/test/spec/ol/disposable.test.js b/test/spec/ol/disposable.test.js index 3e86257dea..4348f255b3 100644 --- a/test/spec/ol/disposable.test.js +++ b/test/spec/ol/disposable.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.Disposable'); +import _ol_Disposable_ from '../../../src/ol/Disposable.js'; describe('ol.Disposable', function() { @@ -8,8 +6,8 @@ describe('ol.Disposable', function() { describe('constructor', function() { it('creates an instance', function() { - var disposable = new ol.Disposable(); - expect(disposable).to.be.a(ol.Disposable); + var disposable = new _ol_Disposable_(); + expect(disposable).to.be.a(_ol_Disposable_); }); }); @@ -17,12 +15,12 @@ describe('ol.Disposable', function() { describe('#disposed_', function() { it('is initially false', function() { - var disposable = new ol.Disposable(); + var disposable = new _ol_Disposable_(); expect(disposable.disposed_).to.be(false); }); it('is true after a call to dispose', function() { - var disposable = new ol.Disposable(); + var disposable = new _ol_Disposable_(); disposable.dispose(); expect(disposable.disposed_).to.be(true); }); @@ -32,7 +30,7 @@ describe('ol.Disposable', function() { describe('#dispose()', function() { it('calls disposeInternal only once', function() { - var disposable = new ol.Disposable(); + var disposable = new _ol_Disposable_(); sinon.spy(disposable, 'disposeInternal'); expect(disposable.disposeInternal.called).to.be(false); disposable.dispose(); diff --git a/test/spec/ol/dom/dom.test.js b/test/spec/ol/dom/dom.test.js index 6a525e99d4..639a02a612 100644 --- a/test/spec/ol/dom/dom.test.js +++ b/test/spec/ol/dom/dom.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.dom'); +import _ol_dom_ from '../../../../src/ol/dom.js'; describe('ol.dom', function() { @@ -11,7 +9,7 @@ describe('ol.dom', function() { var defaultHeight = 150; it('returns a CanvasRenderingContext2D', function() { - var ctx = ol.dom.createCanvasContext2D(); + var ctx = _ol_dom_.createCanvasContext2D(); expect(ctx).to.be.a(CanvasRenderingContext2D); expect(ctx.canvas).to.be.a(HTMLCanvasElement); expect(ctx.canvas.width).to.be(defaultWidth); @@ -19,7 +17,7 @@ describe('ol.dom', function() { }); it('has the desired width', function() { - var ctx = ol.dom.createCanvasContext2D(42); + var ctx = _ol_dom_.createCanvasContext2D(42); expect(ctx).to.be.a(CanvasRenderingContext2D); expect(ctx.canvas).to.be.a(HTMLCanvasElement); expect(ctx.canvas.width).to.be(42); @@ -27,7 +25,7 @@ describe('ol.dom', function() { }); it('has the desired height', function() { - var ctx = ol.dom.createCanvasContext2D(undefined, 42); + var ctx = _ol_dom_.createCanvasContext2D(undefined, 42); expect(ctx).to.be.a(CanvasRenderingContext2D); expect(ctx.canvas).to.be.a(HTMLCanvasElement); expect(ctx.canvas.width).to.be(defaultWidth); @@ -35,7 +33,7 @@ describe('ol.dom', function() { }); it('has the desired height and width', function() { - var ctx = ol.dom.createCanvasContext2D(42, 42); + var ctx = _ol_dom_.createCanvasContext2D(42, 42); expect(ctx).to.be.a(CanvasRenderingContext2D); expect(ctx.canvas).to.be.a(HTMLCanvasElement); expect(ctx.canvas.width).to.be(42); @@ -63,7 +61,7 @@ describe('ol.dom', function() { describe('without padding, margin or border', function() { it('calculates correctly', function() { - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(10); }); @@ -72,13 +70,13 @@ describe('ol.dom', function() { describe('with padding', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); it('calculates correctly (one side)', function() { element.style.paddingLeft = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(15); }); }); @@ -87,13 +85,13 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.margin = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); it('calculates correctly (one side)', function() { element.style.marginLeft = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(15); }); @@ -103,14 +101,14 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.border = '5px solid chocolate'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); it('calculates correctly (one side)', function() { element.style.border = '5px solid chocolate'; element.style.borderRightWidth = '0'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(15); }); @@ -121,14 +119,14 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; element.style.margin = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(30); }); it('calculates correctly (one side)', function() { element.style.paddingLeft = '5px'; element.style.marginLeft = '5px'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); @@ -139,7 +137,7 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; element.style.border = '5px solid chocolate'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(30); }); @@ -147,7 +145,7 @@ describe('ol.dom', function() { element.style.paddingLeft = '5px'; element.style.border = '5px solid chocolate'; element.style.borderRightWidth = '0'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); @@ -158,7 +156,7 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.margin = '5px'; element.style.border = '5px solid chocolate'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(30); }); @@ -166,7 +164,7 @@ describe('ol.dom', function() { element.style.marginLeft = '5px'; element.style.border = '5px solid chocolate'; element.style.borderRightWidth = '0'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(20); }); @@ -178,7 +176,7 @@ describe('ol.dom', function() { element.style.margin = '5px'; element.style.padding = '5px'; element.style.border = '5px solid chocolate'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(40); }); @@ -187,7 +185,7 @@ describe('ol.dom', function() { element.style.paddingLeft = '5px'; element.style.border = '5px solid chocolate'; element.style.borderRightWidth = '0'; - var calcWidth = ol.dom.outerWidth(element); + var calcWidth = _ol_dom_.outerWidth(element); expect(calcWidth).to.be(25); }); @@ -214,7 +212,7 @@ describe('ol.dom', function() { describe('without padding, margin or border', function() { it('calculates correctly', function() { - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(10); }); @@ -223,13 +221,13 @@ describe('ol.dom', function() { describe('with padding', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); it('calculates correctly (one side)', function() { element.style.paddingTop = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(15); }); }); @@ -238,13 +236,13 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.margin = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); it('calculates correctly (one side)', function() { element.style.marginTop = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(15); }); @@ -254,14 +252,14 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.border = '5px solid chocolate'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); it('calculates correctly (one side)', function() { element.style.border = '5px solid chocolate'; element.style.borderBottomWidth = '0'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(15); }); @@ -272,14 +270,14 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; element.style.margin = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(30); }); it('calculates correctly (one side)', function() { element.style.paddingTop = '5px'; element.style.marginTop = '5px'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); @@ -290,7 +288,7 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.padding = '5px'; element.style.border = '5px solid chocolate'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(30); }); @@ -298,7 +296,7 @@ describe('ol.dom', function() { element.style.paddingTop = '5px'; element.style.border = '5px solid chocolate'; element.style.borderBottomWidth = '0'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); @@ -309,7 +307,7 @@ describe('ol.dom', function() { it('calculates correctly (both sides)', function() { element.style.margin = '5px'; element.style.border = '5px solid chocolate'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(30); }); @@ -317,7 +315,7 @@ describe('ol.dom', function() { element.style.marginTop = '5px'; element.style.border = '5px solid chocolate'; element.style.borderBottomWidth = '0'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(20); }); @@ -329,7 +327,7 @@ describe('ol.dom', function() { element.style.margin = '5px'; element.style.padding = '5px'; element.style.border = '5px solid chocolate'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(40); }); @@ -338,7 +336,7 @@ describe('ol.dom', function() { element.style.paddingTop = '5px'; element.style.border = '5px solid chocolate'; element.style.borderBottomWidth = '0'; - var calcHeight = ol.dom.outerHeight(element); + var calcHeight = _ol_dom_.outerHeight(element); expect(calcHeight).to.be(25); }); diff --git a/test/spec/ol/events.test.js b/test/spec/ol/events.test.js index e06fa47841..1cf129ecd9 100644 --- a/test/spec/ol/events.test.js +++ b/test/spec/ol/events.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_events_EventTarget_ from '../../../src/ol/events/EventTarget.js'; describe('ol.events', function() { var add, remove, target; @@ -21,7 +19,7 @@ describe('ol.events', function() { listener: sinon.spy(), bindTo: {id: 1} }; - var boundListener = ol.events.bindListener_(listenerObj); + var boundListener = _ol_events_.bindListener_(listenerObj); expect(listenerObj.boundListener).to.equal(boundListener); boundListener(); expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.bindTo); @@ -31,7 +29,7 @@ describe('ol.events', function() { listener: sinon.spy(), target: {id: 1} }; - var boundListener = ol.events.bindListener_(listenerObj); + var boundListener = _ol_events_.bindListener_(listenerObj); expect(listenerObj.boundListener).to.equal(boundListener); boundListener(); expect(listenerObj.listener.thisValues[0]).to.equal(listenerObj.target); @@ -44,12 +42,12 @@ describe('ol.events', function() { bindTo: bindTo, callOnce: true }; - var unlistenSpy = sinon.spy(ol.events, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires + var unlistenSpy = sinon.spy(_ol_events_, 'unlistenByKey'); // eslint-disable-line openlayers-internal/no-missing-requires listenerObj.listener = function() { expect(this).to.equal(bindTo); expect(unlistenSpy.firstCall.args[0]).to.eql(listenerObj); }; - var boundListener = ol.events.bindListener_(listenerObj); + var boundListener = _ol_events_.bindListener_(listenerObj); expect(listenerObj.boundListener).to.equal(boundListener); boundListener(); unlistenSpy.restore(); @@ -71,18 +69,18 @@ describe('ol.events', function() { it('searches a listener array for a specific listener', function() { var bindTo = {id: 1}; - var result = ol.events.findListener_(listeners, listener); + var result = _ol_events_.findListener_(listeners, listener); expect(result).to.be(listenerObj); - result = ol.events.findListener_(listeners, listener, bindTo); + result = _ol_events_.findListener_(listeners, listener, bindTo); expect(result).to.be(undefined); listenerObj.bindTo = bindTo; - result = ol.events.findListener_(listeners, listener); + result = _ol_events_.findListener_(listeners, listener); expect(result).to.be(undefined); - result = ol.events.findListener_(listeners, listener, bindTo); + result = _ol_events_.findListener_(listeners, listener, bindTo); expect(result).to.be(listenerObj); }); it('marks the delete index on a listener object', function() { - var result = ol.events.findListener_(listeners, listener, undefined, true); + var result = _ol_events_.findListener_(listeners, listener, undefined, true); expect(result).to.be(listenerObj); expect(listenerObj.deleteIndex).to.be(0); }); @@ -90,37 +88,37 @@ describe('ol.events', function() { describe('getListeners()', function() { it('returns listeners for a target and type', function() { - var foo = ol.events.listen(target, 'foo', function() {}); - var bar = ol.events.listen(target, 'bar', function() {}); - expect (ol.events.getListeners(target, 'foo')).to.eql([foo]); - expect (ol.events.getListeners(target, 'bar')).to.eql([bar]); + var foo = _ol_events_.listen(target, 'foo', function() {}); + var bar = _ol_events_.listen(target, 'bar', function() {}); + expect (_ol_events_.getListeners(target, 'foo')).to.eql([foo]); + expect (_ol_events_.getListeners(target, 'bar')).to.eql([bar]); }); it('returns undefined when no listeners are registered', function() { - expect (ol.events.getListeners(target, 'foo')).to.be(undefined); + expect (_ol_events_.getListeners(target, 'foo')).to.be(undefined); }); }); describe('listen()', function() { it('calls addEventListener on the target', function() { - ol.events.listen(target, 'foo', function() {}); + _ol_events_.listen(target, 'foo', function() {}); expect(add.callCount).to.be(1); }); it('returns a key', function() { - var key = ol.events.listen(target, 'foo', function() {}); + var key = _ol_events_.listen(target, 'foo', function() {}); expect(key).to.be.a(Object); }); it('does not add the same listener twice', function() { var listener = function() {}; - var key1 = ol.events.listen(target, 'foo', listener); - var key2 = ol.events.listen(target, 'foo', listener); + var key1 = _ol_events_.listen(target, 'foo', listener); + var key2 = _ol_events_.listen(target, 'foo', listener); expect(key1).to.equal(key2); expect(add.callCount).to.be(1); }); it('only treats listeners as same when all args are equal', function() { var listener = function() {}; - ol.events.listen(target, 'foo', listener, {}); - ol.events.listen(target, 'foo', listener, {}); - ol.events.listen(target, 'foo', listener, undefined); + _ol_events_.listen(target, 'foo', listener, {}); + _ol_events_.listen(target, 'foo', listener, {}); + _ol_events_.listen(target, 'foo', listener, undefined); expect(add.callCount).to.be(3); }); }); @@ -128,7 +126,7 @@ describe('ol.events', function() { describe('listenOnce()', function() { it('creates a one-off listener', function() { var listener = sinon.spy(); - var key = ol.events.listenOnce(target, 'foo', listener); + var key = _ol_events_.listenOnce(target, 'foo', listener); expect(add.callCount).to.be(1); expect(key.callOnce).to.be(true); key.boundListener(); @@ -137,17 +135,17 @@ describe('ol.events', function() { }); it('does not add the same listener twice', function() { var listener = function() {}; - var key1 = ol.events.listenOnce(target, 'foo', listener); - var key2 = ol.events.listenOnce(target, 'foo', listener); + var key1 = _ol_events_.listenOnce(target, 'foo', listener); + var key2 = _ol_events_.listenOnce(target, 'foo', listener); expect(key1).to.equal(key2); expect(add.callCount).to.be(1); expect(key1.callOnce).to.be(true); }); it('listen() can turn a one-off listener into a permanent one', function() { var listener = sinon.spy(); - var key = ol.events.listenOnce(target, 'foo', listener); + var key = _ol_events_.listenOnce(target, 'foo', listener); expect(key.callOnce).to.be(true); - key = ol.events.listen(target, 'foo', listener); + key = _ol_events_.listen(target, 'foo', listener); expect(add.callCount).to.be(1); expect(key.callOnce).to.be(false); key.boundListener(); @@ -158,42 +156,42 @@ describe('ol.events', function() { describe('unlisten()', function() { it('unregisters previously registered listeners', function() { var listener = function() {}; - ol.events.listen(target, 'foo', listener); - ol.events.unlisten(target, 'foo', listener); - expect(ol.events.getListeners(target, 'foo')).to.be(undefined); + _ol_events_.listen(target, 'foo', listener); + _ol_events_.unlisten(target, 'foo', listener); + expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined); }); it('works with multiple types', function() { var listener = function() {}; - ol.events.listen(target, ['foo', 'bar'], listener); - ol.events.unlisten(target, ['bar', 'foo'], listener); - expect(ol.events.getListeners(target, 'foo')).to.be(undefined); - expect(ol.events.getListeners(target, 'bar')).to.be(undefined); + _ol_events_.listen(target, ['foo', 'bar'], listener); + _ol_events_.unlisten(target, ['bar', 'foo'], listener); + expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined); + expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined); }); }); describe('unlistenByKey()', function() { it('unregisters previously registered listeners', function() { - var key = ol.events.listen(target, 'foo', function() {}); - ol.events.unlistenByKey(key); - expect(ol.events.getListeners(target, 'foo')).to.be(undefined); + var key = _ol_events_.listen(target, 'foo', function() {}); + _ol_events_.unlistenByKey(key); + expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined); }); it('works with multiple types', function() { - var key = ol.events.listen(target, ['foo', 'bar'], function() {}); - ol.events.unlistenByKey(key); - expect(ol.events.getListeners(target, 'foo')).to.be(undefined); - expect(ol.events.getListeners(target, 'bar')).to.be(undefined); + var key = _ol_events_.listen(target, ['foo', 'bar'], function() {}); + _ol_events_.unlistenByKey(key); + expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined); + expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined); }); }); describe('unlistenAll()', function() { it('unregisters all listeners registered for a target', function() { var keys = [ - ol.events.listen(target, 'foo', function() {}), - ol.events.listen(target, 'bar', function() {}) + _ol_events_.listen(target, 'foo', function() {}), + _ol_events_.listen(target, 'bar', function() {}) ]; - ol.events.unlistenAll(target); - expect(ol.events.getListeners(target, 'foo')).to.be(undefined); - expect(ol.events.getListeners(target, 'bar')).to.be(undefined); + _ol_events_.unlistenAll(target); + expect(_ol_events_.getListeners(target, 'foo')).to.be(undefined); + expect(_ol_events_.getListeners(target, 'bar')).to.be(undefined); expect('ol_lm' in target).to.be(false); expect(keys).to.eql([{}, {}]); }); @@ -201,19 +199,19 @@ describe('ol.events', function() { describe('Compatibility with ol.events.EventTarget', function() { it('does not register duplicated listeners', function() { - var target = new ol.events.EventTarget(); + var target = new _ol_events_EventTarget_(); var listener = function() {}; - var key1 = ol.events.listen(target, 'foo', listener); + var key1 = _ol_events_.listen(target, 'foo', listener); expect(target.getListeners('foo')).to.eql([key1.boundListener]); - var key2 = ol.events.listen(target, 'foo', listener); + var key2 = _ol_events_.listen(target, 'foo', listener); expect(key2.boundListener).to.equal(key1.boundListener); expect(target.getListeners('foo')).to.eql([key1.boundListener]); }); it('registers multiple listeners if this object is different', function() { - var target = new ol.events.EventTarget(); + var target = new _ol_events_EventTarget_(); var listener = function() {}; - var key1 = ol.events.listen(target, 'foo', listener, {}); - var key2 = ol.events.listen(target, 'foo', listener, {}); + var key1 = _ol_events_.listen(target, 'foo', listener, {}); + var key2 = _ol_events_.listen(target, 'foo', listener, {}); expect(key1.boundListener).to.not.equal(key2.boundListener); expect(target.getListeners('foo')).to.eql( [key1.boundListener, key2.boundListener]); diff --git a/test/spec/ol/events/event.test.js b/test/spec/ol/events/event.test.js index 5aa0a4607d..ea93c2be10 100644 --- a/test/spec/ol/events/event.test.js +++ b/test/spec/ol/events/event.test.js @@ -1,28 +1,26 @@ - - -goog.require('ol.events.Event'); +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; describe('ol.events.Event', function() { describe('constructor', function() { it('takes a type as argument', function() { - var event = new ol.events.Event('foo'); + var event = new _ol_events_Event_('foo'); expect(event.type).to.be('foo'); }); it('does not set the propagationStopped flag', function() { - var event = new ol.events.Event('foo'); + var event = new _ol_events_Event_('foo'); expect(event.propagationStopped).to.be(undefined); }); }); describe('#preventDefault', function() { it('sets the propagationStopped flag', function() { - var event = new ol.events.Event('foo'); + var event = new _ol_events_Event_('foo'); event.preventDefault(); expect(event.propagationStopped).to.be(true); }); it('is the same as #stopPropagation', function() { - var event = new ol.events.Event('foo'); + var event = new _ol_events_Event_('foo'); expect(event.stopPropagation).to.equal(event.preventDefault); }); }); @@ -32,7 +30,7 @@ describe('ol.events.Event', function() { var event = { preventDefault: sinon.spy() }; - ol.events.Event.preventDefault(event); + _ol_events_Event_.preventDefault(event); expect(event.preventDefault.called).to.be(true); }); }); @@ -42,7 +40,7 @@ describe('ol.events.Event', function() { var event = { stopPropagation: sinon.spy() }; - ol.events.Event.stopPropagation(event); + _ol_events_Event_.stopPropagation(event); expect(event.stopPropagation.called).to.be(true); }); }); diff --git a/test/spec/ol/events/eventtarget.test.js b/test/spec/ol/events/eventtarget.test.js index d766d5b39d..c2103c2143 100644 --- a/test/spec/ol/events/eventtarget.test.js +++ b/test/spec/ol/events/eventtarget.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Disposable'); -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventTarget'); +import _ol_Disposable_ from '../../../../src/ol/Disposable.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; describe('ol.events.EventTarget', function() { @@ -19,13 +17,13 @@ describe('ol.events.EventTarget', function() { spy1 = spy.bind({id: 1}); spy2 = spy.bind({id: 2}); spy3 = spy.bind({id: 3}); - eventTarget = new ol.events.EventTarget(); + eventTarget = new _ol_events_EventTarget_(); }); describe('constructor', function() { it('creates an instance', function() { - expect(eventTarget).to.be.a(ol.events.EventTarget); - expect(eventTarget).to.be.a(ol.Disposable); + expect(eventTarget).to.be.a(_ol_events_EventTarget_); + expect(eventTarget).to.be.a(_ol_Disposable_); }); it('creates an empty listeners_ object', function() { expect(Object.keys(eventTarget.listeners_)).to.have.length(0); @@ -107,7 +105,7 @@ describe('ol.events.EventTarget', function() { it('passes a default ol.events.Event object to listeners', function() { eventTarget.addEventListener('foo', spy1); eventTarget.dispatchEvent('foo'); - expect(events[0]).to.be.a(ol.events.Event); + expect(events[0]).to.be.a(_ol_events_Event_); expect(events[0].type).to.be('foo'); expect(events[0].target).to.equal(eventTarget); }); @@ -156,7 +154,7 @@ describe('ol.events.EventTarget', function() { describe('#dispose()', function() { it('cleans up foreign references', function() { - ol.events.listen(eventTarget, 'foo', spy1, document); + _ol_events_.listen(eventTarget, 'foo', spy1, document); expect(eventTarget.hasListener('foo')).to.be(true); eventTarget.dispose(); expect(eventTarget.hasListener('foo')).to.be(false); diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index 81134791a2..d2b1fed1dc 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.extent'); -goog.require('ol.proj'); +import _ol_extent_ from '../../../src/ol/extent.js'; +import _ol_proj_ from '../../../src/ol/proj.js'; describe('ol.extent', function() { @@ -10,7 +8,7 @@ describe('ol.extent', function() { it('buffers an extent by some value', function() { var extent = [-10, -20, 10, 20]; - expect(ol.extent.buffer(extent, 15)).to.eql([-25, -35, 25, 35]); + expect(_ol_extent_.buffer(extent, 15)).to.eql([-25, -35, 25, 35]); }); }); @@ -18,12 +16,12 @@ describe('ol.extent', function() { describe('clone', function() { it('creates a copy of an extent', function() { - var extent = ol.extent.createOrUpdate(1, 2, 3, 4); - var clone = ol.extent.clone(extent); - expect(ol.extent.equals(extent, clone)).to.be(true); + var extent = _ol_extent_.createOrUpdate(1, 2, 3, 4); + var clone = _ol_extent_.clone(extent); + expect(_ol_extent_.equals(extent, clone)).to.be(true); - ol.extent.extendCoordinate(extent, [10, 20]); - expect(ol.extent.equals(extent, clone)).to.be(false); + _ol_extent_.extendCoordinate(extent, [10, 20]); + expect(_ol_extent_.equals(extent, clone)).to.be(false); }); }); @@ -31,45 +29,45 @@ describe('ol.extent', function() { describe('closestSquaredDistanceXY', function() { it('returns correct result when x left of extent', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = -2; var y = 0; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); it('returns correct result when x right of extent', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = 3; var y = 0; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); it('returns correct result for other x values', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = 0.5; var y = 3; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); it('returns correct result when y below extent', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = 0; var y = -2; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); it('returns correct result when y above extent', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = 0; var y = 3; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); it('returns correct result for other y values', function() { - var extent = ol.extent.createOrUpdate(0, 0, 1, 1); + var extent = _ol_extent_.createOrUpdate(0, 0, 1, 1); var x = 3; var y = 0.5; - expect(ol.extent.closestSquaredDistanceXY(extent, x, y)).to.be(4); + expect(_ol_extent_.closestSquaredDistanceXY(extent, x, y)).to.be(4); }); }); @@ -79,15 +77,15 @@ describe('ol.extent', function() { it('works when no extent passed', function() { var coords = [0, 1]; var expected = [0, 1, 0, 1]; - var got = ol.extent.createOrUpdateFromCoordinate(coords); + var got = _ol_extent_.createOrUpdateFromCoordinate(coords); expect(got).to.eql(expected); }); it('updates a passed extent', function() { - var extent = ol.extent.createOrUpdate(-4, -7, -3, -6); + var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6); var coords = [0, 1]; var expected = [0, 1, 0, 1]; - ol.extent.createOrUpdateFromCoordinate(coords, extent); + _ol_extent_.createOrUpdateFromCoordinate(coords, extent); expect(extent).to.eql(expected); }); @@ -98,30 +96,30 @@ describe('ol.extent', function() { it('works when single coordinate and no extent passed', function() { var coords = [[0, 1]]; var expected = [0, 1, 0, 1]; - var got = ol.extent.createOrUpdateFromCoordinates(coords); + var got = _ol_extent_.createOrUpdateFromCoordinates(coords); expect(got).to.eql(expected); }); it('changes the passed extent when single coordinate', function() { - var extent = ol.extent.createOrUpdate(-4, -7, -3, -6); + var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6); var coords = [[0, 1]]; var expected = [0, 1, 0, 1]; - ol.extent.createOrUpdateFromCoordinates(coords, extent); + _ol_extent_.createOrUpdateFromCoordinates(coords, extent); expect(extent).to.eql(expected); }); it('works when multiple coordinates and no extent passed', function() { var coords = [[0, 1], [2, 3]]; var expected = [0, 1, 2, 3]; - var got = ol.extent.createOrUpdateFromCoordinates(coords); + var got = _ol_extent_.createOrUpdateFromCoordinates(coords); expect(got).to.eql(expected); }); it('changes the passed extent when multiple coordinates given', function() { - var extent = ol.extent.createOrUpdate(-4, -7, -3, -6); + var extent = _ol_extent_.createOrUpdate(-4, -7, -3, -6); var coords = [[0, 1], [-2, -1]]; var expected = [-2, -1, 0, 1]; - ol.extent.createOrUpdateFromCoordinates(coords, extent); + _ol_extent_.createOrUpdateFromCoordinates(coords, extent); expect(extent).to.eql(expected); }); @@ -133,7 +131,7 @@ describe('ol.extent', function() { var ring = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]]; var rings = [ring]; var expected = [0, 0, 2, 2]; - var got = ol.extent.createOrUpdateFromRings(rings); + var got = _ol_extent_.createOrUpdateFromRings(rings); expect(got).to.eql(expected); }); @@ -142,7 +140,7 @@ describe('ol.extent', function() { var rings = [ring]; var extent = [1, 1, 4, 7]; var expected = [0, 0, 2, 2]; - ol.extent.createOrUpdateFromRings(rings, extent); + _ol_extent_.createOrUpdateFromRings(rings, extent); expect(extent).to.eql(expected); }); @@ -151,7 +149,7 @@ describe('ol.extent', function() { var ring2 = [[1, 1], [1, 3], [3, 3], [3, 1], [1, 1]]; var rings = [ring1, ring2]; var expected = [0, 0, 3, 3]; - var got = ol.extent.createOrUpdateFromRings(rings); + var got = _ol_extent_.createOrUpdateFromRings(rings); expect(got).to.eql(expected); }); @@ -161,7 +159,7 @@ describe('ol.extent', function() { var rings = [ring1, ring2]; var extent = [1, 1, 4, 7]; var expected = [0, 0, 3, 3]; - ol.extent.createOrUpdateFromRings(rings, extent); + _ol_extent_.createOrUpdateFromRings(rings, extent); expect(extent).to.eql(expected); }); @@ -182,13 +180,13 @@ describe('ol.extent', function() { it('calls the passed callback for each corner', function() { var extent = [1, 2, 3, 4]; - ol.extent.forEachCorner(extent, callbackFalse); + _ol_extent_.forEachCorner(extent, callbackFalse); expect(callbackFalse.callCount).to.be(4); }); it('calls the passed callback with each corner', function() { var extent = [1, 2, 3, 4]; - ol.extent.forEachCorner(extent, callbackFalse); + _ol_extent_.forEachCorner(extent, callbackFalse); var firstCallFirstArg = callbackFalse.args[0][0]; var secondCallFirstArg = callbackFalse.args[1][0]; var thirdCallFirstArg = callbackFalse.args[2][0]; @@ -201,7 +199,7 @@ describe('ol.extent', function() { it('calls a truthy callback only once', function() { var extent = [1, 2, 3, 4]; - ol.extent.forEachCorner(extent, callbackTrue); + _ol_extent_.forEachCorner(extent, callbackTrue); expect(callbackTrue.callCount).to.be(1); }); @@ -220,10 +218,10 @@ describe('ol.extent', function() { return (corner[0] === 1 && corner[1] === 4) ? true : false; }); - ol.extent.forEachCorner(extent, bottomLeftSpy); - ol.extent.forEachCorner(extent, bottomRightSpy); - ol.extent.forEachCorner(extent, topRightSpy); - ol.extent.forEachCorner(extent, topLeftSpy); + _ol_extent_.forEachCorner(extent, bottomLeftSpy); + _ol_extent_.forEachCorner(extent, bottomRightSpy); + _ol_extent_.forEachCorner(extent, topRightSpy); + _ol_extent_.forEachCorner(extent, topLeftSpy); expect(bottomLeftSpy.callCount).to.be(1); expect(bottomRightSpy.callCount).to.be(2); @@ -235,7 +233,7 @@ describe('ol.extent', function() { function() { var extent = [1, 2, 3, 4]; var spy = sinon.spy(); // will return undefined for each corner - var got = ol.extent.forEachCorner(extent, spy); + var got = _ol_extent_.forEachCorner(extent, spy); expect(spy.callCount).to.be(4); expect(got).to.be(false); } @@ -244,7 +242,7 @@ describe('ol.extent', function() { it('calls the callback with given scope', function() { var extent = [1, 2, 3, 4]; var scope = {humpty: 'dumpty'}; - ol.extent.forEachCorner(extent, callbackTrue, scope); + _ol_extent_.forEachCorner(extent, callbackTrue, scope); expect(callbackTrue.calledOn(scope)).to.be(true); }); @@ -252,21 +250,21 @@ describe('ol.extent', function() { describe('getArea', function() { it('returns zero for empty extents', function() { - var emptyExtent = ol.extent.createEmpty(); - var areaEmpty = ol.extent.getArea(emptyExtent); + var emptyExtent = _ol_extent_.createEmpty(); + var areaEmpty = _ol_extent_.getArea(emptyExtent); expect(areaEmpty).to.be(0); var extentDeltaXZero = [45, 67, 45, 78]; - var areaDeltaXZero = ol.extent.getArea(extentDeltaXZero); + var areaDeltaXZero = _ol_extent_.getArea(extentDeltaXZero); expect(areaDeltaXZero).to.be(0); var extentDeltaYZero = [11, 67, 45, 67]; - var areaDeltaYZero = ol.extent.getArea(extentDeltaYZero); + var areaDeltaYZero = _ol_extent_.getArea(extentDeltaYZero); expect(areaDeltaYZero).to.be(0); }); it('calculates correct area for other extents', function() { var extent = [0, 0, 10, 10]; - var area = ol.extent.getArea(extent); + var area = _ol_extent_.getArea(extent); expect(area).to.be(100); }); }); @@ -282,16 +280,16 @@ describe('ol.extent', function() { var farSouth = [-180, -90, 180, -45]; var west = [-180, -90, 0, 90]; var farWest = [-180, -90, -90, 90]; - var none = ol.extent.createEmpty(); - expect(ol.extent.getIntersection(world, none)).to.eql(none); - expect(ol.extent.getIntersection(world, north)).to.eql(north); - expect(ol.extent.getIntersection(world, east)).to.eql(east); - expect(ol.extent.getIntersection(world, south)).to.eql(south); - expect(ol.extent.getIntersection(world, west)).to.eql(west); - expect(ol.extent.getIntersection(farEast, farWest)).to.eql(none); - expect(ol.extent.getIntersection(farNorth, farSouth)).to.eql(none); - expect(ol.extent.getIntersection(north, west)).to.eql([-180, 0, 0, 90]); - expect(ol.extent.getIntersection(east, south)).to.eql([0, -90, 180, 0]); + var none = _ol_extent_.createEmpty(); + expect(_ol_extent_.getIntersection(world, none)).to.eql(none); + expect(_ol_extent_.getIntersection(world, north)).to.eql(north); + expect(_ol_extent_.getIntersection(world, east)).to.eql(east); + expect(_ol_extent_.getIntersection(world, south)).to.eql(south); + expect(_ol_extent_.getIntersection(world, west)).to.eql(west); + expect(_ol_extent_.getIntersection(farEast, farWest)).to.eql(none); + expect(_ol_extent_.getIntersection(farNorth, farSouth)).to.eql(none); + expect(_ol_extent_.getIntersection(north, west)).to.eql([-180, 0, 0, 90]); + expect(_ol_extent_.getIntersection(east, south)).to.eql([0, -90, 180, 0]); }); }); @@ -300,37 +298,37 @@ describe('ol.extent', function() { describe('positive', function() { it('returns true', function() { var extent = [1, 2, 3, 4]; - expect(ol.extent.containsCoordinate(extent, [1, 2])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [1, 3])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [1, 4])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [2, 2])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [2, 3])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [2, 4])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [3, 2])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [3, 3])).to.be.ok(); - expect(ol.extent.containsCoordinate(extent, [3, 4])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [1, 2])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [1, 3])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [1, 4])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [2, 2])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [2, 3])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [2, 4])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [3, 2])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [3, 3])).to.be.ok(); + expect(_ol_extent_.containsCoordinate(extent, [3, 4])).to.be.ok(); }); }); describe('negative', function() { it('returns false', function() { var extent = [1, 2, 3, 4]; - expect(ol.extent.containsCoordinate(extent, [0, 1])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [0, 2])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [0, 3])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [0, 4])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [0, 5])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [1, 1])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [1, 5])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [2, 1])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [2, 5])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [3, 1])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [3, 5])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [4, 1])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [4, 2])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [4, 3])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [4, 4])).to.not.be(); - expect(ol.extent.containsCoordinate(extent, [4, 5])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [0, 1])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [0, 2])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [0, 3])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [0, 4])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [0, 5])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [1, 1])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [1, 5])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [2, 1])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [2, 5])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [3, 1])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [3, 5])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [4, 1])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [4, 2])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [4, 3])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [4, 4])).to.not.be(); + expect(_ol_extent_.containsCoordinate(extent, [4, 5])).to.not.be(); }); }); }); @@ -345,70 +343,70 @@ describe('ol.extent', function() { var LEFT = 16; it('returns intersecting for within', function() { - var rel = ol.extent.coordinateRelationship(extent, [0, 0]); + var rel = _ol_extent_.coordinateRelationship(extent, [0, 0]); expect(rel).to.be(INTERSECTING); }); it('returns intersecting for touching top', function() { - var rel = ol.extent.coordinateRelationship(extent, [0, 90]); + var rel = _ol_extent_.coordinateRelationship(extent, [0, 90]); expect(rel).to.be(INTERSECTING); }); it('returns intersecting for touching right', function() { - var rel = ol.extent.coordinateRelationship(extent, [180, 0]); + var rel = _ol_extent_.coordinateRelationship(extent, [180, 0]); expect(rel).to.be(INTERSECTING); }); it('returns intersecting for touching bottom', function() { - var rel = ol.extent.coordinateRelationship(extent, [0, -90]); + var rel = _ol_extent_.coordinateRelationship(extent, [0, -90]); expect(rel).to.be(INTERSECTING); }); it('returns intersecting for touching left', function() { - var rel = ol.extent.coordinateRelationship(extent, [-180, 0]); + var rel = _ol_extent_.coordinateRelationship(extent, [-180, 0]); expect(rel).to.be(INTERSECTING); }); it('above for north', function() { - var rel = ol.extent.coordinateRelationship(extent, [0, 100]); + var rel = _ol_extent_.coordinateRelationship(extent, [0, 100]); expect(rel).to.be(ABOVE); }); it('above and right for northeast', function() { - var rel = ol.extent.coordinateRelationship(extent, [190, 100]); + var rel = _ol_extent_.coordinateRelationship(extent, [190, 100]); expect(rel & ABOVE).to.be(ABOVE); expect(rel & RIGHT).to.be(RIGHT); }); it('right for east', function() { - var rel = ol.extent.coordinateRelationship(extent, [190, 0]); + var rel = _ol_extent_.coordinateRelationship(extent, [190, 0]); expect(rel).to.be(RIGHT); }); it('below and right for southeast', function() { - var rel = ol.extent.coordinateRelationship(extent, [190, -100]); + var rel = _ol_extent_.coordinateRelationship(extent, [190, -100]); expect(rel & BELOW).to.be(BELOW); expect(rel & RIGHT).to.be(RIGHT); }); it('below for south', function() { - var rel = ol.extent.coordinateRelationship(extent, [0, -100]); + var rel = _ol_extent_.coordinateRelationship(extent, [0, -100]); expect(rel).to.be(BELOW); }); it('below and left for southwest', function() { - var rel = ol.extent.coordinateRelationship(extent, [-190, -100]); + var rel = _ol_extent_.coordinateRelationship(extent, [-190, -100]); expect(rel & BELOW).to.be(BELOW); expect(rel & LEFT).to.be(LEFT); }); it('left for west', function() { - var rel = ol.extent.coordinateRelationship(extent, [-190, 0]); + var rel = _ol_extent_.coordinateRelationship(extent, [-190, 0]); expect(rel).to.be(LEFT); }); it('above and left for northwest', function() { - var rel = ol.extent.coordinateRelationship(extent, [-190, 100]); + var rel = _ol_extent_.coordinateRelationship(extent, [-190, 100]); expect(rel & ABOVE).to.be(ABOVE); expect(rel & LEFT).to.be(LEFT); }); @@ -418,13 +416,13 @@ describe('ol.extent', function() { describe('getCenter', function() { it('returns the expected center', function() { var extent = [1, 2, 3, 4]; - var center = ol.extent.getCenter(extent); + var center = _ol_extent_.getCenter(extent); expect(center[0]).to.eql(2); expect(center[1]).to.eql(3); }); it('returns [NaN, NaN] for empty extents', function() { - var extent = ol.extent.createEmpty(); - var center = ol.extent.getCenter(extent); + var extent = _ol_extent_.createEmpty(); + var center = _ol_extent_.getCenter(extent); expect('' + center[0]).to.be('NaN'); expect('' + center[1]).to.be('NaN'); }); @@ -435,27 +433,27 @@ describe('ol.extent', function() { it('gets the bottom left', function() { var corner = 'bottom-left'; - expect(ol.extent.getCorner(extent, corner)).to.eql([1, 2]); + expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 2]); }); it('gets the bottom right', function() { var corner = 'bottom-right'; - expect(ol.extent.getCorner(extent, corner)).to.eql([3, 2]); + expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 2]); }); it('gets the top left', function() { var corner = 'top-left'; - expect(ol.extent.getCorner(extent, corner)).to.eql([1, 4]); + expect(_ol_extent_.getCorner(extent, corner)).to.eql([1, 4]); }); it('gets the top right', function() { var corner = 'top-right'; - expect(ol.extent.getCorner(extent, corner)).to.eql([3, 4]); + expect(_ol_extent_.getCorner(extent, corner)).to.eql([3, 4]); }); it('throws exception for unexpected corner', function() { expect(function() { - ol.extent.getCorner(extent, 'foobar'); + _ol_extent_.getCorner(extent, 'foobar'); }).to.throwException(); }); @@ -465,7 +463,7 @@ describe('ol.extent', function() { it('returns enlarged area of two extents', function() { var extent1 = [-1, -1, 0, 0]; var extent2 = [0, 0, 1, 1]; - var enlargedArea = ol.extent.getEnlargedArea(extent1, extent2); + var enlargedArea = _ol_extent_.getEnlargedArea(extent1, extent2); expect(enlargedArea).to.be(4); }); }); @@ -473,7 +471,7 @@ describe('ol.extent', function() { describe('getForViewAndSize', function() { it('works for a unit square', function() { - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( [0, 0], 1, 0, [1, 1]); expect(extent[0]).to.be(-0.5); expect(extent[2]).to.be(0.5); @@ -482,7 +480,7 @@ describe('ol.extent', function() { }); it('works for center', function() { - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( [5, 10], 1, 0, [1, 1]); expect(extent[0]).to.be(4.5); expect(extent[2]).to.be(5.5); @@ -491,7 +489,7 @@ describe('ol.extent', function() { }); it('works for rotation', function() { - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( [0, 0], 1, Math.PI / 4, [1, 1]); expect(extent[0]).to.roughlyEqual(-Math.sqrt(0.5), 1e-9); expect(extent[2]).to.roughlyEqual(Math.sqrt(0.5), 1e-9); @@ -500,7 +498,7 @@ describe('ol.extent', function() { }); it('works for resolution', function() { - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( [0, 0], 2, 0, [1, 1]); expect(extent[0]).to.be(-1); expect(extent[2]).to.be(1); @@ -509,7 +507,7 @@ describe('ol.extent', function() { }); it('works for size', function() { - var extent = ol.extent.getForViewAndSize( + var extent = _ol_extent_.getForViewAndSize( [0, 0], 1, 0, [10, 5]); expect(extent[0]).to.be(-5); expect(extent[2]).to.be(5); @@ -522,7 +520,7 @@ describe('ol.extent', function() { describe('getSize', function() { it('returns the expected size', function() { var extent = [0, 1, 2, 4]; - var size = ol.extent.getSize(extent); + var size = _ol_extent_.getSize(extent); expect(size).to.eql([2, 3]); }); }); @@ -531,13 +529,13 @@ describe('ol.extent', function() { it('returns correct area when extents intersect', function() { var extent1 = [0, 0, 2, 2]; var extent2 = [1, 1, 3, 3]; - var intersectionArea = ol.extent.getIntersectionArea(extent1, extent2); + var intersectionArea = _ol_extent_.getIntersectionArea(extent1, extent2); expect(intersectionArea).to.be(1); }); it('returns 0 when extents do not intersect', function() { var extent1 = [0, 0, 1, 1]; var extent2 = [2, 2, 3, 3]; - var intersectionArea = ol.extent.getIntersectionArea(extent1, extent2); + var intersectionArea = _ol_extent_.getIntersectionArea(extent1, extent2); expect(intersectionArea).to.be(0); }); }); @@ -545,14 +543,14 @@ describe('ol.extent', function() { describe('getMargin', function() { it('returns the correct margin (sum of width and height)', function() { var extent = [1, 2, 3, 4]; - expect(ol.extent.getMargin(extent)).to.be(4); + expect(_ol_extent_.getMargin(extent)).to.be(4); }); }); describe('intersects', function() { it('returns the expected value', function() { - var intersects = ol.extent.intersects; + var intersects = _ol_extent_.intersects; var extent = [50, 50, 100, 100]; expect(intersects(extent, extent)).to.be(true); expect(intersects(extent, [20, 20, 80, 80])).to.be(true); @@ -587,7 +585,7 @@ describe('ol.extent', function() { describe('scaleFromCenter', function() { it('scales the extent from its center', function() { var extent = [1, 1, 3, 3]; - ol.extent.scaleFromCenter(extent, 2); + _ol_extent_.scaleFromCenter(extent, 2); expect(extent[0]).to.eql(0); expect(extent[2]).to.eql(4); expect(extent[1]).to.eql(0); @@ -614,107 +612,107 @@ describe('ol.extent', function() { var inside = [10, 10]; it('returns true if contained', function() { - var intersects = ol.extent.intersectsSegment(extent, center, inside); + var intersects = _ol_extent_.intersectsSegment(extent, center, inside); expect(intersects).to.be(true); }); it('returns true if crosses top', function() { - var intersects = ol.extent.intersectsSegment(extent, center, north); + var intersects = _ol_extent_.intersectsSegment(extent, center, north); expect(intersects).to.be(true); }); it('returns true if crosses right', function() { - var intersects = ol.extent.intersectsSegment(extent, center, east); + var intersects = _ol_extent_.intersectsSegment(extent, center, east); expect(intersects).to.be(true); }); it('returns true if crosses bottom', function() { - var intersects = ol.extent.intersectsSegment(extent, center, south); + var intersects = _ol_extent_.intersectsSegment(extent, center, south); expect(intersects).to.be(true); }); it('returns true if crosses left', function() { - var intersects = ol.extent.intersectsSegment(extent, center, west); + var intersects = _ol_extent_.intersectsSegment(extent, center, west); expect(intersects).to.be(true); }); it('returns false if above', function() { - var intersects = ol.extent.intersectsSegment(extent, northwest, north); + var intersects = _ol_extent_.intersectsSegment(extent, northwest, north); expect(intersects).to.be(false); }); it('returns false if right', function() { - var intersects = ol.extent.intersectsSegment(extent, northeast, east); + var intersects = _ol_extent_.intersectsSegment(extent, northeast, east); expect(intersects).to.be(false); }); it('returns false if below', function() { - var intersects = ol.extent.intersectsSegment(extent, south, southwest); + var intersects = _ol_extent_.intersectsSegment(extent, south, southwest); expect(intersects).to.be(false); }); it('returns false if left', function() { - var intersects = ol.extent.intersectsSegment(extent, west, southwest); + var intersects = _ol_extent_.intersectsSegment(extent, west, southwest); expect(intersects).to.be(false); }); it('returns true if crosses top to bottom', function() { - var intersects = ol.extent.intersectsSegment(extent, north, south); + var intersects = _ol_extent_.intersectsSegment(extent, north, south); expect(intersects).to.be(true); }); it('returns true if crosses bottom to top', function() { - var intersects = ol.extent.intersectsSegment(extent, south, north); + var intersects = _ol_extent_.intersectsSegment(extent, south, north); expect(intersects).to.be(true); }); it('returns true if crosses left to right', function() { - var intersects = ol.extent.intersectsSegment(extent, west, east); + var intersects = _ol_extent_.intersectsSegment(extent, west, east); expect(intersects).to.be(true); }); it('returns true if crosses right to left', function() { - var intersects = ol.extent.intersectsSegment(extent, east, west); + var intersects = _ol_extent_.intersectsSegment(extent, east, west); expect(intersects).to.be(true); }); it('returns true if crosses northwest to east', function() { - var intersects = ol.extent.intersectsSegment(extent, northwest, east); + var intersects = _ol_extent_.intersectsSegment(extent, northwest, east); expect(intersects).to.be(true); }); it('returns true if crosses south to west', function() { - var intersects = ol.extent.intersectsSegment(extent, south, west); + var intersects = _ol_extent_.intersectsSegment(extent, south, west); expect(intersects).to.be(true); }); it('returns true if touches top', function() { - var intersects = ol.extent.intersectsSegment(extent, northwest, top); + var intersects = _ol_extent_.intersectsSegment(extent, northwest, top); expect(intersects).to.be(true); }); it('returns true if touches right', function() { - var intersects = ol.extent.intersectsSegment(extent, southeast, right); + var intersects = _ol_extent_.intersectsSegment(extent, southeast, right); expect(intersects).to.be(true); }); it('returns true if touches bottom', function() { - var intersects = ol.extent.intersectsSegment(extent, bottom, south); + var intersects = _ol_extent_.intersectsSegment(extent, bottom, south); expect(intersects).to.be(true); }); it('returns true if touches left', function() { - var intersects = ol.extent.intersectsSegment(extent, left, west); + var intersects = _ol_extent_.intersectsSegment(extent, left, west); expect(intersects).to.be(true); }); it('works for zero length inside', function() { - var intersects = ol.extent.intersectsSegment(extent, center, center); + var intersects = _ol_extent_.intersectsSegment(extent, center, center); expect(intersects).to.be(true); }); it('works for zero length outside', function() { - var intersects = ol.extent.intersectsSegment(extent, north, north); + var intersects = _ol_extent_.intersectsSegment(extent, north, north); expect(intersects).to.be(false); }); @@ -722,16 +720,16 @@ describe('ol.extent', function() { var extent = [2, 1, 3, 4]; var start = [0, 0]; var end = [5, 5]; - expect(ol.extent.intersectsSegment(extent, start, end)).to.be(true); - expect(ol.extent.intersectsSegment(extent, end, start)).to.be(true); + expect(_ol_extent_.intersectsSegment(extent, start, end)).to.be(true); + expect(_ol_extent_.intersectsSegment(extent, end, start)).to.be(true); }); it('works for top/bottom intersection spanning left to right', function() { var extent = [1, 2, 4, 3]; var start = [0, 0]; var end = [5, 5]; - expect(ol.extent.intersectsSegment(extent, start, end)).to.be(true); - expect(ol.extent.intersectsSegment(extent, end, start)).to.be(true); + expect(_ol_extent_.intersectsSegment(extent, start, end)).to.be(true); + expect(_ol_extent_.intersectsSegment(extent, end, start)).to.be(true); }); }); @@ -739,9 +737,9 @@ describe('ol.extent', function() { describe('#applyTransform()', function() { it('does transform', function() { - var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857'); + var transformFn = _ol_proj_.getTransform('EPSG:4326', 'EPSG:3857'); var sourceExtent = [-15, -30, 45, 60]; - var destinationExtent = ol.extent.applyTransform( + var destinationExtent = _ol_extent_.applyTransform( sourceExtent, transformFn); expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(null); @@ -768,7 +766,7 @@ describe('ol.extent', function() { return output; }; var sourceExtent = [-15, -30, 45, 60]; - var destinationExtent = ol.extent.applyTransform( + var destinationExtent = _ol_extent_.applyTransform( sourceExtent, transformFn); expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(null); diff --git a/test/spec/ol/feature.test.js b/test/spec/ol/feature.test.js index a6553d7653..d563d9dce2 100644 --- a/test/spec/ol/feature.test.js +++ b/test/spec/ol/feature.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.obj'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; +import _ol_obj_ from '../../../src/ol/obj.js'; +import _ol_style_Style_ from '../../../src/ol/style/Style.js'; describe('ol.Feature', function() { @@ -11,30 +9,30 @@ describe('ol.Feature', function() { describe('constructor', function() { it('creates a new feature', function() { - var feature = new ol.Feature(); - expect(feature).to.be.a(ol.Feature); + var feature = new _ol_Feature_(); + expect(feature).to.be.a(_ol_Feature_); }); it('takes properties', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ foo: 'bar' }); expect(feature.get('foo')).to.be('bar'); }); it('can store the feature\'s commonly used id', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); expect(feature.getId()).to.be('foo'); }); it('will set the default geometry', function() { - var feature = new ol.Feature({ - geometry: new ol.geom.Point([10, 20]), + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([10, 20]), foo: 'bar' }); var geometry = feature.getGeometry(); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); expect(feature.get('geometry')).to.be(geometry); }); @@ -43,7 +41,7 @@ describe('ol.Feature', function() { describe('#get()', function() { it('returns values set at construction', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ a: 'first', b: 'second' }); @@ -52,12 +50,12 @@ describe('ol.Feature', function() { }); it('returns undefined for unset attributes', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); expect(feature.get('a')).to.be(undefined); }); it('returns values set by set', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('a', 'b'); expect(feature.get('a')).to.be('b'); }); @@ -67,8 +65,8 @@ describe('ol.Feature', function() { describe('#getProperties()', function() { it('returns an object with all attributes', function() { - var point = new ol.geom.Point([15, 30]); - var feature = new ol.Feature({ + var point = new _ol_geom_Point_([15, 30]); + var feature = new _ol_Feature_({ foo: 'bar', ten: 10, geometry: point @@ -85,9 +83,9 @@ describe('ol.Feature', function() { }); it('is empty by default', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); var properties = feature.getProperties(); - expect(ol.obj.isEmpty(properties)).to.be(true); + expect(_ol_obj_.isEmpty(properties)).to.be(true); }); }); @@ -95,37 +93,37 @@ describe('ol.Feature', function() { describe('#getGeometry()', function() { - var point = new ol.geom.Point([15, 30]); + var point = new _ol_geom_Point_([15, 30]); it('returns undefined for unset geometry', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); expect(feature.getGeometry()).to.be(undefined); }); it('returns null for null geometry (constructor)', function() { - var feature = new ol.Feature(null); + var feature = new _ol_Feature_(null); expect(feature.getGeometry()).to.be(null); }); it('returns null for null geometry (setGeometry())', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(null); expect(feature.getGeometry()).to.be(null); }); it('gets the geometry set at construction', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ geometry: point }); expect(feature.getGeometry()).to.be(point); }); it('gets any geometry set by setGeometry', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(point); expect(feature.getGeometry()).to.be(point); - var point2 = new ol.geom.Point([1, 2]); + var point2 = new _ol_geom_Point_([1, 2]); feature.setGeometry(point2); expect(feature.getGeometry()).to.be(point2); }); @@ -135,7 +133,7 @@ describe('ol.Feature', function() { describe('#set()', function() { it('sets values', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ a: 'first', b: 'second' }); @@ -144,9 +142,9 @@ describe('ol.Feature', function() { }); it('can be used to set the geometry', function() { - var point = new ol.geom.Point([3, 4]); - var feature = new ol.Feature({ - geometry: new ol.geom.Point([1, 2]) + var point = new _ol_geom_Point_([3, 4]); + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([1, 2]) }); feature.set('geometry', point); expect(feature.get('geometry')).to.be(point); @@ -155,7 +153,7 @@ describe('ol.Feature', function() { it('can be used to set attributes with arbitrary names', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('toString', 'string'); expect(feature.get('toString')).to.be('string'); @@ -164,8 +162,8 @@ describe('ol.Feature', function() { feature.set('getGeometry', 'x'); expect(feature.get('getGeometry')).to.be('x'); - feature.set('geometry', new ol.geom.Point([1, 2])); - expect(feature.getGeometry()).to.be.a(ol.geom.Point); + feature.set('geometry', new _ol_geom_Point_([1, 2])); + expect(feature.getGeometry()).to.be.a(_ol_geom_Point_); }); @@ -173,21 +171,21 @@ describe('ol.Feature', function() { describe('#setGeometry()', function() { - var point = new ol.geom.Point([15, 30]); + var point = new _ol_geom_Point_([15, 30]); it('sets the default geometry', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(point); expect(feature.get('geometry')).to.be(point); }); it('replaces previous default geometry', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ geometry: point }); expect(feature.getGeometry()).to.be(point); - var point2 = new ol.geom.Point([1, 2]); + var point2 = new _ol_geom_Point_([1, 2]); feature.setGeometry(point2); expect(feature.getGeometry()).to.be(point2); }); @@ -196,14 +194,14 @@ describe('ol.Feature', function() { describe('#setGeometryName()', function() { - var point = new ol.geom.Point([15, 30]); + var point = new _ol_geom_Point_([15, 30]); it('sets property where to to look at geometry', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(point); expect(feature.getGeometry()).to.be(point); - var point2 = new ol.geom.Point([1, 2]); + var point2 = new _ol_geom_Point_([1, 2]); feature.set('altGeometry', point2); expect(feature.getGeometry()).to.be(point); feature.setGeometryName('altGeometry'); @@ -216,9 +214,9 @@ describe('ol.Feature', function() { }); it('changes property listener', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometry(point); - var point2 = new ol.geom.Point([1, 2]); + var point2 = new _ol_geom_Point_([1, 2]); feature.set('altGeometry', point2); feature.setGeometryName('altGeometry'); @@ -229,9 +227,9 @@ describe('ol.Feature', function() { }); it('can use a different geometry name', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setGeometryName('foo'); - var point = new ol.geom.Point([10, 20]); + var point = new _ol_geom_Point_([10, 20]); feature.setGeometry(point); expect(feature.getGeometry()).to.be(point); }); @@ -241,14 +239,14 @@ describe('ol.Feature', function() { describe('#setId()', function() { it('sets the feature identifier', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); expect(feature.getId()).to.be(undefined); feature.setId('foo'); expect(feature.getId()).to.be('foo'); }); it('accepts a string or number', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); expect(feature.getId()).to.be('foo'); feature.setId(2); @@ -256,7 +254,7 @@ describe('ol.Feature', function() { }); it('dispatches the "change" event', function(done) { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.on('change', function() { expect(feature.getId()).to.be('foo'); done(); @@ -273,24 +271,24 @@ describe('ol.Feature', function() { }; it('returns undefined after construction', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); expect(feature.getStyleFunction()).to.be(undefined); }); it('returns the function passed to setStyle', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle(styleFunction); expect(feature.getStyleFunction()).to.be(styleFunction); }); it('does not get confused with user "styleFunction" property', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('styleFunction', 'foo'); expect(feature.getStyleFunction()).to.be(undefined); }); it('does not get confused with "styleFunction" option', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ styleFunction: 'foo' }); expect(feature.getStyleFunction()).to.be(undefined); @@ -300,28 +298,28 @@ describe('ol.Feature', function() { describe('#setStyle()', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); var styleFunction = function(feature, resolution) { return resolution; }; it('accepts a single style', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle(style); var func = feature.getStyleFunction(); expect(func()).to.eql([style]); }); it('accepts an array of styles', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var func = feature.getStyleFunction(); expect(func()).to.eql([style]); }); it('accepts a style function', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); function featureStyleFunction(resolution) { return styleFunction(this, resolution); } @@ -331,14 +329,14 @@ describe('ol.Feature', function() { }); it('accepts a layer style function', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle(styleFunction); expect(feature.getStyleFunction()).to.not.be(styleFunction); expect(feature.getStyleFunction()(42)).to.be(42); }); it('accepts null', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle(style); feature.setStyle(null); expect(feature.getStyle()).to.be(null); @@ -346,7 +344,7 @@ describe('ol.Feature', function() { }); it('dispatches a change event', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); var spy = sinon.spy(); feature.on('change', spy); feature.setStyle(style); @@ -357,14 +355,14 @@ describe('ol.Feature', function() { describe('#getStyle()', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); var styleFunction = function(resolution) { return null; }; it('returns what is passed to setStyle', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); expect(feature.getStyle()).to.be(null); @@ -380,7 +378,7 @@ describe('ol.Feature', function() { }); it('does not get confused with "style" option to constructor', function() { - var feature = new ol.Feature({ + var feature = new _ol_Feature_({ style: 'foo' }); @@ -388,7 +386,7 @@ describe('ol.Feature', function() { }); it('does not get confused with user set "style" property', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('style', 'foo'); expect(feature.getStyle()).to.be(null); @@ -399,13 +397,13 @@ describe('ol.Feature', function() { describe('#clone', function() { it('correctly clones features', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setProperties({'fookey': 'fooval'}); feature.setId(1); feature.setGeometryName('geom'); - var geometry = new ol.geom.Point([1, 2]); + var geometry = new _ol_geom_Point_([1, 2]); feature.setGeometry(geometry); - var style = new ol.style.Style({}); + var style = new _ol_style_Style_({}); feature.setStyle(style); feature.set('barkey', 'barval'); @@ -423,7 +421,7 @@ describe('ol.Feature', function() { }); it('correctly clones features with no geometry and no style', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('fookey', 'fooval'); var clone = feature.clone(); @@ -437,8 +435,8 @@ describe('ol.Feature', function() { it('dispatches a change event when geometry is set to null', function() { - var feature = new ol.Feature({ - geometry: new ol.geom.Point([0, 0]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([0, 0]) }); var spy = sinon.spy(); feature.on('change', spy); @@ -450,15 +448,15 @@ describe('ol.Feature', function() { }); describe('ol.Feature.createStyleFunction()', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('creates a feature style function from a single style', function() { - var styleFunction = ol.Feature.createStyleFunction(style); + var styleFunction = _ol_Feature_.createStyleFunction(style); expect(styleFunction()).to.eql([style]); }); it('creates a feature style function from an array of styles', function() { - var styleFunction = ol.Feature.createStyleFunction([style]); + var styleFunction = _ol_Feature_.createStyleFunction([style]); expect(styleFunction()).to.eql([style]); }); @@ -466,13 +464,13 @@ describe('ol.Feature.createStyleFunction()', function() { var original = function() { return [style]; }; - var styleFunction = ol.Feature.createStyleFunction(original); + var styleFunction = _ol_Feature_.createStyleFunction(original); expect(styleFunction).to.be(original); }); it('throws on (some) unexpected input', function() { expect(function() { - ol.Feature.createStyleFunction({bogus: 'input'}); + _ol_Feature_.createStyleFunction({bogus: 'input'}); }).to.throwException(); }); diff --git a/test/spec/ol/featureloader.test.js b/test/spec/ol/featureloader.test.js index 05758d1627..103e8ec0cd 100644 --- a/test/spec/ol/featureloader.test.js +++ b/test/spec/ol/featureloader.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.featureloader'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.source.Vector'); +import _ol_featureloader_ from '../../../src/ol/featureloader.js'; +import _ol_format_GeoJSON_ from '../../../src/ol/format/GeoJSON.js'; +import _ol_source_Vector_ from '../../../src/ol/source/Vector.js'; describe('ol.featureloader', function() { @@ -15,13 +13,13 @@ describe('ol.featureloader', function() { beforeEach(function() { url = 'spec/ol/data/point.json'; - format = new ol.format.GeoJSON(); + format = new _ol_format_GeoJSON_(); - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('adds features to the source', function(done) { - loader = ol.featureloader.xhr(url, format); + loader = _ol_featureloader_.xhr(url, format); source.on('addfeature', function(e) { expect(source.getFeatures().length).to.be.greaterThan(0); done(); @@ -34,7 +32,7 @@ describe('ol.featureloader', function() { url = function(extent, resolution, projection) { return 'spec/ol/data/point.json'; }; - loader = ol.featureloader.xhr(url, format); + loader = _ol_featureloader_.xhr(url, format); source.on('addfeature', function(e) { expect(source.getFeatures().length).to.be.greaterThan(0); @@ -54,7 +52,7 @@ describe('ol.featureloader', function() { done(); return 'spec/ol/data/point.json'; }; - loader = ol.featureloader.xhr(url, format); + loader = _ol_featureloader_.xhr(url, format); loader.call(source, [], 1, 'EPSG:3857'); }); }); diff --git a/test/spec/ol/format/esrijson.test.js b/test/spec/ol/format/esrijson.test.js index 603c692375..de597efca5 100644 --- a/test/spec/ol/format/esrijson.test.js +++ b/test/spec/ol/format/esrijson.test.js @@ -1,23 +1,21 @@ - - -goog.require('ol.Feature'); -goog.require('ol.extent'); -goog.require('ol.format.EsriJSON'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_format_EsriJSON_ from '../../../../src/ol/format/EsriJSON.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.EsriJSON', function() { var format; beforeEach(function() { - format = new ol.format.EsriJSON(); + format = new _ol_format_EsriJSON_(); }); var pointEsriJSON = { @@ -163,27 +161,27 @@ describe('ol.format.EsriJSON', function() { it('can read a single point feature', function() { var feature = format.readFeature(pointEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.Point); + expect(geometry).to.be.an(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([102.0, 0.5]); expect(feature.get('prop0')).to.be('value0'); }); it('can read a single multipoint feature', function() { var feature = format.readFeature(multiPointEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.MultiPoint); + expect(geometry).to.be.an(_ol_geom_MultiPoint_); expect(geometry.getCoordinates()).to.eql([[102.0, 0.0], [103.0, 1.0]]); expect(feature.get('prop0')).to.be('value0'); }); it('can read a single line string feature', function() { var feature = format.readFeature(lineStringEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql( [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]); expect(feature.get('prop0')).to.be('value0'); @@ -192,9 +190,9 @@ describe('ol.format.EsriJSON', function() { it('can read a multi line string feature', function() { var feature = format.readFeature(multiLineStringEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.MultiLineString); + expect(geometry).to.be.an(_ol_geom_MultiLineString_); expect(geometry.getCoordinates()).to.eql([ [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]], [[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]] @@ -205,9 +203,9 @@ describe('ol.format.EsriJSON', function() { it('can read a single polygon feature', function() { var feature = format.readFeature(polygonEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.Polygon); + expect(geometry).to.be.an(_ol_geom_Polygon_); expect(geometry.getCoordinates()).to.eql([[ [100.0, 0.0], [100.0, 1.0], [101.0, 1.0], [101.0, 0.0] ]]); @@ -217,9 +215,9 @@ describe('ol.format.EsriJSON', function() { it('can read a multi polygon feature', function() { var feature = format.readFeature(multiPolygonEsriJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.MultiPolygon); + expect(geometry).to.be.an(_ol_geom_MultiPolygon_); expect(geometry.getCoordinates()).to.eql([ [[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2], [3, 3], [2, 3]]], [[[10, 1], [11, 5], [14, 3], [13, 0]]] @@ -229,9 +227,9 @@ describe('ol.format.EsriJSON', function() { it('can read a feature collection', function() { var features = format.readFeatures(featureCollectionEsriJSON); expect(features).to.have.length(3); - expect(features[0].getGeometry()).to.be.an(ol.geom.Point); - expect(features[1].getGeometry()).to.be.an(ol.geom.LineString); - expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon); + expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); + expect(features[1].getGeometry()).to.be.an(_ol_geom_LineString_); + expect(features[2].getGeometry()).to.be.an(_ol_geom_Polygon_); }); it('can read and transform a point', function() { @@ -239,9 +237,9 @@ describe('ol.format.EsriJSON', function() { featureProjection: 'EPSG:3857', dataProjection: 'EPSG:4326' }); - expect(feature[0].getGeometry()).to.be.an(ol.geom.Point); + expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); }); it('can read and transform a feature collection', function() { @@ -249,28 +247,28 @@ describe('ol.format.EsriJSON', function() { featureProjection: 'EPSG:3857', dataProjection: 'EPSG:4326' }); - expect(features[0].getGeometry()).to.be.an(ol.geom.Point); + expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(features[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); expect(features[1].getGeometry().getCoordinates()).to.eql([ - ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') ]); expect(features[2].getGeometry().getCoordinates()).to.eql([[ - ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') ]]); }); it('can create a feature with a specific geometryName', function() { - var feature = new ol.format.EsriJSON({geometryName: 'the_geom'}). + var feature = new _ol_format_EsriJSON_({geometryName: 'the_geom'}). readFeature(pointEsriJSON); expect(feature.getGeometryName()).to.be('the_geom'); - expect(feature.getGeometry()).to.be.an(ol.geom.Point); + expect(feature.getGeometry()).to.be.an(_ol_geom_Point_); }); }); @@ -284,16 +282,16 @@ describe('ol.format.EsriJSON', function() { expect(array.length).to.be(2); var first = array[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('LINK_ID')).to.be(573730499); var firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(ol.geom.LineString); + expect(firstGeom).to.be.a(_ol_geom_LineString_); var second = array[1]; - expect(second).to.be.a(ol.Feature); + expect(second).to.be.a(_ol_Feature_); expect(second.get('ST_NAME')).to.be('BRUNNSGATAN'); var secondGeom = second.getGeometry(); - expect(secondGeom).to.be.a(ol.geom.LineString); + expect(secondGeom).to.be.a(_ol_geom_LineString_); }); it('parses ksfields.geojson', function(done) { @@ -302,23 +300,23 @@ describe('ol.format.EsriJSON', function() { expect(result.length).to.be(9); var first = result[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('field_name')).to.be('EUDORA'); expect(first.getId()).to.be(6406); var firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(ol.geom.Polygon); - expect(ol.extent.equals(firstGeom.getExtent(), [ + expect(firstGeom).to.be.a(_ol_geom_Polygon_); + expect(_ol_extent_.equals(firstGeom.getExtent(), [ -10585772.743554419, 4712365.161160459, -10579560.16462974, 4716567.373073828 ])).to.be(true); var last = result[8]; - expect(last).to.be.a(ol.Feature); + expect(last).to.be.a(_ol_Feature_); expect(last.get('field_name')).to.be('FEAGINS'); expect(last.getId()).to.be(6030); var lastGeom = last.getGeometry(); - expect(lastGeom).to.be.a(ol.geom.Polygon); - expect(ol.extent.equals(lastGeom.getExtent(), [ + expect(lastGeom).to.be.a(_ol_geom_Polygon_); + expect(_ol_extent_.equals(lastGeom.getExtent(), [ -10555714.026858449, 4576511.565880965, -10553671.199322715, 4578554.9934867555 ])).to.be(true); @@ -338,7 +336,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Point); + expect(obj).to.be.a(_ol_geom_Point_); expect(obj.getCoordinates()).to.eql([10, 20]); expect(obj.getLayout()).to.eql('XY'); }); @@ -351,7 +349,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Point); + expect(obj).to.be.a(_ol_geom_Point_); expect(obj.getCoordinates()).to.eql([10, 20, 10]); expect(obj.getLayout()).to.eql('XYZ'); }); @@ -364,7 +362,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Point); + expect(obj).to.be.a(_ol_geom_Point_); expect(obj.getCoordinates()).to.eql([10, 20, 10]); expect(obj.getLayout()).to.eql('XYM'); }); @@ -378,7 +376,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Point); + expect(obj).to.be.a(_ol_geom_Point_); expect(obj.getCoordinates()).to.eql([10, 20, 0, 10]); expect(obj.getLayout()).to.eql('XYZM'); }); @@ -389,7 +387,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPoint); + expect(obj).to.be.a(_ol_geom_MultiPoint_); expect(obj.getCoordinates()).to.eql([[10, 20], [20, 30]]); expect(obj.getLayout()).to.eql('XY'); }); @@ -401,7 +399,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPoint); + expect(obj).to.be.a(_ol_geom_MultiPoint_); expect(obj.getCoordinates()).to.eql([[10, 20, 0], [20, 30, 0]]); expect(obj.getLayout()).to.eql('XYZ'); }); @@ -413,7 +411,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPoint); + expect(obj).to.be.a(_ol_geom_MultiPoint_); expect(obj.getCoordinates()).to.eql([[10, 20, 0], [20, 30, 0]]); expect(obj.getLayout()).to.eql('XYM'); }); @@ -426,7 +424,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPoint); + expect(obj).to.be.a(_ol_geom_MultiPoint_); expect(obj.getCoordinates()).to.eql([[10, 20, 0, 1], [20, 30, 0, 1]]); expect(obj.getLayout()).to.eql('XYZM'); }); @@ -437,7 +435,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]); expect(obj.getLayout()).to.eql('XY'); }); @@ -449,7 +447,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getLayout()).to.eql('XYZ'); expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]); }); @@ -461,7 +459,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getLayout()).to.eql('XYM'); expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]); }); @@ -474,7 +472,7 @@ describe('ol.format.EsriJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getLayout()).to.eql('XYZM'); expect(obj.getCoordinates()).to.eql([[10, 20, 1534, 1], [30, 40, 1420, 2]]); @@ -489,7 +487,7 @@ describe('ol.format.EsriJSON', function() { ]] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiLineString); + expect(obj).to.be.a(_ol_geom_MultiLineString_); expect(obj.getCoordinates()).to.eql([ [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]], [[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]] @@ -507,7 +505,7 @@ describe('ol.format.EsriJSON', function() { ]] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiLineString); + expect(obj).to.be.a(_ol_geom_MultiLineString_); expect(obj.getCoordinates()).to.eql([ [[102.0, 0.0, 1], [103.0, 1.0, 1], [104.0, 0.0, 1], [105.0, 1.0, 1]], [[105.0, 3.0, 1], [106.0, 4.0, 1], [107.0, 3.0, 1], [108.0, 4.0, 1]] @@ -525,7 +523,7 @@ describe('ol.format.EsriJSON', function() { ]] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiLineString); + expect(obj).to.be.a(_ol_geom_MultiLineString_); expect(obj.getCoordinates()).to.eql([ [[102.0, 0.0, 1], [103.0, 1.0, 1], [104.0, 0.0, 1], [105.0, 1.0, 1]], [[105.0, 3.0, 1], [106.0, 4.0, 1], [107.0, 3.0, 1], [108.0, 4.0, 1]] @@ -544,7 +542,7 @@ describe('ol.format.EsriJSON', function() { ]] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiLineString); + expect(obj).to.be.a(_ol_geom_MultiLineString_); expect(obj.getCoordinates()).to.eql([ [[102, 0, 1, 2], [103, 1, 1, 2], [104, 0, 1, 2], [105, 1, 1, 2]], [[105, 3, 1, 2], [106, 4, 1, 2], [107, 3, 1, 2], [108, 4, 1, 2]] @@ -560,14 +558,14 @@ describe('ol.format.EsriJSON', function() { rings: [outer, inner1, inner2] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Polygon); + expect(obj).to.be.a(_ol_geom_Polygon_); expect(obj.getLayout()).to.eql('XY'); var rings = obj.getLinearRings(); expect(rings.length).to.be(3); expect(rings[0].getCoordinates()[0].length).to.equal(2); - expect(rings[0]).to.be.a(ol.geom.LinearRing); - expect(rings[1]).to.be.a(ol.geom.LinearRing); - expect(rings[2]).to.be.a(ol.geom.LinearRing); + expect(rings[0]).to.be.a(_ol_geom_LinearRing_); + expect(rings[1]).to.be.a(_ol_geom_LinearRing_); + expect(rings[2]).to.be.a(_ol_geom_LinearRing_); }); it('parses XYZ polygon', function() { @@ -579,14 +577,14 @@ describe('ol.format.EsriJSON', function() { hasZ: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Polygon); + expect(obj).to.be.a(_ol_geom_Polygon_); expect(obj.getLayout()).to.eql('XYZ'); var rings = obj.getLinearRings(); expect(rings.length).to.be(3); expect(rings[0].getCoordinates()[0].length).to.equal(3); - expect(rings[0]).to.be.a(ol.geom.LinearRing); - expect(rings[1]).to.be.a(ol.geom.LinearRing); - expect(rings[2]).to.be.a(ol.geom.LinearRing); + expect(rings[0]).to.be.a(_ol_geom_LinearRing_); + expect(rings[1]).to.be.a(_ol_geom_LinearRing_); + expect(rings[2]).to.be.a(_ol_geom_LinearRing_); }); it('parses XYM polygon', function() { @@ -598,14 +596,14 @@ describe('ol.format.EsriJSON', function() { hasM: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Polygon); + expect(obj).to.be.a(_ol_geom_Polygon_); expect(obj.getLayout()).to.eql('XYM'); var rings = obj.getLinearRings(); expect(rings.length).to.be(3); expect(rings[0].getCoordinates()[0].length).to.equal(3); - expect(rings[0]).to.be.a(ol.geom.LinearRing); - expect(rings[1]).to.be.a(ol.geom.LinearRing); - expect(rings[2]).to.be.a(ol.geom.LinearRing); + expect(rings[0]).to.be.a(_ol_geom_LinearRing_); + expect(rings[1]).to.be.a(_ol_geom_LinearRing_); + expect(rings[2]).to.be.a(_ol_geom_LinearRing_); }); it('parses XYZM polygon', function() { @@ -627,14 +625,14 @@ describe('ol.format.EsriJSON', function() { hasM: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Polygon); + expect(obj).to.be.a(_ol_geom_Polygon_); expect(obj.getLayout()).to.eql('XYZM'); var rings = obj.getLinearRings(); expect(rings.length).to.be(3); expect(rings[0].getCoordinates()[0].length).to.equal(4); - expect(rings[0]).to.be.a(ol.geom.LinearRing); - expect(rings[1]).to.be.a(ol.geom.LinearRing); - expect(rings[2]).to.be.a(ol.geom.LinearRing); + expect(rings[0]).to.be.a(_ol_geom_LinearRing_); + expect(rings[1]).to.be.a(_ol_geom_LinearRing_); + expect(rings[2]).to.be.a(_ol_geom_LinearRing_); }); it('parses XY multipolygon', function() { @@ -646,7 +644,7 @@ describe('ol.format.EsriJSON', function() { ] }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPolygon); + expect(obj).to.be.a(_ol_geom_MultiPolygon_); expect(obj.getLayout()).to.eql('XY'); expect(obj.getCoordinates()).to.eql([ [[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2], @@ -665,7 +663,7 @@ describe('ol.format.EsriJSON', function() { hasZ: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPolygon); + expect(obj).to.be.a(_ol_geom_MultiPolygon_); expect(obj.getLayout()).to.eql('XYZ'); expect(obj.getCoordinates()).to.eql([ [[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0], @@ -684,7 +682,7 @@ describe('ol.format.EsriJSON', function() { hasM: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPolygon); + expect(obj).to.be.a(_ol_geom_MultiPolygon_); expect(obj.getLayout()).to.eql('XYM'); expect(obj.getCoordinates()).to.eql([ [[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0], @@ -704,7 +702,7 @@ describe('ol.format.EsriJSON', function() { hasM: true }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.MultiPolygon); + expect(obj).to.be.a(_ol_geom_MultiPolygon_); expect(obj.getLayout()).to.eql('XYZM'); expect(obj.getCoordinates()).to.eql([ [[[0, 1, 0, 1], [1, 4, 0, 1], [4, 3, 0, 1], [3, 0, 0, 1]], @@ -746,16 +744,16 @@ describe('ol.format.EsriJSON', function() { expect(features.length).to.be(2); var first = features[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('foo')).to.be('bar'); - expect(first.getGeometry()).to.be.a(ol.geom.Point); + expect(first.getGeometry()).to.be.a(_ol_geom_Point_); var second = features[1]; - expect(second).to.be.a(ol.Feature); + expect(second).to.be.a(_ol_Feature_); expect(second.get('bam')).to.be('baz'); - expect(second.getGeometry()).to.be.a(ol.geom.LineString); + expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); - expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:3857')); + expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857')); }); @@ -764,28 +762,28 @@ describe('ol.format.EsriJSON', function() { describe('#writeGeometry', function() { it('encodes point', function() { - var point = new ol.geom.Point([10, 20]); + var point = new _ol_geom_Point_([10, 20]); var esrijson = format.writeGeometry(point); expect(point.getCoordinates()).to.eql( format.readGeometry(esrijson).getCoordinates()); }); it('encodes XYZ point', function() { - var point = new ol.geom.Point([10, 20, 0], 'XYZ'); + var point = new _ol_geom_Point_([10, 20, 0], 'XYZ'); var esrijson = format.writeGeometry(point); expect(point.getCoordinates()).to.eql( format.readGeometry(esrijson).getCoordinates()); }); it('encodes XYM point', function() { - var point = new ol.geom.Point([10, 20, 0], 'XYM'); + var point = new _ol_geom_Point_([10, 20, 0], 'XYM'); var esrijson = format.writeGeometry(point); expect(point.getCoordinates()).to.eql( format.readGeometry(esrijson).getCoordinates()); }); it('encodes XYZM point', function() { - var point = new ol.geom.Point([10, 20, 5, 0], + var point = new _ol_geom_Point_([10, 20, 5, 0], 'XYZM'); var esrijson = format.writeGeometry(point); expect(point.getCoordinates()).to.eql( @@ -793,14 +791,14 @@ describe('ol.format.EsriJSON', function() { }); it('encodes linestring', function() { - var linestring = new ol.geom.LineString([[10, 20], [30, 40]]); + var linestring = new _ol_geom_LineString_([[10, 20], [30, 40]]); var esrijson = format.writeGeometry(linestring); expect(linestring.getCoordinates()).to.eql( format.readGeometry(esrijson).getCoordinates()); }); it('encodes XYZ linestring', function() { - var linestring = new ol.geom.LineString([[10, 20, 1534], [30, 40, 1420]], + var linestring = new _ol_geom_LineString_([[10, 20, 1534], [30, 40, 1420]], 'XYZ'); var esrijson = format.writeGeometry(linestring); expect(linestring.getCoordinates()).to.eql( @@ -808,7 +806,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYM linestring', function() { - var linestring = new ol.geom.LineString([[10, 20, 1534], [30, 40, 1420]], + var linestring = new _ol_geom_LineString_([[10, 20, 1534], [30, 40, 1420]], 'XYM'); var esrijson = format.writeGeometry(linestring); expect(linestring.getCoordinates()).to.eql( @@ -816,7 +814,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZM linestring', function() { - var linestring = new ol.geom.LineString([[10, 20, 1534, 1], + var linestring = new _ol_geom_LineString_([[10, 20, 1534, 1], [30, 40, 1420, 1]], 'XYZM'); var esrijson = format.writeGeometry(linestring); @@ -828,7 +826,7 @@ describe('ol.format.EsriJSON', function() { var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]; var inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]; var inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]]; - var polygon = new ol.geom.Polygon([outer, inner1, inner2]); + var polygon = new _ol_geom_Polygon_([outer, inner1, inner2]); var esrijson = format.writeGeometry(polygon); expect(polygon.getCoordinates(false)).to.eql( format.readGeometry(esrijson).getCoordinates()); @@ -838,7 +836,7 @@ describe('ol.format.EsriJSON', function() { var outer = [[0, 0, 5], [0, 10, 5], [10, 10, 5], [10, 0, 5], [0, 0, 5]]; var inner1 = [[1, 1, 3], [2, 1, 3], [2, 2, 3], [1, 2, 3], [1, 1, 3]]; var inner2 = [[8, 8, 2], [9, 8, 2], [9, 9, 2], [8, 9, 2], [8, 8, 2]]; - var polygon = new ol.geom.Polygon([outer, inner1, inner2], + var polygon = new _ol_geom_Polygon_([outer, inner1, inner2], 'XYZ'); var esrijson = format.writeGeometry(polygon); expect(polygon.getCoordinates(false)).to.eql( @@ -849,7 +847,7 @@ describe('ol.format.EsriJSON', function() { var outer = [[0, 0, 5], [0, 10, 5], [10, 10, 5], [10, 0, 5], [0, 0, 5]]; var inner1 = [[1, 1, 3], [2, 1, 3], [2, 2, 3], [1, 2, 3], [1, 1, 3]]; var inner2 = [[8, 8, 2], [9, 8, 2], [9, 9, 2], [8, 9, 2], [8, 8, 2]]; - var polygon = new ol.geom.Polygon([outer, inner1, inner2], + var polygon = new _ol_geom_Polygon_([outer, inner1, inner2], 'XYM'); var esrijson = format.writeGeometry(polygon); expect(polygon.getCoordinates(false)).to.eql( @@ -866,7 +864,7 @@ describe('ol.format.EsriJSON', function() { var inner2 = [ [8, 8, 2, 1], [9, 8, 2, 2], [9, 9, 2, 1], [8, 9, 2, 1], [8, 8, 2, 1] ]; - var polygon = new ol.geom.Polygon([outer, inner1, inner2], + var polygon = new _ol_geom_Polygon_([outer, inner1, inner2], 'XYZM'); var esrijson = format.writeGeometry(polygon); expect(polygon.getCoordinates(false)).to.eql( @@ -874,14 +872,14 @@ describe('ol.format.EsriJSON', function() { }); it('encodes multipoint', function() { - var multipoint = new ol.geom.MultiPoint([[102.0, 0.0], [103.0, 1.0]]); + var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0], [103.0, 1.0]]); var esrijson = format.writeGeometry(multipoint); expect(multipoint.getCoordinates()).to.eql( format.readGeometry(esrijson).getCoordinates()); }); it('encodes XYZ multipoint', function() { - var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3], + var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3], [103.0, 1.0, 4]], 'XYZ'); var esrijson = format.writeGeometry(multipoint); expect(multipoint.getCoordinates()).to.eql( @@ -889,7 +887,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYM multipoint', function() { - var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3], + var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3], [103.0, 1.0, 4]], 'XYM'); var esrijson = format.writeGeometry(multipoint); expect(multipoint.getCoordinates()).to.eql( @@ -897,7 +895,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZM multipoint', function() { - var multipoint = new ol.geom.MultiPoint([[102.0, 0.0, 3, 1], + var multipoint = new _ol_geom_MultiPoint_([[102.0, 0.0, 3, 1], [103.0, 1.0, 4, 1]], 'XYZM'); var esrijson = format.writeGeometry(multipoint); expect(multipoint.getCoordinates()).to.eql( @@ -905,7 +903,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes multilinestring', function() { - var multilinestring = new ol.geom.MultiLineString([ + var multilinestring = new _ol_geom_MultiLineString_([ [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]], [[105.0, 3.0], [106.0, 4.0], [107.0, 3.0], [108.0, 4.0]] ]); @@ -915,7 +913,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZ multilinestring', function() { - var multilinestring = new ol.geom.MultiLineString([ + var multilinestring = new _ol_geom_MultiLineString_([ [[102.0, 0.0, 1], [103.0, 1.0, 2], [104.0, 0.0, 3], [105.0, 1.0, 4]], [[105.0, 3.0, 1], [106.0, 4.0, 2], [107.0, 3.0, 3], [108.0, 4.0, 4]] ], 'XYZ'); @@ -925,7 +923,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYM multilinestring', function() { - var multilinestring = new ol.geom.MultiLineString([ + var multilinestring = new _ol_geom_MultiLineString_([ [[102.0, 0.0, 1], [103.0, 1.0, 2], [104.0, 0.0, 3], [105.0, 1.0, 4]], [[105.0, 3.0, 1], [106.0, 4.0, 2], [107.0, 3.0, 3], [108.0, 4.0, 4]] ], 'XYM'); @@ -935,7 +933,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZM multilinestring', function() { - var multilinestring = new ol.geom.MultiLineString([ + var multilinestring = new _ol_geom_MultiLineString_([ [[102.0, 0.0, 1, 0], [103.0, 1.0, 2, 2], [104.0, 0.0, 3, 1], [105.0, 1.0, 4, 2]], [[105.0, 3.0, 1, 0], [106.0, 4.0, 2, 1], [107.0, 3.0, 3, 1], @@ -947,7 +945,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes multipolygon', function() { - var multipolygon = new ol.geom.MultiPolygon([ + var multipolygon = new _ol_geom_MultiPolygon_([ [[[0, 1], [1, 4], [4, 3], [3, 0]], [[2, 2], [3, 2], [3, 3], [2, 3]]], [[[10, 1], [11, 5], [14, 3], [13, 0]]] ]); @@ -957,7 +955,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZ multipolygon', function() { - var multipolygon = new ol.geom.MultiPolygon([ + var multipolygon = new _ol_geom_MultiPolygon_([ [[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0], [3, 3, 0], [2, 3, 0]]], [[[10, 1, 0], [11, 5, 0], [14, 3, 0], [13, 0, 0]]] @@ -968,7 +966,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYM multipolygon', function() { - var multipolygon = new ol.geom.MultiPolygon([ + var multipolygon = new _ol_geom_MultiPolygon_([ [[[0, 1, 0], [1, 4, 0], [4, 3, 0], [3, 0, 0]], [[2, 2, 0], [3, 2, 0], [3, 3, 0], [2, 3, 0]]], [[[10, 1, 0], [11, 5, 0], [14, 3, 0], [13, 0, 0]]] @@ -979,7 +977,7 @@ describe('ol.format.EsriJSON', function() { }); it('encodes XYZM multipolygon', function() { - var multipolygon = new ol.geom.MultiPolygon([ + var multipolygon = new _ol_geom_MultiPolygon_([ [[[0, 1, 0, 1], [1, 4, 0, 1], [4, 3, 0, 3], [3, 0, 0, 3]], [[2, 2, 0, 3], [3, 2, 0, 4], [3, 3, 0, 1], [2, 3, 0, 1]]], @@ -991,7 +989,7 @@ describe('ol.format.EsriJSON', function() { }); it('transforms and encodes a point', function() { - var point = new ol.geom.Point([2, 3]); + var point = new _ol_geom_Point_([2, 3]); var esrijson = format.writeGeometry(point, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' @@ -1050,15 +1048,15 @@ describe('ol.format.EsriJSON', function() { it('writes out a feature with a different geometryName correctly', function() { - var feature = new ol.Feature({'foo': 'bar'}); + var feature = new _ol_Feature_({'foo': 'bar'}); feature.setGeometryName('mygeom'); - feature.setGeometry(new ol.geom.Point([5, 10])); + feature.setGeometry(new _ol_geom_Point_([5, 10])); var esrijson = format.writeFeaturesObject([feature]); expect(esrijson.features[0].attributes.mygeom).to.eql(undefined); }); it('writes out a feature without properties correctly', function() { - var feature = new ol.Feature(new ol.geom.Point([5, 10])); + var feature = new _ol_Feature_(new _ol_geom_Point_([5, 10])); var esrijson = format.writeFeatureObject(feature); expect(esrijson.attributes).to.eql({}); }); diff --git a/test/spec/ol/format/geojson.test.js b/test/spec/ol/format/geojson.test.js index 89425ad744..5a9464dc91 100644 --- a/test/spec/ol/format/geojson.test.js +++ b/test/spec/ol/format/geojson.test.js @@ -1,21 +1,21 @@ -goog.require('ol.Feature'); -goog.require('ol.extent'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.GeoJSON', function() { var format; beforeEach(function() { - format = new ol.format.GeoJSON(); + format = new _ol_format_GeoJSON_(); }); var pointGeoJSON = { @@ -145,26 +145,26 @@ describe('ol.format.GeoJSON', function() { it('can read a single point feature', function() { var feature = format.readFeature(pointGeoJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.Point); + expect(geometry).to.be.an(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([102.0, 0.5]); expect(feature.get('prop0')).to.be('value0'); }); it('can read a single point geometry as a feature', function() { var feature = format.readFeature(pointGeoJSON.geometry); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.Point); + expect(geometry).to.be.an(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([102.0, 0.5]); }); it('can read a single line string feature', function() { var feature = format.readFeature(lineStringGeoJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql( [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]); expect(feature.get('prop0')).to.be('value0'); @@ -173,9 +173,9 @@ describe('ol.format.GeoJSON', function() { it('can read a single polygon feature', function() { var feature = format.readFeature(polygonGeoJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.Polygon); + expect(geometry).to.be.an(_ol_geom_Polygon_); expect(geometry.getCoordinates()).to.eql([[ [100.0, 0.0], [100.0, 1.0], [101.0, 1.0], [101.0, 0.0] ]]); @@ -185,7 +185,7 @@ describe('ol.format.GeoJSON', function() { it('can read a feature with null geometry', function() { var feature = format.readFeature(nullGeometryGeoJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); expect(geometry).to.eql(null); expect(feature.get('prop0')).to.be('value0'); @@ -193,71 +193,71 @@ describe('ol.format.GeoJSON', function() { it('can read a feature with id equal to 0', function() { var feature = format.readFeature(zeroIdGeoJSON); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); expect(feature.getId()).to.be(0); }); it('can read a feature collection', function() { var features = format.readFeatures(featureCollectionGeoJSON); expect(features).to.have.length(3); - expect(features[0].getGeometry()).to.be.an(ol.geom.Point); - expect(features[1].getGeometry()).to.be.an(ol.geom.LineString); - expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon); + expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); + expect(features[1].getGeometry()).to.be.an(_ol_geom_LineString_); + expect(features[2].getGeometry()).to.be.an(_ol_geom_Polygon_); }); it('can read and transform a point', function() { var feature = format.readFeatures(pointGeoJSON, { featureProjection: 'EPSG:3857' }); - expect(feature[0].getGeometry()).to.be.an(ol.geom.Point); + expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); }); it('uses featureProjection passed to the constructor', function() { - var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'}); + var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'}); var feature = format.readFeatures(pointGeoJSON); - expect(feature[0].getGeometry()).to.be.an(ol.geom.Point); + expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); }); it('gives precedence to options passed to the read method', function() { - var format = new ol.format.GeoJSON({featureProjection: 'EPSG:1234'}); + var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:1234'}); var feature = format.readFeatures(pointGeoJSON, { featureProjection: 'EPSG:3857' }); - expect(feature[0].getGeometry()).to.be.an(ol.geom.Point); + expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); }); it('can read and transform a feature collection', function() { var features = format.readFeatures(featureCollectionGeoJSON, { featureProjection: 'EPSG:3857' }); - expect(features[0].getGeometry()).to.be.an(ol.geom.Point); + expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(features[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); expect(features[1].getGeometry().getCoordinates()).to.eql([ - ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') ]); expect(features[2].getGeometry().getCoordinates()).to.eql([[ - ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') ]]); }); it('can create a feature with a specific geometryName', function() { - var feature = new ol.format.GeoJSON({geometryName: 'the_geom'}). + var feature = new _ol_format_GeoJSON_({geometryName: 'the_geom'}). readFeature(pointGeoJSON); expect(feature.getGeometryName()).to.be('the_geom'); - expect(feature.getGeometry()).to.be.an(ol.geom.Point); + expect(feature.getGeometry()).to.be.an(_ol_geom_Point_); }); }); @@ -271,16 +271,16 @@ describe('ol.format.GeoJSON', function() { expect(array.length).to.be(2); var first = array[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('LINK_ID')).to.be(573730499); var firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(ol.geom.LineString); + expect(firstGeom).to.be.a(_ol_geom_LineString_); var second = array[1]; - expect(second).to.be.a(ol.Feature); + expect(second).to.be.a(_ol_Feature_); expect(second.get('ST_NAME')).to.be('BRUNNSGATAN'); var secondGeom = second.getGeometry(); - expect(secondGeom).to.be.a(ol.geom.LineString); + expect(secondGeom).to.be.a(_ol_geom_LineString_); }); it('can parse a polygon geometry as an array of one feature', function() { @@ -288,7 +288,7 @@ describe('ol.format.GeoJSON', function() { expect(features).to.be.an(Array); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.an(ol.geom.Polygon); + expect(geometry).to.be.an(_ol_geom_Polygon_); }); it('parses countries.geojson', function(done) { @@ -297,22 +297,22 @@ describe('ol.format.GeoJSON', function() { expect(result.length).to.be(179); var first = result[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('name')).to.be('Afghanistan'); expect(first.getId()).to.be('AFG'); var firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(ol.geom.Polygon); - expect(ol.extent.equals(firstGeom.getExtent(), + expect(firstGeom).to.be.a(_ol_geom_Polygon_); + expect(_ol_extent_.equals(firstGeom.getExtent(), [60.52843, 29.318572, 75.158028, 38.486282])) .to.be(true); var last = result[178]; - expect(last).to.be.a(ol.Feature); + expect(last).to.be.a(_ol_Feature_); expect(last.get('name')).to.be('Zimbabwe'); expect(last.getId()).to.be('ZWE'); var lastGeom = last.getGeometry(); - expect(lastGeom).to.be.a(ol.geom.Polygon); - expect(ol.extent.equals(lastGeom.getExtent(), + expect(lastGeom).to.be.a(_ol_geom_Polygon_); + expect(_ol_extent_.equals(lastGeom.getExtent(), [25.264226, -22.271612, 32.849861, -15.507787])) .to.be(true); done(); @@ -322,7 +322,7 @@ describe('ol.format.GeoJSON', function() { it('generates an array of features for Feature', function() { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var json = { type: 'Feature', properties: { @@ -338,11 +338,11 @@ describe('ol.format.GeoJSON', function() { expect(features.length).to.be(1); var first = features[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('bam')).to.be('baz'); - expect(first.getGeometry()).to.be.a(ol.geom.LineString); + expect(first.getGeometry()).to.be.a(_ol_geom_LineString_); - expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:4326')); + expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326')); }); }); @@ -356,7 +356,7 @@ describe('ol.format.GeoJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Point); + expect(obj).to.be.a(_ol_geom_Point_); expect(obj.getCoordinates()).to.eql([10, 20]); expect(obj.getLayout()).to.eql('XY'); }); @@ -368,7 +368,7 @@ describe('ol.format.GeoJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]); expect(obj.getLayout()).to.eql('XY'); }); @@ -380,7 +380,7 @@ describe('ol.format.GeoJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.LineString); + expect(obj).to.be.a(_ol_geom_LineString_); expect(obj.getLayout()).to.eql('XYZ'); expect(obj.getCoordinates()).to.eql([[10, 20, 1534], [30, 40, 1420]]); }); @@ -395,13 +395,13 @@ describe('ol.format.GeoJSON', function() { }); var obj = format.readGeometry(str); - expect(obj).to.be.a(ol.geom.Polygon); + expect(obj).to.be.a(_ol_geom_Polygon_); expect(obj.getLayout()).to.eql('XY'); var rings = obj.getLinearRings(); expect(rings.length).to.be(3); - expect(rings[0]).to.be.a(ol.geom.LinearRing); - expect(rings[1]).to.be.a(ol.geom.LinearRing); - expect(rings[2]).to.be.a(ol.geom.LinearRing); + expect(rings[0]).to.be.a(_ol_geom_LinearRing_); + expect(rings[1]).to.be.a(_ol_geom_LinearRing_); + expect(rings[2]).to.be.a(_ol_geom_LinearRing_); }); it('parses geometry collection', function() { @@ -414,12 +414,12 @@ describe('ol.format.GeoJSON', function() { }); var geometryCollection = format.readGeometry(str); - expect(geometryCollection).to.be.an(ol.geom.GeometryCollection); + expect(geometryCollection).to.be.an(_ol_geom_GeometryCollection_); var array = geometryCollection.getGeometries(); expect(array.length).to.be(2); - expect(array[0]).to.be.a(ol.geom.Point); + expect(array[0]).to.be.a(_ol_geom_Point_); expect(array[0].getLayout()).to.eql('XY'); - expect(array[1]).to.be.a(ol.geom.LineString); + expect(array[1]).to.be.a(_ol_geom_LineString_); expect(array[1].getLayout()).to.eql('XY'); }); @@ -462,16 +462,16 @@ describe('ol.format.GeoJSON', function() { expect(features.length).to.be(2); var first = features[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('foo')).to.be('bar'); - expect(first.getGeometry()).to.be.a(ol.geom.Point); + expect(first.getGeometry()).to.be.a(_ol_geom_Point_); var second = features[1]; - expect(second).to.be.a(ol.Feature); + expect(second).to.be.a(_ol_Feature_); expect(second.get('bam')).to.be('baz'); - expect(second.getGeometry()).to.be.a(ol.geom.LineString); + expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); - expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:3857')); + expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857')); }); @@ -505,16 +505,16 @@ describe('ol.format.GeoJSON', function() { expect(features.length).to.be(2); var first = features[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); expect(first.get('foo')).to.be('bar'); - expect(first.getGeometry()).to.be.a(ol.geom.Point); + expect(first.getGeometry()).to.be.a(_ol_geom_Point_); var second = features[1]; - expect(second).to.be.a(ol.Feature); + expect(second).to.be.a(_ol_Feature_); expect(second.get('bam')).to.be('baz'); - expect(second.getGeometry()).to.be.a(ol.geom.LineString); + expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); - expect(format.readProjection(json)).to.be(ol.proj.get('EPSG:4326')); + expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326')); }); @@ -560,27 +560,27 @@ describe('ol.format.GeoJSON', function() { it('writes out a feature with a different geometryName correctly', function() { - var feature = new ol.Feature({'foo': 'bar'}); + var feature = new _ol_Feature_({'foo': 'bar'}); feature.setGeometryName('mygeom'); - feature.setGeometry(new ol.geom.Point([5, 10])); + feature.setGeometry(new _ol_geom_Point_([5, 10])); var geojson = format.writeFeaturesObject([feature]); expect(geojson.features[0].properties.mygeom).to.eql(undefined); }); it('writes out a feature without properties correctly', function() { - var feature = new ol.Feature(new ol.geom.Point([5, 10])); + var feature = new _ol_Feature_(new _ol_geom_Point_([5, 10])); var geojson = format.writeFeatureObject(feature); expect(geojson.properties).to.eql(null); }); it('writes out a feature without geometry correctly', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); var geojson = format.writeFeatureObject(feature); expect(geojson.geometry).to.eql(null); }); it('writes out a feature with id equal to 0 correctly', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId(0); var geojson = format.writeFeatureObject(feature); expect(geojson.id).to.eql(0); @@ -590,29 +590,29 @@ describe('ol.format.GeoJSON', function() { describe('#writeGeometry', function() { it('encodes point', function() { - var point = new ol.geom.Point([10, 20]); + var point = new _ol_geom_Point_([10, 20]); var geojson = format.writeGeometry(point); expect(point.getCoordinates()).to.eql( format.readGeometry(geojson).getCoordinates()); }); it('accepts featureProjection', function() { - var point = new ol.geom.Point(ol.proj.fromLonLat([10, 20])); + var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20])); var geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'}); var obj = JSON.parse(geojson); - expect(obj.coordinates).to.eql(ol.proj.toLonLat(point.getCoordinates())); + expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates())); }); it('respects featureProjection passed to constructor', function() { - var format = new ol.format.GeoJSON({featureProjection: 'EPSG:3857'}); - var point = new ol.geom.Point(ol.proj.fromLonLat([10, 20])); + var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'}); + var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20])); var geojson = format.writeGeometry(point); var obj = JSON.parse(geojson); - expect(obj.coordinates).to.eql(ol.proj.toLonLat(point.getCoordinates())); + expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates())); }); it('encodes linestring', function() { - var linestring = new ol.geom.LineString([[10, 20], [30, 40]]); + var linestring = new _ol_geom_LineString_([[10, 20], [30, 40]]); var geojson = format.writeGeometry(linestring); expect(linestring.getCoordinates()).to.eql( format.readGeometry(geojson).getCoordinates()); @@ -622,7 +622,7 @@ describe('ol.format.GeoJSON', function() { var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]; var inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]; var inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]]; - var polygon = new ol.geom.Polygon([outer, inner1, inner2]); + var polygon = new _ol_geom_Polygon_([outer, inner1, inner2]); var geojson = format.writeGeometry(polygon); expect(polygon.getCoordinates()).to.eql( format.readGeometry(geojson).getCoordinates()); @@ -633,10 +633,10 @@ describe('ol.format.GeoJSON', function() { var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]; var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]; - var right = new ol.geom.Polygon([ccw, cw]); - var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]); - var left = new ol.geom.Polygon([cw, ccw]); - var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]); + var right = new _ol_geom_Polygon_([ccw, cw]); + var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]); + var left = new _ol_geom_Polygon_([cw, ccw]); + var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]); var rightObj = { type: 'Polygon', @@ -670,10 +670,10 @@ describe('ol.format.GeoJSON', function() { var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]; var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]; - var right = new ol.geom.Polygon([ccw, cw]); - var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]); - var left = new ol.geom.Polygon([cw, ccw]); - var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]); + var right = new _ol_geom_Polygon_([ccw, cw]); + var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]); + var left = new _ol_geom_Polygon_([cw, ccw]); + var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]); var rightObj = { type: 'Polygon', @@ -701,10 +701,10 @@ describe('ol.format.GeoJSON', function() { var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]; var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]; - var right = new ol.geom.Polygon([ccw, cw]); - var rightMulti = new ol.geom.MultiPolygon([[ccw, cw]]); - var left = new ol.geom.Polygon([cw, ccw]); - var leftMulti = new ol.geom.MultiPolygon([[cw, ccw]]); + var right = new _ol_geom_Polygon_([ccw, cw]); + var rightMulti = new _ol_geom_MultiPolygon_([[ccw, cw]]); + var left = new _ol_geom_Polygon_([cw, ccw]); + var leftMulti = new _ol_geom_MultiPolygon_([[cw, ccw]]); var leftObj = { type: 'Polygon', @@ -729,13 +729,13 @@ describe('ol.format.GeoJSON', function() { }); it('encodes geometry collection', function() { - var collection = new ol.geom.GeometryCollection([ - new ol.geom.Point([10, 20]), - new ol.geom.LineString([[30, 40], [50, 60]]) + var collection = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([10, 20]), + new _ol_geom_LineString_([[30, 40], [50, 60]]) ]); var geojson = format.writeGeometry(collection); var got = format.readGeometry(geojson); - expect(got).to.be.an(ol.geom.GeometryCollection); + expect(got).to.be.an(_ol_geom_GeometryCollection_); var gotGeometries = got.getGeometries(); var geometries = collection.getGeometries(); expect(geometries.length).to.equal(gotGeometries.length); @@ -747,7 +747,7 @@ describe('ol.format.GeoJSON', function() { }); it('encodes a circle as an empty geometry collection', function() { - var circle = new ol.geom.Circle([0, 0], 1); + var circle = new _ol_geom_Circle_([0, 0], 1); var geojson = format.writeGeometryObject(circle); expect(geojson).to.eql({ 'type': 'GeometryCollection', @@ -756,7 +756,7 @@ describe('ol.format.GeoJSON', function() { }); it('transforms and encodes a point', function() { - var point = new ol.geom.Point([2, 3]); + var point = new _ol_geom_Point_([2, 3]); var geojson = format.writeGeometry(point, { featureProjection: 'EPSG:3857' }); @@ -770,9 +770,9 @@ describe('ol.format.GeoJSON', function() { }); it('transforms and encodes geometry collection', function() { - var collection = new ol.geom.GeometryCollection([ - new ol.geom.Point([2, 3]), - new ol.geom.LineString([[3, 2], [2, 1]]) + var collection = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([2, 3]), + new _ol_geom_LineString_([[3, 2], [2, 1]]) ]); var geojson = format.writeGeometry(collection, { featureProjection: 'EPSG:3857' @@ -793,7 +793,7 @@ describe('ol.format.GeoJSON', function() { }); it('truncates transformed point with decimals option', function() { - var point = new ol.geom.Point([2, 3]).transform('EPSG:4326', 'EPSG:3857'); + var point = new _ol_geom_Point_([2, 3]).transform('EPSG:4326', 'EPSG:3857'); var geojson = format.writeGeometry(point, { featureProjection: 'EPSG:3857', decimals: 2 @@ -803,7 +803,7 @@ describe('ol.format.GeoJSON', function() { }); it('truncates a linestring with decimals option', function() { - var linestring = new ol.geom.LineString([[42.123456789, 38.987654321], + var linestring = new _ol_geom_LineString_([[42.123456789, 38.987654321], [43, 39]]); var geojson = format.writeGeometry(linestring, { decimals: 6 @@ -815,7 +815,7 @@ describe('ol.format.GeoJSON', function() { }); it('rounds a linestring with decimals option = 0', function() { - var linestring = new ol.geom.LineString([[42.123456789, 38.987654321], + var linestring = new _ol_geom_LineString_([[42.123456789, 38.987654321], [43, 39]]); var geojson = format.writeGeometry(linestring, { decimals: 0 diff --git a/test/spec/ol/format/gml.test.js b/test/spec/ol/format/gml.test.js index cd6bf81a31..5078cd1363 100644 --- a/test/spec/ol/format/gml.test.js +++ b/test/spec/ol/format/gml.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.Feature'); -goog.require('ol.format.GML'); -goog.require('ol.format.GML2'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); -goog.require('ol.xml'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_format_GML_ from '../../../../src/ol/format/GML.js'; +import _ol_format_GML2_ from '../../../../src/ol/format/GML2.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_xml_ from '../../../../src/ol/xml.js'; var readGeometry = function(format, text, opt_options) { - var doc = ol.xml.parse(text); + var doc = _ol_xml_.parse(text); // we need an intermediate node for testing purposes var node = document.createElement('PRE'); node.appendChild(doc.documentElement); @@ -25,7 +23,7 @@ describe('ol.format.GML2', function() { var format; beforeEach(function() { - format = new ol.format.GML2({srsName: 'CRS:84'}); + format = new _ol_format_GML2_({srsName: 'CRS:84'}); }); describe('#readFeatures', function() { @@ -34,7 +32,7 @@ describe('ol.format.GML2', function() { var url = 'spec/ol/format/gml/osm-wfs-10.xml'; afterLoadText(url, function(xml) { try { - features = new ol.format.GML2().readFeatures(xml); + features = new _ol_format_GML2_().readFeatures(xml); } catch (e) { done(e); } @@ -59,7 +57,7 @@ describe('ol.format.GML2', function() { ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([-180, -90, 0]); }); @@ -70,7 +68,7 @@ describe('ol.format.GML2', function() { ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([-180, -90, 42]); }); @@ -120,7 +118,7 @@ describe('ol.format.GML2', function() { ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [ [ @@ -148,7 +146,7 @@ describe('ol.format.GML2', function() { var node; var featureNS = 'http://www.openlayers.org/'; beforeEach(function() { - node = ol.xml.createElementNS(featureNS, 'layer'); + node = _ol_xml_.createElementNS(featureNS, 'layer'); }); it('can serialize a LineString', function() { @@ -165,8 +163,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.LineString([[1.1, 2], [3, 4.2]]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]]) }); feature.setId(1); var objectStack = [{ @@ -175,7 +173,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); it('can serialize a Polygon', function() { @@ -196,8 +194,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.Polygon([[[1.1, 2], [3, 4.2], [5.2, 6]]]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([[[1.1, 2], [3, 4.2], [5.2, 6]]]) }); feature.setId(1); var objectStack = [{ @@ -206,7 +204,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); it('can serialize a Point', function() { @@ -223,8 +221,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.Point([1.1, 2]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_Point_([1.1, 2]) }); feature.setId(1); var objectStack = [{ @@ -233,7 +231,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); it('can serialize a Multi Point', function() { @@ -254,8 +252,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.MultiPoint([[1.1, 2]]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_MultiPoint_([[1.1, 2]]) }); feature.setId(1); var objectStack = [{ @@ -264,7 +262,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); it('can serialize a Multi Line String', function() { @@ -285,8 +283,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.MultiLineString([[[1.1, 2], [3, 4.2]]]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_MultiLineString_([[[1.1, 2], [3, 4.2]]]) }); feature.setId(1); var objectStack = [{ @@ -295,7 +293,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); it('can serialize a Multi Polygon', function() { @@ -320,8 +318,8 @@ describe('ol.format.GML2', function() { ' ' + ' '; - var feature = new ol.Feature({ - geometry: new ol.geom.MultiPolygon([[[[1.1, 2], [3, 4.2], [5.2, 6]]]]) + var feature = new _ol_Feature_({ + geometry: new _ol_geom_MultiPolygon_([[[[1.1, 2], [3, 4.2], [5.2, 6]]]]) }); feature.setId(1); var objectStack = [{ @@ -330,7 +328,7 @@ describe('ol.format.GML2', function() { }]; format.writeFeatureElement(node, feature, objectStack); - expect(node).to.xmleql(ol.xml.parse(expected)); + expect(node).to.xmleql(_ol_xml_.parse(expected)); }); }); }); @@ -339,11 +337,11 @@ describe('ol.format.GML3', function() { var format, formatWGS84, formatNoSrs; beforeEach(function() { - format = new ol.format.GML({srsName: 'CRS:84'}); - formatWGS84 = new ol.format.GML({ + format = new _ol_format_GML_({srsName: 'CRS:84'}); + formatWGS84 = new _ol_format_GML_({ srsName: 'urn:x-ogc:def:crs:EPSG:4326' }); - formatNoSrs = new ol.format.GML(); + formatNoSrs = new _ol_format_GML_(); }); describe('#readGeometry', function() { @@ -357,10 +355,10 @@ describe('ol.format.GML3', function() { ' 1 2' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([1, 2, 0]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read a point geometry with scientific notation', function() { @@ -370,7 +368,7 @@ describe('ol.format.GML3', function() { ' 1E7 2' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([10000000, 2, 0]); text = '1e7 2' + ''; g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([10000000, 2, 0]); }); @@ -392,10 +390,10 @@ describe('ol.format.GML3', function() { ' 1 2' + ''; var g = readGeometry(format, text, config); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); var coordinates = g.getCoordinates(); expect(coordinates.splice(0, 2)).to.eql( - ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); config.dataProjection = 'CRS:84'; var serialized = format.writeGeometryNode(g, config); var pos = serialized.firstElementChild.firstElementChild.textContent; @@ -414,10 +412,10 @@ describe('ol.format.GML3', function() { ' 1 2' + ''; var g = readGeometry(formatNoSrs, text, config); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); var coordinates = g.getCoordinates(); expect(coordinates.splice(0, 2)).to.eql( - ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); }); it('can read and write a point geometry in EPSG:4326', function() { @@ -427,10 +425,10 @@ describe('ol.format.GML3', function() { ' 2 1' + ''; var g = readGeometry(formatWGS84, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([1, 2, 0]); var serialized = formatWGS84.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -444,10 +442,10 @@ describe('ol.format.GML3', function() { ' 1 2 3 4' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read, transform and write a linestring geometry', function() { @@ -461,12 +459,12 @@ describe('ol.format.GML3', function() { ' 1 2 3 4' + ''; var g = readGeometry(format, text, config); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); var coordinates = g.getCoordinates(); expect(coordinates[0].slice(0, 2)).to.eql( - ol.proj.transform([1, 2], 'CRS:84', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); expect(coordinates[1].slice(0, 2)).to.eql( - ol.proj.transform([3, 4], 'CRS:84', 'EPSG:3857')); + _ol_proj_.transform([3, 4], 'CRS:84', 'EPSG:3857')); var serialized = format.writeGeometryNode(g, config); var poss = serialized.firstElementChild.firstElementChild.textContent; var coordinate = poss.split(' '); @@ -483,10 +481,10 @@ describe('ol.format.GML3', function() { ' 2 1 4 3' + ''; var g = readGeometry(formatWGS84, text); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]); var serialized = formatWGS84.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -502,10 +500,10 @@ describe('ol.format.GML3', function() { ' -90 -180 90 180' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[-180, -90, 0], [180, 90, 0]]); var serialized = formatWGS84.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a point geometry with correct axis order', @@ -516,10 +514,10 @@ describe('ol.format.GML3', function() { ' -90 -180' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([-180, -90, 0]); var serialized = formatWGS84.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a surface geometry with right axis order', @@ -547,11 +545,11 @@ describe('ol.format.GML3', function() { var g = readGeometry(format, text); expect(g.getCoordinates()[0][0][0][0]).to.equal(-77.0081); expect(g.getCoordinates()[0][0][0][1]).to.equal(38.9661); - format = new ol.format.GML({ + format = new _ol_format_GML_({ srsName: 'urn:x-ogc:def:crs:EPSG:4326', surface: false}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -565,7 +563,7 @@ describe('ol.format.GML3', function() { ' 1 2 3 4 5 6' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]); }); @@ -580,11 +578,11 @@ describe('ol.format.GML3', function() { ' 1 2 3 4 5 6 1 2' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.LinearRing); + expect(g).to.be.an(_ol_geom_LinearRing_); expect(g.getCoordinates()).to.eql( [[1, 2, 0], [3, 4, 0], [5, 6, 0], [1, 2, 0]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -612,12 +610,12 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Polygon); + expect(g).to.be.an(_ol_geom_Polygon_); expect(g.getCoordinates()).to.eql([[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -655,13 +653,13 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.Polygon); + expect(g).to.be.an(_ol_geom_Polygon_); expect(g.getCoordinates()).to.eql([[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]]); - format = new ol.format.GML({srsName: 'CRS:84', surface: true}); + format = new _ol_format_GML_({srsName: 'CRS:84', surface: true}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -679,11 +677,11 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[1, 2, 0], [3, 4, 0]]); - format = new ol.format.GML({srsName: 'CRS:84', curve: true}); + format = new _ol_format_GML_({srsName: 'CRS:84', curve: true}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -726,10 +724,10 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPoint); + expect(g).to.be.an(_ol_geom_MultiPoint_); expect(g.getCoordinates()).to.eql([[1, 2, 0], [2, 3, 0], [3, 4, 0]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read a plural multipoint geometry', function() { @@ -749,7 +747,7 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPoint); + expect(g).to.be.an(_ol_geom_MultiPoint_); expect(g.getCoordinates()).to.eql([[1, 2, 0], [2, 3, 0], [3, 4, 0]]); }); @@ -773,12 +771,12 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); - format = new ol.format.GML({srsName: 'CRS:84', multiCurve: false}); + format = new _ol_format_GML_({srsName: 'CRS:84', multiCurve: false}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read a plural multilinestring geometry', function() { @@ -795,7 +793,7 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); }); @@ -846,15 +844,15 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]], [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]); - format = new ol.format.GML({srsName: 'CRS:84', multiSurface: false}); + format = new _ol_format_GML_({srsName: 'CRS:84', multiSurface: false}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read a plural multipolygon geometry', function() { @@ -889,7 +887,7 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], @@ -918,11 +916,11 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a singular multicurve-curve geometry', function() { @@ -949,12 +947,12 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql( [[[1, 2, 0], [2, 3, 0]], [[3, 4, 0], [4, 5, 0]]]); - format = new ol.format.GML({srsName: 'CRS:84', curve: true}); + format = new _ol_format_GML_({srsName: 'CRS:84', curve: true}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1003,14 +1001,14 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]], [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('can read a plural multisurface geometry', function() { @@ -1047,7 +1045,7 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], @@ -1105,15 +1103,15 @@ describe('ol.format.GML3', function() { ' ' + ''; var g = readGeometry(format, text); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]], [[2, 3, 0], [2, 5, 0], [4, 5, 0], [2, 3, 0]], [[3, 4, 0], [3, 6, 0], [5, 6, 0], [3, 4, 0]]], [[[1, 2, 0], [3, 2, 0], [3, 4, 0], [1, 2, 0]]]]); - format = new ol.format.GML({srsName: 'CRS:84', surface: true}); + format = new _ol_format_GML_({srsName: 'CRS:84', surface: true}); var serialized = format.writeGeometryNode(g); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1143,7 +1141,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://www.openplans.org/topp', 'featureType': 'gnis_pop' }; - var features = new ol.format.GML(config).readFeatures(text); + var features = new _ol_format_GML_(config).readFeatures(text); var feature = features[0]; expect(feature.get('empty')).to.be(undefined); }); @@ -1174,7 +1172,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://www.openplans.org/topp', 'featureType': 'gnis_pop' }; - features = new ol.format.GML(config).readFeatures(text); + features = new _ol_format_GML_(config).readFeatures(text); } catch (e) { done(e); } @@ -1195,7 +1193,7 @@ describe('ol.format.GML3', function() { before(function(done) { afterLoadText('spec/ol/format/gml/topp-states-wfs.xml', function(xml) { try { - gmlFormat = new ol.format.GML(); + gmlFormat = new _ol_format_GML_(); features = gmlFormat.readFeatures(xml); } catch (e) { done(e); @@ -1260,7 +1258,7 @@ describe('ol.format.GML3', function() { 'schemaLocation': schemaLoc }; text = xml; - gmlFormat = new ol.format.GML(config); + gmlFormat = new _ol_format_GML_(config); features = gmlFormat.readFeatures(xml); } catch (e) { done(e); @@ -1279,7 +1277,7 @@ describe('ol.format.GML3', function() { it('writes back features as GML', function() { var serialized = gmlFormat.writeFeaturesNode(features); - expect(serialized).to.xmleql(ol.xml.parse(text), {ignoreElementOrder: true}); + expect(serialized).to.xmleql(_ol_xml_.parse(text), {ignoreElementOrder: true}); }); }); @@ -1294,7 +1292,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://www.openplans.org/topp', 'featureType': 'states' }; - features = new ol.format.GML(config).readFeatures(xml); + features = new _ol_format_GML_(config).readFeatures(xml); } catch (e) { done(e); } @@ -1310,7 +1308,7 @@ describe('ol.format.GML3', function() { feature = features[0]; expect(feature.getId()).to.equal('states.1'); expect(feature.get('STATE_NAME')).to.equal('Illinois'); - expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon); + expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_); }); }); @@ -1325,7 +1323,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://opengeo.org/#medford', 'featureType': 'zoning' }; - features = new ol.format.GML(config).readFeatures(xml); + features = new _ol_format_GML_(config).readFeatures(xml); } catch (e) { done(e); } @@ -1335,8 +1333,8 @@ describe('ol.format.GML3', function() { it('creates 2 geometries', function() { var feature = features[0]; - expect(feature.get('center')).to.be.a(ol.geom.Point); - expect(feature.get('the_geom')).to.be.a(ol.geom.MultiPolygon); + expect(feature.get('center')).to.be.a(_ol_geom_Point_); + expect(feature.get('the_geom')).to.be.a(_ol_geom_MultiPolygon_); }); }); @@ -1351,7 +1349,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://opengeo.org/#medford', 'featureType': 'zoning' }; - features = new ol.format.GML(config).readFeatures(xml); + features = new _ol_format_GML_(config).readFeatures(xml); } catch (e) { done(e); } @@ -1372,7 +1370,7 @@ describe('ol.format.GML3', function() { before(function(done) { afterLoadText('spec/ol/format/gml/only-boundedby.xml', function(xml) { try { - features = new ol.format.GML().readFeatures(xml); + features = new _ol_format_GML_().readFeatures(xml); } catch (e) { done(e); } @@ -1393,7 +1391,7 @@ describe('ol.format.GML3', function() { before(function(done) { afterLoadText('spec/ol/format/gml/ogr.xml', function(xml) { try { - features = new ol.format.GML().readFeatures(xml); + features = new _ol_format_GML_().readFeatures(xml); } catch (e) { done(e); } @@ -1413,7 +1411,7 @@ describe('ol.format.GML3', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) { try { - features = new ol.format.GML({ + features = new _ol_format_GML_({ featureNS: 'http://localhost:8080/official', featureType: ['planet_osm_polygon', 'planet_osm_line'] }).readFeatures(xml); @@ -1436,7 +1434,7 @@ describe('ol.format.GML3', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) { try { - features = new ol.format.GML().readFeatures(xml); + features = new _ol_format_GML_().readFeatures(xml); } catch (e) { done(e); } @@ -1457,7 +1455,7 @@ describe('ol.format.GML3', function() { var url = 'spec/ol/format/gml/multiple-typenames-ns.xml'; afterLoadText(url, function(xml) { try { - features = new ol.format.GML({ + features = new _ol_format_GML_({ featureNS: { 'topp': 'http://www.openplans.org/topp', 'sf': 'http://www.openplans.org/spearfish' @@ -1484,7 +1482,7 @@ describe('ol.format.GML3', function() { var url = 'spec/ol/format/gml/multiple-typenames-ns.xml'; afterLoadText(url, function(xml) { try { - features = new ol.format.GML().readFeatures(xml); + features = new _ol_format_GML_().readFeatures(xml); } catch (e) { done(e); } @@ -1509,7 +1507,7 @@ describe('ol.format.GML3', function() { 'featureNS': 'http://www.opengeospatial.net/cite', 'featureType': 'geoserver_layer' }; - features = new ol.format.GML(config).readFeatures(xml); + features = new _ol_format_GML_(config).readFeatures(xml); } catch (e) { done(e); } @@ -1524,19 +1522,19 @@ describe('ol.format.GML3', function() { it('creates a LineString', function() { feature = features[0]; expect(feature.getId()).to.equal('geoserver_layer.1'); - expect(feature.getGeometry()).to.be.an(ol.geom.LineString); + expect(feature.getGeometry()).to.be.an(_ol_geom_LineString_); }); it('creates a Polygon', function() { feature = features[1]; expect(feature.getId()).to.equal('geoserver_layer.2'); - expect(feature.getGeometry()).to.be.an(ol.geom.Polygon); + expect(feature.getGeometry()).to.be.an(_ol_geom_Polygon_); }); it('creates a Point', function() { feature = features[2]; expect(feature.getId()).to.equal('geoserver_layer.3'); - expect(feature.getGeometry()).to.be.an(ol.geom.Point); + expect(feature.getGeometry()).to.be.an(_ol_geom_Point_); }); diff --git a/test/spec/ol/format/gpx.test.js b/test/spec/ol/format/gpx.test.js index 08d526bfe1..1eb03dd0eb 100644 --- a/test/spec/ol/format/gpx.test.js +++ b/test/spec/ol/format/gpx.test.js @@ -1,30 +1,28 @@ - - -goog.require('ol.Feature'); -goog.require('ol.format.GPX'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); -goog.require('ol.xml'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_format_GPX_ from '../../../../src/ol/format/GPX.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_xml_ from '../../../../src/ol/xml.js'; describe('ol.format.GPX', function() { var format; beforeEach(function() { - format = new ol.format.GPX(); + format = new _ol_format_GPX_(); }); describe('#readProjection', function() { it('returns the default projection from document', function() { var projection = format.readProjectionFromDocument(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); it('returns the default projection from node', function() { var projection = format.readProjectionFromNode(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); }); @@ -38,9 +36,9 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([]); expect(g.getLayout()).to.be('XY'); }); @@ -67,7 +65,7 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('name')).to.be('Name'); expect(f.get('cmt')).to.be('Comment'); expect(f.get('desc')).to.be('Description'); @@ -78,7 +76,7 @@ describe('ol.format.GPX', function() { expect(f.get('number')).to.be(1); expect(f.get('type')).to.be('Type'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a rte with multiple rtepts', function() { @@ -95,13 +93,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]); expect(g.getLayout()).to.be('XY'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can transform, read and write a rte', function() { @@ -120,17 +118,17 @@ describe('ol.format.GPX', function() { }); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); - var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); - var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_LineString_); + var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); + var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); expect(g.getCoordinates()).to.eql([p1, p2]); expect(g.getLayout()).to.be('XY'); var serialized = format.writeFeaturesNode(fs, { featureProjection: 'EPSG:3857' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('does not write rte attributes in rtepts', function() { @@ -147,7 +145,7 @@ describe('ol.format.GPX', function() { ''; var fs = format.readFeatures(text); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -162,9 +160,9 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql([]); expect(g.getLayout()).to.be('XY'); }); @@ -191,7 +189,7 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('name')).to.be('Name'); expect(f.get('cmt')).to.be('Comment'); expect(f.get('desc')).to.be('Description'); @@ -202,7 +200,7 @@ describe('ol.format.GPX', function() { expect(f.get('number')).to.be(1); expect(f.get('type')).to.be('Type'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a trk with an empty trkseg', function() { @@ -218,13 +216,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql([[]]); expect(g.getLayout()).to.be('XY'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read/write a trk with a trkseg with multiple trkpts', function() { @@ -249,15 +247,15 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql([ [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]] ]); expect(g.getLayout()).to.be('XYZM'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can transform, read and write a trk with a trkseg', function() { @@ -284,19 +282,19 @@ describe('ol.format.GPX', function() { }); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); - var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_MultiLineString_); + var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); p1.push(3, 1263115752); - var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); + var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); p2.push(7, 1263115812); expect(g.getCoordinates()).to.eql([[p1, p2]]); expect(g.getLayout()).to.be('XYZM'); var serialized = format.writeFeaturesNode(fs, { featureProjection: 'EPSG:3857' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a trk with multiple trksegs', function() { @@ -331,16 +329,16 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql([ [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]], [[9, 8, 10, 1263115872], [12, 11, 13, 1263115932]] ]); expect(g.getLayout()).to.be('XYZM'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('does not write trk attributes in trkpts', function() { @@ -375,7 +373,7 @@ describe('ol.format.GPX', function() { ''; var fs = format.readFeatures(text); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -393,13 +391,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1]); expect(g.getLayout()).to.be('XY'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can transform, read and write a wpt', function() { @@ -415,16 +413,16 @@ describe('ol.format.GPX', function() { }); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); - var expectedPoint = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_Point_); + var expectedPoint = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); expect(g.getCoordinates()).to.eql(expectedPoint); expect(g.getLayout()).to.be('XY'); var serialized = format.writeFeaturesNode(fs, { featureProjection: 'EPSG:3857' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a wpt with ele', function() { @@ -440,13 +438,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1, 3]); expect(g.getLayout()).to.be('XYZ'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a wpt with time', function() { @@ -462,13 +460,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1, 1263115752]); expect(g.getLayout()).to.be('XYM'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write a wpt with ele and time', function() { @@ -485,13 +483,13 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]); expect(g.getLayout()).to.be('XYZM'); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('can read and write various wpt attributes', function() { @@ -525,7 +523,7 @@ describe('ol.format.GPX', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('magvar')).to.be(11); expect(f.get('geoidheight')).to.be(4); expect(f.get('name')).to.be('Name'); @@ -544,7 +542,7 @@ describe('ol.format.GPX', function() { expect(f.get('ageofdgpsdata')).to.be(9); expect(f.get('dgpsid')).to.be(10); var serialized = format.writeFeaturesNode(fs); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -552,7 +550,7 @@ describe('ol.format.GPX', function() { describe('XML namespace support', function() { beforeEach(function() { - format = new ol.format.GPX(); + format = new _ol_format_GPX_(); }); it('can read features with a version 1.0 namespace', function() { @@ -593,7 +591,7 @@ describe('ol.format.GPX', function() { describe('extensions support', function() { beforeEach(function() { - format = new ol.format.GPX({ + format = new _ol_format_GPX_({ readExtensions: function(feature, extensionsNode) { var nodes = extensionsNode.getElementsByTagName('id'); var id = nodes.item(0).textContent; @@ -659,13 +657,13 @@ describe('ol.format.GPX', function() { describe('write unsupported geometries', function() { beforeEach(function() { - format = new ol.format.GPX(); + format = new _ol_format_GPX_(); }); it('does not fail', function() { - var polygon = new ol.geom.Polygon( + var polygon = new _ol_geom_Polygon_( [[[0, 0], [2, 2], [4, 0], [0, 0]]]); - var feature = new ol.Feature(polygon); + var feature = new _ol_Feature_(polygon); var features = [feature]; var gpx = format.writeFeaturesNode(features); var expected = @@ -674,7 +672,7 @@ describe('ol.format.GPX', function() { 'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' + 'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" ' + 'creator="OpenLayers">'; - expect(gpx).to.xmleql(ol.xml.parse(expected)); + expect(gpx).to.xmleql(_ol_xml_.parse(expected)); }); }); diff --git a/test/spec/ol/format/igc.test.js b/test/spec/ol/format/igc.test.js index 981d4a7d5a..6a29ca01bd 100644 --- a/test/spec/ol/format/igc.test.js +++ b/test/spec/ol/format/igc.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.format.IGC'); -goog.require('ol.Feature'); -goog.require('ol.proj'); +import _ol_format_IGC_ from '../../../../src/ol/format/IGC.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.IGC', function() { @@ -31,13 +29,13 @@ describe('ol.format.IGC', function() { 'G60189641B00B00800019000000000000'; beforeEach(function() { - format = new ol.format.IGC(); + format = new _ol_format_IGC_(); }); describe('#readProjectionFromText', function() { it('returns the default projection', function() { var projection = format.readProjectionFromText(igc); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); }); @@ -48,7 +46,7 @@ describe('ol.format.IGC', function() { it('does read a feature', function() { var feature = format.readFeature(igc); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geom = feature.getGeometry(); expect(geom.getType()).to.eql('LineString'); expect(geom.getCoordinates()).to.eql([ @@ -62,20 +60,20 @@ describe('ol.format.IGC', function() { var feature = format.readFeature(igc, { featureProjection: 'EPSG:3857' }); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geom = feature.getGeometry(); expect(geom.getType()).to.eql('LineString'); - var expectedPoint1 = ol.proj.transform( + var expectedPoint1 = _ol_proj_.transform( [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); expectedPoint1.push(1303202928); - var expectedPoint2 = ol.proj.transform( + var expectedPoint2 = _ol_proj_.transform( [6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857'); expectedPoint2.push(1303203353); - var expectedPoint3 = ol.proj.transform( + var expectedPoint3 = _ol_proj_.transform( [6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857'); expectedPoint3.push(1303203815); - var expectedPoint4 = ol.proj.transform( + var expectedPoint4 = _ol_proj_.transform( [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); expectedPoint4.push(1303289328); @@ -95,7 +93,7 @@ describe('ol.format.IGC', function() { var features = format.readFeatures(igc); expect(features.length).to.eql(1); var feature = features[0]; - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geom = feature.getGeometry(); expect(geom.getType()).to.eql('LineString'); expect(geom.getCoordinates()).to.eql([ @@ -111,20 +109,20 @@ describe('ol.format.IGC', function() { }); expect(features.length).to.eql(1); var feature = features[0]; - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geom = feature.getGeometry(); expect(geom.getType()).to.eql('LineString'); - var expectedPoint1 = ol.proj.transform( + var expectedPoint1 = _ol_proj_.transform( [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); expectedPoint1.push(1303202928); - var expectedPoint2 = ol.proj.transform( + var expectedPoint2 = _ol_proj_.transform( [6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857'); expectedPoint2.push(1303203353); - var expectedPoint3 = ol.proj.transform( + var expectedPoint3 = _ol_proj_.transform( [6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857'); expectedPoint3.push(1303203815); - var expectedPoint4 = ol.proj.transform( + var expectedPoint4 = _ol_proj_.transform( [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); expectedPoint4.push(1303289328); diff --git a/test/spec/ol/format/kml.test.js b/test/spec/ol/format/kml.test.js index 07b4c293d6..0a317c41b9 100644 --- a/test/spec/ol/format/kml.test.js +++ b/test/spec/ol/format/kml.test.js @@ -1,29 +1,27 @@ - - -goog.require('ol.Feature'); -goog.require('ol.array'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.format.KML'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); -goog.require('ol.proj.transforms'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.IconAnchorUnits'); -goog.require('ol.style.IconOrigin'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); -goog.require('ol.xml'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_array_ from '../../../../src/ol/array.js'; +import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js'; +import _ol_format_KML_ from '../../../../src/ol/format/KML.js'; +import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_proj_transforms_ from '../../../../src/ol/proj/transforms.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; +import _ol_style_IconAnchorUnits_ from '../../../../src/ol/style/IconAnchorUnits.js'; +import _ol_style_IconOrigin_ from '../../../../src/ol/style/IconOrigin.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; +import _ol_xml_ from '../../../../src/ol/xml.js'; describe('ol.format.KML', function() { @@ -32,16 +30,16 @@ describe('ol.format.KML', function() { describe('using defaultStyle', function() { - var dfltStyle = new ol.style.Style(); + var dfltStyle = new _ol_style_Style_(); beforeEach(function() { - format = new ol.format.KML({ + format = new _ol_format_KML_({ defaultStyle: [dfltStyle] }); }); it('set constant variables', function() { - expect(ol.format.KML.DEFAULT_STYLE_ARRAY_).to.be.an(Array); + expect(_ol_format_KML_.DEFAULT_STYLE_ARRAY_).to.be.an(Array); }); describe('#readFeatures', function() { @@ -56,14 +54,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); expect(style).to.be(dfltStyle); }); }); @@ -72,22 +70,22 @@ describe('ol.format.KML', function() { describe('without parameters', function() { beforeEach(function() { - format = new ol.format.KML(); + format = new _ol_format_KML_(); }); it('set constant variables', function() { - expect(ol.format.KML.DEFAULT_STYLE_ARRAY_).to.be.an(Array); + expect(_ol_format_KML_.DEFAULT_STYLE_ARRAY_).to.be.an(Array); }); describe('#readProjection', function() { it('returns the default projection from document', function() { var projection = format.readProjectionFromDocument(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); it('returns the default projection from node', function() { var projection = format.readProjectionFromNode(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); }); @@ -103,7 +101,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getId()).to.be('foo'); }); @@ -115,12 +113,12 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getId()).to.be(undefined); }); it('can write a Feature', function() { - var features = [new ol.Feature()]; + var features = [new _ol_Feature_()]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write a Feature as string', function() { - var features = [new ol.Feature()]; + var features = [new _ol_Feature_()]; var node = format.writeFeatures(features); var text = '' + ' ' + ''; - expect(ol.xml.parse(node)).to.xmleql(ol.xml.parse(text)); + expect(_ol_xml_.parse(node)).to.xmleql(_ol_xml_.parse(text)); }); it('can write a Feature\'s id', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); var features = [feature]; var node = format.writeFeaturesNode(features); @@ -160,7 +158,7 @@ describe('ol.format.KML', function() { ' https://developers.google.com/kml/schema/kml22gx.xsd">' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -175,13 +173,13 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); expect(g).to.be(null); }); it('can write feature with null geometries', function() { - var features = [new ol.Feature(null)]; + var features = [new _ol_Feature_(null)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write properties', function() { - var lineString = new ol.geom.LineString([[1, 2], [3, 4]]); + var lineString = new _ol_geom_LineString_([[1, 2], [3, 4]]); lineString.set('extrude', false); lineString.set('tessellate', true); lineString.set('altitudeMode', 'clampToGround'); lineString.set('unsupportedProperty', 'foo'); - var features = [new ol.Feature(lineString)]; + var features = [new _ol_Feature_(lineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read Point geometries', function() { @@ -239,9 +237,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([1, 2, 3]); expect(g.get('extrude')).to.be(false); expect(g.get('altitudeMode')).to.be('absolute'); @@ -265,10 +263,10 @@ describe('ol.format.KML', function() { }); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); - var expectedPoint = ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_Point_); + var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); expectedPoint.push(3); expect(g.getCoordinates()).to.eql(expectedPoint); }); @@ -287,9 +285,9 @@ describe('ol.format.KML', function() { ' ' + ''; var f = format.readFeature(text); - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([1, 2, 3]); }); @@ -309,18 +307,18 @@ describe('ol.format.KML', function() { var f = format.readFeature(text, { featureProjection: 'EPSG:3857' }); - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); - var expectedPoint = ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_Point_); + var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); expectedPoint.push(3); expect(g.getCoordinates()).to.eql(expectedPoint); }); it('can write XY Point geometries', function() { var layout = 'XY'; - var point = new ol.geom.Point([1, 2], layout); - var features = [new ol.Feature(point)]; + var point = new _ol_geom_Point_([1, 2], layout); + var features = [new _ol_Feature_(point)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZ Point geometries', function() { var layout = 'XYZ'; - var point = new ol.geom.Point([1, 2, 3], layout); - var features = [new ol.Feature(point)]; + var point = new _ol_geom_Point_([1, 2, 3], layout); + var features = [new _ol_Feature_(point)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can transform and write XYZ Point geometries', function() { - ol.proj.addProjection(new ol.proj.Projection({code: 'double'})); - ol.proj.addCoordinateTransforms('EPSG:4326', 'double', + _ol_proj_.addProjection(new _ol_proj_Projection_({code: 'double'})); + _ol_proj_.addCoordinateTransforms('EPSG:4326', 'double', function(coordinate) { return [2 * coordinate[0], 2 * coordinate[1]]; }, @@ -368,9 +366,9 @@ describe('ol.format.KML', function() { }); var layout = 'XYZ'; - var point = new ol.geom.Point([1, 2, 3], layout).transform( + var point = new _ol_geom_Point_([1, 2, 3], layout).transform( 'EPSG:4326', 'double'); - var features = [new ol.Feature(point)]; + var features = [new _ol_Feature_(point)]; var node = format.writeFeaturesNode(features, { featureProjection: 'double' }); @@ -386,18 +384,18 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); - ol.proj.transforms.remove( - ol.proj.get('EPSG:4326'), ol.proj.get('double')); - ol.proj.transforms.remove( - ol.proj.get('double'), ol.proj.get('EPSG:4326')); + _ol_proj_transforms_.remove( + _ol_proj_.get('EPSG:4326'), _ol_proj_.get('double')); + _ol_proj_transforms_.remove( + _ol_proj_.get('double'), _ol_proj_.get('EPSG:4326')); }); it('can write XYM Point geometries', function() { var layout = 'XYM'; - var point = new ol.geom.Point([1, 2, 100], layout); - var features = [new ol.Feature(point)]; + var point = new _ol_geom_Point_([1, 2, 100], layout); + var features = [new _ol_Feature_(point)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZM Point geometries', function() { var layout = 'XYZM'; - var point = new ol.geom.Point([1, 2, 3, 100], layout); - var features = [new ol.Feature(point)]; + var point = new _ol_geom_Point_([1, 2, 3, 100], layout); + var features = [new _ol_Feature_(point)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read LineString geometries', function() { @@ -449,9 +447,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]); expect(g.get('extrude')).to.be(false); expect(g.get('tessellate')).to.be(true); @@ -460,8 +458,8 @@ describe('ol.format.KML', function() { it('can write XY LineString geometries', function() { var layout = 'XY'; - var lineString = new ol.geom.LineString([[1, 2], [3, 4]], layout); - var features = [new ol.Feature(lineString)]; + var lineString = new _ol_geom_LineString_([[1, 2], [3, 4]], layout); + var features = [new _ol_Feature_(lineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZ LineString geometries', function() { var layout = 'XYZ'; - var lineString = new ol.geom.LineString( + var lineString = new _ol_geom_LineString_( [[1, 2, 3], [4, 5, 6]], layout); - var features = [new ol.Feature(lineString)]; + var features = [new _ol_Feature_(lineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYM LineString geometries', function() { var layout = 'XYM'; - var lineString = new ol.geom.LineString( + var lineString = new _ol_geom_LineString_( [[1, 2, 100], [3, 4, 200]], layout); - var features = [new ol.Feature(lineString)]; + var features = [new _ol_Feature_(lineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZM LineString geometries', function() { var layout = 'XYZM'; - var lineString = new ol.geom.LineString( + var lineString = new _ol_geom_LineString_( [[1, 2, 3, 100], [4, 5, 6, 200]], layout); - var features = [new ol.Feature(lineString)]; + var features = [new _ol_Feature_(lineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read LinearRing geometries', function() { @@ -553,17 +551,17 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Polygon); + expect(g).to.be.an(_ol_geom_Polygon_); expect(g.getCoordinates()).to.eql([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]); }); it('can write XY LinearRing geometries', function() { var layout = 'XY'; - var linearRing = new ol.geom.LinearRing( + var linearRing = new _ol_geom_LinearRing_( [[1, 2], [3, 4], [1, 2]], layout); - var features = [new ol.Feature(linearRing)]; + var features = [new _ol_Feature_(linearRing)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZ LinearRing geometries', function() { var layout = 'XYZ'; - var linearRing = new ol.geom.LinearRing( + var linearRing = new _ol_geom_LinearRing_( [[1, 2, 3], [4, 5, 6], [1, 2, 3]], layout); - var features = [new ol.Feature(linearRing)]; + var features = [new _ol_Feature_(linearRing)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYM LinearRing geometries', function() { var layout = 'XYM'; - var linearRing = new ol.geom.LinearRing( + var linearRing = new _ol_geom_LinearRing_( [[1, 2, 100], [3, 4, 200], [1, 2, 100]], layout); - var features = [new ol.Feature(linearRing)]; + var features = [new _ol_Feature_(linearRing)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZM LinearRing geometries', function() { var layout = 'XYZM'; - var linearRing = new ol.geom.LinearRing( + var linearRing = new _ol_geom_LinearRing_( [[1, 2, 3, 100], [4, 5, 6, 200], [1, 2, 3, 100]], layout); - var features = [new ol.Feature(linearRing)]; + var features = [new _ol_Feature_(linearRing)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read Polygon geometries', function() { @@ -661,9 +659,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Polygon); + expect(g).to.be.an(_ol_geom_Polygon_); expect(g.getCoordinates()).to.eql( [[[0, 0, 1], [0, 5, 1], [5, 5, 2], [5, 0, 3]]]); expect(g.get('extrude')).to.be(false); @@ -672,9 +670,9 @@ describe('ol.format.KML', function() { it('can write XY Polygon geometries', function() { var layout = 'XY'; - var polygon = new ol.geom.Polygon( + var polygon = new _ol_geom_Polygon_( [[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]]], layout); - var features = [new ol.Feature(polygon)]; + var features = [new _ol_Feature_(polygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZ Polygon geometries', function() { var layout = 'XYZ'; - var polygon = new ol.geom.Polygon( + var polygon = new _ol_geom_Polygon_( [[[0, 0, 1], [0, 2, 2], [2, 2, 3], [2, 0, 4], [0, 0, 5]]], layout); - var features = [new ol.Feature(polygon)]; + var features = [new _ol_Feature_(polygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYM Polygon geometries', function() { var layout = 'XYM'; - var polygon = new ol.geom.Polygon( + var polygon = new _ol_geom_Polygon_( [[[0, 0, 1], [0, 2, 1], [2, 2, 1], [2, 0, 1], [0, 0, 1]]], layout); - var features = [new ol.Feature(polygon)]; + var features = [new _ol_Feature_(polygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write XYZM Polygon geometries', function() { var layout = 'XYZM'; - var polygon = new ol.geom.Polygon([ + var polygon = new _ol_geom_Polygon_([ [[0, 0, 1, 1], [0, 2, 2, 1], [2, 2, 3, 1], [2, 0, 4, 1], [0, 0, 5, 1]] ], layout); - var features = [new ol.Feature(polygon)]; + var features = [new _ol_Feature_(polygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read complex Polygon geometries', function() { @@ -801,9 +799,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Polygon); + expect(g).to.be.an(_ol_geom_Polygon_); expect(g.getCoordinates()).to.eql([ [[0, 0, 1], [0, 5, 1], [5, 5, 2], [5, 0, 3]], [[1, 1, 0], [1, 2, 0], [2, 2, 0], [2, 1, 0]], @@ -813,12 +811,12 @@ describe('ol.format.KML', function() { it('can write complex Polygon geometries', function() { var layout = 'XYZ'; - var polygon = new ol.geom.Polygon([ + var polygon = new _ol_geom_Polygon_([ [[0, 0, 1], [0, 5, 1], [5, 5, 2], [5, 0, 3]], [[1, 1, 0], [1, 2, 0], [2, 2, 0], [2, 1, 0]], [[3, 3, 0], [3, 4, 0], [4, 4, 0], [4, 3, 0]] ], layout); - var features = [new ol.Feature(polygon)]; + var features = [new _ol_Feature_(polygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read MultiPolygon geometries', function() { @@ -876,9 +874,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql( [[[[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]]], [[[3, 0, 0], [3, 1, 0], [4, 1, 0], [4, 0, 0]]]]); @@ -894,10 +892,10 @@ describe('ol.format.KML', function() { it('can write MultiPolygon geometries', function() { var layout = 'XYZ'; - var multiPolygon = new ol.geom.MultiPolygon( + var multiPolygon = new _ol_geom_MultiPolygon_( [[[[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]]], [[[3, 0, 0], [3, 1, 0], [4, 1, 0], [4, 0, 0]]]], layout); - var features = [new ol.Feature(multiPolygon)]; + var features = [new _ol_Feature_(multiPolygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read MultiPoint geometries', function() { @@ -948,9 +946,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiPoint); + expect(g).to.be.an(_ol_geom_MultiPoint_); expect(g.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]); expect(g.get('extrude')).to.be.an('array'); expect(g.get('extrude')).to.have.length(2); @@ -964,9 +962,9 @@ describe('ol.format.KML', function() { it('can write MultiPoint geometries', function() { var layout = 'XYZ'; - var multiPoint = new ol.geom.MultiPoint( + var multiPoint = new _ol_geom_MultiPoint_( [[1, 2, 3], [4, 5, 6]], layout); - var features = [new ol.Feature(multiPoint)]; + var features = [new _ol_Feature_(multiPoint)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read MultiLineString geometries', function() { @@ -1008,9 +1006,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g.getCoordinates()).to.eql( [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]); expect(g.get('extrude')).to.be.an('array'); @@ -1029,9 +1027,9 @@ describe('ol.format.KML', function() { it('can write MultiLineString geometries', function() { var layout = 'XYZ'; - var multiLineString = new ol.geom.MultiLineString( + var multiLineString = new _ol_geom_MultiLineString_( [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], layout); - var features = [new ol.Feature(multiLineString)]; + var features = [new _ol_Feature_(multiLineString)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read MultiPolygon geometries', function() { @@ -1080,9 +1078,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiPolygon); + expect(g).to.be.an(_ol_geom_MultiPolygon_); expect(g.getCoordinates()).to.eql([ [[[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]]], [[[3, 0, 0], [3, 1, 0], [4, 1, 0], [4, 0, 0]]] @@ -1099,11 +1097,11 @@ describe('ol.format.KML', function() { it('can write MultiPolygon geometries', function() { var layout = 'XYZ'; - var multiPolygon = new ol.geom.MultiPolygon([ + var multiPolygon = new _ol_geom_MultiPolygon_([ [[[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]]], [[[3, 0, 0], [3, 1, 0], [4, 1, 0], [4, 0, 0]]] ], layout); - var features = [new ol.Feature(multiPolygon)]; + var features = [new _ol_Feature_(multiPolygon)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read empty GeometryCollection geometries', function() { @@ -1144,9 +1142,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.GeometryCollection); + expect(g).to.be.an(_ol_geom_GeometryCollection_); expect(g.getGeometries()).to.be.empty(); }); @@ -1177,15 +1175,15 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.GeometryCollection); + expect(g).to.be.an(_ol_geom_GeometryCollection_); var gs = g.getGeometries(); expect(gs).to.have.length(4); - expect(gs[0]).to.be.an(ol.geom.Point); - expect(gs[1]).to.be.an(ol.geom.LineString); - expect(gs[2]).to.be.an(ol.geom.Polygon); - expect(gs[3]).to.be.an(ol.geom.Polygon); + expect(gs[0]).to.be.an(_ol_geom_Point_); + expect(gs[1]).to.be.an(_ol_geom_LineString_); + expect(gs[2]).to.be.an(_ol_geom_Polygon_); + expect(gs[3]).to.be.an(_ol_geom_Polygon_); }); it('can read nested GeometryCollection geometries', function() { @@ -1201,21 +1199,21 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.GeometryCollection); + expect(g).to.be.an(_ol_geom_GeometryCollection_); var gs = g.getGeometries(); expect(gs).to.have.length(1); - expect(gs[0]).to.be.an(ol.geom.GeometryCollection); + expect(gs[0]).to.be.an(_ol_geom_GeometryCollection_); }); it('can write GeometryCollection geometries', function() { - var collection = new ol.geom.GeometryCollection([ - new ol.geom.Point([1, 2]), - new ol.geom.LineString([[1, 2], [3, 4]]), - new ol.geom.Polygon([[[1, 2], [3, 4], [3, 2], [1, 2]]]) + var collection = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([1, 2]), + new _ol_geom_LineString_([[1, 2], [3, 4]]), + new _ol_geom_Polygon_([[[1, 2], [3, 4], [3, 2], [1, 2]]]) ]); - var features = [new ol.Feature(collection)]; + var features = [new _ol_Feature_(collection)]; var node = format.writeFeaturesNode(features); var text = '' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read gx:Track', function() { @@ -1262,9 +1260,9 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); }); it('can read gx:MultiTrack', function() { @@ -1289,12 +1287,12 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.MultiLineString); + expect(g).to.be.an(_ol_geom_MultiLineString_); var gs = g.getLineStrings(); expect(gs).to.have.length(2); - expect(gs[0]).to.be.an(ol.geom.LineString); + expect(gs[0]).to.be.an(_ol_geom_LineString_); }); it('can read dateTime', function() { @@ -1344,7 +1342,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('open')).to.be(true); expect(f.get('visibility')).to.be(false); }); @@ -1362,7 +1360,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('address')).to.be('My address'); expect(f.get('description')).to.be('My description'); expect(f.get('name')).to.be('My name'); @@ -1379,7 +1377,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('description')).to.be('My description'); }); @@ -1393,7 +1391,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('name')).to.be('My name in CDATA'); }); @@ -1407,12 +1405,12 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('name')).to.be('My name in CDATA'); }); it('can write Feature\'s string attributes', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('address', 'My address'); feature.set('description', 'My description'); feature.set('name', 'My name'); @@ -1432,11 +1430,11 @@ describe('ol.format.KML', function() { ' My description' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write Feature\'s boolean attributes', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('open', true); feature.set('visibility', false); var features = [feature]; @@ -1452,7 +1450,7 @@ describe('ol.format.KML', function() { ' 0' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1481,7 +1479,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var extent = f.get('extent'); expect(extent).to.be.an(Array); expect(extent).to.have.length(4); @@ -1513,7 +1511,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('minLodPixels')).to.be(128); expect(f.get('maxLodPixels')).to.be(2048); expect(f.get('minFadeExtent')).to.be(0.2); @@ -1525,7 +1523,7 @@ describe('ol.format.KML', function() { describe('extended data', function() { it('can write ExtendedData with no values', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('foo', null); feature.set('bar', undefined); var features = [feature]; @@ -1543,11 +1541,11 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write ExtendedData with values', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('foo', 'bar'); feature.set('aNumber', 1000); var features = [feature]; @@ -1569,7 +1567,7 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write ExtendedData pair with displayName and value', function() { @@ -1578,7 +1576,7 @@ describe('ol.format.KML', function() { displayName: 'display name' }; - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.set('foo', pair); var features = [feature]; @@ -1598,7 +1596,7 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can read ExtendedData', function() { @@ -1615,7 +1613,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getProperties()).to.only.have.keys(['foo', 'geometry']); expect(f.get('foo')).to.be('bar'); }); @@ -1635,7 +1633,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getProperties()).to.only.have.keys(['foo', 'bar', 'geometry']); expect(f.get('foo')).to.be('200'); expect(f.get('bar')).to.be(undefined); @@ -1656,7 +1654,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('foo')).to.be('bar'); }); @@ -1675,7 +1673,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('capital')).to.be('London'); expect(f.get('population')).to.be('60000000'); }); @@ -1699,7 +1697,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('capital')).to.be('London'); expect(f.get('country')).to.be('United-Kingdom'); }); @@ -1716,19 +1714,19 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); expect(style.getFill().getColor()).to.eql([255, 255, 255, 1]); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); // FIXME check image style - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); expect(style.getStroke().getColor()).to.eql([255, 255, 255, 1]); expect(style.getStroke().getWidth()).to.be(1); }); @@ -1749,25 +1747,25 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); var imageStyle = style.getImage(); - expect(imageStyle).to.be.an(ol.style.Icon); + expect(imageStyle).to.be.an(_ol_style_Icon_); expect(new URL(imageStyle.getSrc()).href).to.eql(new URL('http://foo.png').href); expect(imageStyle.getAnchor()).to.be(null); expect(imageStyle.getOrigin()).to.be(null); expect(imageStyle.getRotation()).to.eql(0); expect(imageStyle.getSize()).to.be(null); expect(imageStyle.getScale()).to.be(1); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -1828,7 +1826,7 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(5); fs.forEach(function(f) { - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getId()).to.be.within(1, 5); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); @@ -1836,42 +1834,42 @@ describe('ol.format.KML', function() { expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); var imageStyle = style.getImage(); - expect(imageStyle).to.be.an(ol.style.Icon); + expect(imageStyle).to.be.an(_ol_style_Icon_); expect(new URL(imageStyle.getSrc()).href).to.eql(new URL('http://foo.png').href); expect(imageStyle.anchor_).to.be.an(Array); expect(imageStyle.anchor_).to.have.length(2); if (f.getId() == 1) { expect(imageStyle.anchor_[0]).to.be(0.5); expect(imageStyle.anchor_[1]).to.be(0.5); - expect(imageStyle.anchorOrigin_).to.be(ol.style.IconOrigin.BOTTOM_LEFT); - expect(imageStyle.anchorXUnits_).to.be(ol.style.IconAnchorUnits.FRACTION); - expect(imageStyle.anchorYUnits_).to.be(ol.style.IconAnchorUnits.FRACTION); + expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_LEFT); + expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); + expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); } else { expect(imageStyle.anchor_[0]).to.be(5); expect(imageStyle.anchor_[1]).to.be(5); - expect(imageStyle.anchorXUnits_).to.be(ol.style.IconAnchorUnits.PIXELS); - expect(imageStyle.anchorYUnits_).to.be(ol.style.IconAnchorUnits.PIXELS); + expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); + expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); if (f.getId() == 2) { - expect(imageStyle.anchorOrigin_).to.be(ol.style.IconOrigin.BOTTOM_LEFT); + expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_LEFT); } if (f.getId() == 3) { - expect(imageStyle.anchorOrigin_).to.be(ol.style.IconOrigin.BOTTOM_RIGHT); + expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_RIGHT); } if (f.getId() == 4) { - expect(imageStyle.anchorOrigin_).to.be(ol.style.IconOrigin.TOP_LEFT); + expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.TOP_LEFT); } if (f.getId() == 5) { - expect(imageStyle.anchorOrigin_).to.be(ol.style.IconOrigin.TOP_RIGHT); + expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.TOP_RIGHT); } } expect(imageStyle.getRotation()).to.eql(0); expect(imageStyle.getSize()).to.be(null); expect(imageStyle.getScale()).to.be(1); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); }); @@ -1900,16 +1898,16 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); var imageStyle = style.getImage(); imageStyle.iconImage_.size_ = [144, 192]; expect(imageStyle.getSize()).to.eql([48, 48]); @@ -1917,7 +1915,7 @@ describe('ol.format.KML', function() { expect(imageStyle.getOrigin()).to.eql([24, 108]); expect(imageStyle.getRotation()).to.eql(0); expect(imageStyle.getScale()).to.eql(3.0); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -1936,22 +1934,22 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); var textStyle = style.getText(); - expect(textStyle).to.be.an(ol.style.Text); + expect(textStyle).to.be.an(_ol_style_Text_); expect(textStyle.getScale()).to.be(0.25); var textFillStyle = textStyle.getFill(); - expect(textFillStyle).to.be.an(ol.style.Fill); + expect(textFillStyle).to.be.an(_ol_style_Fill_); expect(textFillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); expect(style.getZIndex()).to.be(undefined); }); @@ -1971,21 +1969,21 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); - expect(style.getFill()).to.be(ol.format.KML.DEFAULT_FILL_STYLE_); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style).to.be.an(_ol_style_Style_); + expect(style.getFill()).to.be(_ol_format_KML_.DEFAULT_FILL_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); var strokeStyle = style.getStroke(); - expect(strokeStyle).to.be.an(ol.style.Stroke); + expect(strokeStyle).to.be.an(_ol_style_Stroke_); expect(strokeStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); expect(strokeStyle.getWidth()).to.be(9); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2003,20 +2001,20 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var fillStyle = style.getFill(); - expect(fillStyle).to.be.an(ol.style.Fill); + expect(fillStyle).to.be.an(_ol_style_Fill_); expect(fillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); - expect(style.getStroke()).to.be(ol.format.KML.DEFAULT_STROKE_STYLE_); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); + expect(style.getStroke()).to.be(_ol_format_KML_.DEFAULT_STROKE_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2040,23 +2038,23 @@ describe('ol.format.KML', function() { expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var fillStyle = style.getFill(); - expect(fillStyle).to.be.an(ol.style.Fill); + expect(fillStyle).to.be.an(_ol_style_Fill_); expect(fillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); var strokeStyle = style.getStroke(); - expect(strokeStyle).to.be.an(ol.style.Stroke); + expect(strokeStyle).to.be.an(_ol_style_Stroke_); expect(strokeStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); expect(strokeStyle.getWidth()).to.be(9); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2079,21 +2077,21 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); expect(style.getFill()).to.be(null); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); var strokeStyle = style.getStroke(); - expect(strokeStyle).to.be.an(ol.style.Stroke); + expect(strokeStyle).to.be.an(_ol_style_Stroke_); expect(strokeStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); expect(strokeStyle.getWidth()).to.be(9); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2116,20 +2114,20 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var fillStyle = style.getFill(); - expect(fillStyle).to.be.an(ol.style.Fill); + expect(fillStyle).to.be.an(_ol_style_Fill_); expect(fillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); expect(style.getStroke()).to.be(null); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2154,18 +2152,18 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); expect(style.getFill()).to.be(null); - expect(style.getImage()).to.be(ol.format.KML.DEFAULT_IMAGE_STYLE_); + expect(style.getImage()).to.be(_ol_format_KML_.DEFAULT_IMAGE_STYLE_); expect(style.getStroke()).to.be(null); - expect(style.getText()).to.be(ol.format.KML.DEFAULT_TEXT_STYLE_); + expect(style.getText()).to.be(_ol_format_KML_.DEFAULT_TEXT_STYLE_); expect(style.getZIndex()).to.be(undefined); }); @@ -2207,14 +2205,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(2); var style = styleArray[1]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); expect(style.getText().getText()).to.eql(f.getProperties()['name']); }); @@ -2256,20 +2254,20 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(2); var style = styleArray[1]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); expect(style.getText().getText()).to.eql(f.getProperties()['name']); }); it('can write an feature\'s icon style', function() { - var style = new ol.style.Style({ - image: new ol.style.Icon({ + var style = new _ol_style_Style_({ + image: new _ol_style_Icon_({ anchor: [0.25, 36], anchorOrigin: 'top-left', anchorXUnits: 'fraction', @@ -2285,7 +2283,7 @@ describe('ol.format.KML', function() { }); var imageStyle = style.getImage(); imageStyle.iconImage_.size_ = [192, 144]; // sprite de 12 images(4*3) - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2312,17 +2310,17 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('does not write styles when writeStyles option is false', function() { - format = new ol.format.KML({writeStyles: false}); - var style = new ol.style.Style({ - image: new ol.style.Icon({ + format = new _ol_format_KML_({writeStyles: false}); + var style = new _ol_style_Style_({ + image: new _ol_style_Icon_({ src: 'http://foo.png' }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2334,19 +2332,19 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('skips image styles that are not icon styles', function() { - var style = new ol.style.Style({ - image: new ol.style.Circle({ + var style = new _ol_style_Style_({ + image: new _ol_style_Circle_({ radius: 4, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgb(12, 34, 223)' }) }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2360,20 +2358,20 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write an feature\'s text style', function() { - var style = new ol.style.Style({ - text: new ol.style.Text({ + var style = new _ol_style_Style_({ + text: new _ol_style_Text_({ scale: 0.5, text: 'foo', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: 'rgb(12, 34, 223)' }) }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2392,17 +2390,17 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write an feature\'s stroke style', function() { - var style = new ol.style.Style({ - stroke: new ol.style.Stroke({ + var style = new _ol_style_Style_({ + stroke: new _ol_style_Stroke_({ color: '#112233', width: 2 }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2420,16 +2418,16 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write an feature\'s fill style', function() { - var style = new ol.style.Style({ - fill: new ol.style.Fill({ + var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(12, 34, 223, 0.7)' }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle([style]); var node = format.writeFeaturesNode([feature]); var text = @@ -2446,18 +2444,18 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); it('can write multiple features with Style', function() { - var style = new ol.style.Style({ - fill: new ol.style.Fill({ + var style = new _ol_style_Style_({ + fill: new _ol_style_Fill_({ color: 'rgba(12, 34, 223, 0.7)' }) }); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setStyle(style); - var feature2 = new ol.Feature(); + var feature2 = new _ol_Feature_(); feature2.setStyle(style); var node = format.writeFeaturesNode([feature, feature2]); var text = @@ -2483,7 +2481,7 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -2510,14 +2508,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); + expect(s).to.be.an(_ol_style_Style_); expect(s.getFill()).not.to.be(null); expect(s.getFill().getColor()).to.eql([0, 0, 0, 0]); }); @@ -2543,15 +2541,15 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); - expect(s).to.be(ol.format.KML.DEFAULT_STYLE_); + expect(s).to.be.an(_ol_style_Style_); + expect(s).to.be(_ol_format_KML_.DEFAULT_STYLE_); }); @@ -2584,14 +2582,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); + expect(s).to.be.an(_ol_style_Style_); expect(s.getFill()).not.to.be(null); expect(s.getFill().getColor()).to.eql([0, 0, 0, 0]); }); @@ -2618,14 +2616,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); + expect(s).to.be.an(_ol_style_Style_); expect(s.getFill()).not.to.be(null); expect(s.getFill().getColor()).to.eql([0, 0, 0, 0]); }); @@ -2652,15 +2650,15 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); - expect(s).to.be(ol.format.KML.DEFAULT_STYLE_); + expect(s).to.be.an(_ol_style_Style_); + expect(s).to.be(_ol_format_KML_.DEFAULT_STYLE_); }); it('can use Styles in StyleMaps before they are defined', function() { @@ -2686,14 +2684,14 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var s = styleArray[0]; - expect(s).to.be.an(ol.style.Style); + expect(s).to.be.an(_ol_style_Style_); expect(s.getFill()).not.to.be(null); expect(s.getFill().getColor()).to.eql([120, 86, 52, 18 / 255]); }); @@ -2719,16 +2717,16 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var fillStyle = style.getFill(); - expect(fillStyle).to.be.an(ol.style.Fill); + expect(fillStyle).to.be.an(_ol_style_Fill_); expect(fillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); }); @@ -2751,16 +2749,16 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var styleFunction = f.getStyleFunction(); expect(styleFunction).not.to.be(undefined); var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); expect(styleArray).to.have.length(1); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var fillStyle = style.getFill(); - expect(fillStyle).to.be.an(ol.style.Fill); + expect(fillStyle).to.be.an(_ol_style_Fill_); expect(fillStyle.getColor()).to.eql([0x78, 0x56, 0x34, 0x12 / 255]); }); @@ -2784,13 +2782,13 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(2); var f1 = fs[0]; - expect(f1).to.be.an(ol.Feature); + expect(f1).to.be.an(_ol_Feature_); var styleFunction1 = f1.getStyleFunction(); expect(styleFunction1).not.to.be(undefined); var styleArray1 = styleFunction1.call(f1, 0); expect(styleArray1).to.be.an(Array); var f2 = fs[1]; - expect(f2).to.be.an(ol.Feature); + expect(f2).to.be.an(_ol_Feature_); var styleFunction2 = f2.getStyleFunction(); expect(styleFunction2).not.to.be(undefined); var styleArray2 = styleFunction2.call(f2, 0); @@ -2818,7 +2816,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can read a single feature from nested Document', function() { @@ -2831,7 +2829,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can transform and read a single feature from a Document', function() { @@ -2848,10 +2846,10 @@ describe('ol.format.KML', function() { }); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); - var expectedPoint = ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); + expect(g).to.be.an(_ol_geom_Point_); + var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); expectedPoint.push(3); expect(g.getCoordinates()).to.eql(expectedPoint); }); @@ -2866,9 +2864,9 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(2); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); expect(fs[0].getId()).to.be('1'); - expect(fs[1]).to.be.an(ol.Feature); + expect(fs[1]).to.be.an(_ol_Feature_); expect(fs[1].getId()).to.be('2'); }); @@ -2888,7 +2886,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can read a multiple features from a Folder', function() { @@ -2901,9 +2899,9 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(2); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); expect(fs[0].getId()).to.be('1'); - expect(fs[1]).to.be.an(ol.Feature); + expect(fs[1]).to.be.an(_ol_Feature_); expect(fs[1].getId()).to.be('2'); }); @@ -2917,7 +2915,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can read features from Folders nested in Folders', function() { @@ -2930,7 +2928,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can read a single feature', function() { @@ -2939,7 +2937,7 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(1); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); }); it('can read features at multiple levels', function() { @@ -2959,15 +2957,15 @@ describe('ol.format.KML', function() { ''; var fs = format.readFeatures(text); expect(fs).to.have.length(5); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); expect(fs[0].getId()).to.be('a'); - expect(fs[1]).to.be.an(ol.Feature); + expect(fs[1]).to.be.an(_ol_Feature_); expect(fs[1].getId()).to.be('b'); - expect(fs[2]).to.be.an(ol.Feature); + expect(fs[2]).to.be.an(_ol_Feature_); expect(fs[2].getId()).to.be('c'); - expect(fs[3]).to.be.an(ol.Feature); + expect(fs[3]).to.be.an(_ol_Feature_); expect(fs[3].getId()).to.be('d'); - expect(fs[4]).to.be.an(ol.Feature); + expect(fs[4]).to.be.an(_ol_Feature_); expect(fs[4].getId()).to.be('e'); }); @@ -2994,9 +2992,9 @@ describe('ol.format.KML', function() { }); it('can write multiple features', function() { - var feature1 = new ol.Feature(); + var feature1 = new _ol_Feature_(); feature1.setId('1'); - var feature2 = new ol.Feature(); + var feature2 = new _ol_Feature_(); feature2.setId('2'); var node = format.writeFeaturesNode([feature1, feature2]); var text = @@ -3012,7 +3010,7 @@ describe('ol.format.KML', function() { ' ' + ' ' + ''; - expect(node).to.xmleql(ol.xml.parse(text)); + expect(node).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -3022,7 +3020,7 @@ describe('ol.format.KML', function() { it('should ignore invalid coordinates', function() { var doc = new DOMParser().parseFromString('INVALID', 'application/xml'); var node = doc.firstChild; - expect(ol.format.KML.readFlatCoordinates_(node)).to.be(undefined); + expect(_ol_format_KML_.readFlatCoordinates_(node)).to.be(undefined); }); it('should ignore Points with invalid coordinates', function() { @@ -3038,7 +3036,7 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getGeometry()).to.be(null); }); @@ -3055,7 +3053,7 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getGeometry()).to.be(null); }); @@ -3072,7 +3070,7 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getGeometry()).to.be(null); }); @@ -3093,7 +3091,7 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.getGeometry()).to.be(null); }); @@ -3112,9 +3110,9 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.GeometryCollection); + expect(g).to.be.an(_ol_geom_GeometryCollection_); expect(g.getGeometries()).to.be.empty(); }); @@ -3129,7 +3127,7 @@ describe('ol.format.KML', function() { expect(fs).to.be.an(Array); expect(fs).to.have.length(1); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); expect(f.get('visibility')).to.be(undefined); }); @@ -3149,15 +3147,15 @@ describe('ol.format.KML', function() { var fs = format.readFeatures(kml); expect(fs).to.be.an(Array); expect(fs).to.have.length(5); - expect(fs[0]).to.be.an(ol.Feature); + expect(fs[0]).to.be.an(_ol_Feature_); expect(fs[0].getId()).to.be('a'); - expect(fs[1]).to.be.an(ol.Feature); + expect(fs[1]).to.be.an(_ol_Feature_); expect(fs[1].getId()).to.be('b'); - expect(fs[2]).to.be.an(ol.Feature); + expect(fs[2]).to.be.an(_ol_Feature_); expect(fs[2].getId()).to.be('c'); - expect(fs[3]).to.be.an(ol.Feature); + expect(fs[3]).to.be.an(_ol_Feature_); expect(fs[3].getId()).to.be('d'); - expect(fs[4]).to.be.an(ol.Feature); + expect(fs[4]).to.be.an(_ol_Feature_); expect(fs[4].getId()).to.be('e'); }); @@ -3186,22 +3184,22 @@ describe('ol.format.KML', function() { it('creates features with heterogeneous geometry collections', function() { // FIXME decide if we should instead create features with multiple geoms var feature = features[0]; - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.GeometryCollection); + expect(geometry).to.be.an(_ol_geom_GeometryCollection_); }); it('creates a Point and a MultiPolygon for Alaska', function() { - var alaska = ol.array.find(features, function(feature) { + var alaska = _ol_array_.find(features, function(feature) { return feature.get('name') === 'Alaska'; }); - expect(alaska).to.be.an(ol.Feature); + expect(alaska).to.be.an(_ol_Feature_); var geometry = alaska.getGeometry(); - expect(geometry).to.be.an(ol.geom.GeometryCollection); + expect(geometry).to.be.an(_ol_geom_GeometryCollection_); var components = geometry.getGeometries(); expect(components).to.have.length(2); - expect(components[0]).to.be.an(ol.geom.Point); - expect(components[1]).to.be.an(ol.geom.MultiPolygon); + expect(components[0]).to.be.an(_ol_geom_Point_); + expect(components[1]).to.be.an(_ol_geom_MultiPolygon_); }); it('reads style and icon', function() { @@ -3211,9 +3209,9 @@ describe('ol.format.KML', function() { var styleArray = styleFunction.call(f, 0); expect(styleArray).to.be.an(Array); var style = styleArray[0]; - expect(style).to.be.an(ol.style.Style); + expect(style).to.be.an(_ol_style_Style_); var imageStyle = style.getImage(); - expect(imageStyle).to.be.an(ol.style.Icon); + expect(imageStyle).to.be.an(_ol_style_Icon_); expect(imageStyle.getSrc()).to.eql('http://maps.google.com/mapfiles/kml/shapes/star.png'); }); @@ -3234,7 +3232,7 @@ describe('ol.format.KML', function() { }); it('feature must not have a properties property', function() { - var geojsonFormat = new ol.format.GeoJSON(); + var geojsonFormat = new _ol_format_GeoJSON_(); features.forEach(function(feature) { var geojsonFeature = geojsonFormat.writeFeatureObject(feature); expect(geojsonFeature.properties).to.be(null); diff --git a/test/spec/ol/format/mvt.test.js b/test/spec/ol/format/mvt.test.js index 66b4f14797..af95c16a3b 100644 --- a/test/spec/ol/format/mvt.test.js +++ b/test/spec/ol/format/mvt.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.Feature'); -goog.require('ol.extent'); -goog.require('ol.format.MVT'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.render.Feature'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_render_Feature_ from '../../../../src/ol/render/Feature.js'; where('ArrayBuffer.isView').describe('ol.format.MVT', function() { @@ -25,20 +23,20 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() { describe('#readFeatures', function() { it('uses ol.render.Feature as feature class by default', function() { - var format = new ol.format.MVT({layers: ['water']}); + var format = new _ol_format_MVT_({layers: ['water']}); var features = format.readFeatures(data); - expect(features[0]).to.be.a(ol.render.Feature); + expect(features[0]).to.be.a(_ol_render_Feature_); }); it('parses only specified layers', function() { - var format = new ol.format.MVT({layers: ['water']}); + var format = new _ol_format_MVT_({layers: ['water']}); var features = format.readFeatures(data); expect(features.length).to.be(10); }); it('parses geometries correctly', function() { - var format = new ol.format.MVT({ - featureClass: ol.Feature, + var format = new _ol_format_MVT_({ + featureClass: _ol_Feature_, layers: ['poi_label'] }); var geometry; @@ -62,14 +60,14 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() { it('parses id property', function() { // ol.Feature - var format = new ol.format.MVT({ - featureClass: ol.Feature, + var format = new _ol_format_MVT_({ + featureClass: _ol_Feature_, layers: ['building'] }); var features = format.readFeatures(data); expect(features[0].getId()).to.be(2); // ol.render.Feature - format = new ol.format.MVT({ + format = new _ol_format_MVT_({ layers: ['building'] }); features = format.readFeatures(data); @@ -77,10 +75,10 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() { }); it('sets the extent of the last readFeatures call', function() { - var format = new ol.format.MVT(); + var format = new _ol_format_MVT_(); format.readFeatures(data); var extent = format.getLastExtent(); - expect(ol.extent.getWidth(extent)).to.be(4096); + expect(_ol_extent_.getWidth(extent)).to.be(4096); }); }); @@ -91,8 +89,8 @@ describe('ol.format.MVT', function() { describe('#createFeature_', function() { it('accepts a geometryName', function() { - var format = new ol.format.MVT({ - featureClass: ol.Feature, + var format = new _ol_format_MVT_({ + featureClass: _ol_Feature_, geometryName: 'myGeom' }); var rawFeature = { @@ -105,22 +103,22 @@ describe('ol.format.MVT', function() { name: 'layer1' } }; - var readRawGeometry_ = ol.format.MVT.readRawGeometry_; - ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { + var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { flatCoordinates.push(0, 0); ends.push(2); }; var feature = format.createFeature_({}, rawFeature); - ol.format.MVT.readRawGeometry_ = readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = readRawGeometry_; var geometry = feature.getGeometry(); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); expect(feature.get('myGeom')).to.equal(geometry); expect(feature.get('geometry')).to.be('foo'); }); it('detects a Polygon', function() { - var format = new ol.format.MVT({ - featureClass: ol.Feature + var format = new _ol_format_MVT_({ + featureClass: _ol_Feature_ }); var rawFeature = { type: 3, @@ -129,21 +127,21 @@ describe('ol.format.MVT', function() { name: 'layer1' } }; - var readRawGeometry_ = ol.format.MVT.readRawGeometry_; - ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { + var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { flatCoordinates.push(0, 0, 3, 0, 3, 3, 3, 0, 0, 0); flatCoordinates.push(1, 1, 1, 2, 2, 2, 2, 1, 1, 1); ends.push(10, 20); }; var feature = format.createFeature_({}, rawFeature); - ol.format.MVT.readRawGeometry_ = readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = readRawGeometry_; var geometry = feature.getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); }); it('detects a MultiPolygon', function() { - var format = new ol.format.MVT({ - featureClass: ol.Feature + var format = new _ol_format_MVT_({ + featureClass: _ol_Feature_ }); var rawFeature = { type: 3, @@ -152,20 +150,20 @@ describe('ol.format.MVT', function() { name: 'layer1' } }; - var readRawGeometry_ = ol.format.MVT.readRawGeometry_; - ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { + var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0); flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1); ends.push(10, 20); }; var feature = format.createFeature_({}, rawFeature); - ol.format.MVT.readRawGeometry_ = readRawGeometry_; + _ol_format_MVT_.readRawGeometry_ = readRawGeometry_; var geometry = feature.getGeometry(); - expect(geometry).to.be.a(ol.geom.MultiPolygon); + expect(geometry).to.be.a(_ol_geom_MultiPolygon_); }); it('creates ol.render.Feature instances', function() { - var format = new ol.format.MVT(); + var format = new _ol_format_MVT_(); var rawFeature = { type: 3, properties: { @@ -175,10 +173,10 @@ describe('ol.format.MVT', function() { name: 'layer1' } }; - var readRawGeometry_ = ol.format.MVT.readRawGeometry_; + var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_; var createdFlatCoordinates; var createdEnds; - ol.format.MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { + _ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) { flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0); flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1); createdFlatCoordinates = flatCoordinates; @@ -186,8 +184,8 @@ describe('ol.format.MVT', function() { createdEnds = ends; }; var feature = format.createFeature_({}, rawFeature); - ol.format.MVT.readRawGeometry_ = readRawGeometry_; - expect(feature).to.be.a(ol.render.Feature); + _ol_format_MVT_.readRawGeometry_ = readRawGeometry_; + expect(feature).to.be.a(_ol_render_Feature_); expect(feature.getType()).to.be('Polygon'); expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates); expect(feature.getEnds()).to.equal(createdEnds); diff --git a/test/spec/ol/format/osmxml.test.js b/test/spec/ol/format/osmxml.test.js index a00b56cd25..47aa2e96a5 100644 --- a/test/spec/ol/format/osmxml.test.js +++ b/test/spec/ol/format/osmxml.test.js @@ -1,28 +1,26 @@ - - -goog.require('ol.Feature'); -goog.require('ol.format.OSMXML'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.LineString'); -goog.require('ol.proj'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_format_OSMXML_ from '../../../../src/ol/format/OSMXML.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.OSMXML', function() { var format; beforeEach(function() { - format = new ol.format.OSMXML(); + format = new _ol_format_OSMXML_(); }); describe('#readProjection', function() { it('returns the default projection from document', function() { var projection = format.readProjectionFromDocument(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); it('returns the default projection from node', function() { var projection = format.readProjectionFromNode(); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); }); @@ -51,9 +49,9 @@ describe('ol.format.OSMXML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(2); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1]); }); @@ -76,14 +74,14 @@ describe('ol.format.OSMXML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(3); var point = fs[0]; - expect(point).to.be.an(ol.Feature); + expect(point).to.be.an(_ol_Feature_); var g = point.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql([2, 1]); var line = fs[2]; - expect(line).to.be.an(ol.Feature); + expect(line).to.be.an(_ol_Feature_); g = line.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]); }); @@ -107,9 +105,9 @@ describe('ol.format.OSMXML', function() { var fs = format.readFeatures(text); expect(fs).to.have.length(3); var line = fs[2]; - expect(line).to.be.an(ol.Feature); + expect(line).to.be.an(_ol_Feature_); var g = line.getGeometry(); - expect(g).to.be.an(ol.geom.LineString); + expect(g).to.be.an(_ol_geom_LineString_); expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]); }); @@ -130,11 +128,11 @@ describe('ol.format.OSMXML', function() { }); expect(fs).to.have.length(2); var f = fs[0]; - expect(f).to.be.an(ol.Feature); + expect(f).to.be.an(_ol_Feature_); var g = f.getGeometry(); - expect(g).to.be.an(ol.geom.Point); + expect(g).to.be.an(_ol_geom_Point_); expect(g.getCoordinates()).to.eql( - ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857')); }); }); diff --git a/test/spec/ol/format/ows.test.js b/test/spec/ol/format/ows.test.js index 4d38dda534..5026fbf844 100644 --- a/test/spec/ol/format/ows.test.js +++ b/test/spec/ol/format/ows.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.format.OWS'); -goog.require('ol.xml'); +import _ol_format_OWS_ from '../../../../src/ol/format/OWS.js'; +import _ol_xml_ from '../../../../src/ol/xml.js'; describe('ol.format.OWS 1.1', function() { - var parser = new ol.format.OWS(); + var parser = new _ol_format_OWS_(); it('should read ServiceProvider tag properly', function() { - var doc = ol.xml.parse( + var doc = _ol_xml_.parse( '' + '' + @@ -58,7 +56,7 @@ describe('ol.format.OWS 1.1', function() { }); it('should read ServiceIdentification tag properly', function() { - var doc = ol.xml.parse( + var doc = _ol_xml_.parse( '' + '' + @@ -93,7 +91,7 @@ describe('ol.format.OWS 1.1', function() { }); it('should read OperationsMetadata tag properly', function() { - var doc = ol.xml.parse( + var doc = _ol_xml_.parse( '' + '' + diff --git a/test/spec/ol/format/polyline.test.js b/test/spec/ol/format/polyline.test.js index 1371abf784..40172efb5f 100644 --- a/test/spec/ol/format/polyline.test.js +++ b/test/spec/ol/format/polyline.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Feature'); -goog.require('ol.format.Polyline'); -goog.require('ol.geom.LineString'); -goog.require('ol.proj'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_format_Polyline_ from '../../../../src/ol/format/Polyline.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.Polyline', function() { @@ -16,7 +14,7 @@ describe('ol.format.Polyline', function() { var points3857; function resetTestingData() { - format = new ol.format.Polyline(); + format = new _ol_format_Polyline_(); points = [ [-120.20000, 38.50000], [-120.95000, 40.70000], @@ -34,9 +32,9 @@ describe('ol.format.Polyline', function() { ]; encodedFlatPoints = '_p~iF~ps|U_ulLnnqC_mqNvxq`@'; points3857 = [ - ol.proj.transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857') ]; floats = [0.00, 0.15, -0.01, -0.16, 0.16, 0.01]; @@ -56,13 +54,13 @@ describe('ol.format.Polyline', function() { describe('#readProjectionFromText', function() { it('returns the default projection', function() { var projection = format.readProjectionFromText(encodedFlatPoints); - expect(projection).to.eql(ol.proj.get('EPSG:4326')); + expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); }); }); describe('encodeDeltas', function() { it('returns expected value', function() { - var encodeDeltas = ol.format.Polyline.encodeDeltas; + var encodeDeltas = _ol_format_Polyline_.encodeDeltas; expect(encodeDeltas(flippedFlatPoints, 2)).to.eql(encodedFlatPoints); }); @@ -70,7 +68,7 @@ describe('ol.format.Polyline', function() { describe('decodeDeltas', function() { it('returns expected value', function() { - var decodeDeltas = ol.format.Polyline.decodeDeltas; + var decodeDeltas = _ol_format_Polyline_.decodeDeltas; expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flippedFlatPoints); }); @@ -79,7 +77,7 @@ describe('ol.format.Polyline', function() { describe('encodeFloats', function() { it('returns expected value', function() { - var encodeFloats = ol.format.Polyline.encodeFloats; + var encodeFloats = _ol_format_Polyline_.encodeFloats; expect(encodeFloats(smallFloats)).to.eql(encodedFloats); @@ -92,7 +90,7 @@ describe('ol.format.Polyline', function() { describe('decodeFloats', function() { it('returns expected value', function() { - var decodeFloats = ol.format.Polyline.decodeFloats; + var decodeFloats = _ol_format_Polyline_.decodeFloats; expect(decodeFloats(encodedFloats)).to.eql(smallFloats); expect(decodeFloats(encodedFloats, 1e5)).to.eql(smallFloats); @@ -103,7 +101,7 @@ describe('ol.format.Polyline', function() { describe('encodeSignedIntegers', function() { it('returns expected value', function() { - var encodeSignedIntegers = ol.format.Polyline.encodeSignedIntegers; + var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers; expect(encodeSignedIntegers( signedIntegers)).to.eql(encodedSignedIntegers); @@ -112,7 +110,7 @@ describe('ol.format.Polyline', function() { describe('decodeSignedIntegers', function() { it('returns expected value', function() { - var decodeSignedIntegers = ol.format.Polyline.decodeSignedIntegers; + var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers; expect(decodeSignedIntegers( encodedSignedIntegers)).to.eql(signedIntegers); @@ -122,7 +120,7 @@ describe('ol.format.Polyline', function() { describe('encodeUnsignedIntegers', function() { it('returns expected value', function() { - var encodeUnsignedIntegers = ol.format.Polyline.encodeUnsignedIntegers; + var encodeUnsignedIntegers = _ol_format_Polyline_.encodeUnsignedIntegers; expect(encodeUnsignedIntegers( unsignedIntegers)).to.eql(encodedUnsignedIntegers); @@ -131,7 +129,7 @@ describe('ol.format.Polyline', function() { describe('decodeUnsignedIntegers', function() { it('returns expected value', function() { - var decodeUnsignedIntegers = ol.format.Polyline.decodeUnsignedIntegers; + var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers; expect(decodeUnsignedIntegers( encodedUnsignedIntegers)).to.eql(unsignedIntegers); @@ -141,7 +139,7 @@ describe('ol.format.Polyline', function() { describe('encodeFloat', function() { it('returns expected value', function() { - var encodeFloats = ol.format.Polyline.encodeFloats; + var encodeFloats = _ol_format_Polyline_.encodeFloats; expect(encodeFloats([0.00000])).to.eql('?'); expect(encodeFloats([-0.00001])).to.eql('@'); @@ -164,7 +162,7 @@ describe('ol.format.Polyline', function() { describe('decodeFloat', function() { it('returns expected value', function() { - var decodeFloats = ol.format.Polyline.decodeFloats; + var decodeFloats = _ol_format_Polyline_.decodeFloats; expect(decodeFloats('?')).to.eql([0.00000]); expect(decodeFloats('@')).to.eql([-0.00001]); @@ -188,7 +186,7 @@ describe('ol.format.Polyline', function() { describe('encodeSignedInteger', function() { it('returns expected value', function() { - var encodeSignedIntegers = ol.format.Polyline.encodeSignedIntegers; + var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers; expect(encodeSignedIntegers([0])).to.eql('?'); expect(encodeSignedIntegers([-1])).to.eql('@'); @@ -206,7 +204,7 @@ describe('ol.format.Polyline', function() { describe('decodeSignedInteger', function() { it('returns expected value', function() { - var decodeSignedIntegers = ol.format.Polyline.decodeSignedIntegers; + var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers; expect(decodeSignedIntegers('?')).to.eql([0]); expect(decodeSignedIntegers('@')).to.eql([-1]); @@ -225,7 +223,7 @@ describe('ol.format.Polyline', function() { describe('encodeUnsignedInteger', function() { it('returns expected value', function() { - var encodeUnsignedInteger = ol.format.Polyline.encodeUnsignedInteger; + var encodeUnsignedInteger = _ol_format_Polyline_.encodeUnsignedInteger; expect(encodeUnsignedInteger(0)).to.eql('?'); expect(encodeUnsignedInteger(1)).to.eql('@'); @@ -245,7 +243,7 @@ describe('ol.format.Polyline', function() { describe('decodeUnsignedInteger', function() { it('returns expected value', function() { - var decodeUnsignedIntegers = ol.format.Polyline.decodeUnsignedIntegers; + var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers; expect(decodeUnsignedIntegers('?')).to.eql([0]); expect(decodeUnsignedIntegers('@')).to.eql([1]); @@ -267,9 +265,9 @@ describe('ol.format.Polyline', function() { it('returns the expected feature', function() { var feature = format.readFeature(encodedFlatPoints); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getFlatCoordinates()).to.eql(flatPoints); }); @@ -277,9 +275,9 @@ describe('ol.format.Polyline', function() { var feature = format.readFeature(encodedFlatPoints, { featureProjection: 'EPSG:3857' }); - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql(points3857); }); @@ -292,9 +290,9 @@ describe('ol.format.Polyline', function() { expect(features).to.be.an(Array); expect(features).to.have.length(1); var feature = features[0]; - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getFlatCoordinates()).to.eql(flatPoints); }); @@ -305,9 +303,9 @@ describe('ol.format.Polyline', function() { expect(features).to.be.an(Array); expect(features).to.have.length(1); var feature = features[0]; - expect(feature).to.be.an(ol.Feature); + expect(feature).to.be.an(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql(points3857); }); @@ -317,17 +315,17 @@ describe('ol.format.Polyline', function() { it('returns the expected geometry', function() { var geometry = format.readGeometry(encodedFlatPoints); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getFlatCoordinates()).to.eql(flatPoints); }); it('parses XYZ linestring', function() { - var xyz = ol.format.Polyline.encodeDeltas([ + var xyz = _ol_format_Polyline_.encodeDeltas([ 38.500, -120.200, 100, 40.700, -120.950, 200, 43.252, -126.453, 20 ], 3); - var format = new ol.format.Polyline({ + var format = new _ol_format_Polyline_({ geometryLayout: 'XYZ' }); @@ -344,7 +342,7 @@ describe('ol.format.Polyline', function() { var geometry = format.readGeometry(encodedFlatPoints, { featureProjection: 'EPSG:3857' }); - expect(geometry).to.be.an(ol.geom.LineString); + expect(geometry).to.be.an(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql(points3857); }); @@ -354,7 +352,7 @@ describe('ol.format.Polyline', function() { it('returns the expected projection', function() { var projection = format.readProjection(encodedFlatPoints); - expect(projection).to.be(ol.proj.get('EPSG:4326')); + expect(projection).to.be(_ol_proj_.get('EPSG:4326')); }); }); @@ -362,12 +360,12 @@ describe('ol.format.Polyline', function() { describe('#writeFeature', function() { it('returns the expected text', function() { - var feature = new ol.Feature(new ol.geom.LineString(points)); + var feature = new _ol_Feature_(new _ol_geom_LineString_(points)); expect(format.writeFeature(feature)).to.be(encodedFlatPoints); }); it('transforms and returns the expected text', function() { - var feature = new ol.Feature(new ol.geom.LineString(points3857)); + var feature = new _ol_Feature_(new _ol_geom_LineString_(points3857)); expect(format.writeFeature(feature, { featureProjection: 'EPSG:3857' })).to.be(encodedFlatPoints); @@ -378,12 +376,12 @@ describe('ol.format.Polyline', function() { describe('#writeFeature', function() { it('returns the expected text', function() { - var features = [new ol.Feature(new ol.geom.LineString(points))]; + var features = [new _ol_Feature_(new _ol_geom_LineString_(points))]; expect(format.writeFeatures(features)).to.be(encodedFlatPoints); }); it('transforms and returns the expected text', function() { - var features = [new ol.Feature(new ol.geom.LineString(points3857))]; + var features = [new _ol_Feature_(new _ol_geom_LineString_(points3857))]; expect(format.writeFeatures(features, { featureProjection: 'EPSG:3857' })).to.be(encodedFlatPoints); @@ -394,12 +392,12 @@ describe('ol.format.Polyline', function() { describe('#writeGeometry', function() { it('returns the expected text', function() { - var geometry = new ol.geom.LineString(points); + var geometry = new _ol_geom_LineString_(points); expect(format.writeGeometry(geometry)).to.be(encodedFlatPoints); }); it('transforms and returns the expected text', function() { - var geometry = new ol.geom.LineString(points3857); + var geometry = new _ol_geom_LineString_(points3857); expect(format.writeGeometry(geometry, { featureProjection: 'EPSG:3857' })).to.be(encodedFlatPoints); diff --git a/test/spec/ol/format/topojson.test.js b/test/spec/ol/format/topojson.test.js index c1008dc4a8..886b95c1bb 100644 --- a/test/spec/ol/format/topojson.test.js +++ b/test/spec/ol/format/topojson.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.format.Feature'); -goog.require('ol.proj'); -goog.require('ol.format.TopoJSON'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_format_Feature_ from '../../../../src/ol/format/Feature.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_format_TopoJSON_ from '../../../../src/ol/format/TopoJSON.js'; var aruba = { type: 'Topology', @@ -44,13 +42,13 @@ describe('ol.format.TopoJSON', function() { var format; before(function() { - format = new ol.format.TopoJSON(); + format = new _ol_format_TopoJSON_(); }); describe('constructor', function() { it('creates a new format', function() { - expect(format).to.be.a(ol.format.Feature); - expect(format).to.be.a(ol.format.TopoJSON); + expect(format).to.be.a(_ol_format_Feature_); + expect(format).to.be.a(_ol_format_TopoJSON_); }); }); @@ -61,10 +59,10 @@ describe('ol.format.TopoJSON', function() { expect(features).to.have.length(1); var feature = features[0]; - expect(feature).to.be.a(ol.Feature); + expect(feature).to.be.a(_ol_Feature_); var geometry = feature.getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); // Parses identifier expect(feature.getId()).to.be(533); @@ -82,7 +80,7 @@ describe('ol.format.TopoJSON', function() { expect(features).to.have.length(1); var feature = features[0]; - expect(feature).to.be.a(ol.Feature); + expect(feature).to.be.a(_ol_Feature_); expect(feature.getId()).to.be(0); }); @@ -125,25 +123,25 @@ describe('ol.format.TopoJSON', function() { var point = features[0].getGeometry(); expect(point.getType()).to.be('Point'); expect(features[0].getGeometry().getCoordinates()).to.eql( - ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); var line = features[1].getGeometry(); expect(line.getType()).to.be('LineString'); expect(line.getCoordinates()).to.eql([ - ol.proj.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') ]); var polygon = features[2].getGeometry(); expect(polygon.getType()).to.be('Polygon'); expect(polygon.getCoordinates()).to.eql([[ - ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'), - ol.proj.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857') + _ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'), + _ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857') ]]); done(); @@ -157,16 +155,16 @@ describe('ol.format.TopoJSON', function() { expect(features.length).to.be(178); var first = features[0]; - expect(first).to.be.a(ol.Feature); + expect(first).to.be.a(_ol_Feature_); var firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(ol.geom.MultiPolygon); + expect(firstGeom).to.be.a(_ol_geom_MultiPolygon_); expect(firstGeom.getExtent()).to.eql( [-180, -85.60903777459777, 180, 83.64513000000002]); var last = features[177]; - expect(last).to.be.a(ol.Feature); + expect(last).to.be.a(_ol_Feature_); var lastGeom = last.getGeometry(); - expect(lastGeom).to.be.a(ol.geom.Polygon); + expect(lastGeom).to.be.a(_ol_geom_Polygon_); expect(lastGeom.getExtent()).to.eql([ 25.26325263252633, -22.271802279310577, 32.848528485284874, -15.50833810039586 @@ -178,7 +176,7 @@ describe('ol.format.TopoJSON', function() { it('sets the topology\'s child names as feature property', function(done) { afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) { - var format = new ol.format.TopoJSON({ + var format = new _ol_format_TopoJSON_({ layerName: 'layer' }); var features = format.readFeatures(text); @@ -190,7 +188,7 @@ describe('ol.format.TopoJSON', function() { it('only parses features from specified topology\'s children', function(done) { afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) { - var format = new ol.format.TopoJSON({ + var format = new _ol_format_TopoJSON_({ layers: ['land'] }); var features = format.readFeatures(text); diff --git a/test/spec/ol/format/wfs.test.js b/test/spec/ol/format/wfs.test.js index 4bd6fb5423..518a039a5a 100644 --- a/test/spec/ol/format/wfs.test.js +++ b/test/spec/ol/format/wfs.test.js @@ -1,21 +1,21 @@ -goog.require('ol.Feature'); -goog.require('ol.format.GML2'); -goog.require('ol.format.WFS'); -goog.require('ol.format.filter'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); -goog.require('ol.xml'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_format_GML2_ from '../../../../src/ol/format/GML2.js'; +import _ol_format_WFS_ from '../../../../src/ol/format/WFS.js'; +import _ol_format_filter_ from '../../../../src/ol/format/filter.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_xml_ from '../../../../src/ol/xml.js'; describe('ol.format.WFS', function() { describe('featureType', function() { it('#getFeatureType #setFeatureType', function() { - var format = new ol.format.WFS({ + var format = new _ol_format_WFS_({ featureNS: 'http://www.openplans.org/topp', featureType: ['foo', 'bar'] }); @@ -39,7 +39,7 @@ describe('ol.format.WFS', function() { afterLoadText('spec/ol/format/wfs/topp-states-wfs.xml', function(data) { try { xml = data; - features = new ol.format.WFS(config).readFeatures(xml); + features = new _ol_format_WFS_(config).readFeatures(xml); } catch (e) { done(e); } @@ -55,19 +55,19 @@ describe('ol.format.WFS', function() { feature = features[0]; expect(feature.getId()).to.equal('states.1'); expect(feature.get('STATE_NAME')).to.equal('Illinois'); - expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon); + expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_); }); it('transforms and creates a polygon for Illinois', function() { - features = new ol.format.WFS(config).readFeatures(xml, { + features = new _ol_format_WFS_(config).readFeatures(xml, { featureProjection: 'EPSG:3857' }); feature = features[0]; expect(feature.getId()).to.equal('states.1'); expect(feature.get('STATE_NAME')).to.equal('Illinois'); var geom = feature.getGeometry(); - expect(geom).to.be.an(ol.geom.MultiPolygon); - var p = ol.proj.transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857'); + expect(geom).to.be.an(_ol_geom_MultiPolygon_); + var p = _ol_proj_.transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857'); p.push(0); expect(geom.getFirstCoordinate()).to.eql(p); }); @@ -80,7 +80,7 @@ describe('ol.format.WFS', function() { var config = { 'featureNS': 'http://mapserver.gis.umn.edu/mapserver', 'featureType': 'polygon', - 'gmlFormat': new ol.format.GML2() + 'gmlFormat': new _ol_format_GML2_() }; before(function(done) { @@ -88,7 +88,7 @@ describe('ol.format.WFS', function() { afterLoadText('spec/ol/format/wfs/polygonv2.xml', function(data) { try { xml = data; - features = new ol.format.WFS(config).readFeatures(xml); + features = new _ol_format_WFS_(config).readFeatures(xml); } catch (e) { done(e); } @@ -106,7 +106,7 @@ describe('ol.format.WFS', function() { expect(feature.get('name')).to.equal('My Polygon with hole'); expect(feature.get('boundedBy')).to.eql( [47.003018, -0.768746, 47.925567, 0.532597]); - expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon); + expect(feature.getGeometry()).to.be.an(_ol_geom_MultiPolygon_); expect(feature.getGeometry().getFlatCoordinates()). to.have.length(60); }); @@ -123,7 +123,7 @@ describe('ol.format.WFS', function() { }); }); it('returns an empty array of features when none exist', function() { - var result = new ol.format.WFS().readFeatures(xml); + var result = new _ol_format_WFS_().readFeatures(xml); expect(result).to.have.length(0); }); }); @@ -134,7 +134,7 @@ describe('ol.format.WFS', function() { afterLoadText('spec/ol/format/wfs/NumberOfFeatures.xml', function(xml) { try { - response = new ol.format.WFS().readFeatureCollectionMetadata(xml); + response = new _ol_format_WFS_().readFeatureCollectionMetadata(xml); } catch (e) { done(e); } @@ -156,7 +156,7 @@ describe('ol.format.WFS', function() { afterLoadText('spec/ol/format/wfs/boundedBy.xml', function(xml) { try { - response = new ol.format.WFS().readFeatureCollectionMetadata(xml); + response = new _ol_format_WFS_().readFeatureCollectionMetadata(xml); } catch (e) { done(e); } @@ -175,7 +175,7 @@ describe('ol.format.WFS', function() { afterLoadText('spec/ol/format/wfs/TransactionResponse.xml', function(xml) { try { - response = new ol.format.WFS().readTransactionResponse(xml); + response = new _ol_format_WFS_().readTransactionResponse(xml); } catch (e) { done(e); } @@ -210,7 +210,7 @@ describe('ol.format.WFS', function() { ' STATE_ABBR' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ resultType: 'hits', featureTypes: ['states'], featureNS: 'http://www.openplans.org/topp', @@ -218,7 +218,7 @@ describe('ol.format.WFS', function() { srsName: 'urn:ogc:def:crs:EPSG::4326', propertyNames: ['STATE_NAME', 'STATE_FIPS', 'STATE_ABBR'] }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('creates paging headers', function() { @@ -235,7 +235,7 @@ describe('ol.format.WFS', function() { ' xmlns:topp="http://www.openplans.org/topp">' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ count: 10, startIndex: 20, srsName: 'urn:ogc:def:crs:EPSG::4326', @@ -243,7 +243,7 @@ describe('ol.format.WFS', function() { featurePrefix: 'topp', featureTypes: ['states'] }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('creates a BBOX filter', function() { @@ -262,7 +262,7 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', @@ -270,7 +270,7 @@ describe('ol.format.WFS', function() { geometryName: 'the_geom', bbox: [1, 2, 3, 4] }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates a property filter', function() { @@ -285,14 +285,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.equalTo('name', 'New York', false) + filter: _ol_format_filter_.equalTo('name', 'New York', false) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates two property filters', function() { @@ -313,16 +313,16 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.or( - ol.format.filter.equalTo('name', 'New York'), - ol.format.filter.equalTo('area', 1234)) + filter: _ol_format_filter_.or( + _ol_format_filter_.equalTo('name', 'New York'), + _ol_format_filter_.equalTo('area', 1234)) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates greater/less than property filters', function() { @@ -355,23 +355,23 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.or( - ol.format.filter.and( - ol.format.filter.greaterThan('area', 100), - ol.format.filter.greaterThanOrEqualTo('pop', 20000) + filter: _ol_format_filter_.or( + _ol_format_filter_.and( + _ol_format_filter_.greaterThan('area', 100), + _ol_format_filter_.greaterThanOrEqualTo('pop', 20000) ), - ol.format.filter.and( - ol.format.filter.lessThan('area', 100), - ol.format.filter.lessThanOrEqualTo('pop', 20000) + _ol_format_filter_.and( + _ol_format_filter_.lessThan('area', 100), + _ol_format_filter_.lessThanOrEqualTo('pop', 20000) ) ) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates isBetween property filter', function() { @@ -387,14 +387,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.between('area', 100, 1000) + filter: _ol_format_filter_.between('area', 100, 1000) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates isNull property filter', function() { @@ -408,14 +408,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.isNull('area') + filter: _ol_format_filter_.isNull('area') }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates isLike property filter', function() { @@ -430,14 +430,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.like('name', 'New*') + filter: _ol_format_filter_.like('name', 'New*') }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates isLike property filter with arguments', function() { @@ -452,14 +452,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.like('name', 'New*', '*', '.', '!', false) + filter: _ol_format_filter_.like('name', 'New*', '*', '.', '!', false) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates a Not filter', function() { @@ -476,14 +476,14 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.not(ol.format.filter.equalTo('name', 'New York')) + filter: _ol_format_filter_.not(_ol_format_filter_.equalTo('name', 'New York')) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates an AND filter', function() { @@ -512,18 +512,18 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'urn:ogc:def:crs:EPSG::4326', featureNS: 'http://www.openplans.org/topp', featurePrefix: 'topp', featureTypes: ['states'], - filter: ol.format.filter.and( - ol.format.filter.equalTo('name', 'New York'), - ol.format.filter.bbox('the_geom', [1, 2, 3, 4], 'urn:ogc:def:crs:EPSG::4326'), - ol.format.filter.greaterThan('population', 2000000) + filter: _ol_format_filter_.and( + _ol_format_filter_.equalTo('name', 'New York'), + _ol_format_filter_.bbox('the_geom', [1, 2, 3, 4], 'urn:ogc:def:crs:EPSG::4326'), + _ol_format_filter_.greaterThan('population', 2000000) ) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates a contains filter', function() { @@ -546,12 +546,12 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'EPSG:4326', featureTypes: ['area'], - filter: ol.format.filter.contains( + filter: _ol_format_filter_.contains( 'the_geom', - new ol.geom.Polygon([[ + new _ol_geom_Polygon_([[ [10, 20], [10, 25], [15, 25], @@ -560,7 +560,7 @@ describe('ol.format.WFS', function() { ]]) ) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates a intersects filter', function() { @@ -583,12 +583,12 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'EPSG:4326', featureTypes: ['area'], - filter: ol.format.filter.intersects( + filter: _ol_format_filter_.intersects( 'the_geom', - new ol.geom.Polygon([[ + new _ol_geom_Polygon_([[ [10, 20], [10, 25], [15, 25], @@ -597,7 +597,7 @@ describe('ol.format.WFS', function() { ]]) ) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates a within filter', function() { @@ -620,12 +620,12 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'EPSG:4326', featureTypes: ['area'], - filter: ol.format.filter.within( + filter: _ol_format_filter_.within( 'the_geom', - new ol.geom.Polygon([[ + new _ol_geom_Polygon_([[ [10, 20], [10, 25], [15, 25], @@ -634,7 +634,7 @@ describe('ol.format.WFS', function() { ]]) ) }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); it('creates During property filter', function() { @@ -660,12 +660,12 @@ describe('ol.format.WFS', function() { ' ' + ''; - var serialized = new ol.format.WFS().writeGetFeature({ + var serialized = new _ol_format_WFS_().writeGetFeature({ srsName: 'EPSG:4326', featureTypes: ['states'], - filter: ol.format.filter.during('date_prop', '2010-01-20T00:00:00Z', '2012-12-31T00:00:00Z') + filter: _ol_format_filter_.during('date_prop', '2010-01-20T00:00:00Z', '2012-12-31T00:00:00Z') }); - expect(serialized.firstElementChild).to.xmleql(ol.xml.parse(text)); + expect(serialized.firstElementChild).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -679,9 +679,9 @@ describe('ol.format.WFS', function() { 'service="WFS" version="1.1.0" handle="handle_t" ' + 'xsi:schemaLocation="http://www.opengis.net/wfs ' + 'http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>'; - var serialized = new ol.format.WFS().writeTransaction(null, null, null, + var serialized = new _ol_format_WFS_().writeTransaction(null, null, null, {handle: 'handle_t'}); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -695,9 +695,9 @@ describe('ol.format.WFS', function() { }); }); it('creates the correct srsName', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.MultiLineString([[ + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiLineString_([[ [-5178372.1885436, 1992365.7775042], [-4434792.7774889, 1601008.1927386], [-4043435.1927233, 2148908.8114105] @@ -712,7 +712,7 @@ describe('ol.format.WFS', function() { featurePrefix: 'feature', gmlOptions: {multiCurve: true, srsName: 'EPSG:900913'} }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -726,10 +726,10 @@ describe('ol.format.WFS', function() { }); it('creates the correct update', function() { - var format = new ol.format.WFS(); - var updateFeature = new ol.Feature(); + var format = new _ol_format_WFS_(); + var updateFeature = new _ol_Feature_(); updateFeature.setGeometryName('the_geom'); - updateFeature.setGeometry(new ol.geom.MultiLineString([[ + updateFeature.setGeometry(new _ol_geom_MultiLineString_([[ [-12279454, 6741885], [-12064207, 6732101], [-11941908, 6595126], @@ -743,12 +743,12 @@ describe('ol.format.WFS', function() { featurePrefix: 'foo', gmlOptions: {srsName: 'EPSG:900913'} }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); it('creates the correct update if geometry name is alias', function() { - var format = new ol.format.WFS(); - var updateFeature = new ol.Feature(new ol.geom.MultiLineString([[ + var format = new _ol_format_WFS_(); + var updateFeature = new _ol_Feature_(new _ol_geom_MultiLineString_([[ [-12279454, 6741885], [-12064207, 6732101], [-11941908, 6595126], @@ -763,7 +763,7 @@ describe('ol.format.WFS', function() { featurePrefix: 'foo', gmlOptions: {srsName: 'EPSG:900913'} }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -771,10 +771,10 @@ describe('ol.format.WFS', function() { describe('when writing out a Transaction request', function() { it('creates the correct update with default featurePrefix', function() { - var format = new ol.format.WFS(); - var updateFeature = new ol.Feature(); + var format = new _ol_format_WFS_(); + var updateFeature = new _ol_Feature_(); updateFeature.setGeometryName('the_geom'); - updateFeature.setGeometry(new ol.geom.MultiLineString([[ + updateFeature.setGeometry(new _ol_geom_MultiLineString_([[ [-12279454, 6741885], [-12064207, 6732101], [-11941908, 6595126], @@ -794,10 +794,10 @@ describe('ol.format.WFS', function() { describe('when writing out a Transaction request', function() { it('does not create an update if no fid', function() { - var format = new ol.format.WFS(); - var updateFeature = new ol.Feature(); + var format = new _ol_format_WFS_(); + var updateFeature = new _ol_Feature_(); updateFeature.setGeometryName('the_geom'); - updateFeature.setGeometry(new ol.geom.MultiLineString([[ + updateFeature.setGeometry(new _ol_geom_MultiLineString_([[ [-12279454, 6741885], [-12064207, 6732101], [-11941908, 6595126], @@ -827,17 +827,17 @@ describe('ol.format.WFS', function() { }); it('handles multiple geometries', function() { - var format = new ol.format.WFS(); - var updateFeature = new ol.Feature(); + var format = new _ol_format_WFS_(); + var updateFeature = new _ol_Feature_(); updateFeature.setGeometryName('the_geom'); - updateFeature.setGeometry(new ol.geom.MultiLineString([[ + updateFeature.setGeometry(new _ol_geom_MultiLineString_([[ [-12279454, 6741885], [-12064207, 6732101], [-11941908, 6595126], [-12240318, 6507071], [-12416429, 6604910] ]])); - updateFeature.set('geom2', new ol.geom.MultiLineString([[ + updateFeature.set('geom2', new _ol_geom_MultiLineString_([[ [-12000000, 6700000], [-12000001, 6700001], [-12000002, 6700002] @@ -848,7 +848,7 @@ describe('ol.format.WFS', function() { featurePrefix: 'foo', gmlOptions: {srsName: 'EPSG:900913'} }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -862,16 +862,16 @@ describe('ol.format.WFS', function() { }); it('creates the correct transaction body', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2]]), + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2]]), foo: 'bar', nul: null }); insertFeature.setGeometryName('the_geom'); var inserts = [insertFeature]; - var updateFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2]]), + var updateFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2]]), foo: 'bar', // null value gets Property element with no Value nul: null, @@ -882,7 +882,7 @@ describe('ol.format.WFS', function() { updateFeature.setGeometryName('the_geom'); var updates = [updateFeature]; - var deleteFeature = new ol.Feature(); + var deleteFeature = new _ol_Feature_(); deleteFeature.setId('fid.37'); var deletes = [deleteFeature]; var serialized = format.writeTransaction(inserts, updates, deletes, { @@ -890,7 +890,7 @@ describe('ol.format.WFS', function() { featureType: 'states', featurePrefix: 'topp' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -905,7 +905,7 @@ describe('ol.format.WFS', function() { }); it('handles writing out Native', function() { - var format = new ol.format.WFS(); + var format = new _ol_format_WFS_(); var serialized = format.writeTransaction(null, null, null, { nativeElements: [{ vendorId: 'ORACLE', @@ -917,7 +917,7 @@ describe('ol.format.WFS', function() { value: 'Another native line goes here' }] }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -932,16 +932,16 @@ describe('ol.format.WFS', function() { }); it('handles the WFS version', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]), + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]]), foo: 'bar', nul: null }); insertFeature.setGeometryName('the_geom'); var inserts = [insertFeature]; - var updateFeature = new ol.Feature({ - the_geom: new ol.geom.LineString([[1.1, 2], [3, 4.2]]), + var updateFeature = new _ol_Feature_({ + the_geom: new _ol_geom_LineString_([[1.1, 2], [3, 4.2]]), foo: 'bar', // null value gets Property element with no Value nul: null, @@ -952,7 +952,7 @@ describe('ol.format.WFS', function() { updateFeature.setGeometryName('the_geom'); var updates = [updateFeature]; - var deleteFeature = new ol.Feature(); + var deleteFeature = new _ol_Feature_(); deleteFeature.setId('fid.37'); var deletes = [deleteFeature]; var serialized = format.writeTransaction(inserts, updates, deletes, { @@ -962,7 +962,7 @@ describe('ol.format.WFS', function() { version: '1.0.0' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -976,16 +976,16 @@ describe('ol.format.WFS', function() { }); it('do not add feature prefix twice', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2]]), + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2]]), foo: 'bar', nul: null }); insertFeature.setGeometryName('the_geom'); var inserts = [insertFeature]; - var updateFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2]]), + var updateFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2]]), foo: 'bar', // null value gets Property element with no Value nul: null, @@ -996,7 +996,7 @@ describe('ol.format.WFS', function() { updateFeature.setGeometryName('the_geom'); var updates = [updateFeature]; - var deleteFeature = new ol.Feature(); + var deleteFeature = new _ol_Feature_(); deleteFeature.setId('fid.37'); var deletes = [deleteFeature]; var serialized = format.writeTransaction(inserts, updates, deletes, { @@ -1004,7 +1004,7 @@ describe('ol.format.WFS', function() { featureType: 'topp:states', featurePrefix: 'topp' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1019,16 +1019,16 @@ describe('ol.format.WFS', function() { }); it('handles 3D in WFS 1.0.0', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.LineString([[1.1, 2, 4], [3, 4.2, 5]]), + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_LineString_([[1.1, 2, 4], [3, 4.2, 5]]), foo: 'bar', nul: null }); insertFeature.setGeometryName('the_geom'); var inserts = [insertFeature]; - var updateFeature = new ol.Feature({ - the_geom: new ol.geom.LineString([[1.1, 2, 6], [3, 4.2, 7]]), + var updateFeature = new _ol_Feature_({ + the_geom: new _ol_geom_LineString_([[1.1, 2, 6], [3, 4.2, 7]]), foo: 'bar', // null value gets Property element with no Value nul: null, @@ -1047,7 +1047,7 @@ describe('ol.format.WFS', function() { version: '1.0.0' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1061,16 +1061,16 @@ describe('ol.format.WFS', function() { }); it('handles 3D in WFS 1.1.0', function() { - var format = new ol.format.WFS(); - var insertFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2, 3]]), + var format = new _ol_format_WFS_(); + var insertFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2, 3]]), foo: 'bar', nul: null }); insertFeature.setGeometryName('the_geom'); var inserts = [insertFeature]; - var updateFeature = new ol.Feature({ - the_geom: new ol.geom.MultiPoint([[1, 2, 3]]), + var updateFeature = new _ol_Feature_({ + the_geom: new _ol_geom_MultiPoint_([[1, 2, 3]]), foo: 'bar', // null value gets Property element with no Value nul: null, @@ -1087,7 +1087,7 @@ describe('ol.format.WFS', function() { hasZ: true, featurePrefix: 'topp' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1101,13 +1101,13 @@ describe('ol.format.WFS', function() { }); it('handles writing multiple Query elements', function() { - var format = new ol.format.WFS(); + var format = new _ol_format_WFS_(); var serialized = format.writeGetFeature({ featureNS: 'http://www.openplans.org/topp', featureTypes: ['states', 'cities'], featurePrefix: 'topp' }); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); @@ -1121,7 +1121,7 @@ describe('ol.format.WFS', function() { 'featureNS': 'http://mapserver.gis.umn.edu/mapserver', 'featureType': 'Historische_Messtischblaetter_WFS' }; - features = new ol.format.WFS(config).readFeatures(xml); + features = new _ol_format_WFS_(config).readFeatures(xml); } catch (e) { done(e); } @@ -1138,7 +1138,7 @@ describe('ol.format.WFS', function() { var fid = 'Historische_Messtischblaetter_WFS.71055885'; expect(feature.getId()).to.equal(fid); expect(feature.get('titel')).to.equal('Arnstadt'); - expect(feature.getGeometry()).to.be.an(ol.geom.Polygon); + expect(feature.getGeometry()).to.be.an(_ol_geom_Polygon_); }); }); @@ -1149,7 +1149,7 @@ describe('ol.format.WFS', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) { try { - features = new ol.format.WFS({ + features = new _ol_format_WFS_({ featureNS: 'http://localhost:8080/official', featureType: ['planet_osm_polygon', 'planet_osm_line'] }).readFeatures(xml); @@ -1172,11 +1172,11 @@ describe('ol.format.WFS', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) { try { - lineFeatures = new ol.format.WFS({ + lineFeatures = new _ol_format_WFS_({ featureNS: 'http://localhost:8080/official', featureType: ['planet_osm_line'] }).readFeatures(xml); - polygonFeatures = new ol.format.WFS({ + polygonFeatures = new _ol_format_WFS_({ featureNS: 'http://localhost:8080/official', featureType: ['planet_osm_polygon'] }).readFeatures(xml); @@ -1200,7 +1200,7 @@ describe('ol.format.WFS', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function(xml) { try { - features = new ol.format.WFS().readFeatures(xml); + features = new _ol_format_WFS_().readFeatures(xml); } catch (e) { done(e); } @@ -1220,7 +1220,7 @@ describe('ol.format.WFS', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) { try { - features = new ol.format.WFS().readFeatures(xml); + features = new _ol_format_WFS_().readFeatures(xml); } catch (e) { done(e); } @@ -1231,7 +1231,7 @@ describe('ol.format.WFS', function() { it('reads all features', function() { expect(features.length).to.be(5); features.forEach(function(feature) { - expect(feature instanceof ol.Feature).to.be(true); + expect(feature instanceof _ol_Feature_).to.be(true); }); }); @@ -1243,11 +1243,11 @@ describe('ol.format.WFS', function() { before(function(done) { afterLoadText('spec/ol/format/gml/multiple-typenames-mapserver.xml', function(xml) { try { - busFeatures = new ol.format.WFS({ + busFeatures = new _ol_format_WFS_({ featureNS: 'http://mapserver.gis.umn.edu/mapserver', featureType: ['bus_stop'] }).readFeatures(xml); - infoFeatures = new ol.format.WFS({ + infoFeatures = new _ol_format_WFS_({ featureNS: 'http://mapserver.gis.umn.edu/mapserver', featureType: ['information'] }).readFeatures(xml); @@ -1280,13 +1280,13 @@ describe('ol.format.WFS', function() { ' ' + ' ' + ''; - var serialized = ol.format.WFS.writeFilter( - ol.format.filter.and( - ol.format.filter.like('name', 'Mississippi*'), - ol.format.filter.equalTo('waterway', 'riverbank') + var serialized = _ol_format_WFS_.writeFilter( + _ol_format_filter_.and( + _ol_format_filter_.like('name', 'Mississippi*'), + _ol_format_filter_.equalTo('waterway', 'riverbank') ) ); - expect(serialized).to.xmleql(ol.xml.parse(text)); + expect(serialized).to.xmleql(_ol_xml_.parse(text)); }); }); diff --git a/test/spec/ol/format/wkt.test.js b/test/spec/ol/format/wkt.test.js index aed98631dd..4e5c282cfa 100644 --- a/test/spec/ol/format/wkt.test.js +++ b/test/spec/ol/format/wkt.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.format.WKT'); -goog.require('ol.proj'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_format_WKT_ from '../../../../src/ol/format/WKT.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.format.WKT', function() { - var format = new ol.format.WKT(); + var format = new _ol_format_WKT_(); describe('#readProjectionFromText', function() { it('returns the default projection', function() { @@ -26,7 +24,7 @@ describe('ol.format.WKT', function() { featureProjection: 'EPSG:3857' }); expect(geom.getCoordinates()).to.eql( - ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); }); }); @@ -34,7 +32,7 @@ describe('ol.format.WKT', function() { describe('#writeGeometry()', function() { it('transforms with dataProjection and featureProjection', function() { - var geom = new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857'); + var geom = new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857'); var wkt = format.writeGeometry(geom, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' @@ -56,7 +54,7 @@ describe('ol.format.WKT', function() { }); var geom = feature.getGeometry(); expect(geom.getCoordinates()).to.eql( - ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); }); }); @@ -64,14 +62,14 @@ describe('ol.format.WKT', function() { describe('#writeFeature()', function() { it('transforms with dataProjection and featureProjection', function() { - var feature = new ol.Feature( - new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857')); + var feature = new _ol_Feature_( + new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857')); var wkt = format.writeFeature(feature, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }); var gotFeature = format.readFeature(wkt); - expect(gotFeature).to.be.a(ol.Feature); + expect(gotFeature).to.be.a(_ol_Feature_); var got = gotFeature.getGeometry().getCoordinates(); expect(got[0]).to.roughlyEqual(1, 1e-6); expect(got[1]).to.roughlyEqual(2, 1e-6); @@ -93,9 +91,9 @@ describe('ol.format.WKT', function() { expect(point1.getType()).to.eql('Point'); expect(point2.getType()).to.eql('Point'); expect(point1.getCoordinates()).to.eql( - ol.proj.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); expect(point2.getCoordinates()).to.eql( - ol.proj.transform([4, 5], 'EPSG:4326', 'EPSG:3857')); + _ol_proj_.transform([4, 5], 'EPSG:4326', 'EPSG:3857')); }); }); @@ -103,10 +101,10 @@ describe('ol.format.WKT', function() { it('transforms with dataProjection and featureProjection', function() { var features = [ - new ol.Feature( - new ol.geom.Point([1, 2]).transform('EPSG:4326', 'EPSG:3857')), - new ol.Feature( - new ol.geom.Point([4, 5]).transform('EPSG:4326', 'EPSG:3857')) + new _ol_Feature_( + new _ol_geom_Point_([1, 2]).transform('EPSG:4326', 'EPSG:3857')), + new _ol_Feature_( + new _ol_geom_Point_([4, 5]).transform('EPSG:4326', 'EPSG:3857')) ]; var wkt = format.writeFeatures(features, { dataProjection: 'EPSG:4326', @@ -781,7 +779,7 @@ describe('ol.format.WKT', function() { }); it('GeometryCollection split / merged correctly', function() { - format = new ol.format.WKT({splitCollection: true}); + format = new _ol_format_WKT_({splitCollection: true}); var wkt = 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))'; var features = format.readFeatures(wkt); expect(features.length).to.eql(2); diff --git a/test/spec/ol/format/wmscapabilities.test.js b/test/spec/ol/format/wmscapabilities.test.js index 5bd0b93643..2f9f01989d 100644 --- a/test/spec/ol/format/wmscapabilities.test.js +++ b/test/spec/ol/format/wmscapabilities.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.format.WMSCapabilities'); +import _ol_format_WMSCapabilities_ from '../../../../src/ol/format/WMSCapabilities.js'; describe('ol.format.WMSCapabilities', function() { describe('when parsing ogcsample.xml', function() { - var parser = new ol.format.WMSCapabilities(); + var parser = new _ol_format_WMSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wms/ogcsample.xml', function(xml) { diff --git a/test/spec/ol/format/wmsgetfeatureinfo.test.js b/test/spec/ol/format/wmsgetfeatureinfo.test.js index 3aef6842d3..b506fb11b9 100644 --- a/test/spec/ol/format/wmsgetfeatureinfo.test.js +++ b/test/spec/ol/format/wmsgetfeatureinfo.test.js @@ -1,4 +1,4 @@ -goog.require('ol.format.WMSGetFeatureInfo'); +import _ol_format_WMSGetFeatureInfo_ from '../../../../src/ol/format/WMSGetFeatureInfo.js'; describe('ol.format.WMSGetFeatureInfo', function() { @@ -6,12 +6,12 @@ describe('ol.format.WMSGetFeatureInfo', function() { describe('#getLayers', function() { it('returns null if layers is undefined', function() { - var format = new ol.format.WMSGetFeatureInfo(); + var format = new _ol_format_WMSGetFeatureInfo_(); expect(format.getLayers()).to.be(null); }); it('returns the value provided in the layers option', function() { - var format = new ol.format.WMSGetFeatureInfo({ + var format = new _ol_format_WMSGetFeatureInfo_({ layers: ['a', 'z'] }); expect(format.getLayers()).to.eql(['a', 'z']); @@ -29,7 +29,7 @@ describe('ol.format.WMSGetFeatureInfo', function() { proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) { try { - features = new ol.format.WMSGetFeatureInfo().readFeatures(data); + features = new _ol_format_WMSGetFeatureInfo_().readFeatures(data); } catch (e) { done(e); } @@ -68,7 +68,7 @@ describe('ol.format.WMSGetFeatureInfo', function() { ' ' + ' ' + ''; - var features = new ol.format.WMSGetFeatureInfo().readFeatures(text); + var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text); expect(features.length).to.be(0); }); @@ -93,7 +93,7 @@ describe('ol.format.WMSGetFeatureInfo', function() { ' ' + ' ' + ''; - var features = new ol.format.WMSGetFeatureInfo().readFeatures(text); + var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text); expect(features.length).to.be(1); expect(features[0].get('FOO')).to.be('bar'); // FIXME is that really wanted ? @@ -153,7 +153,7 @@ describe('ol.format.WMSGetFeatureInfo', function() { ' ' + ' ' + ''; - var format = new ol.format.WMSGetFeatureInfo(); + var format = new _ol_format_WMSGetFeatureInfo_(); var features = format.readFeatures(text); expect(features.length).to.be(2); expect(features[0].get('OBJECTID')).to.be('287'); @@ -219,7 +219,7 @@ describe('ol.format.WMSGetFeatureInfo', function() { ' ' + ' ' + ''; - var features = new ol.format.WMSGetFeatureInfo().readFeatures(text); + var features = new _ol_format_WMSGetFeatureInfo_().readFeatures(text); expect(features.length).to.be(1); expect(features[0].get('cat')).to.be('3'); expect(features[0].getGeometry().getType()).to.be('MultiLineString'); diff --git a/test/spec/ol/format/wmtscapabilities.test.js b/test/spec/ol/format/wmtscapabilities.test.js index 7271481958..9e928ddd3d 100644 --- a/test/spec/ol/format/wmtscapabilities.test.js +++ b/test/spec/ol/format/wmtscapabilities.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.format.WMTSCapabilities'); +import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabilities.js'; describe('ol.format.WMTSCapabilities', function() { describe('when parsing ogcsample.xml', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) { @@ -118,7 +116,7 @@ describe('ol.format.WMTSCapabilities', function() { describe('when parsing ign.xml', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) { diff --git a/test/spec/ol/format/xsd.test.js b/test/spec/ol/format/xsd.test.js index 34c4b0f785..e4a6a0546a 100644 --- a/test/spec/ol/format/xsd.test.js +++ b/test/spec/ol/format/xsd.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.format.XSD'); +import _ol_format_XSD_ from '../../../../src/ol/format/XSD.js'; describe('ol.format.XSD', function() { @@ -9,7 +7,7 @@ describe('ol.format.XSD', function() { it('can handle non-Zulu time zones', function() { var node = document.createElement('time'); node.textContent = '2016-07-12T15:00:00+03:00'; - expect(new Date(ol.format.XSD.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z'); + expect(new Date(_ol_format_XSD_.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z'); }); }); diff --git a/test/spec/ol/geolocation.test.js b/test/spec/ol/geolocation.test.js index 922677fb15..ed993aa388 100644 --- a/test/spec/ol/geolocation.test.js +++ b/test/spec/ol/geolocation.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.Geolocation'); +import _ol_Geolocation_ from '../../../src/ol/Geolocation.js'; describe('ol.Geolocation', function() { @@ -8,8 +6,8 @@ describe('ol.Geolocation', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.Geolocation(); - expect(instance).to.be.an(ol.Geolocation); + var instance = new _ol_Geolocation_(); + expect(instance).to.be.an(_ol_Geolocation_); }); }); diff --git a/test/spec/ol/geom/circle.test.js b/test/spec/ol/geom/circle.test.js index f6c62f7871..3491d48bc6 100644 --- a/test/spec/ol/geom/circle.test.js +++ b/test/spec/ol/geom/circle.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.Circle'); +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; describe('ol.geom.Circle', function() { @@ -9,14 +7,14 @@ describe('ol.geom.Circle', function() { var circle; beforeEach(function() { - circle = new ol.geom.Circle([0, 0], 1); + circle = new _ol_geom_Circle_([0, 0], 1); }); describe('#clone', function() { it('returns a clone', function() { var clone = circle.clone(); - expect(clone).to.be.an(ol.geom.Circle); + expect(clone).to.be.an(_ol_geom_Circle_); expect(clone.getCenter()).to.eql(circle.getCenter()); expect(clone.getCenter()).not.to.be(circle.getCenter()); expect(clone.getRadius()).to.be(circle.getRadius()); @@ -92,7 +90,7 @@ describe('ol.geom.Circle', function() { }); it('maintains Z coordinates', function() { - var circle = new ol.geom.Circle([0, 0, 1], 1); + var circle = new _ol_geom_Circle_([0, 0, 1], 1); expect(circle.getLayout()).to.be('XYZ'); var closestPoint = circle.getClosestPoint([2, 0]); expect(closestPoint).to.have.length(3); @@ -102,7 +100,7 @@ describe('ol.geom.Circle', function() { }); it('maintains M coordinates', function() { - var circle = new ol.geom.Circle([0, 0, 2], 1, + var circle = new _ol_geom_Circle_([0, 0, 2], 1, 'XYM'); var closestPoint = circle.getClosestPoint([2, 0]); expect(closestPoint).to.have.length(3); @@ -112,7 +110,7 @@ describe('ol.geom.Circle', function() { }); it('maintains Z and M coordinates', function() { - var circle = new ol.geom.Circle([0, 0, 1, 2], 1); + var circle = new _ol_geom_Circle_([0, 0, 1, 2], 1); expect(circle.getLayout()).to.be('XYZM'); var closestPoint = circle.getClosestPoint([2, 0]); expect(closestPoint).to.have.length(4); diff --git a/test/spec/ol/geom/flat/area.test.js b/test/spec/ol/geom/flat/area.test.js index d82cd3f3df..3119535ac1 100644 --- a/test/spec/ol/geom/flat/area.test.js +++ b/test/spec/ol/geom/flat/area.test.js @@ -1,19 +1,17 @@ - - -goog.require('ol.geom.flat.area'); +import _ol_geom_flat_area_ from '../../../../../src/ol/geom/flat/area.js'; describe('ol.geom.flat.area', function() { describe('ol.geom.flat.area.linearRing', function() { it('calculates the area of a triangle', function() { - var area = ol.geom.flat.area.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2); + var area = _ol_geom_flat_area_.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2); expect(area).to.be(0.5); }); it('calculates the area of a unit square', function() { var area = - ol.geom.flat.area.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2); + _ol_geom_flat_area_.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2); expect(area).to.be(1); }); @@ -22,7 +20,7 @@ describe('ol.geom.flat.area', function() { describe('ol.geom.flat.area.linearRings', function() { it('calculates the area with holes', function() { - var area = ol.geom.flat.area.linearRings( + var area = _ol_geom_flat_area_.linearRings( [0, 0, 0, 3, 3, 3, 3, 0, 1, 1, 2, 1, 2, 2, 1, 2], 0, [8, 16], 2); expect(area).to.be(8); }); diff --git a/test/spec/ol/geom/flat/center.test.js b/test/spec/ol/geom/flat/center.test.js index a6a4a15755..3e14ccbe0f 100644 --- a/test/spec/ol/geom/flat/center.test.js +++ b/test/spec/ol/geom/flat/center.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.geom.flat.center'); -goog.require('ol.geom.MultiPolygon'); +import _ol_geom_flat_center_ from '../../../../../src/ol/geom/flat/center.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; describe('ol.geom.flat.center', function() { @@ -9,10 +7,10 @@ describe('ol.geom.flat.center', function() { describe('ol.geom.flat.center.linearRingss', function() { it('calculates the center of a square', function() { - var squareMultiPoly = new ol.geom.MultiPolygon([[ + var squareMultiPoly = new _ol_geom_MultiPolygon_([[ [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]] ]]); - var got = ol.geom.flat.center.linearRingss( + var got = _ol_geom_flat_center_.linearRingss( squareMultiPoly.flatCoordinates, 0, squareMultiPoly.endss_, @@ -22,7 +20,7 @@ describe('ol.geom.flat.center', function() { }); it('calculates the centers of two squares', function() { - var squareMultiPoly = new ol.geom.MultiPolygon([ + var squareMultiPoly = new _ol_geom_MultiPolygon_([ [ [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]] ], @@ -30,7 +28,7 @@ describe('ol.geom.flat.center', function() { [[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]] ] ]); - var got = ol.geom.flat.center.linearRingss( + var got = _ol_geom_flat_center_.linearRingss( squareMultiPoly.flatCoordinates, 0, squareMultiPoly.endss_, @@ -40,11 +38,11 @@ describe('ol.geom.flat.center', function() { }); it('does not care about holes', function() { - var polywithHole = new ol.geom.MultiPolygon([[ + var polywithHole = new _ol_geom_MultiPolygon_([[ [[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]], [[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]] ]]); - var got = ol.geom.flat.center.linearRingss( + var got = _ol_geom_flat_center_.linearRingss( polywithHole.flatCoordinates, 0, polywithHole.endss_, diff --git a/test/spec/ol/geom/flat/closest.test.js b/test/spec/ol/geom/flat/closest.test.js index e2e995117b..b5ded9e431 100644 --- a/test/spec/ol/geom/flat/closest.test.js +++ b/test/spec/ol/geom/flat/closest.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.closest'); +import _ol_geom_flat_closest_ from '../../../../../src/ol/geom/flat/closest.js'; describe('ol.geom.flat.closest', function() { @@ -12,7 +10,7 @@ describe('ol.geom.flat.closest', function() { describe('ol.geom.flat.closest.getMaxSquaredDelta', function() { it('returns the expected value in simple cases', function() { - expect(ol.geom.flat.closest.getMaxSquaredDelta( + expect(_ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9); }); @@ -21,23 +19,23 @@ describe('ol.geom.flat.closest', function() { describe('ol.geom.flat.closest.getClosestPoint', function() { it('returns the expected value', function() { - var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta( + var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, 0, flatCoordinates.length, 2, 0)); expect(maxDelta).to.be(3); var closestPoint = [NaN, NaN]; - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0); expect(closestPoint).to.eql([0, 0]); - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1); expect(closestPoint).to.eql([4, 0]); - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4); expect(closestPoint).to.eql([5, 0]); - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000); expect(closestPoint).to.eql([10, 0]); @@ -80,7 +78,7 @@ describe('ol.geom.flat.closest', function() { describe('ol.geom.closet.maSquaredDelta', function() { it('returns the expected value', function() { - expect(ol.geom.flat.closest.getMaxSquaredDelta( + expect(_ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, 0, flatCoordinates.length, 2, 0)). to.roughlyEqual(1389.1058, 1e-9); }); @@ -90,21 +88,21 @@ describe('ol.geom.flat.closest', function() { describe('ol.geom.flat.closest.getClosestPoint', function() { it('returns the expected value', function() { - var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta( + var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, 0, flatCoordinates.length, 2, 0)); expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9); var closestPoint = [NaN, NaN]; - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 0, 0, closestPoint, Infinity)). to.roughlyEqual(110902.405, 1e-9); expect(closestPoint).to.eql([292.41, 159.37]); - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 500, 500, closestPoint, Infinity)). to.roughlyEqual(106407.905, 1e-9); expect(closestPoint).to.eql([671.55, 222.55]); - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, 2, maxDelta, false, 1000, 500, closestPoint, Infinity)). to.roughlyEqual(18229.4425, 1e-9); @@ -123,11 +121,11 @@ describe('ol.geom.flat.closest', function() { describe('ol.geom.flat.closest.getClosestPoint', function() { it('interpolates M coordinates', function() { - var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta( + var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta( flatCoordinates, 0, flatCoordinates.length, stride, 0)); expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9); var closestPoint = [NaN, NaN]; - expect(ol.geom.flat.closest.getClosestPoint( + expect(_ol_geom_flat_closest_.getClosestPoint( flatCoordinates, 0, flatCoordinates.length, stride, maxDelta, false, 1, 1, closestPoint, Infinity)). to.roughlyEqual(0, 1e-9); diff --git a/test/spec/ol/geom/flat/contains.test.js b/test/spec/ol/geom/flat/contains.test.js index 173a4becaf..7741a19a97 100644 --- a/test/spec/ol/geom/flat/contains.test.js +++ b/test/spec/ol/geom/flat/contains.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.contains'); +import _ol_geom_flat_contains_ from '../../../../../src/ol/geom/flat/contains.js'; describe('ol.geom.flat.contains', function() { @@ -13,27 +11,27 @@ describe('ol.geom.flat.contains', function() { describe('ol.geom.flat.contains.linearRingContainsXY', function() { it('returns true for point inside a simple polygon', function() { - expect(ol.geom.flat.contains.linearRingContainsXY( + expect(_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 0.5, 0.5)).to.be(true); }); it('returns false for point outside a simple polygon', function() { - expect(ol.geom.flat.contains.linearRingContainsXY( + expect(_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 1.5, 1.5)).to.be(false); }); it('returns true for point inside a non-simple polygon', function() { - expect(ol.geom.flat.contains.linearRingContainsXY( + expect(_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1, 1)).to.be(true); }); it('returns true for point inside an overlap of a non-simple polygon', function() { - expect(ol.geom.flat.contains.linearRingContainsXY( + expect(_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1.5, 2.5)).to.be(true); }); it('returns false for a point inside a hole of a non-simple polygon', function() { - expect(ol.geom.flat.contains.linearRingContainsXY( + expect(_ol_geom_flat_contains_.linearRingContainsXY( flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false); }); diff --git a/test/spec/ol/geom/flat/deflate.test.js b/test/spec/ol/geom/flat/deflate.test.js index 9745a1a3ea..bfa357e32d 100644 --- a/test/spec/ol/geom/flat/deflate.test.js +++ b/test/spec/ol/geom/flat/deflate.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.deflate'); +import _ol_geom_flat_deflate_ from '../../../../../src/ol/geom/flat/deflate.js'; describe('ol.geom.flat.deflate', function() { @@ -13,7 +11,7 @@ describe('ol.geom.flat.deflate', function() { }); it('flattens coordinates', function() { - var offset = ol.geom.flat.deflate.coordinates( + var offset = _ol_geom_flat_deflate_.coordinates( flatCoordinates, 0, [[1, 2], [3, 4]], 2); expect(offset).to.be(4); expect(flatCoordinates).to.eql([1, 2, 3, 4]); @@ -29,7 +27,7 @@ describe('ol.geom.flat.deflate', function() { }); it('flattens arrays of coordinates', function() { - var ends = ol.geom.flat.deflate.coordinatess(flatCoordinates, 0, + var ends = _ol_geom_flat_deflate_.coordinatess(flatCoordinates, 0, [[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2); expect(ends).to.eql([4, 8]); expect(flatCoordinates).to.eql([1, 2, 3, 4, 5, 6, 7, 8]); diff --git a/test/spec/ol/geom/flat/flip.test.js b/test/spec/ol/geom/flat/flip.test.js index 884e68d1af..c2f0447ea2 100644 --- a/test/spec/ol/geom/flat/flip.test.js +++ b/test/spec/ol/geom/flat/flip.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.flip'); +import _ol_geom_flat_flip_ from '../../../../../src/ol/geom/flat/flip.js'; describe('ol.geom.flat.flip', function() { @@ -8,19 +6,19 @@ describe('ol.geom.flat.flip', function() { describe('ol.geom.flat.flip.flipXY', function() { it('can flip XY coordinates', function() { - var flatCoordinates = ol.geom.flat.flip.flipXY([1, 2, 3, 4], 0, 4, 2); + var flatCoordinates = _ol_geom_flat_flip_.flipXY([1, 2, 3, 4], 0, 4, 2); expect(flatCoordinates).to.eql([2, 1, 4, 3]); }); it('can flip XY coordinates while preserving other dimensions', function() { - var flatCoordinates = ol.geom.flat.flip.flipXY( + var flatCoordinates = _ol_geom_flat_flip_.flipXY( [1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4); expect(flatCoordinates).to.eql([2, 1, 3, 4, 6, 5, 7, 8]); }); it('can flip XY coordinates in place', function() { var flatCoordinates = [1, 2, 3, 4]; - expect(ol.geom.flat.flip.flipXY( + expect(_ol_geom_flat_flip_.flipXY( flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates); expect(flatCoordinates).to.eql([2, 1, 4, 3]); }); @@ -28,7 +26,7 @@ describe('ol.geom.flat.flip', function() { it('can flip XY coordinates in place while preserving other dimensions', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9]; - expect(ol.geom.flat.flip.flipXY( + expect(_ol_geom_flat_flip_.flipXY( flatCoordinates, 0, 9, 3, flatCoordinates)). to.be(flatCoordinates); expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]); diff --git a/test/spec/ol/geom/flat/inflate.test.js b/test/spec/ol/geom/flat/inflate.test.js index 4a9f08070e..fdefac9c28 100644 --- a/test/spec/ol/geom/flat/inflate.test.js +++ b/test/spec/ol/geom/flat/inflate.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.inflate'); +import _ol_geom_flat_inflate_ from '../../../../../src/ol/geom/flat/inflate.js'; describe('ol.geom.flat.inflate', function() { @@ -8,7 +6,7 @@ describe('ol.geom.flat.inflate', function() { describe('ol.geom.flat.inflate.coordinates', function() { it('inflates coordinates', function() { - var coordinates = ol.geom.flat.inflate.coordinates([1, 2, 3, 4], 0, 4, 2); + var coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2); expect(coordinates).to.eql([[1, 2], [3, 4]]); }); @@ -17,7 +15,7 @@ describe('ol.geom.flat.inflate', function() { describe('ol.geom.flat.inflate.coordinatess', function() { it('inflates arrays of coordinates', function() { - var coordinatess = ol.geom.flat.inflate.coordinatess( + var coordinatess = _ol_geom_flat_inflate_.coordinatess( [1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2); expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]); }); diff --git a/test/spec/ol/geom/flat/interpolate.test.js b/test/spec/ol/geom/flat/interpolate.test.js index fd11ef5915..de0e1659a5 100644 --- a/test/spec/ol/geom/flat/interpolate.test.js +++ b/test/spec/ol/geom/flat/interpolate.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.interpolate'); +import _ol_geom_flat_interpolate_ from '../../../../../src/ol/geom/flat/interpolate.js'; describe('ol.geom.flat.interpolate', function() { @@ -10,14 +8,14 @@ describe('ol.geom.flat.interpolate', function() { it('returns the expected value for single points', function() { var flatCoordinates = [0, 1]; var point = - ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 2, 2, 0.5); + _ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 2, 2, 0.5); expect(point).to.eql([0, 1]); }); it('returns the expected value for simple line segments', function() { var flatCoordinates = [0, 1, 2, 3]; var point = - ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 4, 2, 0.5); + _ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 4, 2, 0.5); expect(point).to.eql([1, 2]); }); @@ -25,14 +23,14 @@ describe('ol.geom.flat.interpolate', function() { 'coordinate', function() { var flatCoordinates = [0, 1, 2, 3, 4, 5]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 6, 2, 0.5); expect(point).to.eql([2, 3]); }); xit('also when vertices are repeated', function() { var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 6, 2, 0.5); expect(point).to.eql([2, 3]); }); @@ -41,14 +39,14 @@ describe('ol.geom.flat.interpolate', function() { 'two existing coordinates', function() { var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 8, 2, 0.5); expect(point).to.eql([3, 4]); }); xit('also when vertices are repeated', function() { var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 8, 2, 0.5); expect(point).to.eql([3, 4]); }); @@ -56,7 +54,7 @@ describe('ol.geom.flat.interpolate', function() { it('returns the expected value when the coordinates are not evenly spaced', function() { var flatCoordinates = [0, 1, 2, 3, 6, 7]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 6, 2, 0.5); expect(point).to.eql([3, 4]); }); @@ -64,7 +62,7 @@ describe('ol.geom.flat.interpolate', function() { xit('also when vertices are repeated', function() { var flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 6, 2, 0.5); expect(point).to.eql([3, 4]); }); @@ -72,7 +70,7 @@ describe('ol.geom.flat.interpolate', function() { it('returns the expected value when using opt_dest', function() { var flatCoordinates = [0, 1, 2, 3, 6, 7]; - var point = ol.geom.flat.interpolate.lineString( + var point = _ol_geom_flat_interpolate_.lineString( flatCoordinates, 0, 6, 2, 0.5, [0, 0]); expect(point).to.eql([3, 4]); }); diff --git a/test/spec/ol/geom/flat/intersectsextent.test.js b/test/spec/ol/geom/flat/intersectsextent.test.js index e86be1ffbd..6f17e28ae3 100644 --- a/test/spec/ol/geom/flat/intersectsextent.test.js +++ b/test/spec/ol/geom/flat/intersectsextent.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.intersectsextent'); +import _ol_geom_flat_intersectsextent_ from '../../../../../src/ol/geom/flat/intersectsextent.js'; describe('ol.geom.flat.intersectsextent', function() { @@ -13,7 +11,7 @@ describe('ol.geom.flat.intersectsextent', function() { describe('linestring envelope does not intersect the extent', function() { it('returns false', function() { var extent = [3, 3, 4, 4]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(false); }); @@ -21,7 +19,7 @@ describe('ol.geom.flat.intersectsextent', function() { describe('linestring envelope within the extent', function() { it('returns true', function() { var extent = [-1, -1, 3, 3]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(true); }); @@ -30,7 +28,7 @@ describe('ol.geom.flat.intersectsextent', function() { function() { it('returns true', function() { var extent = [-0.1, 0.1, 2.1, 0.1]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(true); }); @@ -38,7 +36,7 @@ describe('ol.geom.flat.intersectsextent', function() { describe('a segment intersects the extent', function() { it('returns true', function() { var extent = [-0.5, -0.5, 0.5, 0.5]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(true); }); @@ -46,13 +44,13 @@ describe('ol.geom.flat.intersectsextent', function() { describe('no segments intersect the extent', function() { it('returns false', function() { var extent = [0.5, 1.5, 1, 1.75]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(false); }); it('returns false', function() { var extent = [1, 0.25, 1.5, 0.5]; - var r = ol.geom.flat.intersectsextent.lineString( + var r = _ol_geom_flat_intersectsextent_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(false); }); @@ -67,7 +65,7 @@ describe('ol.geom.flat.intersectsextent', function() { describe('boundary intersects the extent', function() { it('returns true', function() { var extent = [1.5, 0.0, 2.5, 1.0]; - var r = ol.geom.flat.intersectsextent.linearRing( + var r = _ol_geom_flat_intersectsextent_.linearRing( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(true); }); @@ -77,7 +75,7 @@ describe('ol.geom.flat.intersectsextent', function() { function() { it('returns false', function() { var extent = [2.0, 0.5, 3, 1.5]; - var r = ol.geom.flat.intersectsextent.linearRing( + var r = _ol_geom_flat_intersectsextent_.linearRing( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(false); }); @@ -85,7 +83,7 @@ describe('ol.geom.flat.intersectsextent', function() { describe('ring contains the extent', function() { it('returns true', function() { var extent = [0.75, -0.25, 1.25, 0.25]; - var r = ol.geom.flat.intersectsextent.linearRing( + var r = _ol_geom_flat_intersectsextent_.linearRing( flatCoordinates, 0, flatCoordinates.length, 2, extent); expect(r).to.be(true); }); diff --git a/test/spec/ol/geom/flat/length.test.js b/test/spec/ol/geom/flat/length.test.js index f600399c45..5e34a743ee 100644 --- a/test/spec/ol/geom/flat/length.test.js +++ b/test/spec/ol/geom/flat/length.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.length'); +import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js'; describe('ol.geom.flat.length', function() { @@ -15,7 +13,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 8; var expected = 3; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -23,7 +21,7 @@ describe('ol.geom.flat.length', function() { var offset = 2; var end = 8; var expected = 2; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -31,7 +29,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 4; var expected = 1; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -45,7 +43,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 12; var expected = 3; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -53,7 +51,7 @@ describe('ol.geom.flat.length', function() { var offset = 3; var end = 12; var expected = 2; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -61,7 +59,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 6; var expected = 1; - var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -76,7 +74,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 8; var expected = 4; - var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride); expect(got).to.be(expected); }); @@ -86,7 +84,7 @@ describe('ol.geom.flat.length', function() { var offset = 0; var end = 14; var expected = 8; - var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride); + var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride); expect(got).to.be(expected); }); diff --git a/test/spec/ol/geom/flat/orient.test.js b/test/spec/ol/geom/flat/orient.test.js index ca28fbc2e7..e5493a1fa0 100644 --- a/test/spec/ol/geom/flat/orient.test.js +++ b/test/spec/ol/geom/flat/orient.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.orient'); +import _ol_geom_flat_orient_ from '../../../../../src/ol/geom/flat/orient.js'; describe('ol.geom.flat.orient', function() { @@ -9,14 +7,14 @@ describe('ol.geom.flat.orient', function() { it('identifies clockwise rings', function() { var flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0]; - var isClockwise = ol.geom.flat.orient.linearRingIsClockwise( + var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise( flatCoordinates, 0, flatCoordinates.length, 2); expect(isClockwise).to.be(true); }); it('identifies anti-clockwise rings', function() { var flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3]; - var isClockwise = ol.geom.flat.orient.linearRingIsClockwise( + var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise( flatCoordinates, 0, flatCoordinates.length, 2); expect(isClockwise).to.be(false); }); @@ -24,7 +22,7 @@ describe('ol.geom.flat.orient', function() { }); describe('ol.geom.flat.orient.linearRingsAreOriented()', function() { - var oriented = ol.geom.flat.orient.linearRingsAreOriented; + var oriented = _ol_geom_flat_orient_.linearRingsAreOriented; var rightCoords = [ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90, @@ -51,7 +49,7 @@ describe('ol.geom.flat.orient', function() { }); describe('ol.geom.flat.orient.linearRingssAreOriented()', function() { - var oriented = ol.geom.flat.orient.linearRingssAreOriented; + var oriented = _ol_geom_flat_orient_.linearRingssAreOriented; var rightCoords = [ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90, @@ -82,7 +80,7 @@ describe('ol.geom.flat.orient', function() { }); describe('ol.geom.flat.orient.orientLinearRings()', function() { - var orient = ol.geom.flat.orient.orientLinearRings; + var orient = _ol_geom_flat_orient_.orientLinearRings; var rightCoords = [ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90, @@ -119,7 +117,7 @@ describe('ol.geom.flat.orient', function() { }); describe('ol.geom.flat.orient.orientLinearRingss()', function() { - var orient = ol.geom.flat.orient.orientLinearRingss; + var orient = _ol_geom_flat_orient_.orientLinearRingss; var rightCoords = [ -180, -90, 180, -90, 180, 90, -180, 90, -180, -90, diff --git a/test/spec/ol/geom/flat/reverse.test.js b/test/spec/ol/geom/flat/reverse.test.js index 333903554f..559da54105 100644 --- a/test/spec/ol/geom/flat/reverse.test.js +++ b/test/spec/ol/geom/flat/reverse.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.reverse'); +import _ol_geom_flat_reverse_ from '../../../../../src/ol/geom/flat/reverse.js'; describe('ol.geom.flat.reverse', function() { @@ -11,35 +9,35 @@ describe('ol.geom.flat.reverse', function() { it('can reverse empty flat coordinates', function() { var flatCoordinates = []; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 2); expect(flatCoordinates).to.be.empty(); }); it('can reverse one flat coordinates', function() { var flatCoordinates = [1, 2]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 2); expect(flatCoordinates).to.eql([1, 2]); }); it('can reverse two flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 2); expect(flatCoordinates).to.eql([3, 4, 1, 2]); }); it('can reverse three flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 2); expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]); }); it('can reverse four flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 2); expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]); }); @@ -50,35 +48,35 @@ describe('ol.geom.flat.reverse', function() { it('can reverse empty flat coordinates', function() { var flatCoordinates = []; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 3); expect(flatCoordinates).to.be.empty(); }); it('can reverse one flat coordinates', function() { var flatCoordinates = [1, 2, 3]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 3); expect(flatCoordinates).to.eql([1, 2, 3]); }); it('can reverse two flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 3); expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]); }); it('can reverse three flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 3); expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]); }); it('can reverse four flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 3); expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]); }); @@ -89,28 +87,28 @@ describe('ol.geom.flat.reverse', function() { it('can reverse empty flat coordinates', function() { var flatCoordinates = []; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 4); expect(flatCoordinates).to.be.empty(); }); it('can reverse one flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 4); expect(flatCoordinates).to.eql([1, 2, 3, 4]); }); it('can reverse two flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 4); expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]); }); it('can reverse three flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 4); expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]); }); @@ -118,7 +116,7 @@ describe('ol.geom.flat.reverse', function() { it('can reverse four flat coordinates', function() { var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - ol.geom.flat.reverse.coordinates( + _ol_geom_flat_reverse_.coordinates( flatCoordinates, 0, flatCoordinates.length, 4); expect(flatCoordinates).to.eql( [13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]); diff --git a/test/spec/ol/geom/flat/segments.test.js b/test/spec/ol/geom/flat/segments.test.js index 46adb5b854..0abf3fb7ae 100644 --- a/test/spec/ol/geom/flat/segments.test.js +++ b/test/spec/ol/geom/flat/segments.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.segments'); +import _ol_geom_flat_segments_ from '../../../../../src/ol/geom/flat/segments.js'; describe('ol.geom.flat.segments', function() { @@ -19,7 +17,7 @@ describe('ol.geom.flat.segments', function() { var spy = sinon.spy(function(point1, point2) { args.push([point1[0], point1[1], point2[0], point2[1]]); }); - var ret = ol.geom.flat.segments.forEach( + var ret = _ol_geom_flat_segments_.forEach( flatCoordinates, offset, end, stride, spy); expect(spy.callCount).to.be(3); expect(args[0][0]).to.be(0); @@ -44,7 +42,7 @@ describe('ol.geom.flat.segments', function() { args.push([point1[0], point1[1], point2[0], point2[1]]); return true; }); - var ret = ol.geom.flat.segments.forEach( + var ret = _ol_geom_flat_segments_.forEach( flatCoordinates, offset, end, stride, spy); expect(spy.callCount).to.be(1); expect(args[0][0]).to.be(0); diff --git a/test/spec/ol/geom/flat/simplify.test.js b/test/spec/ol/geom/flat/simplify.test.js index dbabfc7c97..546cf7c574 100644 --- a/test/spec/ol/geom/flat/simplify.test.js +++ b/test/spec/ol/geom/flat/simplify.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.simplify'); +import _ol_geom_flat_simplify_ from '../../../../../src/ol/geom/flat/simplify.js'; describe('ol.geom.flat.simplify', function() { @@ -86,28 +84,28 @@ describe('ol.geom.flat.simplify', function() { describe('ol.geom.flat.simplify.lineString', function() { it('works with empty line strings', function() { - expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, true)).to. + expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, true)).to. eql([]); - expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, false)).to. + expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, false)).to. eql([]); }); it('works with a line string with a single point', function() { - expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, true)).to. + expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, true)).to. eql([1, 2]); - expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, false)).to. + expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, false)).to. eql([1, 2]); }); it('returns the expected result with low quality', function() { - var result = ol.geom.flat.simplify.lineString( + var result = _ol_geom_flat_simplify_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, 25, false); expect(result.length).to.be(simplifiedFlatCoordinates.length); expect(result).to.eql(simplifiedFlatCoordinates); }); it('returns the expected result with high quality', function() { - var result = ol.geom.flat.simplify.lineString( + var result = _ol_geom_flat_simplify_.lineString( flatCoordinates, 0, flatCoordinates.length, 2, 25, true); expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length); expect(result).to.eql(simplifiedHighQualityFlatCoordinates); @@ -123,63 +121,63 @@ describe('ol.geom.flat.simplify', function() { }); it('works with empty line strings', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [], 0, 0, 2, 1, dest, 0)).to.be(0); expect(dest).to.eql([]); }); it('works with a line string with a single point', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [1, 2], 0, 2, 2, 1, dest, 0)).to.be(2); expect(dest).to.eql([1, 2]); }); it('works with a line string with two points', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4); expect(dest).to.eql([1, 2, 3, 4]); }); it('works when the points are widely spaced', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8); expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]); }); it('works when the spacing matches the tolerance', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6); expect(dest).to.eql([0, 0, 2, 0, 3, 0]); }); it('works when the points are closely spaced', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6); expect(dest).to.eql([0, 0, 2, 0, 3, 0]); }); it('works when the line oscillates with widely spaced points', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)). to.be(12); expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]); }); it('works when the line oscillates with closely spaced points', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 1, 1]); }); it('works when the line oscillates within the tolerance', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)). to.be(2); expect(dest).to.eql([0, 0]); }); it('works with real data', function() { - expect(ol.geom.flat.simplify.radialDistance( + expect(_ol_geom_flat_simplify_.radialDistance( flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)). to.be(simplifiedRadiallyFlatCoordinates.length); expect(dest).to.eql(simplifiedRadiallyFlatCoordinates); @@ -195,93 +193,93 @@ describe('ol.geom.flat.simplify', function() { }); it('works with empty line strings', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [], 0, 0, 2, 1, dest, 0)).to.be(0); expect(dest).to.eql([]); }); it('works with a line string with a single point', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [1, 2], 0, 2, 2, 1, dest, 0)).to.be(2); expect(dest).to.eql([1, 2]); }); it('works with a line string with two points', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4); expect(dest).to.eql([1, 2, 3, 4]); }); it('works when the points are widely spaced', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 3, 0]); }); it('works when the spacing matches the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 3, 0]); }); it('works when the points are closely spaced', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 3, 0]); }); it('does not elimnate points outside the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6); expect(dest).to.eql([0, 0, 1, 1, 2, 0]); }); it('does eliminate points within the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 2, 0]); }); it('does not eliminate multiple points outside the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8); expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]); }); it('does eliminate multiple points within the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 2, 0]); }); it('works when the line oscillates with widely spaced points', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4); expect(dest).to.eql([0, 0, 1, 1]); }); it('works when the line oscillates with closely spaced points', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)). to.be(4); expect(dest).to.eql([0, 0, 1, 1]); }); it('works when the line oscillates within the tolerance', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)). to.be(4); expect(dest).to.eql([0, 0, 0, 0]); }); it('works on small triangles', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( [3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6); expect(dest).to.eql([3, 0, 5, 2, 5, 0]); }); it('is the same as high quality simplification', function() { - expect(ol.geom.flat.simplify.douglasPeucker( + expect(_ol_geom_flat_simplify_.douglasPeucker( flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)). to.be(simplifiedHighQualityFlatCoordinates.length); expect(dest).to.eql(simplifiedHighQualityFlatCoordinates); @@ -293,28 +291,28 @@ describe('ol.geom.flat.simplify', function() { it('handles empty coordinates', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0); expect(simplifiedFlatCoordinates).to.be.empty(); }); it('expands points to a zero-length line', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]); }); it('snaps near-by points to the same value', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]); }); it('eliminates duplicate snapped points', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]); @@ -322,7 +320,7 @@ describe('ol.geom.flat.simplify', function() { it('eliminates horizontal colinear points', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]); @@ -330,7 +328,7 @@ describe('ol.geom.flat.simplify', function() { it('eliminates vertical colinear points', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]); @@ -338,7 +336,7 @@ describe('ol.geom.flat.simplify', function() { it('eliminates diagonal colinear points', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4); expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]); @@ -346,7 +344,7 @@ describe('ol.geom.flat.simplify', function() { it('handles switchbacks', function() { var simplifiedFlatCoordinates = []; - expect(ol.geom.flat.simplify.quantize( + expect(_ol_geom_flat_simplify_.quantize( [0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2, simplifiedFlatCoordinates, 0)).to.be(8); expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]); diff --git a/test/spec/ol/geom/flat/straightchunk.test.js b/test/spec/ol/geom/flat/straightchunk.test.js index 4b645d8d58..a92cf2a9a1 100644 --- a/test/spec/ol/geom/flat/straightchunk.test.js +++ b/test/spec/ol/geom/flat/straightchunk.test.js @@ -1,4 +1,4 @@ -goog.require('ol.geom.flat.straightchunk'); +import _ol_geom_flat_straightchunk_ from '../../../../../src/ol/geom/flat/straightchunk.js'; describe('ol.geom.flat.straightchunk', function() { @@ -10,12 +10,12 @@ describe('ol.geom.flat.straightchunk', function() { var stride = 3; it('returns whole line with angle delta', function() { - var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 6, stride); + var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 6, stride); expect(got).to.eql([0, 6]); }); it('returns whole line with zero angle delta', function() { - var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 6, stride); + var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 6, stride); expect(got).to.eql([0, 6]); }); @@ -26,12 +26,12 @@ describe('ol.geom.flat.straightchunk', function() { var stride = 2; it('returns whole line if straight enough', function() { - var got = ol.geom.flat.straightchunk.lineString(Math.PI, flatCoords, 0, 8, stride); + var got = _ol_geom_flat_straightchunk_.lineString(Math.PI, flatCoords, 0, 8, stride); expect(got).to.eql([0, 8]); }); it('returns first matching chunk if all chunk lengths are the same', function() { - var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 8, stride); + var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 8, stride); expect(got).to.eql([0, 4]); }); @@ -42,12 +42,12 @@ describe('ol.geom.flat.straightchunk', function() { var stride = 2; it('returns stright chunk from within the linestring', function() { - var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 18, stride); + var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 18, stride); expect(got).to.eql([10, 16]); }); it('returns long chunk at the end if angle and length within threshold', function() { - var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 18, stride); + var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 18, stride); expect(got).to.eql([10, 18]); }); diff --git a/test/spec/ol/geom/flat/textpath.test.js b/test/spec/ol/geom/flat/textpath.test.js index 64fca500ee..30e4f3216c 100644 --- a/test/spec/ol/geom/flat/textpath.test.js +++ b/test/spec/ol/geom/flat/textpath.test.js @@ -1,5 +1,5 @@ -goog.require('ol.geom.flat.textpath'); -goog.require('ol.geom.flat.length'); +import _ol_geom_flat_textpath_ from '../../../../../src/ol/geom/flat/textpath.js'; +import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js'; describe('textpath', function() { @@ -16,27 +16,27 @@ describe('textpath', function() { it('center-aligns text on a horizontal line', function() { var startM = 50 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity); expect(instructions).to.eql([[40, 0, 5, 0, 'foo']]); }); it('left-aligns text on a horizontal line', function() { - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity); expect(instructions).to.eql([[5, 0, 5, 0, 'foo']]); }); it('right-aligns text on a horizontal line', function() { var startM = 100 - 30; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity); expect(instructions).to.eql([[75, 0, 5, 0, 'foo']]); }); it('draws text on a vertical line', function() { var startM = 50 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity); var a = 90 * Math.PI / 180; expect(instructions).to.eql([[0, 40, 5, a, 'foo']]); @@ -44,7 +44,7 @@ describe('textpath', function() { it('draws text on a diagonal line', function() { var startM = Math.sqrt(2) * 50 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity); expect(instructions[0][3]).to.be(45 * Math.PI / 180); expect(instructions.length).to.be(1); @@ -52,7 +52,7 @@ describe('textpath', function() { it('draws reverse text on a diagonal line', function() { var startM = Math.sqrt(2) * 50 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity); expect(instructions[0][3]).to.be(-45 * Math.PI / 180); expect(instructions.length).to.be(1); @@ -60,16 +60,16 @@ describe('textpath', function() { it('renders long text with extrapolation', function() { var startM = 50 - 75; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity); expect(instructions[0]).to.eql([-20, 0, 5, 0, 'foo-foo-foo-foo']); expect(instructions.length).to.be(1); }); it('renders angled text', function() { - var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2); + var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2); var startM = length / 2 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( angled, 0, angled.length, 2, 'foo', measure, startM, Infinity); expect(instructions[0][3]).to.eql(45 * Math.PI / 180); expect(instructions[0][4]).to.be('fo'); @@ -78,34 +78,34 @@ describe('textpath', function() { }); it('respects maxAngle', function() { - var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2); + var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2); var startM = length / 2 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4); expect(instructions).to.be(null); }); it('uses the smallest angle for maxAngleDelta', function() { - var length = ol.geom.flat.length.lineString(reverseangled, 0, reverseangled.length, 2); + var length = _ol_geom_flat_length_.lineString(reverseangled, 0, reverseangled.length, 2); var startM = length / 2 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI); expect(instructions).to.not.be(undefined); }); it('respects the offset option', function() { - var length = ol.geom.flat.length.lineString(angled, 2, angled.length, 2); + var length = _ol_geom_flat_length_.lineString(angled, 2, angled.length, 2); var startM = length / 2 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( angled, 2, angled.length, 2, 'foo', measure, startM, Infinity); expect(instructions[0][3]).to.be(-45 * Math.PI / 180); expect(instructions.length).to.be(1); }); it('respects the end option', function() { - var length = ol.geom.flat.length.lineString(angled, 0, 4, 2); + var length = _ol_geom_flat_length_.lineString(angled, 0, 4, 2); var startM = length / 2 - 15; - var instructions = ol.geom.flat.textpath.lineString( + var instructions = _ol_geom_flat_textpath_.lineString( angled, 0, 4, 2, 'foo', measure, startM, Infinity); expect(instructions[0][3]).to.be(45 * Math.PI / 180); expect(instructions.length).to.be(1); diff --git a/test/spec/ol/geom/flat/topologyflatgeom.test.js b/test/spec/ol/geom/flat/topologyflatgeom.test.js index 157a0d8df2..714f76ea1e 100644 --- a/test/spec/ol/geom/flat/topologyflatgeom.test.js +++ b/test/spec/ol/geom/flat/topologyflatgeom.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.geom.flat.topology'); +import _ol_geom_flat_topology_ from '../../../../../src/ol/geom/flat/topology.js'; describe('ol.geom.flat.topology', function() { @@ -8,23 +6,23 @@ describe('ol.geom.flat.topology', function() { it('identifies closed lines aka boundaries', function() { var flatCoordinates = [0, 0, 3, 0, 0, 3, 0, 0]; - var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); + var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); expect(isClosed).to.be(true); }); it('identifies regular linestrings', function() { var flatCoordinates = [0, 0, 3, 0, 0, 3, 5, 2]; - var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); + var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); expect(isClosed).to.be(false); }); it('identifies degenerate boundaries', function() { var flatCoordinates = [0, 0, 3, 0, 0, 0]; - var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); + var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); expect(isClosed).to.be(false); flatCoordinates = [0, 0, 1, 1, 3, 3, 5, 5, 0, 0]; - isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); + isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2); expect(isClosed).to.be(false); }); diff --git a/test/spec/ol/geom/flat/transform.test.js b/test/spec/ol/geom/flat/transform.test.js index f52cb37fb9..38d984b535 100644 --- a/test/spec/ol/geom/flat/transform.test.js +++ b/test/spec/ol/geom/flat/transform.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.SimpleGeometry'); -goog.require('ol.geom.flat.transform'); +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_SimpleGeometry_ from '../../../../../src/ol/geom/SimpleGeometry.js'; +import _ol_geom_flat_transform_ from '../../../../../src/ol/geom/flat/transform.js'; describe('ol.geom.flat.transform', function() { @@ -11,7 +9,7 @@ describe('ol.geom.flat.transform', function() { it('transforms a Simple Geometry to 2D', function() { - var multiPolygonGeometry = new ol.geom.MultiPolygon([ + var multiPolygonGeometry = new _ol_geom_MultiPolygon_([ [[[-80.736061, 28.788576000000006, 0], [-80.763557, 28.821799999999996, 0], [-80.817406, 28.895123999999996, 0], @@ -33,7 +31,7 @@ describe('ol.geom.flat.transform', function() { 0, -0.0004088332670837288, 4480.991370439071, 1529.5752568707105 ]; - var pixelCoordinates = ol.geom.SimpleGeometry.transform2D( + var pixelCoordinates = _ol_geom_SimpleGeometry_.transform2D( multiPolygonGeometry, transform, []); expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9); expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9); @@ -71,13 +69,13 @@ describe('ol.geom.flat.transform', function() { describe('ol.geom.flat.transform.translate', function() { it('translates the coordinates array', function() { - var multiPolygon = new ol.geom.MultiPolygon([ + var multiPolygon = new _ol_geom_MultiPolygon_([ [[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]], [[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]); var flatCoordinates = multiPolygon.getFlatCoordinates(); var deltaX = 1; var deltaY = 2; - ol.geom.flat.transform.translate(flatCoordinates, 0, + _ol_geom_flat_transform_.translate(flatCoordinates, 0, flatCoordinates.length, multiPolygon.getStride(), deltaX, deltaY, flatCoordinates); expect(flatCoordinates).to.eql([ @@ -88,13 +86,13 @@ describe('ol.geom.flat.transform', function() { describe('ol.geom.flat.transform.rotate', function() { it('rotates the coordinates array', function() { - var multiPolygon = new ol.geom.MultiPolygon([ + var multiPolygon = new _ol_geom_MultiPolygon_([ [[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]], [[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]); var flatCoordinates = multiPolygon.getFlatCoordinates(); var angle = Math.PI / 2; var anchor = [0, 1]; - ol.geom.flat.transform.rotate(flatCoordinates, 0, + _ol_geom_flat_transform_.rotate(flatCoordinates, 0, flatCoordinates.length, multiPolygon.getStride(), angle, anchor, flatCoordinates); expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9); diff --git a/test/spec/ol/geom/geometrycollection.test.js b/test/spec/ol/geom/geometrycollection.test.js index 2024fdd361..e4b337ddf8 100644 --- a/test/spec/ol/geom/geometrycollection.test.js +++ b/test/spec/ol/geom/geometrycollection.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.geom.Geometry'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); +import _ol_geom_Geometry_ from '../../../../src/ol/geom/Geometry.js'; +import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; describe('ol.geom.GeometryCollection', function() { @@ -16,15 +14,15 @@ describe('ol.geom.GeometryCollection', function() { var line, multi, point, poly; beforeEach(function() { - point = new ol.geom.Point([10, 20]); - line = new ol.geom.LineString([[10, 20], [30, 40]]); - poly = new ol.geom.Polygon([outer, inner1, inner2]); - multi = new ol.geom.GeometryCollection([point, line, poly]); + point = new _ol_geom_Point_([10, 20]); + line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + poly = new _ol_geom_Polygon_([outer, inner1, inner2]); + multi = new _ol_geom_GeometryCollection_([point, line, poly]); }); it('creates a geometry collection from an array of geometries', function() { - expect(multi).to.be.a(ol.geom.GeometryCollection); - expect(multi).to.be.a(ol.geom.Geometry); + expect(multi).to.be.a(_ol_geom_GeometryCollection_); + expect(multi).to.be.a(_ol_geom_Geometry_); }); it('fires a change event when one of its component changes', @@ -45,7 +43,7 @@ describe('ol.geom.GeometryCollection', function() { }); it('register new components', function(done) { - var point2 = new ol.geom.Point([10, 20]); + var point2 = new _ol_geom_Point_([10, 20]); multi.setGeometriesArray([point2]); multi.on('change', function() { done(); @@ -58,17 +56,17 @@ describe('ol.geom.GeometryCollection', function() { describe('#getGeometries', function() { it('returns a collection of geometries', function() { - var point = new ol.geom.Point([10, 20]); - var line = new ol.geom.LineString([[10, 20], [30, 40]]); - var poly = new ol.geom.Polygon([outer, inner1, inner2]); - var multi = new ol.geom.GeometryCollection([point, line, poly]); + var point = new _ol_geom_Point_([10, 20]); + var line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + var poly = new _ol_geom_Polygon_([outer, inner1, inner2]); + var multi = new _ol_geom_GeometryCollection_([point, line, poly]); var geometries = multi.getGeometries(); expect(geometries).to.be.an(Array); expect(geometries).to.have.length(3); - expect(geometries[0]).to.be.a(ol.geom.Point); - expect(geometries[1]).to.be.a(ol.geom.LineString); - expect(geometries[2]).to.be.a(ol.geom.Polygon); + expect(geometries[0]).to.be.a(_ol_geom_Point_); + expect(geometries[1]).to.be.a(_ol_geom_LineString_); + expect(geometries[2]).to.be.a(_ol_geom_Polygon_); }); }); @@ -76,10 +74,10 @@ describe('ol.geom.GeometryCollection', function() { describe('#clone()', function() { it('has a working clone method', function() { - var point = new ol.geom.Point([10, 20]); - var line = new ol.geom.LineString([[10, 20], [30, 40]]); - var poly = new ol.geom.Polygon([outer, inner1, inner2]); - var multi = new ol.geom.GeometryCollection([point, line, poly]); + var point = new _ol_geom_Point_([10, 20]); + var line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + var poly = new _ol_geom_Polygon_([outer, inner1, inner2]); + var multi = new _ol_geom_GeometryCollection_([point, line, poly]); var clone = multi.clone(); expect(clone).to.not.be(multi); var geometries = clone.getGeometries(); @@ -89,9 +87,9 @@ describe('ol.geom.GeometryCollection', function() { }); it('does a deep clone', function() { - var point = new ol.geom.Point([30, 40]); + var point = new _ol_geom_Point_([30, 40]); var originalGeometries = [point]; - var multi = new ol.geom.GeometryCollection(originalGeometries); + var multi = new _ol_geom_GeometryCollection_(originalGeometries); var clone = multi.clone(); var clonedGeometries = clone.getGeometries(); expect(clonedGeometries).not.to.be(originalGeometries); @@ -107,9 +105,9 @@ describe('ol.geom.GeometryCollection', function() { describe('#getExtent()', function() { it('returns the bounding extent', function() { - var point = new ol.geom.Point([10, 2]); - var line = new ol.geom.LineString([[1, 20], [30, 40]]); - var multi = new ol.geom.GeometryCollection([point, line]); + var point = new _ol_geom_Point_([10, 2]); + var line = new _ol_geom_LineString_([[1, 20], [30, 40]]); + var multi = new _ol_geom_GeometryCollection_([point, line]); var extent = multi.getExtent(); expect(extent[0]).to.be(1); expect(extent[2]).to.be(30); @@ -124,10 +122,10 @@ describe('ol.geom.GeometryCollection', function() { var point, line, poly, multi; beforeEach(function() { - point = new ol.geom.Point([5, 20]); - line = new ol.geom.LineString([[10, 20], [30, 40]]); - poly = new ol.geom.Polygon([outer, inner1, inner2]); - multi = new ol.geom.GeometryCollection([point, line, poly]); + point = new _ol_geom_Point_([5, 20]); + line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + poly = new _ol_geom_Polygon_([outer, inner1, inner2]); + multi = new _ol_geom_GeometryCollection_([point, line, poly]); }); it('returns true for intersecting point', function() { @@ -153,10 +151,10 @@ describe('ol.geom.GeometryCollection', function() { var line, multi, point, poly; beforeEach(function() { - point = new ol.geom.Point([10, 20]); - line = new ol.geom.LineString([[10, 20], [30, 40]]); - poly = new ol.geom.Polygon([outer, inner1, inner2]); - multi = new ol.geom.GeometryCollection([point, line, poly]); + point = new _ol_geom_Point_([10, 20]); + line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + poly = new _ol_geom_Polygon_([outer, inner1, inner2]); + multi = new _ol_geom_GeometryCollection_([point, line, poly]); }); it('fires a change event', function() { @@ -177,9 +175,9 @@ describe('ol.geom.GeometryCollection', function() { describe('#scale()', function() { it('scales a collection', function() { - var geom = new ol.geom.GeometryCollection([ - new ol.geom.Point([-1, -2]), - new ol.geom.LineString([[0, 0], [1, 2]]) + var geom = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([-1, -2]), + new _ol_geom_LineString_([[0, 0], [1, 2]]) ]); geom.scale(10); var geometries = geom.getGeometries(); @@ -188,9 +186,9 @@ describe('ol.geom.GeometryCollection', function() { }); it('accepts sx and sy', function() { - var geom = new ol.geom.GeometryCollection([ - new ol.geom.Point([-1, -2]), - new ol.geom.LineString([[0, 0], [1, 2]]) + var geom = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([-1, -2]), + new _ol_geom_LineString_([[0, 0], [1, 2]]) ]); geom.scale(2, 3); var geometries = geom.getGeometries(); @@ -199,9 +197,9 @@ describe('ol.geom.GeometryCollection', function() { }); it('accepts an anchor', function() { - var geom = new ol.geom.GeometryCollection([ - new ol.geom.Point([-1, -2]), - new ol.geom.LineString([[0, 0], [1, 2]]) + var geom = new _ol_geom_GeometryCollection_([ + new _ol_geom_Point_([-1, -2]), + new _ol_geom_LineString_([[0, 0], [1, 2]]) ]); geom.scale(10, 15, [-1, -2]); var geometries = geom.getGeometries(); @@ -215,17 +213,17 @@ describe('ol.geom.GeometryCollection', function() { var line, multi, point; beforeEach(function() { - point = new ol.geom.Point([10, 20]); - line = new ol.geom.LineString([[10, 20], [30, 40]]); - multi = new ol.geom.GeometryCollection([point, line]); + point = new _ol_geom_Point_([10, 20]); + line = new _ol_geom_LineString_([[10, 20], [30, 40]]); + multi = new _ol_geom_GeometryCollection_([point, line]); }); it('transforms all geometries', function() { multi.transform('EPSG:4326', 'EPSG:3857'); var geometries = multi.getGeometries(); - expect(geometries[0]).to.be.a(ol.geom.Point); - expect(geometries[1]).to.be.a(ol.geom.LineString); + expect(geometries[0]).to.be.a(_ol_geom_Point_); + expect(geometries[1]).to.be.a(_ol_geom_LineString_); var coords = geometries[0].getCoordinates(); expect(coords[0]).to.roughlyEqual(1113194.90, 1e-2); diff --git a/test/spec/ol/geom/linestring.test.js b/test/spec/ol/geom/linestring.test.js index 971e5e4cc8..39e0d1cc7e 100644 --- a/test/spec/ol/geom/linestring.test.js +++ b/test/spec/ol/geom/linestring.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.extent'); -goog.require('ol.geom.LineString'); +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; describe('ol.geom.LineString', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.LineString(null); + return new _ol_geom_LineString_(null); }).not.to.throwException(); }); @@ -16,7 +14,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString([]); + lineString = new _ol_geom_LineString_([]); }); it('defaults to layout XY', function() { @@ -28,7 +26,7 @@ describe('ol.geom.LineString', function() { }); it('has an empty extent', function() { - expect(ol.extent.isEmpty(lineString.getExtent())).to.be(true); + expect(_ol_extent_.isEmpty(lineString.getExtent())).to.be(true); }); it('has empty flat coordinates', function() { @@ -52,7 +50,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString([[1, 2], [3, 4]]); + lineString = new _ol_geom_LineString_([[1, 2], [3, 4]]); }); it('has the expected layout', function() { @@ -113,7 +111,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString([[1, 2, 3], [4, 5, 6]]); + lineString = new _ol_geom_LineString_([[1, 2, 3], [4, 5, 6]]); }); it('has the expected layout', function() { @@ -158,7 +156,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString( + lineString = new _ol_geom_LineString_( [[1, 2, 3], [4, 5, 6]], 'XYM'); }); @@ -204,7 +202,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString([[1, 2, 3, 4], [5, 6, 7, 8]]); + lineString = new _ol_geom_LineString_([[1, 2, 3, 4], [5, 6, 7, 8]]); }); it('has the expected layout', function() { @@ -248,21 +246,21 @@ describe('ol.geom.LineString', function() { describe('#scale()', function() { it('scales a linestring', function() { - var geom = new ol.geom.LineString([[-10, -20], [10, 20]]); + var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]); geom.scale(10); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-100, -200], [100, 200]]); }); it('accepts sx and sy', function() { - var geom = new ol.geom.LineString([[-10, -20], [10, 20]]); + var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]); geom.scale(2, 3); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-20, -60], [20, 60]]); }); it('accepts an anchor', function() { - var geom = new ol.geom.LineString([[-10, -20], [10, 20]]); + var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]); geom.scale(3, 2, [10, 20]); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-50, -60], [10, 20]]); @@ -274,7 +272,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString( + lineString = new _ol_geom_LineString_( [[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]); }); @@ -310,7 +308,7 @@ describe('ol.geom.LineString', function() { it('returns a simplified geometry', function() { var simplified = lineString.simplify(1); - expect(simplified).to.be.an(ol.geom.LineString); + expect(simplified).to.be.an(_ol_geom_LineString_); expect(simplified.getCoordinates()).to.eql( [[0, 0], [3, 3], [5, 1], [7, 5]]); }); @@ -333,7 +331,7 @@ describe('ol.geom.LineString', function() { it('returns the expectedResult', function() { var simplifiedGeometry = lineString.getSimplifiedGeometry(1); - expect(simplifiedGeometry).to.be.an(ol.geom.LineString); + expect(simplifiedGeometry).to.be.an(_ol_geom_LineString_); expect(simplifiedGeometry.getCoordinates()).to.eql( [[0, 0], [3, 3], [5, 1], [7, 5]]); }); @@ -386,7 +384,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString( + lineString = new _ol_geom_LineString_( [[1, 2, 3], [4, 5, 6]], 'XYM'); }); @@ -415,7 +413,7 @@ describe('ol.geom.LineString', function() { var lineString; beforeEach(function() { - lineString = new ol.geom.LineString([ + lineString = new _ol_geom_LineString_([ [0, 0, 0, 0], [1, -1, 2, 1], [2, -2, 4, 2], diff --git a/test/spec/ol/geom/multilinestring.test.js b/test/spec/ol/geom/multilinestring.test.js index 6480d3bb28..487115bf80 100644 --- a/test/spec/ol/geom/multilinestring.test.js +++ b/test/spec/ol/geom/multilinestring.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.extent'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; describe('ol.geom.MultiLineString', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.MultiLineString(null); + return new _ol_geom_MultiLineString_(null); }).not.to.throwException(); }); @@ -17,7 +15,7 @@ describe('ol.geom.MultiLineString', function() { var multiLineString; beforeEach(function() { - multiLineString = new ol.geom.MultiLineString([]); + multiLineString = new _ol_geom_MultiLineString_([]); }); it('defaults to layout XY', function() { @@ -29,7 +27,7 @@ describe('ol.geom.MultiLineString', function() { }); it('has an empty extent', function() { - expect(ol.extent.isEmpty(multiLineString.getExtent())).to.be(true); + expect(_ol_extent_.isEmpty(multiLineString.getExtent())).to.be(true); }); it('has empty flat coordinates', function() { @@ -42,11 +40,11 @@ describe('ol.geom.MultiLineString', function() { it('can append line strings', function() { multiLineString.appendLineString( - new ol.geom.LineString([[1, 2], [3, 4]])); + new _ol_geom_LineString_([[1, 2], [3, 4]])); expect(multiLineString.getCoordinates()).to.eql( [[[1, 2], [3, 4]]]); multiLineString.appendLineString( - new ol.geom.LineString([[5, 6], [7, 8]])); + new _ol_geom_LineString_([[5, 6], [7, 8]])); expect(multiLineString.getCoordinates()).to.eql( [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]); }); @@ -57,7 +55,7 @@ describe('ol.geom.MultiLineString', function() { var multiLineString; beforeEach(function() { - multiLineString = new ol.geom.MultiLineString( + multiLineString = new _ol_geom_MultiLineString_( [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]); }); @@ -109,7 +107,7 @@ describe('ol.geom.MultiLineString', function() { var multiLineString; beforeEach(function() { - multiLineString = new ol.geom.MultiLineString( + multiLineString = new _ol_geom_MultiLineString_( [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]); }); @@ -141,7 +139,7 @@ describe('ol.geom.MultiLineString', function() { var multiLineString; beforeEach(function() { - multiLineString = new ol.geom.MultiLineString( + multiLineString = new _ol_geom_MultiLineString_( [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], 'XYM'); }); @@ -170,11 +168,11 @@ describe('ol.geom.MultiLineString', function() { it('can return individual line strings', function() { var lineString0 = multiLineString.getLineString(0); - expect(lineString0).to.be.an(ol.geom.LineString); + expect(lineString0).to.be.an(_ol_geom_LineString_); expect(lineString0.getLayout()).to.be('XYM'); expect(lineString0.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]); var lineString1 = multiLineString.getLineString(1); - expect(lineString1).to.be.an(ol.geom.LineString); + expect(lineString1).to.be.an(_ol_geom_LineString_); expect(lineString1.getLayout()).to.be('XYM'); expect(lineString1.getCoordinates()).to.eql([[7, 8, 9], [10, 11, 12]]); }); @@ -289,7 +287,7 @@ describe('ol.geom.MultiLineString', function() { var multiLineString; beforeEach(function() { - multiLineString = new ol.geom.MultiLineString( + multiLineString = new _ol_geom_MultiLineString_( [[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]); }); @@ -320,21 +318,21 @@ describe('ol.geom.MultiLineString', function() { describe('#scale()', function() { it('scales a multi-linestring', function() { - var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); + var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); geom.scale(10); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[[-100, -200], [100, 200]], [[50, -100], [-50, 100]]]); }); it('accepts sx and sy', function() { - var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); + var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); geom.scale(2, 3); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[[-20, -60], [20, 60]], [[10, -30], [-10, 30]]]); }); it('accepts an anchor', function() { - var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); + var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]); geom.scale(3, 2, [10, 20]); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[[-50, -60], [10, 20]], [[-5, -40], [-35, 0]]]); @@ -345,9 +343,9 @@ describe('ol.geom.MultiLineString', function() { describe('#setLineStrings', function() { it('sets the line strings', function() { - var multiLineString = new ol.geom.MultiLineString(null); - var lineString1 = new ol.geom.LineString([[1, 2], [3, 4]]); - var lineString2 = new ol.geom.LineString([[5, 6], [7, 8]]); + var multiLineString = new _ol_geom_MultiLineString_(null); + var lineString1 = new _ol_geom_LineString_([[1, 2], [3, 4]]); + var lineString2 = new _ol_geom_LineString_([[5, 6], [7, 8]]); multiLineString.setLineStrings([lineString1, lineString2]); expect(multiLineString.getFlatCoordinates()).to.eql( [1, 2, 3, 4, 5, 6, 7, 8]); diff --git a/test/spec/ol/geom/multipoint.test.js b/test/spec/ol/geom/multipoint.test.js index d3c7bb9c05..f9dda7ea65 100644 --- a/test/spec/ol/geom/multipoint.test.js +++ b/test/spec/ol/geom/multipoint.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.extent'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.Point'); +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; describe('ol.geom.MultiPoint', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.MultiPoint(null); + return new _ol_geom_MultiPoint_(null); }).not.to.throwException(); }); @@ -17,7 +15,7 @@ describe('ol.geom.MultiPoint', function() { var multiPoint; beforeEach(function() { - multiPoint = new ol.geom.MultiPoint([]); + multiPoint = new _ol_geom_MultiPoint_([]); }); it('defaults to layout XY', function() { @@ -29,7 +27,7 @@ describe('ol.geom.MultiPoint', function() { }); it('has an empty extent', function() { - expect(ol.extent.isEmpty(multiPoint.getExtent())).to.be(true); + expect(_ol_extent_.isEmpty(multiPoint.getExtent())).to.be(true); }); it('has empty flat coordinates', function() { @@ -41,9 +39,9 @@ describe('ol.geom.MultiPoint', function() { }); it('can append points', function() { - multiPoint.appendPoint(new ol.geom.Point([1, 2])); + multiPoint.appendPoint(new _ol_geom_Point_([1, 2])); expect(multiPoint.getCoordinates()).to.eql([[1, 2]]); - multiPoint.appendPoint(new ol.geom.Point([3, 4])); + multiPoint.appendPoint(new _ol_geom_Point_([3, 4])); expect(multiPoint.getCoordinates()).to.eql([[1, 2], [3, 4]]); }); @@ -53,7 +51,7 @@ describe('ol.geom.MultiPoint', function() { var multiPoint; beforeEach(function() { - multiPoint = new ol.geom.MultiPoint([[1, 2], [3, 4]]); + multiPoint = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]); }); it('has the expected layout', function() { @@ -94,7 +92,7 @@ describe('ol.geom.MultiPoint', function() { var multiPoint; beforeEach(function() { - multiPoint = new ol.geom.MultiPoint([[1, 2, 3], [4, 5, 6]]); + multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3], [4, 5, 6]]); }); it('has the expected layout', function() { @@ -123,7 +121,7 @@ describe('ol.geom.MultiPoint', function() { var multiPoint; beforeEach(function() { - multiPoint = new ol.geom.MultiPoint( + multiPoint = new _ol_geom_MultiPoint_( [[1, 2, 3], [4, 5, 6]], 'XYM'); }); @@ -159,10 +157,10 @@ describe('ol.geom.MultiPoint', function() { it('can return all points', function() { var points = multiPoint.getPoints(); expect(points).to.have.length(2); - expect(points[0]).to.be.an(ol.geom.Point); + expect(points[0]).to.be.an(_ol_geom_Point_); expect(points[0].getLayout()).to.be('XYM'); expect(points[0].getCoordinates()).to.eql([1, 2, 3]); - expect(points[1]).to.be.an(ol.geom.Point); + expect(points[1]).to.be.an(_ol_geom_Point_); expect(points[1].getLayout()).to.be('XYM'); expect(points[1].getCoordinates()).to.eql([4, 5, 6]); }); @@ -173,7 +171,7 @@ describe('ol.geom.MultiPoint', function() { var multiPoint; beforeEach(function() { - multiPoint = new ol.geom.MultiPoint([[1, 2, 3, 4], [5, 6, 7, 8]]); + multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3, 4], [5, 6, 7, 8]]); }); it('has the expected layout', function() { @@ -210,21 +208,21 @@ describe('ol.geom.MultiPoint', function() { describe('#scale()', function() { it('scales a multi-point', function() { - var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]); + var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]); geom.scale(10); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-100, -200], [100, 200]]); }); it('accepts sx and sy', function() { - var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]); + var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]); geom.scale(2, 3); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-20, -60], [20, 60]]); }); it('accepts an anchor', function() { - var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]); + var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]); geom.scale(3, 2, [-10, -20]); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([[-10, -20], [50, 60]]); @@ -236,7 +234,7 @@ describe('ol.geom.MultiPoint', function() { var multi, transform; beforeEach(function() { - multi = new ol.geom.MultiPoint([[1, 2], [3, 4]]); + multi = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]); transform = sinon.spy(); }); @@ -273,10 +271,10 @@ describe('ol.geom.MultiPoint', function() { describe('#transform()', function() { it('transforms a geometry given CRS identifiers', function() { - var multi = new ol.geom.MultiPoint([[-111, 45], [111, -45]]).transform( + var multi = new _ol_geom_MultiPoint_([[-111, 45], [111, -45]]).transform( 'EPSG:4326', 'EPSG:3857'); - expect(multi).to.be.a(ol.geom.MultiPoint); + expect(multi).to.be.a(_ol_geom_MultiPoint_); var coords = multi.getCoordinates(); diff --git a/test/spec/ol/geom/multipolygon.test.js b/test/spec/ol/geom/multipolygon.test.js index 4ec851383b..f723be16b3 100644 --- a/test/spec/ol/geom/multipolygon.test.js +++ b/test/spec/ol/geom/multipolygon.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; describe('ol.geom.MultiPolygon', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.MultiPolygon(null); + return new _ol_geom_MultiPolygon_(null); }).not.to.throwException(); }); @@ -16,16 +14,16 @@ describe('ol.geom.MultiPolygon', function() { var multiPolygon; beforeEach(function() { - multiPolygon = new ol.geom.MultiPolygon(null); + multiPolygon = new _ol_geom_MultiPolygon_(null); }); it('can append polygons', function() { multiPolygon.appendPolygon( - new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]])); + new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]])); expect(multiPolygon.getCoordinates()).to.eql( [[[[0, 0], [0, 2], [1, 1], [2, 0]]]]); multiPolygon.appendPolygon( - new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]])); + new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]])); expect(multiPolygon.getCoordinates()).to.eql([ [[[0, 0], [0, 2], [1, 1], [2, 0]]], [[[3, 0], [4, 1], [5, 2], [5, 0]]] @@ -39,16 +37,16 @@ describe('ol.geom.MultiPolygon', function() { var multiPolygon; beforeEach(function() { - multiPolygon = new ol.geom.MultiPolygon([]); + multiPolygon = new _ol_geom_MultiPolygon_([]); }); it('can append polygons', function() { multiPolygon.appendPolygon( - new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]])); + new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]])); expect(multiPolygon.getCoordinates()).to.eql( [[[[0, 0], [0, 2], [1, 1], [2, 0]]]]); multiPolygon.appendPolygon( - new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]])); + new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]])); expect(multiPolygon.getCoordinates()).to.eql([ [[[0, 0], [0, 2], [1, 1], [2, 0]]], [[[3, 0], [4, 1], [5, 2], [5, 0]]] @@ -61,7 +59,7 @@ describe('ol.geom.MultiPolygon', function() { describe('#scale()', function() { it('scales a multi-polygon', function() { - var geom = new ol.geom.MultiPolygon([[ + var geom = new _ol_geom_MultiPolygon_([[ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]]); geom.scale(10); @@ -70,7 +68,7 @@ describe('ol.geom.MultiPolygon', function() { }); it('accepts sx and sy', function() { - var geom = new ol.geom.MultiPolygon([[ + var geom = new _ol_geom_MultiPolygon_([[ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]]); geom.scale(2, 3); @@ -79,7 +77,7 @@ describe('ol.geom.MultiPolygon', function() { }); it('accepts an anchor', function() { - var geom = new ol.geom.MultiPolygon([[ + var geom = new _ol_geom_MultiPolygon_([[ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]]); geom.scale(3, 2, [-1, -2]); @@ -93,7 +91,7 @@ describe('ol.geom.MultiPolygon', function() { var multiPolygon; beforeEach(function() { - multiPolygon = new ol.geom.MultiPolygon([ + multiPolygon = new _ol_geom_MultiPolygon_([ [[[0, 0], [0, 2], [1, 1], [2, 0]]], [[[3, 0], [4, 1], [5, 2], [5, 0]]] ]); @@ -101,11 +99,11 @@ describe('ol.geom.MultiPolygon', function() { it('can return individual polygons', function() { var polygon0 = multiPolygon.getPolygon(0); - expect(polygon0).to.be.an(ol.geom.Polygon); + expect(polygon0).to.be.an(_ol_geom_Polygon_); expect(polygon0.getCoordinates()).to.eql( [[[0, 0], [0, 2], [1, 1], [2, 0]]]); var polygon1 = multiPolygon.getPolygon(1); - expect(polygon1).to.be.an(ol.geom.Polygon); + expect(polygon1).to.be.an(_ol_geom_Polygon_); expect(polygon1.getCoordinates()).to.eql( [[[3, 0], [4, 1], [5, 2], [5, 0]]]); }); @@ -114,10 +112,10 @@ describe('ol.geom.MultiPolygon', function() { var polygons = multiPolygon.getPolygons(); expect(polygons).to.be.an(Array); expect(polygons).to.have.length(2); - expect(polygons[0]).to.be.an(ol.geom.Polygon); + expect(polygons[0]).to.be.an(_ol_geom_Polygon_); expect(polygons[0].getCoordinates()).to.eql( [[[0, 0], [0, 2], [1, 1], [2, 0]]]); - expect(polygons[1]).to.be.an(ol.geom.Polygon); + expect(polygons[1]).to.be.an(_ol_geom_Polygon_); expect(polygons[1].getCoordinates()).to.eql( [[[3, 0], [4, 1], [5, 2], [5, 0]]]); }); @@ -137,8 +135,8 @@ describe('ol.geom.MultiPolygon', function() { var cw2 = [[-140, -60], [-140, 60], [140, 60], [140, -60], [-140, -60]]; var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]; var ccw2 = [[-140, -60], [140, -60], [140, 60], [-140, 60], [-140, -60]]; - var right = new ol.geom.MultiPolygon([[ccw, cw], [ccw2, cw2]]); - var left = new ol.geom.MultiPolygon([[cw, ccw], [cw2, ccw2]]); + var right = new _ol_geom_MultiPolygon_([[ccw, cw], [ccw2, cw2]]); + var left = new _ol_geom_MultiPolygon_([[cw, ccw], [cw2, ccw2]]); it('returns coordinates as they were constructed', function() { expect(right.getCoordinates()).to.eql([[ccw, cw], [ccw2, cw2]]); @@ -169,7 +167,7 @@ describe('ol.geom.MultiPolygon', function() { it('returns the expected result', function() { var simplifiedGeometry = multiPolygon.getSimplifiedGeometry(1); - expect(simplifiedGeometry).to.be.an(ol.geom.MultiPolygon); + expect(simplifiedGeometry).to.be.an(_ol_geom_MultiPolygon_); expect(simplifiedGeometry.getCoordinates()).to.eql([ [[[0, 0], [0, 2], [2, 0]]], [[[3, 0], [5, 2], [5, 0]]] @@ -198,7 +196,7 @@ describe('ol.geom.MultiPolygon', function() { describe('#getInteriorPoints', function() { it('returns XYM multipoint with intersection width as M', function() { - var geom = new ol.geom.MultiPolygon([ + var geom = new _ol_geom_MultiPolygon_([ [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], [[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]] ]); diff --git a/test/spec/ol/geom/point.test.js b/test/spec/ol/geom/point.test.js index d93e873343..5a013e1b05 100644 --- a/test/spec/ol/geom/point.test.js +++ b/test/spec/ol/geom/point.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.geom.Point'); +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; describe('ol.geom.Point', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.Point(null); + return new _ol_geom_Point_(null); }).not.to.throwException(); }); @@ -15,7 +13,7 @@ describe('ol.geom.Point', function() { var point; beforeEach(function() { - point = new ol.geom.Point([1, 2]); + point = new _ol_geom_Point_([1, 2]); }); it('has the expected layout', function() { @@ -52,7 +50,7 @@ describe('ol.geom.Point', function() { var point; beforeEach(function() { - point = new ol.geom.Point([1, 2, 3], 'XYM'); + point = new _ol_geom_Point_([1, 2, 3], 'XYM'); }); it('has the expected layout', function() { @@ -89,7 +87,7 @@ describe('ol.geom.Point', function() { var point; beforeEach(function() { - point = new ol.geom.Point([1, 2, 3, 4]); + point = new _ol_geom_Point_([1, 2, 3, 4]); }); it('has the expected layout', function() { @@ -134,21 +132,21 @@ describe('ol.geom.Point', function() { describe('#scale()', function() { it('scales a point', function() { - var geom = new ol.geom.Point([1, 2]); + var geom = new _ol_geom_Point_([1, 2]); geom.scale(10e6); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([1, 2]); }); it('accepts sx and sy', function() { - var geom = new ol.geom.Point([1, 2]); + var geom = new _ol_geom_Point_([1, 2]); geom.scale(1e6, -42); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([1, 2]); }); it('accepts an anchor', function() { - var geom = new ol.geom.Point([1, 2]); + var geom = new _ol_geom_Point_([1, 2]); geom.scale(10, 15, [0, 0]); var coordinates = geom.getCoordinates(); expect(coordinates).to.eql([10, 30]); @@ -160,7 +158,7 @@ describe('ol.geom.Point', function() { var point, transform; beforeEach(function() { - point = new ol.geom.Point([1, 2]); + point = new _ol_geom_Point_([1, 2]); transform = sinon.spy(); }); @@ -195,10 +193,10 @@ describe('ol.geom.Point', function() { describe('#transform()', function() { it('transforms a geometry given CRS identifiers', function() { - var point = new ol.geom.Point([-111, 45]).transform( + var point = new _ol_geom_Point_([-111, 45]).transform( 'EPSG:4326', 'EPSG:3857'); - expect(point).to.be.a(ol.geom.Point); + expect(point).to.be.a(_ol_geom_Point_); var coords = point.getCoordinates(); @@ -207,7 +205,7 @@ describe('ol.geom.Point', function() { }); it('modifies the original', function() { - var point = new ol.geom.Point([-111, 45]); + var point = new _ol_geom_Point_([-111, 45]); point.transform('EPSG:4326', 'EPSG:3857'); var coords = point.getCoordinates(); diff --git a/test/spec/ol/geom/polygon.test.js b/test/spec/ol/geom/polygon.test.js index 915771081c..398b6f8524 100644 --- a/test/spec/ol/geom/polygon.test.js +++ b/test/spec/ol/geom/polygon.test.js @@ -1,16 +1,14 @@ - - -goog.require('ol.extent'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.LinearRing'); -goog.require('ol.geom.Polygon'); +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; describe('ol.geom.Polygon', function() { it('can be constructed with a null geometry', function() { expect(function() { - return new ol.geom.Polygon(null); + return new _ol_geom_Polygon_(null); }).not.to.throwException(); }); @@ -18,7 +16,7 @@ describe('ol.geom.Polygon', function() { var polygon; beforeEach(function() { - polygon = new ol.geom.Polygon([]); + polygon = new _ol_geom_Polygon_([]); }); it('defaults to layout XY', function() { @@ -30,7 +28,7 @@ describe('ol.geom.Polygon', function() { }); it('has an empty extent', function() { - expect(ol.extent.isEmpty(polygon.getExtent())).to.be(true); + expect(_ol_extent_.isEmpty(polygon.getExtent())).to.be(true); }); it('has empty flat coordinates', function() { @@ -43,11 +41,11 @@ describe('ol.geom.Polygon', function() { it('can append linear rings', function() { polygon.appendLinearRing( - new ol.geom.LinearRing([[1, 2], [3, 4], [5, 6]])); + new _ol_geom_LinearRing_([[1, 2], [3, 4], [5, 6]])); expect(polygon.getCoordinates()).to.eql( [[[1, 2], [3, 4], [5, 6]]]); polygon.appendLinearRing( - new ol.geom.LinearRing([[7, 8], [9, 10], [11, 12]])); + new _ol_geom_LinearRing_([[7, 8], [9, 10], [11, 12]])); expect(polygon.getCoordinates()).to.eql( [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]); }); @@ -61,7 +59,7 @@ describe('ol.geom.Polygon', function() { beforeEach(function() { outerRing = [[0, 1], [1, 4], [4, 3], [3, 0]]; innerRing = [[2, 2], [3, 2], [3, 3], [2, 3]]; - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0, 2, 2, 3, 2, 3, 3, 2, 3]; outsideOuter = [0, 4]; inside = [1.5, 1.5]; @@ -97,16 +95,16 @@ describe('ol.geom.Polygon', function() { var linearRings = polygon.getLinearRings(); expect(linearRings).to.be.an(Array); expect(linearRings).to.have.length(2); - expect(linearRings[0]).to.be.an(ol.geom.LinearRing); + expect(linearRings[0]).to.be.an(_ol_geom_LinearRing_); expect(linearRings[0].getCoordinates()).to.eql(outerRing); - expect(linearRings[1]).to.be.an(ol.geom.LinearRing); + expect(linearRings[1]).to.be.an(_ol_geom_LinearRing_); expect(linearRings[1].getCoordinates()).to.eql(innerRing); }); it('does not reverse any rings', function() { outerRing.reverse(); innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); var coordinates = polygon.getCoordinates(); expect(coordinates[0]).to.eql(outerRing); expect(coordinates[1]).to.eql(innerRing); @@ -128,8 +126,8 @@ describe('ol.geom.Polygon', function() { var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]]; var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]; - var right = new ol.geom.Polygon([ccw, cw]); - var left = new ol.geom.Polygon([cw, ccw]); + var right = new _ol_geom_Polygon_([ccw, cw]); + var left = new _ol_geom_Polygon_([cw, ccw]); it('returns coordinates as they were constructed', function() { expect(right.getCoordinates()).to.eql([ccw, cw]); @@ -152,20 +150,20 @@ describe('ol.geom.Polygon', function() { it('reverses the outer ring if necessary', function() { outerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses inner rings if necessary', function() { innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses all rings if necessary', function() { outerRing.reverse(); innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); @@ -180,7 +178,7 @@ describe('ol.geom.Polygon', function() { beforeEach(function() { outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]]; innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]]; - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6]; outsideOuter = [1, 3]; inside = [3.5, 0.5]; @@ -223,25 +221,25 @@ describe('ol.geom.Polygon', function() { it('does not intersect outside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([outsideOuter]))).to.be(false); + _ol_extent_.boundingExtent([outsideOuter]))).to.be(false); }); it('does intersect inside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([inside]))).to.be(true); + _ol_extent_.boundingExtent([inside]))).to.be(true); }); it('does intersect boundary extent', function() { var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2; var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2; - expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX, + expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX, firstMidY]]))).to.be(true); }); it('does not intersect extent fully contained by inner ring', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([insideInner]))).to.be(false); + _ol_extent_.boundingExtent([insideInner]))).to.be(false); }); }); @@ -250,20 +248,20 @@ describe('ol.geom.Polygon', function() { it('reverses the outer ring if necessary', function() { outerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses inner rings if necessary', function() { innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses all rings if necessary', function() { outerRing.reverse(); innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); @@ -278,7 +276,7 @@ describe('ol.geom.Polygon', function() { beforeEach(function() { outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]]; innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]]; - polygon = new ol.geom.Polygon( + polygon = new _ol_geom_Polygon_( [outerRing, innerRing], 'XYM'); flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6]; outsideOuter = [1, 3]; @@ -322,25 +320,25 @@ describe('ol.geom.Polygon', function() { it('does not intersect outside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([outsideOuter]))).to.be(false); + _ol_extent_.boundingExtent([outsideOuter]))).to.be(false); }); it('does intersect inside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([inside]))).to.be(true); + _ol_extent_.boundingExtent([inside]))).to.be(true); }); it('does intersect boundary extent', function() { var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2; var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2; - expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX, + expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX, firstMidY]]))).to.be(true); }); it('does not intersect extent fully contained by inner ring', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([insideInner]))).to.be(false); + _ol_extent_.boundingExtent([insideInner]))).to.be(false); }); }); @@ -349,20 +347,20 @@ describe('ol.geom.Polygon', function() { it('reverses the outer ring if necessary', function() { outerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses inner rings if necessary', function() { innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses all rings if necessary', function() { outerRing.reverse(); innerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); @@ -379,7 +377,7 @@ describe('ol.geom.Polygon', function() { innerRing1 = [[2, 4, 7, 8], [4, 4, 9, 10], [4, 5, 11, 12], [2, 5, 13, 14]]; innerRing2 = [[3, 2, 15, 16], [4, 3, 17, 18], [2, 3, 19, 20]]; - polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]); flatCoordinates = [ 0, 6, 1, 2, 6, 6, 3, 4, 3, 0, 5, 6, 2, 4, 7, 8, 4, 4, 9, 10, 4, 5, 11, 12, 2, 5, 13, 14, @@ -429,27 +427,27 @@ describe('ol.geom.Polygon', function() { it('does not intersect outside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([outsideOuter]))).to.be(false); + _ol_extent_.boundingExtent([outsideOuter]))).to.be(false); }); it('does intersect inside extent', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([inside]))).to.be(true); + _ol_extent_.boundingExtent([inside]))).to.be(true); }); it('does intersect boundary extent', function() { var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2; var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2; - expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX, + expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX, firstMidY]]))).to.be(true); }); it('does not intersect extent fully contained by inner ring', function() { expect(polygon.intersectsExtent( - ol.extent.boundingExtent([insideInner1]))).to.be(false); + _ol_extent_.boundingExtent([insideInner1]))).to.be(false); expect(polygon.intersectsExtent( - ol.extent.boundingExtent([insideInner2]))).to.be(false); + _ol_extent_.boundingExtent([insideInner2]))).to.be(false); }); }); @@ -458,14 +456,14 @@ describe('ol.geom.Polygon', function() { it('reverses the outer ring if necessary', function() { outerRing.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); it('reverses inner rings if necessary', function() { innerRing1.reverse(); innerRing2.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); @@ -473,7 +471,7 @@ describe('ol.geom.Polygon', function() { outerRing.reverse(); innerRing1.reverse(); innerRing2.reverse(); - polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]); + polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]); expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates); }); @@ -485,7 +483,7 @@ describe('ol.geom.Polygon', function() { var polygon; beforeEach(function() { - polygon = new ol.geom.Polygon( + polygon = new _ol_geom_Polygon_( [[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]); }); @@ -493,7 +491,7 @@ describe('ol.geom.Polygon', function() { it('returns the expected result', function() { var simplifiedGeometry = polygon.getSimplifiedGeometry(9); - expect(simplifiedGeometry).to.be.an(ol.geom.Polygon); + expect(simplifiedGeometry).to.be.an(_ol_geom_Polygon_); expect(simplifiedGeometry.getCoordinates()).to.eql( [[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]); }); @@ -513,7 +511,7 @@ describe('ol.geom.Polygon', function() { describe('#scale()', function() { it('scales a polygon', function() { - var geom = new ol.geom.Polygon([ + var geom = new _ol_geom_Polygon_([ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]); geom.scale(10); @@ -522,7 +520,7 @@ describe('ol.geom.Polygon', function() { }); it('accepts sx and sy', function() { - var geom = new ol.geom.Polygon([ + var geom = new _ol_geom_Polygon_([ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]); geom.scale(2, 3); @@ -531,7 +529,7 @@ describe('ol.geom.Polygon', function() { }); it('accepts an anchor', function() { - var geom = new ol.geom.Polygon([ + var geom = new _ol_geom_Polygon_([ [[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]] ]); geom.scale(3, 2, [-1, -2]); @@ -544,7 +542,7 @@ describe('ol.geom.Polygon', function() { describe('#getInteriorPoint', function() { it('returns XYM point with intersection width as M', function() { - var geom = new ol.geom.Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]); + var geom = new _ol_geom_Polygon_([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]); var interiorPoint = geom.getInteriorPoint(); expect(interiorPoint.getType()).to.be('Point'); expect(interiorPoint.layout).to.be('XYM'); @@ -552,7 +550,7 @@ describe('ol.geom.Polygon', function() { }); it('returns XYM point for donut polygons', function() { - var geom = new ol.geom.Polygon([ + var geom = new _ol_geom_Polygon_([ [[0.5, 0.5], [0.5, 2.5], [2.5, 2.5], [2.5, 0.5], [0.5, 0.5]], [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]] ]); @@ -566,7 +564,7 @@ describe('ol.geom.Polygon', function() { describe('ol.geom.Polygon.fromExtent', function() { it('creates the correct polygon', function() { var extent = [1, 2, 3, 5]; - var polygon = ol.geom.Polygon.fromExtent(extent); + var polygon = _ol_geom_Polygon_.fromExtent(extent); var flatCoordinates = polygon.getFlatCoordinates(); expect(flatCoordinates).to.eql( [1, 2, 1, 5, 3, 5, 3, 2, 1, 2]); @@ -579,8 +577,8 @@ describe('ol.geom.Polygon', function() { describe('ol.geom.Polygon.fromCircle', function() { it('creates a regular polygon', function() { - var circle = new ol.geom.Circle([0, 0, 0], 1, 'XYZ'); - var polygon = ol.geom.Polygon.fromCircle(circle); + var circle = new _ol_geom_Circle_([0, 0, 0], 1, 'XYZ'); + var polygon = _ol_geom_Polygon_.fromCircle(circle); var coordinates = polygon.getLinearRing(0).getCoordinates(); expect(coordinates[0].length).to.eql(3); expect(coordinates[0][2]).to.eql(0); @@ -600,8 +598,8 @@ describe('ol.geom.Polygon', function() { }); it('creates a regular polygon with custom sides and angle', function() { - var circle = new ol.geom.Circle([0, 0], 1); - var polygon = ol.geom.Polygon.fromCircle(circle, 4, Math.PI / 2); + var circle = new _ol_geom_Circle_([0, 0], 1); + var polygon = _ol_geom_Polygon_.fromCircle(circle, 4, Math.PI / 2); var coordinates = polygon.getLinearRing(0).getCoordinates(); expect(coordinates[4]).to.eql(coordinates[0]); expect(coordinates[0][0]).to.roughlyEqual(0, 1e-9); diff --git a/test/spec/ol/graticule.test.js b/test/spec/ol/graticule.test.js index 800509df52..e4848a61d8 100644 --- a/test/spec/ol/graticule.test.js +++ b/test/spec/ol/graticule.test.js @@ -1,17 +1,15 @@ - - -goog.require('ol.Graticule'); -goog.require('ol.Map'); -goog.require('ol.proj'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Text'); +import _ol_Graticule_ from '../../../src/ol/Graticule.js'; +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_proj_ from '../../../src/ol/proj.js'; +import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js'; +import _ol_style_Text_ from '../../../src/ol/style/Text.js'; describe('ol.Graticule', function() { var graticule; function createGraticule() { - graticule = new ol.Graticule({ - map: new ol.Map({}) + graticule = new _ol_Graticule_({ + map: new _ol_Map_({}) }); } @@ -20,7 +18,7 @@ describe('ol.Graticule', function() { createGraticule(); var extent = [-25614353.926475704, -7827151.696402049, 25614353.926475704, 7827151.696402049]; - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); var resolution = 39135.75848201024; var squaredTolerance = resolution * resolution / 4.0; graticule.updateProjectionInfo_(projection); @@ -32,13 +30,13 @@ describe('ol.Graticule', function() { }); it('creates a graticule with labels', function() { - graticule = new ol.Graticule({ - map: new ol.Map({}), + graticule = new _ol_Graticule_({ + map: new _ol_Map_({}), showLabels: true }); var extent = [-25614353.926475704, -7827151.696402049, 25614353.926475704, 7827151.696402049]; - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); var resolution = 39135.75848201024; var squaredTolerance = resolution * resolution / 4.0; graticule.updateProjectionInfo_(projection); @@ -56,16 +54,16 @@ describe('ol.Graticule', function() { var actualStyle = graticule.strokeStyle_; expect(actualStyle).not.to.be(undefined); - expect(actualStyle instanceof ol.style.Stroke).to.be(true); + expect(actualStyle instanceof _ol_style_Stroke_).to.be(true); }); it('can be configured with a stroke style', function() { createGraticule(); - var customStrokeStyle = new ol.style.Stroke({ + var customStrokeStyle = new _ol_style_Stroke_({ color: 'rebeccapurple' }); - var styledGraticule = new ol.Graticule({ - map: new ol.Map({}), + var styledGraticule = new _ol_Graticule_({ + map: new _ol_Map_({}), strokeStyle: customStrokeStyle }); var actualStyle = styledGraticule.strokeStyle_; @@ -75,10 +73,10 @@ describe('ol.Graticule', function() { }); it('can be configured with label options', function() { - var latLabelStyle = new ol.style.Text(); - var lonLabelStyle = new ol.style.Text(); - graticule = new ol.Graticule({ - map: new ol.Map({}), + var latLabelStyle = new _ol_style_Text_(); + var lonLabelStyle = new _ol_style_Text_(); + graticule = new _ol_Graticule_({ + map: new _ol_Map_({}), showLabels: true, lonLabelFormatter: function(lon) { return 'lon: ' + lon.toString(); @@ -93,7 +91,7 @@ describe('ol.Graticule', function() { }); var extent = [-25614353.926475704, -7827151.696402049, 25614353.926475704, 7827151.696402049]; - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); var resolution = 39135.75848201024; var squaredTolerance = resolution * resolution / 4.0; graticule.updateProjectionInfo_(projection); diff --git a/test/spec/ol/imagetile.test.js b/test/spec/ol/imagetile.test.js index 5fe0b9c337..416a96dbf5 100644 --- a/test/spec/ol/imagetile.test.js +++ b/test/spec/ol/imagetile.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.ImageTile'); -goog.require('ol.TileState'); -goog.require('ol.events'); -goog.require('ol.events.EventType'); -goog.require('ol.source.Image'); +import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; +import _ol_TileState_ from '../../../src/ol/TileState.js'; +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_events_EventType_ from '../../../src/ol/events/EventType.js'; +import _ol_source_Image_ from '../../../src/ol/source/Image.js'; describe('ol.ImageTile', function() { @@ -13,19 +11,19 @@ describe('ol.ImageTile', function() { it('can load idle tile', function(done) { var tileCoord = [0, 0, 0]; - var state = ol.TileState.IDLE; + var state = _ol_TileState_.IDLE; var src = 'spec/ol/data/osm-0-0-0.png'; - var tileLoadFunction = ol.source.Image.defaultImageLoadFunction; - var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction); + var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; + var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var previousState = tile.getState(); - ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) { + _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) { var state = tile.getState(); - if (previousState == ol.TileState.IDLE) { - expect(state).to.be(ol.TileState.LOADING); - } else if (previousState == ol.TileState.LOADING) { - expect(state).to.be(ol.TileState.LOADED); + if (previousState == _ol_TileState_.IDLE) { + expect(state).to.be(_ol_TileState_.LOADING); + } else if (previousState == _ol_TileState_.LOADING) { + expect(state).to.be(_ol_TileState_.LOADED); done(); } else { expect().fail(); @@ -38,19 +36,19 @@ describe('ol.ImageTile', function() { it('can load error tile', function(done) { var tileCoord = [0, 0, 0]; - var state = ol.TileState.ERROR; + var state = _ol_TileState_.ERROR; var src = 'spec/ol/data/osm-0-0-0.png'; - var tileLoadFunction = ol.source.Image.defaultImageLoadFunction; - var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction); + var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; + var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var previousState = tile.getState(); - ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) { + _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) { var state = tile.getState(); - if (previousState == ol.TileState.ERROR) { - expect(state).to.be(ol.TileState.LOADING); - } else if (previousState == ol.TileState.LOADING) { - expect(state).to.be(ol.TileState.LOADED); + if (previousState == _ol_TileState_.ERROR) { + expect(state).to.be(_ol_TileState_.LOADING); + } else if (previousState == _ol_TileState_.LOADING) { + expect(state).to.be(_ol_TileState_.LOADED); done(); } else { expect().fail(); @@ -63,17 +61,17 @@ describe('ol.ImageTile', function() { it('loads an empty image on error ', function(done) { var tileCoord = [0, 0, 0]; - var state = ol.TileState.IDLE; + var state = _ol_TileState_.IDLE; var src = 'spec/ol/data/osm-0-0-99.png'; - var tileLoadFunction = ol.source.Image.defaultImageLoadFunction; - var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction); + var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; + var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); - var key = ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) { + var key = _ol_events_.listen(tile, _ol_events_EventType_.CHANGE, function(event) { var state = tile.getState(); - if (state == ol.TileState.ERROR) { - expect(state).to.be(ol.TileState.ERROR); + if (state == _ol_TileState_.ERROR) { + expect(state).to.be(_ol_TileState_.ERROR); expect(tile.image_).to.be.a(HTMLCanvasElement); - ol.events.unlistenByKey(key); + _ol_events_.unlistenByKey(key); tile.load(); expect(tile.image_).to.be.a(HTMLImageElement); done(); @@ -89,15 +87,15 @@ describe('ol.ImageTile', function() { it('sets image src to a blank image data uri', function() { var tileCoord = [0, 0, 0]; - var state = ol.TileState.IDLE; + var state = _ol_TileState_.IDLE; var src = 'spec/ol/data/osm-0-0-0.png'; - var tileLoadFunction = ol.source.Image.defaultImageLoadFunction; - var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction); + var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; + var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); tile.load(); - expect(tile.getState()).to.be(ol.TileState.LOADING); + expect(tile.getState()).to.be(_ol_TileState_.LOADING); tile.dispose(); - expect(tile.getState()).to.be(ol.TileState.ABORT); - expect(tile.getImage().src).to.be(ol.ImageTile.blankImageUrl); + expect(tile.getState()).to.be(_ol_TileState_.ABORT); + expect(tile.getImage().src).to.be(_ol_ImageTile_.blankImageUrl); }); }); diff --git a/test/spec/ol/index.test.js b/test/spec/ol/index.test.js index b103a91209..d72b38614b 100644 --- a/test/spec/ol/index.test.js +++ b/test/spec/ol/index.test.js @@ -1,23 +1,20 @@ - -goog.require('ol'); +import _ol_ from '../../../src/ol.js'; describe('getUid()', function() { it('is constant once generated', function() { var a = {}; - expect(ol.getUid(a)).to.be(ol.getUid(a)); + expect(_ol_.getUid(a)).to.be(_ol_.getUid(a)); }); it('generates a strictly increasing sequence', function() { var a = {}, b = {}, c = {}; - ol.getUid(a); - ol.getUid(c); - ol.getUid(b); + _ol_.getUid(a); + _ol_.getUid(c); + _ol_.getUid(b); //uid order should be a < c < b - expect(ol.getUid(a)).to.be.lessThan(ol.getUid(c)); - expect(ol.getUid(c)).to.be.lessThan(ol.getUid(b)); - expect(ol.getUid(a)).to.be.lessThan(ol.getUid(b)); + expect(_ol_.getUid(a)).to.be.lessThan(_ol_.getUid(c)); + expect(_ol_.getUid(c)).to.be.lessThan(_ol_.getUid(b)); + expect(_ol_.getUid(a)).to.be.lessThan(_ol_.getUid(b)); }); }); - - diff --git a/test/spec/ol/interaction/draganddrop.test.js b/test/spec/ol/interaction/draganddrop.test.js index fa111ce8b6..a4d5a9e6bd 100644 --- a/test/spec/ol/interaction/draganddrop.test.js +++ b/test/spec/ol/interaction/draganddrop.test.js @@ -1,36 +1,34 @@ - - -goog.require('ol'); -goog.require('ol.View'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventTarget'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.interaction.DragAndDrop'); -goog.require('ol.source.Vector'); +import _ol_ from '../../../../src/ol.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; +import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js'; +import _ol_interaction_DragAndDrop_ from '../../../../src/ol/interaction/DragAndDrop.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; where('FileReader').describe('ol.interaction.DragAndDrop', function() { var viewport, map, interaction; beforeEach(function() { - viewport = new ol.events.EventTarget(); + viewport = new _ol_events_EventTarget_(); map = { getViewport: function() { return viewport; }, getView: function() { - return new ol.View(); + return new _ol_View_(); } }; - interaction = new ol.interaction.DragAndDrop({ - formatConstructors: [ol.format.GeoJSON] + interaction = new _ol_interaction_DragAndDrop_({ + formatConstructors: [_ol_format_GeoJSON_] }); }); describe('constructor', function() { it('can be constructed without arguments', function() { - var interaction = new ol.interaction.DragAndDrop(); - expect(interaction).to.be.an(ol.interaction.DragAndDrop); + var interaction = new _ol_interaction_DragAndDrop_(); + expect(interaction).to.be.an(_ol_interaction_DragAndDrop_); }); it('sets formatConstructors on the instance', function() { @@ -38,9 +36,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { }); it('accepts a source option', function() { - var source = new ol.source.Vector(); - var drop = new ol.interaction.DragAndDrop({ - formatConstructors: [ol.format.GeoJSON], + var source = new _ol_source_Vector_(); + var drop = new _ol_interaction_DragAndDrop_({ + formatConstructors: [_ol_format_GeoJSON_], source: source }); expect(drop.source_).to.equal(source); @@ -74,9 +72,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { }); it('registers and unregisters listeners on a custom target', function() { - var customTarget = new ol.events.EventTarget(); - interaction = new ol.interaction.DragAndDrop({ - formatConstructors: [ol.format.GeoJSON], + var customTarget = new _ol_events_EventTarget_(); + interaction = new _ol_interaction_DragAndDrop_({ + formatConstructors: [_ol_format_GeoJSON_], target: customTarget }); interaction.setMap(map); @@ -97,13 +95,13 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { OrigFileReader = FileReader; FileReader = function() { - ol.events.EventTarget.apply(this, arguments); + _ol_events_EventTarget_.apply(this, arguments); this.readAsText = function(file) { this.result = file; this.dispatchEvent('load'); }; }; - ol.inherits(FileReader, ol.events.EventTarget); + _ol_.inherits(FileReader, _ol_events_EventTarget_); }); afterEach(function() { @@ -116,7 +114,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { done(); }); interaction.setMap(map); - var event = new ol.events.Event(); + var event = new _ol_events_Event_(); event.dataTransfer = {}; event.type = 'dragenter'; viewport.dispatchEvent(event); @@ -138,9 +136,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { }); it('adds dropped features to a source', function(done) { - var source = new ol.source.Vector(); - var drop = new ol.interaction.DragAndDrop({ - formatConstructors: [ol.format.GeoJSON], + var source = new _ol_source_Vector_(); + var drop = new _ol_interaction_DragAndDrop_({ + formatConstructors: [_ol_format_GeoJSON_], source: source }); drop.setMap(map); @@ -151,7 +149,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { done(); }); - var event = new ol.events.Event(); + var event = new _ol_events_Event_(); event.dataTransfer = {}; event.type = 'dragenter'; viewport.dispatchEvent(event); diff --git a/test/spec/ol/interaction/dragrotateandzoom.test.js b/test/spec/ol/interaction/dragrotateandzoom.test.js index 06fbb7562e..bf518c4be3 100644 --- a/test/spec/ol/interaction/dragrotateandzoom.test.js +++ b/test/spec/ol/interaction/dragrotateandzoom.test.js @@ -1,21 +1,19 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.interaction.DragRotateAndZoom'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.layer.Vector'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_interaction_DragRotateAndZoom_ from '../../../../src/ol/interaction/DragRotateAndZoom.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.DragRotateAndZoom', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.interaction.DragRotateAndZoom(); - expect(instance).to.be.an(ol.interaction.DragRotateAndZoom); + var instance = new _ol_interaction_DragRotateAndZoom_(); + expect(instance).to.be.an(_ol_interaction_DragRotateAndZoom_); }); }); @@ -36,14 +34,14 @@ describe('ol.interaction.DragRotateAndZoom', function() { style.width = width + 'px'; style.height = height + 'px'; document.body.appendChild(target); - var source = new ol.source.Vector(); - var layer = new ol.layer.Vector({source: source}); - interaction = new ol.interaction.DragRotateAndZoom(); - map = new ol.Map({ + var source = new _ol_source_Vector_(); + var layer = new _ol_layer_Vector_({source: source}); + interaction = new _ol_interaction_DragRotateAndZoom_(); + map = new _ol_Map_({ target: target, layers: [layer], interactions: [interaction], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -60,26 +58,26 @@ describe('ol.interaction.DragRotateAndZoom', function() { }); it('does not rotate when rotation is disabled on the view', function() { - var event = new ol.MapBrowserPointerEvent('pointermove', map, - new ol.pointer.PointerEvent('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}), + var event = new _ol_MapBrowserPointerEvent_('pointermove', map, + new _ol_pointer_PointerEvent_('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}), true); interaction.lastAngle_ = Math.PI; - var spy = sinon.spy(ol.interaction.Interaction, 'rotateWithoutConstraints'); + var spy = sinon.spy(_ol_interaction_Interaction_, 'rotateWithoutConstraints'); interaction.handleDragEvent_(event); expect(spy.callCount).to.be(1); expect(interaction.lastAngle_).to.be(-0.8308214428190254); - map.setView(new ol.View({ + map.setView(new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1, enableRotation: false })); - event = new ol.MapBrowserPointerEvent('pointermove', map, - new ol.pointer.PointerEvent('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}), + event = new _ol_MapBrowserPointerEvent_('pointermove', map, + new _ol_pointer_PointerEvent_('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}), true); interaction.handleDragEvent_(event); expect(spy.callCount).to.be(1); - ol.interaction.Interaction.rotateWithoutConstraints.restore(); + _ol_interaction_Interaction_.rotateWithoutConstraints.restore(); }); }); diff --git a/test/spec/ol/interaction/dragzoom.test.js b/test/spec/ol/interaction/dragzoom.test.js index 7735431d05..7ed855d201 100644 --- a/test/spec/ol/interaction/dragzoom.test.js +++ b/test/spec/ol/interaction/dragzoom.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.DragZoom'); -goog.require('ol.layer.Vector'); -goog.require('ol.render.Box'); -goog.require('ol.source.Vector'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_interaction_DragZoom_ from '../../../../src/ol/interaction/DragZoom.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_render_Box_ from '../../../../src/ol/render/Box.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.DragZoom', function() { @@ -26,12 +24,12 @@ describe('ol.interaction.DragZoom', function() { style.width = width + 'px'; style.height = height + 'px'; document.body.appendChild(target); - source = new ol.source.Vector(); - var layer = new ol.layer.Vector({source: source}); - map = new ol.Map({ + source = new _ol_source_Vector_(); + var layer = new _ol_layer_Vector_({source: source}); + map = new _ol_Map_({ target: target, layers: [layer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -50,15 +48,15 @@ describe('ol.interaction.DragZoom', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.interaction.DragZoom(); - expect(instance).to.be.an(ol.interaction.DragZoom); + var instance = new _ol_interaction_DragZoom_(); + expect(instance).to.be.an(_ol_interaction_DragZoom_); }); it('sets "ol-dragzoom" as box className', function() { - var instance = new ol.interaction.DragZoom(); + var instance = new _ol_interaction_DragZoom_(); expect(instance.box_.element_.className).to.be('ol-box ol-dragzoom'); }); it('sets a custom box className', function() { - var instance = new ol.interaction.DragZoom({className: 'test-dragzoom'}); + var instance = new _ol_interaction_DragZoom_({className: 'test-dragzoom'}); expect(instance.box_.element_.className).to.be('ol-box test-dragzoom'); }); @@ -67,36 +65,36 @@ describe('ol.interaction.DragZoom', function() { describe('#onBoxEnd()', function() { it('centers the view on the box geometry', function(done) { - var interaction = new ol.interaction.DragZoom({ + var interaction = new _ol_interaction_DragZoom_({ duration: 10 }); map.addInteraction(interaction); - var box = new ol.render.Box(); + var box = new _ol_render_Box_(); var extent = [-110, 40, -90, 60]; - box.geometry_ = ol.geom.Polygon.fromExtent(extent); + box.geometry_ = _ol_geom_Polygon_.fromExtent(extent); interaction.box_ = box; interaction.onBoxEnd(); setTimeout(function() { var view = map.getView(); var center = view.getCenter(); - expect(center).to.eql(ol.extent.getCenter(extent)); + expect(center).to.eql(_ol_extent_.getCenter(extent)); done(); }, 50); }); it('sets new resolution while zooming out', function(done) { - var interaction = new ol.interaction.DragZoom({ + var interaction = new _ol_interaction_DragZoom_({ duration: 10, out: true }); map.addInteraction(interaction); - var box = new ol.render.Box(); + var box = new _ol_render_Box_(); var extent = [-11.25, -11.25, 11.25, 11.25]; - box.geometry_ = ol.geom.Polygon.fromExtent(extent); + box.geometry_ = _ol_geom_Polygon_.fromExtent(extent); interaction.box_ = box; map.getView().setResolution(0.25); diff --git a/test/spec/ol/interaction/draw.test.js b/test/spec/ol/interaction/draw.test.js index f47aaa9dea..eec4a6a7ee 100644 --- a/test/spec/ol/interaction/draw.test.js +++ b/test/spec/ol/interaction/draw.test.js @@ -1,24 +1,22 @@ - - -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.array'); -goog.require('ol.events'); -goog.require('ol.events.condition'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Draw'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.layer.Vector'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.source.Vector'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_array_ from '../../../../src/ol/array.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_condition_ from '../../../../src/ol/events/condition.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_interaction_Draw_ from '../../../../src/ol/interaction/Draw.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.Draw', function() { @@ -36,12 +34,12 @@ describe('ol.interaction.Draw', function() { style.width = width + 'px'; style.height = height + 'px'; document.body.appendChild(target); - source = new ol.source.Vector(); - var layer = new ol.layer.Vector({source: source}); - map = new ol.Map({ + source = new _ol_source_Vector_(); + var layer = new _ol_layer_Vector_({source: source}); + map = new _ol_Map_({ target: target, layers: [layer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -70,33 +68,33 @@ describe('ol.interaction.Draw', function() { // calculated in case body has top < 0 (test runner with small window) var position = viewport.getBoundingClientRect(); var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; - var event = new ol.pointer.PointerEvent(type, { + var event = new _ol_pointer_PointerEvent_(type, { clientX: position.left + x + width / 2, clientY: position.top + y + height / 2, shiftKey: shiftKey }); - map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event)); + map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event)); } describe('constructor', function() { it('creates a new interaction', function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'Point' }); - expect(draw).to.be.a(ol.interaction.Draw); - expect(draw).to.be.a(ol.interaction.Interaction); + expect(draw).to.be.a(_ol_interaction_Draw_); + expect(draw).to.be.a(_ol_interaction_Interaction_); }); it('accepts a freehand option', function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'LineString', freehand: true }); - var event = new ol.pointer.PointerEvent('pointerdown', { + var event = new _ol_pointer_PointerEvent_('pointerdown', { clientX: 0, clientY: 0, shiftKey: false @@ -110,7 +108,7 @@ describe('ol.interaction.Draw', function() { describe('specifying a geometryName', function() { beforeEach(function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, geometryName: 'the_geom', type: 'Point' @@ -125,13 +123,13 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); var geometry = features[0].getGeometry(); expect(features[0].getGeometryName()).to.equal('the_geom'); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); }); }); describe('specifying a clickTolerance', function() { beforeEach(function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'Point', clickTolerance: 6 @@ -160,7 +158,7 @@ describe('ol.interaction.Draw', function() { var draw; beforeEach(function() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: 'Point' }); @@ -174,7 +172,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([10, -20]); }); @@ -198,8 +196,8 @@ describe('ol.interaction.Draw', function() { it('triggers draw events', function() { var ds = sinon.spy(); var de = sinon.spy(); - ol.events.listen(draw, 'drawstart', ds); - ol.events.listen(draw, 'drawend', de); + _ol_events_.listen(draw, 'drawstart', ds); + _ol_events_.listen(draw, 'drawend', de); simulateEvent('pointermove', 10, 20); simulateEvent('pointerdown', 10, 20); simulateEvent('pointerup', 10, 20); @@ -215,7 +213,7 @@ describe('ol.interaction.Draw', function() { end: 0, addfeature: 0 }; - ol.events.listen(draw, 'drawend', + _ol_events_.listen(draw, 'drawend', function() { expect(receivedEvents.end).to.be(0); expect(receivedEvents.addfeature).to.be(0); @@ -238,7 +236,7 @@ describe('ol.interaction.Draw', function() { describe('drawing multipoints', function() { beforeEach(function() { - map.addInteraction(new ol.interaction.Draw({ + map.addInteraction(new _ol_interaction_Draw_({ source: source, type: 'MultiPoint' })); @@ -251,7 +249,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.MultiPoint); + expect(geometry).to.be.a(_ol_geom_MultiPoint_); expect(geometry.getCoordinates()).to.eql([[30, -15]]); }); @@ -261,7 +259,7 @@ describe('ol.interaction.Draw', function() { var draw; beforeEach(function() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: 'LineString' }); @@ -286,7 +284,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.LineString); + expect(geometry).to.be.a(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]); }); @@ -328,7 +326,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.LineString); + expect(geometry).to.be.a(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql( [[10, -20], [20, -30], [20, -40]]); }); @@ -365,7 +363,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); // expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.LineString); + expect(geometry).to.be.a(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql( [[10, -20], [20, -30], [30, -40], [40, -50], [50, -60], [60, -70]]); }); @@ -394,15 +392,15 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.LineString); + expect(geometry).to.be.a(_ol_geom_LineString_); expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]); }); it('triggers draw events', function() { var ds = sinon.spy(); var de = sinon.spy(); - ol.events.listen(draw, 'drawstart', ds); - ol.events.listen(draw, 'drawend', de); + _ol_events_.listen(draw, 'drawstart', ds); + _ol_events_.listen(draw, 'drawend', de); // first point simulateEvent('pointermove', 10, 20); @@ -429,11 +427,11 @@ describe('ol.interaction.Draw', function() { describe('drawing with a finishCondition', function() { beforeEach(function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'LineString', finishCondition: function(event) { - if (ol.array.equals(event.coordinate, [30, -20])) { + if (_ol_array_.equals(event.coordinate, [30, -20])) { return true; } return false; @@ -479,7 +477,7 @@ describe('ol.interaction.Draw', function() { describe('drawing multi-linestrings', function() { beforeEach(function() { - map.addInteraction(new ol.interaction.Draw({ + map.addInteraction(new _ol_interaction_Draw_({ source: source, type: 'MultiLineString' })); @@ -503,7 +501,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.MultiLineString); + expect(geometry).to.be.a(_ol_geom_MultiLineString_); expect(geometry.getCoordinates()).to.eql([[[10, -20], [30, -20]]]); }); @@ -513,7 +511,7 @@ describe('ol.interaction.Draw', function() { var draw; beforeEach(function() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: 'Polygon' }); @@ -553,7 +551,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); expect(geometry.getCoordinates()).to.eql([ [[10, -20], [30, -20], [40, -10], [10, -20]] @@ -631,7 +629,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); expect(geometry.getCoordinates()).to.eql([ [[10, -20], [30, -20], [40, -10], [10, -20]] @@ -655,7 +653,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); expect(geometry.getCoordinates()).to.eql([ [[10, -20], [30, -20], [40, -10], [10, -20]] @@ -665,8 +663,8 @@ describe('ol.interaction.Draw', function() { it('triggers draw events', function() { var ds = sinon.spy(); var de = sinon.spy(); - ol.events.listen(draw, 'drawstart', ds); - ol.events.listen(draw, 'drawend', de); + _ol_events_.listen(draw, 'drawstart', ds); + _ol_events_.listen(draw, 'drawend', de); // first point simulateEvent('pointermove', 10, 20); @@ -699,7 +697,7 @@ describe('ol.interaction.Draw', function() { describe('drawing multi-polygons', function() { beforeEach(function() { - map.addInteraction(new ol.interaction.Draw({ + map.addInteraction(new _ol_interaction_Draw_({ source: source, type: 'MultiPolygon' })); @@ -729,7 +727,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.MultiPolygon); + expect(geometry).to.be.a(_ol_geom_MultiPolygon_); var coordinates = geometry.getCoordinates(); expect(coordinates).to.have.length(1); @@ -761,7 +759,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.MultiPolygon); + expect(geometry).to.be.a(_ol_geom_MultiPolygon_); var coordinates = geometry.getCoordinates(); expect(coordinates).to.have.length(1); @@ -776,7 +774,7 @@ describe('ol.interaction.Draw', function() { var draw; beforeEach(function() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: 'Circle' }); @@ -797,14 +795,14 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); expect(features).to.have.length(1); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Circle); + expect(geometry).to.be.a(_ol_geom_Circle_); expect(geometry.getCenter()).to.eql([10, -20]); expect(geometry.getRadius()).to.eql(20); }); it('supports freehand drawing for circles', function() { draw.freehand_ = true; - draw.freehandCondition_ = ol.events.condition.always; + draw.freehandCondition_ = _ol_events_condition_.always; // no feture created when not moved simulateEvent('pointermove', 10, 20); @@ -823,8 +821,8 @@ describe('ol.interaction.Draw', function() { it('triggers draw events', function() { var ds = sinon.spy(); var de = sinon.spy(); - ol.events.listen(draw, 'drawstart', ds); - ol.events.listen(draw, 'drawend', de); + _ol_events_.listen(draw, 'drawstart', ds); + _ol_events_.listen(draw, 'drawend', de); // first point simulateEvent('pointermove', 10, 20); @@ -848,7 +846,7 @@ describe('ol.interaction.Draw', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Draw({ + interaction = new _ol_interaction_Draw_({ type: 'LineString' }); @@ -917,7 +915,7 @@ describe('ol.interaction.Draw', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Draw({ + interaction = new _ol_interaction_Draw_({ type: 'LineString' }); expect(interaction.getActive()).to.be(true); @@ -970,11 +968,11 @@ describe('ol.interaction.Draw', function() { describe('ol.interaction.Draw.createRegularPolygon', function() { it('creates a regular polygon in Circle mode', function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'Circle', geometryFunction: - ol.interaction.Draw.createRegularPolygon(4, Math.PI / 4) + _ol_interaction_Draw_.createRegularPolygon(4, Math.PI / 4) }); map.addInteraction(draw); @@ -990,7 +988,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); var coordinates = geometry.getCoordinates(); expect(coordinates[0].length).to.eql(5); expect(coordinates[0][0][0]).to.roughlyEqual(20, 1e-9); @@ -1000,10 +998,10 @@ describe('ol.interaction.Draw', function() { describe('ol.interaction.Draw.createBox', function() { it('creates a box-shaped polygon in Circle mode', function() { - var draw = new ol.interaction.Draw({ + var draw = new _ol_interaction_Draw_({ source: source, type: 'Circle', - geometryFunction: ol.interaction.Draw.createBox() + geometryFunction: _ol_interaction_Draw_.createBox() }); map.addInteraction(draw); @@ -1019,7 +1017,7 @@ describe('ol.interaction.Draw', function() { var features = source.getFeatures(); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Polygon); + expect(geometry).to.be.a(_ol_geom_Polygon_); var coordinates = geometry.getCoordinates(); expect(coordinates[0]).to.have.length(5); expect(geometry.getArea()).to.equal(400); @@ -1032,13 +1030,13 @@ describe('ol.interaction.Draw', function() { var feature; beforeEach(function() { - draw = new ol.interaction.Draw({ + draw = new _ol_interaction_Draw_({ source: source, type: 'LineString' }); map.addInteraction(draw); - feature = new ol.Feature( - new ol.geom.LineString([[0, 0], [1, 1], [2, 0]])); + feature = new _ol_Feature_( + new _ol_geom_LineString_([[0, 0], [1, 1], [2, 0]])); }); it('sets the initial state', function() { @@ -1050,7 +1048,7 @@ describe('ol.interaction.Draw', function() { it('dispatches a drawstart event', function() { var spy = sinon.spy(); - ol.events.listen(draw, 'drawstart', spy); + _ol_events_.listen(draw, 'drawstart', spy); draw.extend(feature); expect(spy.callCount).to.be(1); }); diff --git a/test/spec/ol/interaction/extent.test.js b/test/spec/ol/interaction/extent.test.js index 337367e77f..249d1890ef 100644 --- a/test/spec/ol/interaction/extent.test.js +++ b/test/spec/ol/interaction/extent.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.interaction.Extent'); -goog.require('ol.pointer.PointerEvent'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_interaction_Extent_ from '../../../../src/ol/interaction/Extent.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; describe('ol.interaction.Extent', function() { var map, interaction; @@ -15,10 +13,10 @@ describe('ol.interaction.Extent', function() { beforeEach(function() { var target = createMapDiv(width, height); - map = new ol.Map({ + map = new _ol_Map_({ target: target, layers: [], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -26,7 +24,7 @@ describe('ol.interaction.Extent', function() { }); map.renderSync(); - interaction = new ol.interaction.Extent(); + interaction = new _ol_interaction_Extent_(); map.addInteraction(interaction); }); @@ -52,14 +50,14 @@ describe('ol.interaction.Extent', function() { // calculated in case body has top < 0 (test runner with small window) var position = viewport.getBoundingClientRect(); var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; - var pointerEvent = new ol.pointer.PointerEvent(type, { + var pointerEvent = new _ol_pointer_PointerEvent_(type, { type: type, button: button, clientX: position.left + x + width / 2, clientY: position.top - y + height / 2, shiftKey: shiftKey }); - var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent); + var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent); event.pointerEvent.pointerId = 1; map.handleMapBrowserEvent(event); } @@ -68,7 +66,7 @@ describe('ol.interaction.Extent', function() { it('can be configured with an extent', function() { expect(function() { - new ol.interaction.Extent({ + new _ol_interaction_Extent_({ extent: [-10, -10, 10, 10] }); }).to.not.throwException(); diff --git a/test/spec/ol/interaction/interaction.test.js b/test/spec/ol/interaction/interaction.test.js index caaa21f461..f47be29f43 100644 --- a/test/spec/ol/interaction/interaction.test.js +++ b/test/spec/ol/interaction/interaction.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.events.EventTarget'); -goog.require('ol.interaction.Interaction'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; describe('ol.interaction.Interaction', function() { @@ -11,12 +9,12 @@ describe('ol.interaction.Interaction', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Interaction({}); + interaction = new _ol_interaction_Interaction_({}); }); it('creates a new interaction', function() { - expect(interaction).to.be.a(ol.interaction.Interaction); - expect(interaction).to.be.a(ol.events.EventTarget); + expect(interaction).to.be.a(_ol_interaction_Interaction_); + expect(interaction).to.be.a(_ol_events_EventTarget_); }); it('creates an active interaction', function() { @@ -28,14 +26,14 @@ describe('ol.interaction.Interaction', function() { describe('#getMap()', function() { it('retrieves the associated map', function() { - var map = new ol.Map({}); - var interaction = new ol.interaction.Interaction({}); + var map = new _ol_Map_({}); + var interaction = new _ol_interaction_Interaction_({}); interaction.setMap(map); expect(interaction.getMap()).to.be(map); }); it('returns null if no map', function() { - var interaction = new ol.interaction.Interaction({}); + var interaction = new _ol_interaction_Interaction_({}); expect(interaction.getMap()).to.be(null); }); @@ -44,14 +42,14 @@ describe('ol.interaction.Interaction', function() { describe('#setMap()', function() { it('allows a map to be set', function() { - var map = new ol.Map({}); - var interaction = new ol.interaction.Interaction({}); + var map = new _ol_Map_({}); + var interaction = new _ol_interaction_Interaction_({}); interaction.setMap(map); expect(interaction.getMap()).to.be(map); }); it('accepts null', function() { - var interaction = new ol.interaction.Interaction({}); + var interaction = new _ol_interaction_Interaction_({}); interaction.setMap(null); expect(interaction.getMap()).to.be(null); }); @@ -61,62 +59,62 @@ describe('ol.interaction.Interaction', function() { describe('zoomByDelta()', function() { it('changes view resolution', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolution: 1, resolutions: [4, 2, 1, 0.5, 0.25] }); - ol.interaction.Interaction.zoomByDelta(view, 1); + _ol_interaction_Interaction_.zoomByDelta(view, 1); expect(view.getResolution()).to.be(0.5); - ol.interaction.Interaction.zoomByDelta(view, -1); + _ol_interaction_Interaction_.zoomByDelta(view, -1); expect(view.getResolution()).to.be(1); - ol.interaction.Interaction.zoomByDelta(view, 2); + _ol_interaction_Interaction_.zoomByDelta(view, 2); expect(view.getResolution()).to.be(0.25); - ol.interaction.Interaction.zoomByDelta(view, -2); + _ol_interaction_Interaction_.zoomByDelta(view, -2); expect(view.getResolution()).to.be(1); }); it('changes view resolution and center relative to the anchor', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], resolution: 1, resolutions: [4, 2, 1, 0.5, 0.25] }); - ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]); + _ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]); expect(view.getCenter()).to.eql([5, 5]); - ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]); + _ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]); expect(view.getCenter()).to.eql([10, 10]); - ol.interaction.Interaction.zoomByDelta(view, 2, [0, 0]); + _ol_interaction_Interaction_.zoomByDelta(view, 2, [0, 0]); expect(view.getCenter()).to.eql([2.5, 2.5]); - ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]); + _ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]); expect(view.getCenter()).to.eql([10, 10]); }); it('changes view resolution and center relative to the anchor, while respecting the extent', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], extent: [-2.5, -2.5, 2.5, 2.5], resolution: 1, resolutions: [4, 2, 1, 0.5, 0.25] }); - ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]); + _ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]); expect(view.getCenter()).to.eql([2.5, 2.5]); - ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]); + _ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]); expect(view.getCenter()).to.eql([2.5, 2.5]); - ol.interaction.Interaction.zoomByDelta(view, 2, [10, 10]); + _ol_interaction_Interaction_.zoomByDelta(view, 2, [10, 10]); expect(view.getCenter()).to.eql([2.5, 2.5]); - ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]); + _ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]); expect(view.getCenter()).to.eql([2.5, 2.5]); }); }); diff --git a/test/spec/ol/interaction/keyboardpan.test.js b/test/spec/ol/interaction/keyboardpan.test.js index 52ce66a555..6fbf6a753a 100644 --- a/test/spec/ol/interaction/keyboardpan.test.js +++ b/test/spec/ol/interaction/keyboardpan.test.js @@ -1,17 +1,15 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserEvent'); -goog.require('ol.View'); -goog.require('ol.events.Event'); -goog.require('ol.interaction.Interaction'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; describe('ol.interaction.KeyboardPan', function() { var map; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: createMapDiv(100, 100), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], resolutions: [1], zoom: 0 @@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardPan', function() { describe('handleEvent()', function() { it('pans on arrow keys', function() { - var spy = sinon.spy(ol.interaction.Interaction, 'pan'); - var event = new ol.MapBrowserEvent('keydown', map, { + var spy = sinon.spy(_ol_interaction_Interaction_, 'pan'); + var event = new _ol_MapBrowserEvent_('keydown', map, { type: 'keydown', target: map.getTargetElement(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.originalEvent.keyCode = 40; // DOWN map.handleMapBrowserEvent(event); @@ -43,7 +41,7 @@ describe('ol.interaction.KeyboardPan', function() { expect(spy.getCall(1).args[1]).to.eql([0, 128]); expect(spy.getCall(2).args[1]).to.eql([-128, 0]); expect(spy.getCall(3).args[1]).to.eql([128, 0]); - ol.interaction.Interaction.pan.restore(); + _ol_interaction_Interaction_.pan.restore(); }); }); diff --git a/test/spec/ol/interaction/keyboardzoom.test.js b/test/spec/ol/interaction/keyboardzoom.test.js index 7229a93cf1..ae71af5bd8 100644 --- a/test/spec/ol/interaction/keyboardzoom.test.js +++ b/test/spec/ol/interaction/keyboardzoom.test.js @@ -1,17 +1,15 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserEvent'); -goog.require('ol.View'); -goog.require('ol.events.Event'); -goog.require('ol.interaction.Interaction'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; describe('ol.interaction.KeyboardZoom', function() { var map; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: createMapDiv(100, 100), - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], resolutions: [1], zoom: 0 @@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardZoom', function() { describe('handleEvent()', function() { it('zooms on + and - keys', function() { - var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); - var event = new ol.MapBrowserEvent('keydown', map, { + var spy = sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta'); + var event = new _ol_MapBrowserEvent_('keydown', map, { type: 'keydown', target: map.getTargetElement(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.originalEvent.charCode = '+'.charCodeAt(0); map.handleMapBrowserEvent(event); @@ -37,7 +35,7 @@ describe('ol.interaction.KeyboardZoom', function() { map.handleMapBrowserEvent(event); expect(spy.getCall(0).args[1]).to.eql(1); expect(spy.getCall(1).args[1]).to.eql(-1); - ol.interaction.Interaction.zoomByDelta.restore(); + _ol_interaction_Interaction_.zoomByDelta.restore(); }); }); diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index 2783e58283..52891c6065 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.Collection'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.events'); -goog.require('ol.events.condition'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Modify'); -goog.require('ol.layer.Vector'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.source.Vector'); +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_condition_ from '../../../../src/ol/events/condition.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_interaction_Modify_ from '../../../../src/ol/interaction/Modify.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.Modify', function() { @@ -36,23 +34,23 @@ describe('ol.interaction.Modify', function() { document.body.appendChild(target); features = [ - new ol.Feature({ - geometry: new ol.geom.Polygon([ + new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([ [[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]] ]) }) ]; - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ features: features }); - var layer = new ol.layer.Vector({source: source}); + var layer = new _ol_layer_Vector_({source: source}); - map = new ol.Map({ + map = new _ol_Map_({ target: target, layers: [layer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -83,7 +81,7 @@ describe('ol.interaction.Modify', function() { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) var position = viewport.getBoundingClientRect(); - var pointerEvent = new ol.pointer.PointerEvent(type, { + var pointerEvent = new _ol_pointer_PointerEvent_(type, { type: type, clientX: position.left + x + width / 2, clientY: position.top + y + height / 2, @@ -93,7 +91,7 @@ describe('ol.interaction.Modify', function() { button: button, isPrimary: true }); - var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent); + var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent); event.pointerEvent.pointerId = 1; map.handleMapBrowserEvent(event); } @@ -132,11 +130,11 @@ describe('ol.interaction.Modify', function() { var endevent = events[events.length - 1]; // first event should be modifystary - expect(startevent).to.be.an(ol.interaction.Modify.Event); + expect(startevent).to.be.an(_ol_interaction_Modify_.Event); expect(startevent.type).to.eql('modifystart'); // last event should be modifyend - expect(endevent).to.be.an(ol.interaction.Modify.Event); + expect(endevent).to.be.an(_ol_interaction_Modify_.Event); expect(endevent.type).to.eql('modifyend'); // make sure we get change events to events array @@ -153,10 +151,10 @@ describe('ol.interaction.Modify', function() { describe('constructor', function() { it('adds features to the RTree', function() { - var feature = new ol.Feature( - new ol.geom.Point([0, 0])); - var features = new ol.Collection([feature]); - var modify = new ol.interaction.Modify({ + var feature = new _ol_Feature_( + new _ol_geom_Point_([0, 0])); + var features = new _ol_Collection_([feature]); + var modify = new _ol_interaction_Modify_({ features: features }); var rbushEntries = modify.rBush_.getAll(); @@ -165,25 +163,25 @@ describe('ol.interaction.Modify', function() { }); it('accepts feature without geometry', function() { - var feature = new ol.Feature(); - var features = new ol.Collection([feature]); - var modify = new ol.interaction.Modify({ + var feature = new _ol_Feature_(); + var features = new _ol_Collection_([feature]); + var modify = new _ol_interaction_Modify_({ features: features }); var rbushEntries = modify.rBush_.getAll(); expect(rbushEntries.length).to.be(0); - feature.setGeometry(new ol.geom.Point([0, 10])); + feature.setGeometry(new _ol_geom_Point_([0, 10])); rbushEntries = modify.rBush_.getAll(); expect(rbushEntries.length).to.be(1); expect(rbushEntries[0].feature).to.be(feature); }); it('accepts a source', function() { - var feature = new ol.Feature( - new ol.geom.Point([0, 0])); - var source = new ol.source.Vector({features: [feature]}); - var modify = new ol.interaction.Modify({source: source}); + var feature = new _ol_Feature_( + new _ol_geom_Point_([0, 0])); + var source = new _ol_source_Vector_({features: [feature]}); + var modify = new _ol_interaction_Modify_({source: source}); var rbushEntries = modify.rBush_.getAll(); expect(rbushEntries.length).to.be(1); expect(rbushEntries[0].feature).to.be(feature); @@ -201,8 +199,8 @@ describe('ol.interaction.Modify', function() { var second = features[1]; var secondRevision = second.getGeometry().getRevision(); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -227,8 +225,8 @@ describe('ol.interaction.Modify', function() { }); it('deletes first vertex of a LineString', function() { - var lineFeature = new ol.Feature({ - geometry: new ol.geom.LineString( + var lineFeature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]] ) }); @@ -239,8 +237,8 @@ describe('ol.interaction.Modify', function() { var first = features[0]; var firstRevision = first.getGeometry().getRevision(); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -263,8 +261,8 @@ describe('ol.interaction.Modify', function() { }); it('deletes last vertex of a LineString', function() { - var lineFeature = new ol.Feature({ - geometry: new ol.geom.LineString( + var lineFeature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]] ) }); @@ -275,8 +273,8 @@ describe('ol.interaction.Modify', function() { var first = features[0]; var firstRevision = first.getGeometry().getRevision(); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -299,8 +297,8 @@ describe('ol.interaction.Modify', function() { }); it('deletes vertex of a LineString programmatically', function() { - var lineFeature = new ol.Feature({ - geometry: new ol.geom.LineString( + var lineFeature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]] ) }); @@ -311,8 +309,8 @@ describe('ol.interaction.Modify', function() { var first = features[0]; var firstRevision = first.getGeometry().getRevision(); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -341,16 +339,16 @@ describe('ol.interaction.Modify', function() { describe('vertex modification', function() { it('keeps the third dimension', function() { - var lineFeature = new ol.Feature({ - geometry: new ol.geom.LineString( + var lineFeature = new _ol_Feature_({ + geometry: new _ol_geom_LineString_( [[0, 0, 10], [10, 20, 20], [0, 40, 30], [40, 40, 40], [40, 0, 50]] ) }); features.length = 0; features.push(lineFeature); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -384,12 +382,12 @@ describe('ol.interaction.Modify', function() { describe('circle modification', function() { it('changes the circle radius and center', function() { - var circleFeature = new ol.Feature(new ol.geom.Circle([10, 10], 20)); + var circleFeature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20)); features.length = 0; features.push(circleFeature); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -419,8 +417,8 @@ describe('ol.interaction.Modify', function() { var modify, feature, events; beforeEach(function() { - modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -524,9 +522,9 @@ describe('ol.interaction.Modify', function() { var modify, feature, events; beforeEach(function() { - modify = new ol.interaction.Modify({ - features: new ol.Collection(features), - deleteCondition: ol.events.condition.doubleClick + modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features), + deleteCondition: _ol_events_condition_.doubleClick }); map.addInteraction(modify); @@ -577,8 +575,8 @@ describe('ol.interaction.Modify', function() { return false; }); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features), + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features), insertVertexCondition: listenerSpy }); map.addInteraction(modify); @@ -610,7 +608,7 @@ describe('ol.interaction.Modify', function() { beforeEach(function() { getListeners = function(feature, modify) { - var listeners = ol.events.getListeners( + var listeners = _ol_events_.getListeners( feature, 'change'); return listeners.filter(function(listener) { return listener.bindTo === modify; @@ -619,12 +617,12 @@ describe('ol.interaction.Modify', function() { }); it('updates circle segment data', function() { - var feature = new ol.Feature(new ol.geom.Circle([10, 10], 20)); + var feature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20)); features.length = 0; features.push(feature); - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -659,8 +657,8 @@ describe('ol.interaction.Modify', function() { }); it('updates polygon segment data', function() { - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); @@ -699,8 +697,8 @@ describe('ol.interaction.Modify', function() { describe('#setActive', function() { it('removes the vertexFeature of deactivation', function() { - var modify = new ol.interaction.Modify({ - features: new ol.Collection(features) + var modify = new _ol_interaction_Modify_({ + features: new _ol_Collection_(features) }); map.addInteraction(modify); expect(modify.vertexFeature_).to.be(null); diff --git a/test/spec/ol/interaction/mousewheelzoom.test.js b/test/spec/ol/interaction/mousewheelzoom.test.js index e538616e9e..a420fe4c49 100644 --- a/test/spec/ol/interaction/mousewheelzoom.test.js +++ b/test/spec/ol/interaction/mousewheelzoom.test.js @@ -1,23 +1,21 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserEvent'); -goog.require('ol.View'); -goog.require('ol.events.Event'); -goog.require('ol.has'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.MouseWheelZoom'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_has_ from '../../../../src/ol/has.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; +import _ol_interaction_MouseWheelZoom_ from '../../../../src/ol/interaction/MouseWheelZoom.js'; describe('ol.interaction.MouseWheelZoom', function() { var map, interaction; beforeEach(function() { - interaction = new ol.interaction.MouseWheelZoom(); - map = new ol.Map({ + interaction = new _ol_interaction_MouseWheelZoom_(); + map = new _ol_Map_({ target: createMapDiv(100, 100), interactions: [interaction], - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], resolutions: [2, 1, 0.5], zoom: 1 @@ -35,27 +33,27 @@ describe('ol.interaction.MouseWheelZoom', function() { describe('timeout duration', function() { var clock; beforeEach(function() { - sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); + sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta'); clock = sinon.useFakeTimers(); }); afterEach(function() { clock.restore(); - ol.interaction.Interaction.zoomByDelta.restore(); + _ol_interaction_Interaction_.zoomByDelta.restore(); }); it('works with the defaut value', function(done) { - var event = new ol.MapBrowserEvent('mousewheel', map, { + var event = new _ol_MapBrowserEvent_('mousewheel', map, { type: 'mousewheel', target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); map.handleMapBrowserEvent(event); clock.tick(50); // default timeout is 80 ms, not called yet - expect(ol.interaction.Interaction.zoomByDelta.called).to.be(false); + expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(false); clock.tick(30); - expect(ol.interaction.Interaction.zoomByDelta.called).to.be(true); + expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(true); done(); }); @@ -65,38 +63,38 @@ describe('ol.interaction.MouseWheelZoom', function() { describe('handleEvent()', function() { it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) { - var origHasFirefox = ol.has.FIREFOX; - ol.has.FIREFOX = true; + var origHasFirefox = _ol_has_.FIREFOX; + _ol_has_.FIREFOX = true; map.once('postrender', function() { - expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD); - ol.has.FIREFOX = origHasFirefox; + expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD); + _ol_has_.FIREFOX = origHasFirefox; done(); }); - var event = new ol.MapBrowserEvent('wheel', map, { + var event = new _ol_MapBrowserEvent_('wheel', map, { type: 'wheel', deltaMode: WheelEvent.DOM_DELTA_PIXEL, - deltaY: ol.has.DEVICE_PIXEL_RATIO, + deltaY: _ol_has_.DEVICE_PIXEL_RATIO, target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.coordinate = [0, 0]; map.handleMapBrowserEvent(event); }); it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) { - var origHasFirefox = ol.has.FIREFOX; - ol.has.FIREFOX = false; + var origHasFirefox = _ol_has_.FIREFOX; + _ol_has_.FIREFOX = false; map.once('postrender', function() { - expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD); - ol.has.FIREFOX = origHasFirefox; + expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD); + _ol_has_.FIREFOX = origHasFirefox; done(); }); - var event = new ol.MapBrowserEvent('wheel', map, { + var event = new _ol_MapBrowserEvent_('wheel', map, { type: 'wheel', deltaMode: WheelEvent.DOM_DELTA_PIXEL, deltaY: 1, target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.coordinate = [0, 0]; map.handleMapBrowserEvent(event); @@ -104,65 +102,65 @@ describe('ol.interaction.MouseWheelZoom', function() { describe('spying on ol.interaction.Interaction.zoomByDelta', function() { beforeEach(function() { - sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); + sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta'); }); afterEach(function() { - ol.interaction.Interaction.zoomByDelta.restore(); + _ol_interaction_Interaction_.zoomByDelta.restore(); }); it('works in DOM_DELTA_LINE mode (wheel)', function(done) { map.once('postrender', function() { - var call = ol.interaction.Interaction.zoomByDelta.getCall(0); + var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0); expect(call.args[1]).to.be(-1); expect(call.args[2]).to.eql([0, 0]); done(); }); - var event = new ol.MapBrowserEvent('wheel', map, { + var event = new _ol_MapBrowserEvent_('wheel', map, { type: 'wheel', deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 3.714599609375, target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.coordinate = [0, 0]; map.handleMapBrowserEvent(event); }); it('works on Safari (wheel)', function(done) { - var origHasSafari = ol.has.SAFARI; - ol.has.SAFARI = true; + var origHasSafari = _ol_has_.SAFARI; + _ol_has_.SAFARI = true; map.once('postrender', function() { - var call = ol.interaction.Interaction.zoomByDelta.getCall(0); + var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0); expect(call.args[1]).to.be(-1); expect(call.args[2]).to.eql([0, 0]); - ol.has.SAFARI = origHasSafari; + _ol_has_.SAFARI = origHasSafari; done(); }); - var event = new ol.MapBrowserEvent('mousewheel', map, { + var event = new _ol_MapBrowserEvent_('mousewheel', map, { type: 'mousewheel', wheelDeltaY: -50, target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.coordinate = [0, 0]; map.handleMapBrowserEvent(event); }); it('works on other browsers (wheel)', function(done) { - var origHasSafari = ol.has.SAFARI; - ol.has.SAFARI = false; + var origHasSafari = _ol_has_.SAFARI; + _ol_has_.SAFARI = false; map.once('postrender', function() { - var call = ol.interaction.Interaction.zoomByDelta.getCall(0); + var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0); expect(call.args[1]).to.be(-1); expect(call.args[2]).to.eql([0, 0]); - ol.has.SAFARI = origHasSafari; + _ol_has_.SAFARI = origHasSafari; done(); }); - var event = new ol.MapBrowserEvent('mousewheel', map, { + var event = new _ol_MapBrowserEvent_('mousewheel', map, { type: 'mousewheel', wheelDeltaY: -120, target: map.getViewport(), - preventDefault: ol.events.Event.prototype.preventDefault + preventDefault: _ol_events_Event_.prototype.preventDefault }); event.coordinate = [0, 0]; map.handleMapBrowserEvent(event); diff --git a/test/spec/ol/interaction/select.test.js b/test/spec/ol/interaction/select.test.js index f1b55b11b9..1d8b52ce6c 100644 --- a/test/spec/ol/interaction/select.test.js +++ b/test/spec/ol/interaction/select.test.js @@ -1,17 +1,15 @@ - - -goog.require('ol.Collection'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.MapBrowserEventType'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.geom.Polygon'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.Select'); -goog.require('ol.layer.Vector'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.source.Vector'); +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserEventType_ from '../../../../src/ol/MapBrowserEventType.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; +import _ol_interaction_Select_ from '../../../../src/ol/interaction/Select.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.Select', function() { @@ -31,40 +29,40 @@ describe('ol.interaction.Select', function() { style.height = height + 'px'; document.body.appendChild(target); - var geometry = new ol.geom.Polygon([[[0, 0], [0, 40], [40, 40], [40, 0]]]); + var geometry = new _ol_geom_Polygon_([[[0, 0], [0, 40], [40, 40], [40, 0]]]); // Four overlapping features, two features of type "foo" and two features // of type "bar". The rendering order is, from top to bottom, foo -> bar // -> foo -> bar. var features = []; features.push( - new ol.Feature({ + new _ol_Feature_({ geometry: geometry, type: 'bar' }), - new ol.Feature({ + new _ol_Feature_({ geometry: geometry, type: 'foo' }), - new ol.Feature({ + new _ol_Feature_({ geometry: geometry, type: 'bar' }), - new ol.Feature({ + new _ol_Feature_({ geometry: geometry, type: 'foo' })); - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ features: features }); - layer = new ol.layer.Vector({source: source}); + layer = new _ol_layer_Vector_({source: source}); - map = new ol.Map({ + map = new _ol_Map_({ target: target, layers: [layer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -94,27 +92,27 @@ describe('ol.interaction.Select', function() { // calculated in case body has top < 0 (test runner with small window) var position = viewport.getBoundingClientRect(); var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; - var event = new ol.pointer.PointerEvent(type, { + var event = new _ol_pointer_PointerEvent_(type, { clientX: position.left + x + width / 2, clientY: position.top + y + height / 2, shiftKey: shiftKey }); - map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event)); + map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event)); } describe('constructor', function() { it('creates a new interaction', function() { - var select = new ol.interaction.Select(); - expect(select).to.be.a(ol.interaction.Select); - expect(select).to.be.a(ol.interaction.Interaction); + var select = new _ol_interaction_Select_(); + expect(select).to.be.a(_ol_interaction_Select_); + expect(select).to.be.a(_ol_interaction_Interaction_); }); describe('user-provided collection', function() { it('uses the user-provided collection', function() { - var features = new ol.Collection(); - var select = new ol.interaction.Select({features: features}); + var features = new _ol_Collection_(); + var select = new _ol_interaction_Select_({features: features}); expect(select.getFeatures()).to.be(features); }); @@ -126,7 +124,7 @@ describe('ol.interaction.Select', function() { var select; beforeEach(function() { - select = new ol.interaction.Select(); + select = new _ol_interaction_Select_(); map.addInteraction(select); }); @@ -150,7 +148,7 @@ describe('ol.interaction.Select', function() { }); select.on('select', listenerSpy); - simulateEvent(ol.MapBrowserEventType.SINGLECLICK, -10, -10); + simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, -10, -10); expect(listenerSpy.callCount).to.be(0); @@ -164,8 +162,8 @@ describe('ol.interaction.Select', function() { }); select.on('select', listenerSpy); - simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 10, -20); - simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 9, -21); + simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 10, -20); + simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 9, -21); expect(listenerSpy.callCount).to.be(1); @@ -192,7 +190,7 @@ describe('ol.interaction.Select', function() { var select; beforeEach(function() { - select = new ol.interaction.Select({ + select = new _ol_interaction_Select_({ multi: true }); map.addInteraction(select); @@ -241,7 +239,7 @@ describe('ol.interaction.Select', function() { var select; beforeEach(function() { - select = new ol.interaction.Select({ + select = new _ol_interaction_Select_({ multi: true }); map.addInteraction(select); @@ -274,7 +272,7 @@ describe('ol.interaction.Select', function() { describe('with multi set to true', function() { it('only selects features that pass the filter', function() { - var select = new ol.interaction.Select({ + var select = new _ol_interaction_Select_({ multi: true, filter: function(feature, layer) { return feature.get('type') === 'bar'; @@ -291,7 +289,7 @@ describe('ol.interaction.Select', function() { it('only selects features that pass the filter ' + 'using shift single-click', function() { - var select = new ol.interaction.Select({ + var select = new _ol_interaction_Select_({ multi: true, filter: function(feature, layer) { return feature.get('type') === 'bar'; @@ -311,7 +309,7 @@ describe('ol.interaction.Select', function() { describe('with multi set to false', function() { it('only selects the first feature that passes the filter', function() { - var select = new ol.interaction.Select({ + var select = new _ol_interaction_Select_({ multi: false, filter: function(feature, layer) { return feature.get('type') === 'bar'; @@ -326,7 +324,7 @@ describe('ol.interaction.Select', function() { it('only selects the first feature that passes the filter ' + 'using shift single-click', function() { - var select = new ol.interaction.Select({ + var select = new _ol_interaction_Select_({ multi: false, filter: function(feature, layer) { return feature.get('type') === 'bar'; @@ -346,7 +344,7 @@ describe('ol.interaction.Select', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Select(); + interaction = new _ol_interaction_Select_(); map.addInteraction(interaction); }); afterEach(function() { @@ -358,8 +356,8 @@ describe('ol.interaction.Select', function() { var feature = e.selected[0]; var layer_ = interaction.getLayer(feature); expect(e.selected).to.have.length(1); - expect(feature).to.be.a(ol.Feature); - expect(layer_).to.be.a(ol.layer.Vector); + expect(feature).to.be.a(_ol_Feature_); + expect(layer_).to.be.a(_ol_layer_Vector_); expect(layer_).to.equal(layer); }); interaction.on('select', listenerSpy); @@ -374,7 +372,7 @@ describe('ol.interaction.Select', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Select(); + interaction = new _ol_interaction_Select_(); expect(interaction.getActive()).to.be(true); @@ -414,7 +412,7 @@ describe('ol.interaction.Select', function() { var interaction; beforeEach(function() { - interaction = new ol.interaction.Select(); + interaction = new _ol_interaction_Select_(); expect(interaction.getActive()).to.be(true); }); diff --git a/test/spec/ol/interaction/snap.test.js b/test/spec/ol/interaction/snap.test.js index d87c319ec0..4c2d2f1993 100644 --- a/test/spec/ol/interaction/snap.test.js +++ b/test/spec/ol/interaction/snap.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.Collection'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.LineString'); -goog.require('ol.interaction.Snap'); +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_interaction_Snap_ from '../../../../src/ol/interaction/Snap.js'; describe('ol.interaction.Snap', function() { @@ -15,8 +13,8 @@ describe('ol.interaction.Snap', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.interaction.Snap(); - expect(instance).to.be.an(ol.interaction.Snap); + var instance = new _ol_interaction_Snap_(); + expect(instance).to.be.an(_ol_interaction_Snap_); }); }); @@ -38,9 +36,9 @@ describe('ol.interaction.Snap', function() { style.height = height + 'px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -58,9 +56,9 @@ describe('ol.interaction.Snap', function() { }); it('can handle XYZ coordinates', function() { - var point = new ol.Feature(new ol.geom.Point([0, 0, 123])); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([point]) + var point = new _ol_Feature_(new _ol_geom_Point_([0, 0, 123])); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([point]) }); snapInteraction.setMap(map); @@ -69,15 +67,15 @@ describe('ol.interaction.Snap', function() { coordinate: [0, 0], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); // check that the coordinate is in XY and not XYZ expect(event.coordinate).to.eql([0, 0]); }); it('snaps to edges only', function() { - var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]])); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([point]), + var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]])); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([point]), pixelTolerance: 5, vertex: false }); @@ -88,14 +86,14 @@ describe('ol.interaction.Snap', function() { coordinate: [7, 4], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate).to.eql([7, 0]); }); it('snaps to vertices only', function() { - var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]])); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([point]), + var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]])); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([point]), pixelTolerance: 5, edge: false }); @@ -106,14 +104,14 @@ describe('ol.interaction.Snap', function() { coordinate: [7, 4], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate).to.eql([10, 0]); }); it('snaps to circle', function() { - var circle = new ol.Feature(new ol.geom.Circle([0, 0], 10)); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([circle]), + var circle = new _ol_Feature_(new _ol_geom_Circle_([0, 0], 10)); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([circle]), pixelTolerance: 5 }); snapInteraction.setMap(map); @@ -123,36 +121,36 @@ describe('ol.interaction.Snap', function() { coordinate: [5, 5], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate[0]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10); expect(event.coordinate[1]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10); }); it('handle feature without geometry', function() { - var feature = new ol.Feature(); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([feature]), + var feature = new _ol_Feature_(); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([feature]), pixelTolerance: 5, edge: false }); snapInteraction.setMap(map); - feature.setGeometry(new ol.geom.LineString([[-10, 0], [10, 0]])); + feature.setGeometry(new _ol_geom_LineString_([[-10, 0], [10, 0]])); var event = { pixel: [7 + width / 2, height / 2 - 4], coordinate: [7, 4], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate).to.eql([10, 0]); }); it('handle geometry changes', function() { - var line = new ol.Feature(new ol.geom.LineString([[-10, 0], [0, 0]])); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([line]), + var line = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [0, 0]])); + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([line]), pixelTolerance: 5, edge: false }); @@ -165,17 +163,17 @@ describe('ol.interaction.Snap', function() { coordinate: [7, 4], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate).to.eql([10, 0]); }); it('handle geometry name changes', function() { - var line = new ol.Feature({ - geometry: new ol.geom.LineString([[-10, 0], [0, 0]]), - alt_geometry: new ol.geom.LineString([[-10, 0], [10, 0]]) + var line = new _ol_Feature_({ + geometry: new _ol_geom_LineString_([[-10, 0], [0, 0]]), + alt_geometry: new _ol_geom_LineString_([[-10, 0], [10, 0]]) }); - var snapInteraction = new ol.interaction.Snap({ - features: new ol.Collection([line]), + var snapInteraction = new _ol_interaction_Snap_({ + features: new _ol_Collection_([line]), pixelTolerance: 5, edge: false }); @@ -188,7 +186,7 @@ describe('ol.interaction.Snap', function() { coordinate: [7, 4], map: map }; - ol.interaction.Snap.handleEvent_.call(snapInteraction, event); + _ol_interaction_Snap_.handleEvent_.call(snapInteraction, event); expect(event.coordinate).to.eql([10, 0]); }); diff --git a/test/spec/ol/interaction/translate.test.js b/test/spec/ol/interaction/translate.test.js index e2a08163fd..e97f594521 100644 --- a/test/spec/ol/interaction/translate.test.js +++ b/test/spec/ol/interaction/translate.test.js @@ -1,16 +1,14 @@ - - -goog.require('ol.Collection'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.interaction.Translate'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.layer.Vector'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.source.Vector'); +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_interaction_Translate_ from '../../../../src/ol/interaction/Translate.js'; +import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.interaction.Translate', function() { @@ -28,18 +26,18 @@ describe('ol.interaction.Translate', function() { style.width = width + 'px'; style.height = height + 'px'; document.body.appendChild(target); - source = new ol.source.Vector(); - features = [new ol.Feature({ - geometry: new ol.geom.Point([10, -20]) - }), new ol.Feature({ - geometry: new ol.geom.Point([20, -30]) + source = new _ol_source_Vector_(); + features = [new _ol_Feature_({ + geometry: new _ol_geom_Point_([10, -20]) + }), new _ol_Feature_({ + geometry: new _ol_geom_Point_([20, -30]) })]; source.addFeatures(features); - var layer = new ol.layer.Vector({source: source}); - map = new ol.Map({ + var layer = new _ol_layer_Vector_({source: source}); + map = new _ol_Map_({ target: target, layers: [layer], - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -68,8 +66,8 @@ describe('ol.interaction.Translate', function() { // calculated in case body has top < 0 (test runner with small window) var position = viewport.getBoundingClientRect(); var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false; - var event = new ol.MapBrowserPointerEvent(type, map, - new ol.pointer.PointerEvent(type, { + var event = new _ol_MapBrowserPointerEvent_(type, map, + new _ol_pointer_PointerEvent_(type, { clientX: position.left + x + width / 2, clientY: position.top + y + height / 2, shiftKey: shiftKey @@ -111,11 +109,11 @@ describe('ol.interaction.Translate', function() { var endevent = events[events.length - 1]; // first event should be translatestart - expect(startevent).to.be.an(ol.interaction.Translate.Event); + expect(startevent).to.be.an(_ol_interaction_Translate_.Event); expect(startevent.type).to.eql('translatestart'); // last event should be translateend - expect(endevent).to.be.an(ol.interaction.Translate.Event); + expect(endevent).to.be.an(_ol_interaction_Translate_.Event); expect(endevent.type).to.eql('translateend'); // make sure we get change events to events array @@ -134,11 +132,11 @@ describe('ol.interaction.Translate', function() { describe('constructor', function() { it('creates a new interaction', function() { - var translate = new ol.interaction.Translate({ + var translate = new _ol_interaction_Translate_({ features: features }); - expect(translate).to.be.a(ol.interaction.Translate); - expect(translate).to.be.a(ol.interaction.Interaction); + expect(translate).to.be.a(_ol_interaction_Translate_); + expect(translate).to.be.a(_ol_interaction_Interaction_); }); }); @@ -146,7 +144,7 @@ describe('ol.interaction.Translate', function() { describe('setActive', function() { it('works when the map is not set', function() { - var translate = new ol.interaction.Translate({ + var translate = new _ol_interaction_Translate_({ features: features }); expect(translate.getActive()).to.be(true); @@ -160,8 +158,8 @@ describe('ol.interaction.Translate', function() { var translate; beforeEach(function() { - translate = new ol.interaction.Translate({ - features: new ol.Collection([features[0]]) + translate = new _ol_interaction_Translate_({ + features: new _ol_Collection_([features[0]]) }); map.addInteraction(translate); }); @@ -174,7 +172,7 @@ describe('ol.interaction.Translate', function() { simulateEvent('pointerdrag', 50, -40); simulateEvent('pointerup', 50, -40); var geometry = features[0].getGeometry(); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([50, 40]); validateEvents(events, [features[0]]); @@ -188,7 +186,7 @@ describe('ol.interaction.Translate', function() { simulateEvent('pointerdrag', 50, -40); simulateEvent('pointerup', 50, -40); var geometry = features[1].getGeometry(); - expect(geometry).to.be.a(ol.geom.Point); + expect(geometry).to.be.a(_ol_geom_Point_); expect(geometry.getCoordinates()).to.eql([20, -30]); expect(events).to.be.empty(); @@ -199,7 +197,7 @@ describe('ol.interaction.Translate', function() { var translate; beforeEach(function() { - translate = new ol.interaction.Translate(); + translate = new _ol_interaction_Translate_(); map.addInteraction(translate); }); @@ -221,7 +219,7 @@ describe('ol.interaction.Translate', function() { var element, translate; beforeEach(function() { - translate = new ol.interaction.Translate(); + translate = new _ol_interaction_Translate_(); map.addInteraction(translate); element = map.getViewport(); }); diff --git a/test/spec/ol/layer/group.test.js b/test/spec/ol/layer/group.test.js index d051809023..1f2bc94c3e 100644 --- a/test/spec/ol/layer/group.test.js +++ b/test/spec/ol/layer/group.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol'); -goog.require('ol.array'); -goog.require('ol.Collection'); -goog.require('ol.extent'); -goog.require('ol.layer.Group'); -goog.require('ol.layer.Layer'); -goog.require('ol.obj'); -goog.require('ol.renderer.Map'); -goog.require('ol.source.Source'); +import _ol_ from '../../../../src/ol.js'; +import _ol_array_ from '../../../../src/ol/array.js'; +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_layer_Group_ from '../../../../src/ol/layer/Group.js'; +import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js'; +import _ol_obj_ from '../../../../src/ol/obj.js'; +import _ol_renderer_Map_ from '../../../../src/ol/renderer/Map.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; describe('ol.layer.Group', function() { @@ -18,7 +16,7 @@ describe('ol.layer.Group', function() { var layerGroup; beforeEach(function() { - layerGroup = new ol.layer.Group(); + layerGroup = new _ol_layer_Group_(); }); afterEach(function() { @@ -26,7 +24,7 @@ describe('ol.layer.Group', function() { }); it('creates an instance', function() { - expect(layerGroup).to.be.a(ol.layer.Group); + expect(layerGroup).to.be.a(_ol_layer_Group_); }); it('provides default opacity', function() { @@ -52,7 +50,7 @@ describe('ol.layer.Group', function() { }); it('provides default empty layers collection', function() { - expect(layerGroup.getLayers()).to.be.a(ol.Collection); + expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); expect(layerGroup.getLayers().getLength()).to.be(0); }); @@ -62,12 +60,12 @@ describe('ol.layer.Group', function() { var layer, group, listener; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); - group = new ol.layer.Group({ + group = new _ol_layer_Group_({ layers: [layer] }); listener = sinon.spy(); @@ -101,12 +99,12 @@ describe('ol.layer.Group', function() { var layer, group, listener; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); - group = new ol.layer.Group({ + group = new _ol_layer_Group_({ layers: [layer] }); listener = sinon.spy(); @@ -139,12 +137,12 @@ describe('ol.layer.Group', function() { describe('constructor (options)', function() { it('accepts options', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer], opacity: 0.5, visible: false, @@ -168,7 +166,7 @@ describe('ol.layer.Group', function() { maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getLayers()).to.be.a(ol.Collection); + expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); expect(layerGroup.getLayers().getLength()).to.be(1); expect(layerGroup.getLayers().item(0)).to.be(layer); @@ -177,14 +175,14 @@ describe('ol.layer.Group', function() { }); it('accepts an extent option', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); var groupExtent = [-10, -5, 10, 5]; - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer], opacity: 0.5, visible: false, @@ -209,7 +207,7 @@ describe('ol.layer.Group', function() { maxResolution: 500, minResolution: 0.25 }); - expect(layerGroup.getLayers()).to.be.a(ol.Collection); + expect(layerGroup.getLayers()).to.be.a(_ol_Collection_); expect(layerGroup.getLayers().getLength()).to.be(1); expect(layerGroup.getLayers().item(0)).to.be(layer); @@ -223,7 +221,7 @@ describe('ol.layer.Group', function() { var layerGroup; beforeEach(function() { - layerGroup = new ol.layer.Group(); + layerGroup = new _ol_layer_Group_(); }); afterEach(function() { @@ -286,16 +284,16 @@ describe('ol.layer.Group', function() { describe('layers events', function() { it('listen / unlisten for layers added to the collection', function() { - var layers = new ol.Collection(); - var layerGroup = new ol.layer.Group({ + var layers = new _ol_Collection_(); + var layerGroup = new _ol_layer_Group_({ layers: layers }); expect(Object.keys(layerGroup.listenerKeys_).length).to.eql(0); - var layer = new ol.layer.Layer({}); + var layer = new _ol_layer_Layer_({}); layers.push(layer); expect(Object.keys(layerGroup.listenerKeys_).length).to.eql(1); - var listeners = layerGroup.listenerKeys_[ol.getUid(layer)]; + var listeners = layerGroup.listenerKeys_[_ol_.getUid(layer)]; expect(listeners.length).to.eql(2); expect(typeof listeners[0]).to.be('object'); expect(typeof listeners[1]).to.be('object'); @@ -312,13 +310,13 @@ describe('ol.layer.Group', function() { describe('#setLayers', function() { it('sets layers property', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); - var layers = new ol.Collection([layer]); - var layerGroup = new ol.layer.Group(); + var layers = new _ol_Collection_([layer]); + var layerGroup = new _ol_layer_Group_(); layerGroup.setLayers(layers); expect(layerGroup.getLayers()).to.be(layers); @@ -334,7 +332,7 @@ describe('ol.layer.Group', function() { describe('#getLayerStatesArray', function() { it('returns an empty array if no layer', function() { - var layerGroup = new ol.layer.Group(); + var layerGroup = new _ol_layer_Group_(); var layerStatesArray = layerGroup.getLayerStatesArray(); expect(layerStatesArray).to.be.a(Array); @@ -343,13 +341,13 @@ describe('ol.layer.Group', function() { layerGroup.dispose(); }); - var layer1 = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer1 = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); - var layer2 = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer2 = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }), opacity: 0.5, @@ -357,15 +355,15 @@ describe('ol.layer.Group', function() { maxResolution: 500, minResolution: 0.25 }); - var layer3 = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer3 = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }), extent: [-5, -2, 5, 2] }); it('does not transform layerStates by default', function() { - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer1, layer2] }); @@ -375,9 +373,9 @@ describe('ol.layer.Group', function() { expect(layerStatesArray[0]).to.eql(layer1.getLayerState()); // layer state should match except for layer reference - var layerState = ol.obj.assign({}, layerStatesArray[0]); + var layerState = _ol_obj_.assign({}, layerStatesArray[0]); delete layerState.layer; - var groupState = ol.obj.assign({}, layerGroup.getLayerState()); + var groupState = _ol_obj_.assign({}, layerGroup.getLayerState()); delete groupState.layer; expect(layerState).to.eql(groupState); @@ -388,7 +386,7 @@ describe('ol.layer.Group', function() { it('uses the layer group extent if layer has no extent', function() { var groupExtent = [-10, -5, 10, 5]; - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ extent: groupExtent, layers: [layer1] }); @@ -399,18 +397,18 @@ describe('ol.layer.Group', function() { it('uses the intersection of group and child extent', function() { var groupExtent = [-10, -5, 10, 5]; - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ extent: groupExtent, layers: [layer3] }); var layerStatesArray = layerGroup.getLayerStatesArray(); expect(layerStatesArray[0].extent).to.eql( - ol.extent.getIntersection(layer3.getExtent(), groupExtent)); + _ol_extent_.getIntersection(layer3.getExtent(), groupExtent)); layerGroup.dispose(); }); it('transforms layerStates correctly', function() { - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer1, layer2], opacity: 0.5, visible: false, @@ -424,14 +422,14 @@ describe('ol.layer.Group', function() { var groupState, layerState; // layer state should match except for layer reference - layerState = ol.obj.assign({}, layerStatesArray[0]); + layerState = _ol_obj_.assign({}, layerStatesArray[0]); delete layerState.layer; - groupState = ol.obj.assign({}, layerGroup.getLayerState()); + groupState = _ol_obj_.assign({}, layerGroup.getLayerState()); delete groupState.layer; expect(layerState).to.eql(groupState); // layer state should be transformed (and we ignore layer reference) - layerState = ol.obj.assign({}, layerStatesArray[1]); + layerState = _ol_obj_.assign({}, layerStatesArray[1]); delete layerState.layer; expect(layerState).to.eql({ opacity: 0.25, @@ -448,13 +446,13 @@ describe('ol.layer.Group', function() { }); it('let order of layers without Z-index unchanged', function() { - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer1, layer2] }); var layerStatesArray = layerGroup.getLayerStatesArray(); var initialArray = layerStatesArray.slice(); - ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex); + _ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex); expect(layerStatesArray[0]).to.eql(initialArray[0]); expect(layerStatesArray[1]).to.eql(initialArray[1]); @@ -462,27 +460,27 @@ describe('ol.layer.Group', function() { }); it('orders layer with higher Z-index on top', function() { - var layer10 = new ol.layer.Layer({ - source: new ol.source.Source({ + var layer10 = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); layer10.setZIndex(10); - var layerM1 = new ol.layer.Layer({ - source: new ol.source.Source({ + var layerM1 = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ projection: 'EPSG:4326' }) }); layerM1.setZIndex(-1); - var layerGroup = new ol.layer.Group({ + var layerGroup = new _ol_layer_Group_({ layers: [layer1, layer10, layer2, layerM1] }); var layerStatesArray = layerGroup.getLayerStatesArray(); var initialArray = layerStatesArray.slice(); - ol.array.stableSort(layerStatesArray, ol.renderer.Map.sortByZIndex); + _ol_array_.stableSort(layerStatesArray, _ol_renderer_Map_.sortByZIndex); expect(layerStatesArray[0]).to.eql(initialArray[3]); expect(layerStatesArray[1]).to.eql(initialArray[0]); expect(layerStatesArray[2]).to.eql(initialArray[2]); diff --git a/test/spec/ol/layer/heatmap.test.js b/test/spec/ol/layer/heatmap.test.js index 404ba75f2b..b25fd33044 100644 --- a/test/spec/ol/layer/heatmap.test.js +++ b/test/spec/ol/layer/heatmap.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.layer.Heatmap'); +import _ol_layer_Heatmap_ from '../../../../src/ol/layer/Heatmap.js'; describe('ol.layer.Heatmap', function() { @@ -8,8 +6,8 @@ describe('ol.layer.Heatmap', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new ol.layer.Heatmap(); - expect(instance).to.be.an(ol.layer.Heatmap); + var instance = new _ol_layer_Heatmap_(); + expect(instance).to.be.an(_ol_layer_Heatmap_); }); }); diff --git a/test/spec/ol/layer/layer.test.js b/test/spec/ol/layer/layer.test.js index 608caabc9d..2cbf01cd55 100644 --- a/test/spec/ol/layer/layer.test.js +++ b/test/spec/ol/layer/layer.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol'); -goog.require('ol.Map'); -goog.require('ol.layer.Layer'); -goog.require('ol.proj'); -goog.require('ol.render.Event'); -goog.require('ol.source.Source'); +import _ol_ from '../../../../src/ol.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_render_Event_ from '../../../../src/ol/render/Event.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; describe('ol.layer.Layer', function() { @@ -15,9 +13,9 @@ describe('ol.layer.Layer', function() { var layer; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }) }); }); @@ -27,7 +25,7 @@ describe('ol.layer.Layer', function() { }); it('creates an instance', function() { - expect(layer).to.be.a(ol.layer.Layer); + expect(layer).to.be.a(_ol_layer_Layer_); }); it('provides default opacity', function() { @@ -65,9 +63,9 @@ describe('ol.layer.Layer', function() { describe('constructor (options)', function() { it('accepts options', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }), opacity: 0.5, visible: false, @@ -103,9 +101,9 @@ describe('ol.layer.Layer', function() { var layer; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }) }); }); @@ -119,7 +117,7 @@ describe('ol.layer.Layer', function() { layer.setMinResolution(3); layer.setMaxResolution(5); var layerState = layer.getLayerState(); - expect(ol.layer.Layer.visibleAtResolution(layerState, 4)).to.be(false); + expect(_ol_layer_Layer_.visibleAtResolution(layerState, 4)).to.be(false); }); it('returns false if resolution lower than minResolution', function() { @@ -127,7 +125,7 @@ describe('ol.layer.Layer', function() { layer.setMinResolution(3); layer.setMaxResolution(5); var layerState = layer.getLayerState(); - expect(ol.layer.Layer.visibleAtResolution(layerState, 2)).to.be(false); + expect(_ol_layer_Layer_.visibleAtResolution(layerState, 2)).to.be(false); }); it('returns false if resolution greater than maxResolution', function() { @@ -135,7 +133,7 @@ describe('ol.layer.Layer', function() { layer.setMinResolution(3); layer.setMaxResolution(5); var layerState = layer.getLayerState(); - expect(ol.layer.Layer.visibleAtResolution(layerState, 6)).to.be(false); + expect(_ol_layer_Layer_.visibleAtResolution(layerState, 6)).to.be(false); }); it('returns true otherwise', function() { @@ -143,7 +141,7 @@ describe('ol.layer.Layer', function() { layer.setMinResolution(3); layer.setMaxResolution(5); var layerState = layer.getLayerState(); - expect(ol.layer.Layer.visibleAtResolution(layerState, 4)).to.be(true); + expect(_ol_layer_Layer_.visibleAtResolution(layerState, 4)).to.be(true); }); }); @@ -153,9 +151,9 @@ describe('ol.layer.Layer', function() { var layer; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }) }); }); @@ -218,47 +216,47 @@ describe('ol.layer.Layer', function() { describe('#getSource', function() { it('gets the layer source', function() { - var source = new ol.source.Source({projection: ol.proj.get('EPSG:4326')}); - var layer = new ol.layer.Layer({source: source}); + var source = new _ol_source_Source_({projection: _ol_proj_.get('EPSG:4326')}); + var layer = new _ol_layer_Layer_({source: source}); expect(layer.getSource()).to.be(source); }); }); describe('#set("source", source)', function() { - var projection = ol.proj.get('EPSG:4326'); + var projection = _ol_proj_.get('EPSG:4326'); it('sets the layer source', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({projection: projection}) + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({projection: projection}) }); - var source = new ol.source.Source({projection: projection}); + var source = new _ol_source_Source_({projection: projection}); layer.set('source', source); expect(layer.getSource()).to.be(source); }); it('calls changed', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({projection: projection}) + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({projection: projection}) }); sinon.spy(layer, 'changed'); - var source = new ol.source.Source({projection: projection}); + var source = new _ol_source_Source_({projection: projection}); layer.set('source', source); expect(layer.changed.calledOnce).to.be(true); }); it('sets up event listeners', function() { - sinon.spy(ol.layer.Layer.prototype, 'handleSourceChange_'); + sinon.spy(_ol_layer_Layer_.prototype, 'handleSourceChange_'); - var first = new ol.source.Source({projection: projection}); - var layer = new ol.layer.Layer({source: first}); + var first = new _ol_source_Source_({projection: projection}); + var layer = new _ol_layer_Layer_({source: first}); first.setState('ready'); expect(layer.handleSourceChange_.calledOnce).to.be(true); - var second = new ol.source.Source({projection: projection}); + var second = new _ol_source_Source_({projection: projection}); layer.set('source', second); expect(layer.handleSourceChange_.calledOnce).to.be(true); @@ -266,45 +264,45 @@ describe('ol.layer.Layer', function() { expect(layer.handleSourceChange_.callCount).to.be(2); // remove spy - ol.layer.Layer.prototype.handleSourceChange_.restore(); + _ol_layer_Layer_.prototype.handleSourceChange_.restore(); }); }); describe('#setSource()', function() { - var projection = ol.proj.get('EPSG:4326'); + var projection = _ol_proj_.get('EPSG:4326'); it('sets the layer source', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({projection: projection}) + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({projection: projection}) }); - var source = new ol.source.Source({projection: projection}); + var source = new _ol_source_Source_({projection: projection}); layer.setSource(source); expect(layer.getSource()).to.be(source); }); it('calls changed', function() { - var layer = new ol.layer.Layer({ - source: new ol.source.Source({projection: projection}) + var layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({projection: projection}) }); sinon.spy(layer, 'changed'); - var source = new ol.source.Source({projection: projection}); + var source = new _ol_source_Source_({projection: projection}); layer.setSource(source); expect(layer.changed.calledOnce).to.be(true); }); it('sets up event listeners', function() { - sinon.spy(ol.layer.Layer.prototype, 'handleSourceChange_'); + sinon.spy(_ol_layer_Layer_.prototype, 'handleSourceChange_'); - var first = new ol.source.Source({projection: projection}); - var layer = new ol.layer.Layer({source: first}); + var first = new _ol_source_Source_({projection: projection}); + var layer = new _ol_layer_Layer_({source: first}); first.setState('ready'); expect(layer.handleSourceChange_.calledOnce).to.be(true); - var second = new ol.source.Source({projection: projection}); + var second = new _ol_source_Source_({projection: projection}); layer.setSource(second); expect(layer.handleSourceChange_.calledOnce).to.be(true); @@ -312,7 +310,7 @@ describe('ol.layer.Layer', function() { expect(layer.handleSourceChange_.callCount).to.be(2); // remove spy - ol.layer.Layer.prototype.handleSourceChange_.restore(); + _ol_layer_Layer_.prototype.handleSourceChange_.restore(); }); }); @@ -323,9 +321,9 @@ describe('ol.layer.Layer', function() { var layer; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }) }); }); @@ -353,9 +351,9 @@ describe('ol.layer.Layer', function() { var layer; beforeEach(function() { - layer = new ol.layer.Layer({ - source: new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + layer = new _ol_layer_Layer_({ + source: new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }) }); }); @@ -389,24 +387,24 @@ describe('ol.layer.Layer', function() { var map; beforeEach(function() { - map = new ol.Map({}); + map = new _ol_Map_({}); }); describe('with map in constructor options', function() { it('renders the layer', function() { - var layer = new ol.layer.Layer({ + var layer = new _ol_layer_Layer_({ map: map }); var frameState = { layerStatesArray: [], layerStates: {} }; - map.dispatchEvent(new ol.render.Event('precompose', null, + map.dispatchEvent(new _ol_render_Event_('precompose', null, frameState, null, null)); expect(frameState.layerStatesArray.length).to.be(1); var layerState = frameState.layerStatesArray[0]; expect(layerState.layer).to.equal(layer); - expect(frameState.layerStates[ol.getUid(layer)]).to.equal(layerState); + expect(frameState.layerStates[_ol_.getUid(layer)]).to.equal(layerState); }); }); @@ -422,7 +420,7 @@ describe('ol.layer.Layer', function() { }); it('requests a render frame', function() { - var layer = new ol.layer.Layer({}); + var layer = new _ol_layer_Layer_({}); layer.setMap(map); expect(mapRenderSpy.callCount).to.be(1); diff --git a/test/spec/ol/layer/tile.test.js b/test/spec/ol/layer/tile.test.js index 2fbc552703..340b510037 100644 --- a/test/spec/ol/layer/tile.test.js +++ b/test/spec/ol/layer/tile.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.layer.Tile'); -goog.require('ol.source.OSM'); +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_source_OSM_ from '../../../../src/ol/source/OSM.js'; describe('ol.layer.Tile', function() { @@ -11,8 +9,8 @@ describe('ol.layer.Tile', function() { var layer; beforeEach(function() { - layer = new ol.layer.Tile({ - source: new ol.source.OSM() + layer = new _ol_layer_Tile_({ + source: new _ol_source_OSM_() }); }); @@ -21,7 +19,7 @@ describe('ol.layer.Tile', function() { }); it('creates an instance', function() { - expect(layer).to.be.a(ol.layer.Tile); + expect(layer).to.be.a(_ol_layer_Tile_); }); it('provides default preload', function() { diff --git a/test/spec/ol/layer/vector.test.js b/test/spec/ol/layer/vector.test.js index 3d2dd283c0..da9cfb601f 100644 --- a/test/spec/ol/layer/vector.test.js +++ b/test/spec/ol/layer/vector.test.js @@ -1,25 +1,23 @@ - - -goog.require('ol.layer.Layer'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); +import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; describe('ol.layer.Vector', function() { describe('constructor', function() { - var source = new ol.source.Vector(); - var style = new ol.style.Style(); + var source = new _ol_source_Vector_(); + var style = new _ol_style_Style_(); it('creates a new layer', function() { - var layer = new ol.layer.Vector({source: source}); - expect(layer).to.be.a(ol.layer.Vector); - expect(layer).to.be.a(ol.layer.Layer); + var layer = new _ol_layer_Vector_({source: source}); + expect(layer).to.be.a(_ol_layer_Vector_); + expect(layer).to.be.a(_ol_layer_Layer_); }); it('accepts a style option with a single style', function() { - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source, style: style }); @@ -29,7 +27,7 @@ describe('ol.layer.Vector', function() { }); it('accepts a style option with an array of styles', function() { - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source, style: [style] }); @@ -39,7 +37,7 @@ describe('ol.layer.Vector', function() { }); it('accepts a style option with a style function', function() { - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source, style: function(feature, resolution) { return [style]; @@ -57,10 +55,10 @@ describe('ol.layer.Vector', function() { var layer, style; beforeEach(function() { - layer = new ol.layer.Vector({ - source: new ol.source.Vector() + layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_() }); - style = new ol.style.Style(); + style = new _ol_style_Style_(); }); it('allows the style to be set after construction', function() { @@ -76,10 +74,10 @@ describe('ol.layer.Vector', function() { }); it('updates the internal style function', function() { - expect(layer.getStyleFunction()).to.be(ol.style.Style.defaultFunction); + expect(layer.getStyleFunction()).to.be(_ol_style_Style_.defaultFunction); layer.setStyle(style); expect(layer.getStyleFunction()).not.to.be( - ol.style.Style.defaultFunction); + _ol_style_Style_.defaultFunction); }); it('allows setting an null style', function() { @@ -91,23 +89,23 @@ describe('ol.layer.Vector', function() { it('sets the default style when passing undefined', function() { layer.setStyle(style); layer.setStyle(undefined); - expect(layer.getStyle()).to.be(ol.style.Style.defaultFunction); - expect(layer.getStyleFunction()).to.be(ol.style.Style.defaultFunction); + expect(layer.getStyle()).to.be(_ol_style_Style_.defaultFunction); + expect(layer.getStyleFunction()).to.be(_ol_style_Style_.defaultFunction); }); }); describe('#getStyle()', function() { - var source = new ol.source.Vector(); - var style = new ol.style.Style(); + var source = new _ol_source_Vector_(); + var style = new _ol_style_Style_(); it('returns what is provided to setStyle', function() { - var layer = new ol.layer.Vector({ + var layer = new _ol_layer_Vector_({ source: source }); - expect(layer.getStyle()).to.be(ol.style.Style.defaultFunction); + expect(layer.getStyle()).to.be(_ol_style_Style_.defaultFunction); layer.setStyle(style); expect(layer.getStyle()).to.be(style); diff --git a/test/spec/ol/layer/vectortile.test.js b/test/spec/ol/layer/vectortile.test.js index 9acc63786b..060d5a3b2a 100644 --- a/test/spec/ol/layer/vectortile.test.js +++ b/test/spec/ol/layer/vectortile.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.layer.VectorTile'); -goog.require('ol.source.VectorTile'); +import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; +import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; describe('ol.layer.VectorTile', function() { @@ -11,8 +9,8 @@ describe('ol.layer.VectorTile', function() { var layer; beforeEach(function() { - layer = new ol.layer.VectorTile({ - source: new ol.source.VectorTile({}) + layer = new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({}) }); }); @@ -21,7 +19,7 @@ describe('ol.layer.VectorTile', function() { }); it('creates an instance', function() { - expect(layer).to.be.a(ol.layer.VectorTile); + expect(layer).to.be.a(_ol_layer_VectorTile_); }); it('provides default preload', function() { @@ -40,20 +38,20 @@ describe('ol.layer.VectorTile', function() { describe('constructor (options)', function() { it('works with options', function() { - var layer = new ol.layer.VectorTile({ + var layer = new _ol_layer_VectorTile_({ renderMode: 'vector', - source: new ol.source.VectorTile({}) + source: new _ol_source_VectorTile_({}) }); expect(layer.getRenderMode()).to.be('vector'); - layer = new ol.layer.VectorTile({ + layer = new _ol_layer_VectorTile_({ renderMode: 'image', - source: new ol.source.VectorTile({}) + source: new _ol_source_VectorTile_({}) }); expect(layer.getRenderMode()).to.be('image'); expect(function() { - layer = new ol.layer.VectorTile({ + layer = new _ol_layer_VectorTile_({ renderMode: 'foo', - source: new ol.source.VectorTile({}) + source: new _ol_source_VectorTile_({}) }); }).to.throwException(); }); diff --git a/test/spec/ol/map.test.js b/test/spec/ol/map.test.js index b4c1d1f7ea..d46a4d72ee 100644 --- a/test/spec/ol/map.test.js +++ b/test/spec/ol/map.test.js @@ -1,33 +1,31 @@ - - -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.MapEvent'); -goog.require('ol.Overlay'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.has'); -goog.require('ol.interaction'); -goog.require('ol.interaction.DoubleClickZoom'); -goog.require('ol.interaction.Interaction'); -goog.require('ol.interaction.MouseWheelZoom'); -goog.require('ol.interaction.PinchZoom'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.renderer.canvas.IntermediateCanvas'); -goog.require('ol.source.Vector'); -goog.require('ol.source.XYZ'); +import _ol_Feature_ from '../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_MapEvent_ from '../../../src/ol/MapEvent.js'; +import _ol_Overlay_ from '../../../src/ol/Overlay.js'; +import _ol_View_ from '../../../src/ol/View.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; +import _ol_has_ from '../../../src/ol/has.js'; +import _ol_interaction_ from '../../../src/ol/interaction.js'; +import _ol_interaction_DoubleClickZoom_ from '../../../src/ol/interaction/DoubleClickZoom.js'; +import _ol_interaction_Interaction_ from '../../../src/ol/interaction/Interaction.js'; +import _ol_interaction_MouseWheelZoom_ from '../../../src/ol/interaction/MouseWheelZoom.js'; +import _ol_interaction_PinchZoom_ from '../../../src/ol/interaction/PinchZoom.js'; +import _ol_layer_Tile_ from '../../../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../../../src/ol/layer/Vector.js'; +import _ol_renderer_canvas_IntermediateCanvas_ from '../../../src/ol/renderer/canvas/IntermediateCanvas.js'; +import _ol_source_Vector_ from '../../../src/ol/source/Vector.js'; +import _ol_source_XYZ_ from '../../../src/ol/source/XYZ.js'; describe('ol.Map', function() { describe('constructor', function() { it('creates a new map', function() { - var map = new ol.Map({}); - expect(map).to.be.a(ol.Map); + var map = new _ol_Map_({}); + expect(map).to.be.a(_ol_Map_); }); it('creates a set of default interactions', function() { - var map = new ol.Map({}); + var map = new _ol_Map_({}); var interactions = map.getInteractions(); var length = interactions.getLength(); expect(length).to.be.greaterThan(0); @@ -38,14 +36,14 @@ describe('ol.Map', function() { }); it('creates the viewport', function() { - var map = new ol.Map({}); + var map = new _ol_Map_({}); var viewport = map.getViewport(); - var className = 'ol-viewport' + (ol.has.TOUCH ? ' ol-touch' : ''); + var className = 'ol-viewport' + (_ol_has_.TOUCH ? ' ol-touch' : ''); expect(viewport.className).to.be(className); }); it('creates the overlay containers', function() { - var map = new ol.Map({}); + var map = new _ol_Map_({}); var container = map.getOverlayContainer(); expect(container.className).to.be('ol-overlaycontainer'); @@ -57,16 +55,16 @@ describe('ol.Map', function() { describe('#addLayer()', function() { it('adds a layer to the map', function() { - var map = new ol.Map({}); - var layer = new ol.layer.Tile(); + var map = new _ol_Map_({}); + var layer = new _ol_layer_Tile_(); map.addLayer(layer); expect(map.getLayers().item(0)).to.be(layer); }); it('throws if a layer is added twice', function() { - var map = new ol.Map({}); - var layer = new ol.layer.Tile(); + var map = new _ol_Map_({}); + var layer = new _ol_layer_Tile_(); map.addLayer(layer); var call = function() { @@ -78,8 +76,8 @@ describe('ol.Map', function() { describe('#addInteraction()', function() { it('adds an interaction to the map', function() { - var map = new ol.Map({}); - var interaction = new ol.interaction.Interaction({}); + var map = new _ol_Map_({}); + var interaction = new _ol_interaction_Interaction_({}); var before = map.getInteractions().getLength(); map.addInteraction(interaction); @@ -91,8 +89,8 @@ describe('ol.Map', function() { describe('#removeInteraction()', function() { it('removes an interaction from the map', function() { - var map = new ol.Map({}); - var interaction = new ol.interaction.Interaction({}); + var map = new _ol_Map_({}); + var interaction = new _ol_interaction_Interaction_({}); var before = map.getInteractions().getLength(); map.addInteraction(interaction); @@ -119,15 +117,15 @@ describe('ol.Map', function() { style.height = '180px'; document.body.appendChild(target); - view = new ol.View({ + view = new _ol_View_({ projection: 'EPSG:4326' }); - map = new ol.Map({ + map = new _ol_Map_({ target: target, view: view, layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ({ + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ url: '#{x}/{y}/{z}' }) }) @@ -195,14 +193,14 @@ describe('ol.Map', function() { target = document.createElement('div'); target.style.width = target.style.height = '100px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - layers: [new ol.layer.Vector({ - source: new ol.source.Vector({ - features: [new ol.Feature(new ol.geom.Point([0, 0]))] + layers: [new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ + features: [new _ol_Feature_(new _ol_geom_Point_([0, 0]))] }) })], - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 2 }) @@ -221,12 +219,12 @@ describe('ol.Map', function() { it('returns an array of found features', function() { var features = map.getFeaturesAtPixel([50, 50]); expect(features).to.be.an(Array); - expect(features[0]).to.be.an(ol.Feature); + expect(features[0]).to.be.an(_ol_Feature_); }); it('respects options', function() { - var otherLayer = new ol.layer.Vector({ - source: new ol.source.Vector + var otherLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_ }); map.addLayer(otherLayer); var features = map.getFeaturesAtPixel([50, 50], { @@ -245,8 +243,8 @@ describe('ol.Map', function() { beforeEach(function(done) { log = []; - original = ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate; - ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = function(coordinate) { + original = _ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate; + _ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate = function(coordinate) { log.push(coordinate.slice()); }; @@ -259,21 +257,21 @@ describe('ol.Map', function() { style.height = '180px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 1 }), layers: [ - new ol.layer.Tile({ - source: new ol.source.XYZ() + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_() }), - new ol.layer.Tile({ - source: new ol.source.XYZ() + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_() }), - new ol.layer.Tile({ - source: new ol.source.XYZ() + new _ol_layer_Tile_({ + source: new _ol_source_XYZ_() }) ] }); @@ -284,7 +282,7 @@ describe('ol.Map', function() { }); afterEach(function() { - ol.renderer.canvas.IntermediateCanvas.prototype.forEachLayerAtCoordinate = original; + _ol_renderer_canvas_IntermediateCanvas_.prototype.forEachLayerAtCoordinate = original; map.dispose(); document.body.removeChild(target); log = null; @@ -314,9 +312,9 @@ describe('ol.Map', function() { style.width = '360px'; style.height = '180px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -351,7 +349,7 @@ describe('ol.Map', function() { var spy = sinon.spy(map, 'renderFrame_'); map.render(); map.once('postrender', function(event) { - expect(event).to.be.a(ol.MapEvent); + expect(event).to.be.a(_ol_MapEvent_); expect(typeof spy.firstCall.args[0]).to.be('number'); spy.restore(); var frameState = event.frameState; @@ -391,7 +389,7 @@ describe('ol.Map', function() { map.render(); map.once('postrender', function(event) { - expect(event).to.be.a(ol.MapEvent); + expect(event).to.be.a(_ol_MapEvent_); var frameState = event.frameState; expect(frameState).to.be(null); done(); @@ -405,7 +403,7 @@ describe('ol.Map', function() { map.render(); map.once('postrender', function(event) { - expect(event).to.be.a(ol.MapEvent); + expect(event).to.be.a(_ol_MapEvent_); var frameState = event.frameState; expect(frameState).to.be(null); done(); @@ -419,7 +417,7 @@ describe('ol.Map', function() { var map; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: document.createElement('div') }); }); @@ -439,7 +437,7 @@ describe('ol.Map', function() { var map; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: document.createElement('div') }); expect(map.handleResize_).to.be.ok(); @@ -482,9 +480,9 @@ describe('ol.Map', function() { describe('create mousewheel interaction', function() { it('creates mousewheel interaction', function() { options.mouseWheelZoom = true; - var interactions = ol.interaction.defaults(options); + var interactions = _ol_interaction_.defaults(options); expect(interactions.getLength()).to.eql(1); - expect(interactions.item(0)).to.be.a(ol.interaction.MouseWheelZoom); + expect(interactions.item(0)).to.be.a(_ol_interaction_MouseWheelZoom_); expect(interactions.item(0).constrainResolution_).to.eql(false); expect(interactions.item(0).useAnchor_).to.eql(true); interactions.item(0).setMouseAnchor(false); @@ -495,9 +493,9 @@ describe('ol.Map', function() { describe('create pinchZoom interaction', function() { it('creates pinchZoom interaction', function() { options.pinchZoom = true; - var interactions = ol.interaction.defaults(options); + var interactions = _ol_interaction_.defaults(options); expect(interactions.getLength()).to.eql(1); - expect(interactions.item(0)).to.be.a(ol.interaction.PinchZoom); + expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_); expect(interactions.item(0).constrainResolution_).to.eql(false); }); }); @@ -507,11 +505,11 @@ describe('ol.Map', function() { options.pinchZoom = true; options.mouseWheelZoom = true; options.constrainResolution = true; - var interactions = ol.interaction.defaults(options); + var interactions = _ol_interaction_.defaults(options); expect(interactions.getLength()).to.eql(2); - expect(interactions.item(0)).to.be.a(ol.interaction.PinchZoom); + expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_); expect(interactions.item(0).constrainResolution_).to.eql(true); - expect(interactions.item(1)).to.be.a(ol.interaction.MouseWheelZoom); + expect(interactions.item(1)).to.be.a(_ol_interaction_MouseWheelZoom_); expect(interactions.item(1).constrainResolution_).to.eql(true); }); }); @@ -524,9 +522,9 @@ describe('ol.Map', function() { describe('default zoomDelta', function() { it('create double click interaction with default delta', function() { - var interactions = ol.interaction.defaults(options); + var interactions = _ol_interaction_.defaults(options); expect(interactions.getLength()).to.eql(1); - expect(interactions.item(0)).to.be.a(ol.interaction.DoubleClickZoom); + expect(interactions.item(0)).to.be.a(_ol_interaction_DoubleClickZoom_); expect(interactions.item(0).delta_).to.eql(1); }); }); @@ -534,9 +532,9 @@ describe('ol.Map', function() { describe('set zoomDelta', function() { it('create double click interaction with set delta', function() { options.zoomDelta = 7; - var interactions = ol.interaction.defaults(options); + var interactions = _ol_interaction_.defaults(options); expect(interactions.getLength()).to.eql(1); - expect(interactions.item(0)).to.be.a(ol.interaction.DoubleClickZoom); + expect(interactions.item(0)).to.be.a(_ol_interaction_DoubleClickZoom_); expect(interactions.item(0).delta_).to.eql(7); }); }); @@ -562,7 +560,7 @@ describe('ol.Map', function() { it('works with touchend events', function() { - var map = new ol.Map({ + var map = new _ol_Map_({ target: target }); @@ -594,9 +592,9 @@ describe('ol.Map', function() { style.width = '360px'; style.height = '180px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -612,7 +610,7 @@ describe('ol.Map', function() { }); it('returns an overlay by id', function() { - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ id: 'foo', element: overlay_target, position: [0, 0] @@ -622,7 +620,7 @@ describe('ol.Map', function() { }); it('returns null when no overlay is found', function() { - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ id: 'foo', element: overlay_target, position: [0, 0] @@ -632,7 +630,7 @@ describe('ol.Map', function() { }); it('returns null after removing overlay', function() { - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ id: 'foo', element: overlay_target, position: [0, 0] diff --git a/test/spec/ol/mapbrowserevent.test.js b/test/spec/ol/mapbrowserevent.test.js index 86558b0fde..eea7cf7e7f 100644 --- a/test/spec/ol/mapbrowserevent.test.js +++ b/test/spec/ol/mapbrowserevent.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.Map'); -goog.require('ol.MapBrowserEventHandler'); -goog.require('ol.events'); -goog.require('ol.has'); -goog.require('ol.pointer.PointerEvent'); +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_MapBrowserEventHandler_ from '../../../src/ol/MapBrowserEventHandler.js'; +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_has_ from '../../../src/ol/has.js'; +import _ol_pointer_PointerEvent_ from '../../../src/ol/pointer/PointerEvent.js'; describe('ol.MapBrowserEventHandler', function() { describe('#emulateClick_', function() { @@ -18,18 +16,18 @@ describe('ol.MapBrowserEventHandler', function() { beforeEach(function() { clock = sinon.useFakeTimers(); target = document.createElement('DIV'); - handler = new ol.MapBrowserEventHandler(new ol.Map({ + handler = new _ol_MapBrowserEventHandler_(new _ol_Map_({ target: target })); clickSpy = sinon.spy(); - ol.events.listen(handler, 'click', clickSpy); + _ol_events_.listen(handler, 'click', clickSpy); singleclickSpy = sinon.spy(); - ol.events.listen(handler, 'singleclick', singleclickSpy); + _ol_events_.listen(handler, 'singleclick', singleclickSpy); dblclickSpy = sinon.spy(); - ol.events.listen(handler, 'dblclick', dblclickSpy); + _ol_events_.listen(handler, 'dblclick', dblclickSpy); }); @@ -38,7 +36,7 @@ describe('ol.MapBrowserEventHandler', function() { }); it('emulates click', function() { - handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', { + handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', { type: 'mousedown', target: target, clientX: 0, @@ -48,7 +46,7 @@ describe('ol.MapBrowserEventHandler', function() { }); it('emulates singleclick', function() { - handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', { + handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', { type: 'mousedown', target: target, clientX: 0, @@ -61,7 +59,7 @@ describe('ol.MapBrowserEventHandler', function() { expect(singleclickSpy.calledOnce).to.be.ok(); expect(dblclickSpy.called).to.not.be.ok(); - handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', { + handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', { type: 'mousedown', target: target, clientX: 0, @@ -72,7 +70,7 @@ describe('ol.MapBrowserEventHandler', function() { }); it('emulates dblclick', function() { - handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', { + handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', { type: 'mousedown', target: target, clientX: 0, @@ -81,7 +79,7 @@ describe('ol.MapBrowserEventHandler', function() { expect(singleclickSpy.called).to.not.be.ok(); expect(dblclickSpy.called).to.not.be.ok(); - handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown', { + handler.emulateClick_(new _ol_pointer_PointerEvent_('pointerdown', { type: 'mousedown', target: target, clientX: 0, @@ -101,7 +99,7 @@ describe('ol.MapBrowserEventHandler', function() { var handler; beforeEach(function() { - handler = new ol.MapBrowserEventHandler(new ol.Map({})); + handler = new _ol_MapBrowserEventHandler_(new _ol_Map_({})); }); it('is null if no "down" type event has been handled', function() { @@ -109,7 +107,7 @@ describe('ol.MapBrowserEventHandler', function() { }); it('is an event after handlePointerDown_ has been called', function() { - var event = new ol.pointer.PointerEvent('pointerdown', {}); + var event = new _ol_pointer_PointerEvent_('pointerdown', {}); handler.handlePointerDown_(event); expect(handler.down_).to.be(event); }); @@ -121,9 +119,9 @@ describe('ol.MapBrowserEventHandler', function() { var moveToleranceHandler; var pointerdownAt0; beforeEach(function() { - defaultHandler = new ol.MapBrowserEventHandler(new ol.Map({})); - moveToleranceHandler = new ol.MapBrowserEventHandler(new ol.Map({}), 8); - pointerdownAt0 = new ol.pointer.PointerEvent('pointerdown', {}, { + defaultHandler = new _ol_MapBrowserEventHandler_(new _ol_Map_({})); + moveToleranceHandler = new _ol_MapBrowserEventHandler_(new _ol_Map_({}), 8); + pointerdownAt0 = new _ol_pointer_PointerEvent_('pointerdown', {}, { clientX: 0, clientY: 0 }); @@ -132,7 +130,7 @@ describe('ol.MapBrowserEventHandler', function() { }); it('is not moving if distance is 0', function() { - var pointerdownAt0 = new ol.pointer.PointerEvent('pointerdown', {}, { + var pointerdownAt0 = new _ol_pointer_PointerEvent_('pointerdown', {}, { clientX: 0, clientY: 0 }); @@ -140,33 +138,33 @@ describe('ol.MapBrowserEventHandler', function() { }); it('is moving if distance is 2', function() { - var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, { - clientX: ol.has.DEVICE_PIXEL_RATIO + 1, - clientY: ol.has.DEVICE_PIXEL_RATIO + 1 + var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, { + clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1, + clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1 }); expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true); }); it('is moving with negative distance', function() { - var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, { - clientX: -(ol.has.DEVICE_PIXEL_RATIO + 1), - clientY: -(ol.has.DEVICE_PIXEL_RATIO + 1) + var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, { + clientX: -(_ol_has_.DEVICE_PIXEL_RATIO + 1), + clientY: -(_ol_has_.DEVICE_PIXEL_RATIO + 1) }); expect(defaultHandler.isMoving_(pointerdownAt2)).to.be(true); }); it('is not moving if distance is less than move tolerance', function() { - var pointerdownAt2 = new ol.pointer.PointerEvent('pointerdown', {}, { - clientX: ol.has.DEVICE_PIXEL_RATIO + 1, - clientY: ol.has.DEVICE_PIXEL_RATIO + 1 + var pointerdownAt2 = new _ol_pointer_PointerEvent_('pointerdown', {}, { + clientX: _ol_has_.DEVICE_PIXEL_RATIO + 1, + clientY: _ol_has_.DEVICE_PIXEL_RATIO + 1 }); expect(moveToleranceHandler.isMoving_(pointerdownAt2)).to.be(false); }); it('is moving if distance is greater than move tolerance', function() { - var pointerdownAt9 = new ol.pointer.PointerEvent('pointerdown', {}, { - clientX: (ol.has.DEVICE_PIXEL_RATIO * 8) + 1, - clientY: (ol.has.DEVICE_PIXEL_RATIO * 8) + 1 + var pointerdownAt9 = new _ol_pointer_PointerEvent_('pointerdown', {}, { + clientX: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1, + clientY: (_ol_has_.DEVICE_PIXEL_RATIO * 8) + 1 }); expect(moveToleranceHandler.isMoving_(pointerdownAt9)).to.be(true); }); diff --git a/test/spec/ol/math.test.js b/test/spec/ol/math.test.js index d9be136a1e..ed93f51e7e 100644 --- a/test/spec/ol/math.test.js +++ b/test/spec/ol/math.test.js @@ -1,28 +1,26 @@ - - -goog.require('ol.math'); +import _ol_math_ from '../../../src/ol/math.js'; describe('ol.math.clamp', function() { it('returns the correct value at -Infinity', function() { - expect(ol.math.clamp(-Infinity, 10, 20)).to.eql(10); + expect(_ol_math_.clamp(-Infinity, 10, 20)).to.eql(10); }); it('returns the correct value at min', function() { - expect(ol.math.clamp(10, 10, 20)).to.eql(10); + expect(_ol_math_.clamp(10, 10, 20)).to.eql(10); }); it('returns the correct value at mid point', function() { - expect(ol.math.clamp(15, 10, 20)).to.eql(15); + expect(_ol_math_.clamp(15, 10, 20)).to.eql(15); }); it('returns the correct value at max', function() { - expect(ol.math.clamp(20, 10, 20)).to.eql(20); + expect(_ol_math_.clamp(20, 10, 20)).to.eql(20); }); it('returns the correct value at Infinity', function() { - expect(ol.math.clamp(Infinity, 10, 20)).to.eql(20); + expect(_ol_math_.clamp(Infinity, 10, 20)).to.eql(20); }); }); @@ -30,23 +28,23 @@ describe('ol.math.clamp', function() { describe('ol.math.cosh', function() { it('returns the correct value at -Infinity', function() { - expect(ol.math.cosh(-Infinity)).to.eql(Infinity); + expect(_ol_math_.cosh(-Infinity)).to.eql(Infinity); }); it('returns the correct value at -1', function() { - expect(ol.math.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9); + expect(_ol_math_.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9); }); it('returns the correct value at 0', function() { - expect(ol.math.cosh(0)).to.eql(1); + expect(_ol_math_.cosh(0)).to.eql(1); }); it('returns the correct value at 1', function() { - expect(ol.math.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9); + expect(_ol_math_.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9); }); it('returns the correct value at Infinity', function() { - expect(ol.math.cosh(Infinity)).to.eql(Infinity); + expect(_ol_math_.cosh(Infinity)).to.eql(Infinity); }); }); @@ -55,37 +53,37 @@ describe('ol.math.roundUpToPowerOfTwo', function() { it('raises an exception when x is negative', function() { expect(function() { - ol.math.roundUpToPowerOfTwo(-1); + _ol_math_.roundUpToPowerOfTwo(-1); }).to.throwException(); }); it('raises an exception when x is zero', function() { expect(function() { - ol.math.roundUpToPowerOfTwo(0); + _ol_math_.roundUpToPowerOfTwo(0); }).to.throwException(); }); it('returns the expected value for simple powers of two', function() { - expect(ol.math.roundUpToPowerOfTwo(1)).to.be(1); - expect(ol.math.roundUpToPowerOfTwo(2)).to.be(2); - expect(ol.math.roundUpToPowerOfTwo(4)).to.be(4); - expect(ol.math.roundUpToPowerOfTwo(8)).to.be(8); - expect(ol.math.roundUpToPowerOfTwo(16)).to.be(16); - expect(ol.math.roundUpToPowerOfTwo(32)).to.be(32); - expect(ol.math.roundUpToPowerOfTwo(64)).to.be(64); - expect(ol.math.roundUpToPowerOfTwo(128)).to.be(128); - expect(ol.math.roundUpToPowerOfTwo(256)).to.be(256); + expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1); + expect(_ol_math_.roundUpToPowerOfTwo(2)).to.be(2); + expect(_ol_math_.roundUpToPowerOfTwo(4)).to.be(4); + expect(_ol_math_.roundUpToPowerOfTwo(8)).to.be(8); + expect(_ol_math_.roundUpToPowerOfTwo(16)).to.be(16); + expect(_ol_math_.roundUpToPowerOfTwo(32)).to.be(32); + expect(_ol_math_.roundUpToPowerOfTwo(64)).to.be(64); + expect(_ol_math_.roundUpToPowerOfTwo(128)).to.be(128); + expect(_ol_math_.roundUpToPowerOfTwo(256)).to.be(256); }); it('returns the expected value for simple powers of ten', function() { - expect(ol.math.roundUpToPowerOfTwo(1)).to.be(1); - expect(ol.math.roundUpToPowerOfTwo(10)).to.be(16); - expect(ol.math.roundUpToPowerOfTwo(100)).to.be(128); - expect(ol.math.roundUpToPowerOfTwo(1000)).to.be(1024); - expect(ol.math.roundUpToPowerOfTwo(10000)).to.be(16384); - expect(ol.math.roundUpToPowerOfTwo(100000)).to.be(131072); - expect(ol.math.roundUpToPowerOfTwo(1000000)).to.be(1048576); - expect(ol.math.roundUpToPowerOfTwo(10000000)).to.be(16777216); + expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1); + expect(_ol_math_.roundUpToPowerOfTwo(10)).to.be(16); + expect(_ol_math_.roundUpToPowerOfTwo(100)).to.be(128); + expect(_ol_math_.roundUpToPowerOfTwo(1000)).to.be(1024); + expect(_ol_math_.roundUpToPowerOfTwo(10000)).to.be(16384); + expect(_ol_math_.roundUpToPowerOfTwo(100000)).to.be(131072); + expect(_ol_math_.roundUpToPowerOfTwo(1000000)).to.be(1048576); + expect(_ol_math_.roundUpToPowerOfTwo(10000000)).to.be(16777216); }); }); @@ -93,7 +91,7 @@ describe('ol.math.roundUpToPowerOfTwo', function() { describe('ol.math.solveLinearSystem', function() { it('calculates correctly', function() { - var result = ol.math.solveLinearSystem([ + var result = _ol_math_.solveLinearSystem([ [2, 1, 3, 1], [2, 6, 8, 3], [6, 8, 18, 5] @@ -104,7 +102,7 @@ describe('ol.math.solveLinearSystem', function() { }); it('can handle singular matrix', function() { - var result = ol.math.solveLinearSystem([ + var result = _ol_math_.solveLinearSystem([ [2, 1, 3, 1], [2, 6, 8, 3], [2, 1, 3, 1] @@ -116,60 +114,60 @@ describe('ol.math.solveLinearSystem', function() { describe('ol.math.toDegrees', function() { it('returns the correct value at -π', function() { - expect(ol.math.toDegrees(-Math.PI)).to.be(-180); + expect(_ol_math_.toDegrees(-Math.PI)).to.be(-180); }); it('returns the correct value at 0', function() { - expect(ol.math.toDegrees(0)).to.be(0); + expect(_ol_math_.toDegrees(0)).to.be(0); }); it('returns the correct value at π', function() { - expect(ol.math.toDegrees(Math.PI)).to.be(180); + expect(_ol_math_.toDegrees(Math.PI)).to.be(180); }); }); describe('ol.math.toRadians', function() { it('returns the correct value at -180', function() { - expect(ol.math.toRadians(-180)).to.be(-Math.PI); + expect(_ol_math_.toRadians(-180)).to.be(-Math.PI); }); it('returns the correct value at 0', function() { - expect(ol.math.toRadians(0)).to.be(0); + expect(_ol_math_.toRadians(0)).to.be(0); }); it('returns the correct value at 180', function() { - expect(ol.math.toRadians(180)).to.be(Math.PI); + expect(_ol_math_.toRadians(180)).to.be(Math.PI); }); }); describe('ol.math.modulo', function() { it('256 / 8 returns 0', function() { - expect(ol.math.modulo(256, 8)).to.be(0); + expect(_ol_math_.modulo(256, 8)).to.be(0); }); it('positive and positive returns a positive ', function() { - expect(ol.math.modulo(7, 8)).to.be(7); + expect(_ol_math_.modulo(7, 8)).to.be(7); }); it('same Dividend and Divisor returns 0', function() { - expect(ol.math.modulo(4, 4)).to.be(0); + expect(_ol_math_.modulo(4, 4)).to.be(0); }); it('negative and positive returns positive', function() { - expect(ol.math.modulo(-3, 4)).to.be(1); + expect(_ol_math_.modulo(-3, 4)).to.be(1); }); it('negative and negative returns negative', function() { - expect(ol.math.modulo(-4, -5)).to.be(-4); - expect(ol.math.modulo(-3, -4)).to.be(-3); + expect(_ol_math_.modulo(-4, -5)).to.be(-4); + expect(_ol_math_.modulo(-3, -4)).to.be(-3); }); it('positive and negative returns negative', function() { - expect(ol.math.modulo(3, -4)).to.be(-1); - expect(ol.math.modulo(1, -5)).to.be(-4); - expect(ol.math.modulo(6, -5)).to.be(-4); + expect(_ol_math_.modulo(3, -4)).to.be(-1); + expect(_ol_math_.modulo(1, -5)).to.be(-4); + expect(_ol_math_.modulo(6, -5)).to.be(-4); }); }); describe('ol.math.lerp', function() { it('correctly interpolated numbers', function() { - expect(ol.math.lerp(0, 0, 0)).to.be(0); - expect(ol.math.lerp(0, 1, 0)).to.be(0); - expect(ol.math.lerp(1, 11, 5)).to.be(51); + expect(_ol_math_.lerp(0, 0, 0)).to.be(0); + expect(_ol_math_.lerp(0, 1, 0)).to.be(0); + expect(_ol_math_.lerp(1, 11, 5)).to.be(51); }); it('correctly interpolates floats', function() { - expect(ol.math.lerp(0, 1, 0.5)).to.be(0.5); - expect(ol.math.lerp(0.25, 0.75, 0.5)).to.be(0.5); + expect(_ol_math_.lerp(0, 1, 0.5)).to.be(0.5); + expect(_ol_math_.lerp(0.25, 0.75, 0.5)).to.be(0.5); }); }); diff --git a/test/spec/ol/net.test.js b/test/spec/ol/net.test.js index 358c727ea6..436bcdcb64 100644 --- a/test/spec/ol/net.test.js +++ b/test/spec/ol/net.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol'); -goog.require('ol.net'); +import _ol_ from '../../../src/ol.js'; +import _ol_net_ from '../../../src/ol/net.js'; describe('ol.net', function() { @@ -19,7 +17,7 @@ describe('ol.net', function() { expect(removeChild.called).to.be(true); done(); }; - key = 'olc_' + ol.getUid(callback); + key = 'olc_' + _ol_.getUid(callback); return callback; } @@ -56,11 +54,11 @@ describe('ol.net', function() { }); it('appends callback param to url, cleans up after call', function(done) { - ol.net.jsonp('foo', createCallback('foo?callback=', done)); + _ol_net_.jsonp('foo', createCallback('foo?callback=', done)); }); it('appends correct callback param to a url with query', function(done) { var callback = createCallback('http://foo/bar?baz&callback=', done); - ol.net.jsonp('http://foo/bar?baz', callback); + _ol_net_.jsonp('http://foo/bar?baz', callback); }); it('calls errback when jsonp is not executed, cleans up', function(done) { head.appendChild = function(element) { @@ -76,11 +74,11 @@ describe('ol.net', function() { expect(removeChild.called).to.be(true); done(); } - ol.net.jsonp('foo', callback, errback); + _ol_net_.jsonp('foo', callback, errback); }); it('accepts a custom callback param', function(done) { var callback = createCallback('foo?mycallback=', done); - ol.net.jsonp('foo', callback, undefined, 'mycallback'); + _ol_net_.jsonp('foo', callback, undefined, 'mycallback'); }); }); diff --git a/test/spec/ol/object.test.js b/test/spec/ol/object.test.js index 646225a668..379a151903 100644 --- a/test/spec/ol/object.test.js +++ b/test/spec/ol/object.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.Object'); -goog.require('ol.events'); +import _ol_Object_ from '../../../src/ol/Object.js'; +import _ol_events_ from '../../../src/ol/events.js'; describe('ol.Object', function() { var o; beforeEach(function() { - o = new ol.Object(); + o = new _ol_Object_(); }); describe('get, set and unset', function() { @@ -51,7 +49,7 @@ describe('ol.Object', function() { describe('#get()', function() { it('does not return values that are not explicitly set', function() { - var o = new ol.Object(); + var o = new _ol_Object_(); expect(o.get('constructor')).to.be(undefined); expect(o.get('hasOwnProperty')).to.be(undefined); expect(o.get('isPrototypeOf')).to.be(undefined); @@ -65,7 +63,7 @@ describe('ol.Object', function() { describe('#set()', function() { it('can be used with arbitrary names', function() { - var o = new ol.Object(); + var o = new _ol_Object_(); o.set('set', 'sat'); expect(o.get('set')).to.be('sat'); @@ -82,7 +80,7 @@ describe('ol.Object', function() { describe('#getKeys()', function() { it('returns property names set at construction', function() { - var o = new ol.Object({ + var o = new _ol_Object_({ prop1: 'val1', prop2: 'val2', toString: 'string', @@ -117,10 +115,10 @@ describe('ol.Object', function() { beforeEach(function() { listener1 = sinon.spy(); - ol.events.listen(o, 'change:k', listener1); + _ol_events_.listen(o, 'change:k', listener1); listener2 = sinon.spy(); - ol.events.listen(o, 'propertychange', listener2); + _ol_events_.listen(o, 'propertychange', listener2); }); it('dispatches events', function() { @@ -150,10 +148,10 @@ describe('ol.Object', function() { beforeEach(function() { listener1 = sinon.spy(); - ol.events.listen(o, 'change:k', listener1); + _ol_events_.listen(o, 'change:k', listener1); listener2 = sinon.spy(); - ol.events.listen(o, 'propertychange', listener2); + _ol_events_.listen(o, 'propertychange', listener2); }); it('dispatches events to object', function() { @@ -214,7 +212,7 @@ describe('ol.Object', function() { describe('create with options', function() { it('sets the property', function() { - var o = new ol.Object({k: 1}); + var o = new _ol_Object_({k: 1}); expect(o.get('k')).to.eql(1); expect(o.getKeys()).to.eql(['k']); @@ -226,9 +224,9 @@ describe('ol.Object', function() { beforeEach(function() { listener1 = sinon.spy(); - ol.events.listen(o, 'change:k', listener1); + _ol_events_.listen(o, 'change:k', listener1); listener2 = sinon.spy(); - ol.events.listen(o, 'change:K', listener2); + _ol_events_.listen(o, 'change:K', listener2); }); it('dispatches the expected event', function() { diff --git a/test/spec/ol/objectutil.test.js b/test/spec/ol/objectutil.test.js index e4296fba0c..69da1fcd11 100644 --- a/test/spec/ol/objectutil.test.js +++ b/test/spec/ol/objectutil.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.obj'); +import _ol_obj_ from '../../../src/ol/obj.js'; describe('ol.obj.assign()', function() { it('is an alias for Object.assign() where available', function() { if (typeof Object.assign === 'function') { - expect(ol.obj.assign).to.be(Object.assign); + expect(_ol_obj_.assign).to.be(Object.assign); } }); @@ -23,7 +21,7 @@ describe('ol.obj.assign()', function() { targetProp1: 'targetValue1' }; - var assigned = ol.obj.assign(target, source); + var assigned = _ol_obj_.assign(target, source); expect(assigned).to.be(target); expect(assigned.sourceProp1).to.be('sourceValue1'); expect(assigned.sourceProp2).to.be('sourceValue2'); @@ -32,13 +30,13 @@ describe('ol.obj.assign()', function() { }); it('throws a TypeError with `undefined` as target', function() { - expect(ol.obj.assign).withArgs(undefined).to.throwException(function(e) { + expect(_ol_obj_.assign).withArgs(undefined).to.throwException(function(e) { expect(e).to.be.a(TypeError); }); }); it('throws a TypeError with `null` as target', function() { - expect(ol.obj.assign).withArgs(null).to.throwException(function(e) { + expect(_ol_obj_.assign).withArgs(null).to.throwException(function(e) { expect(e).to.be.a(TypeError); }); }); @@ -48,8 +46,8 @@ describe('ol.obj.assign()', function() { describe('ol.obj.clear()', function() { it('removes all properties from an object', function() { - var clear = ol.obj.clear; - var isEmpty = ol.obj.isEmpty; + var clear = _ol_obj_.clear; + var isEmpty = _ol_obj_.isEmpty; expect(isEmpty(clear({foo: 'bar'}))).to.be(true); expect(isEmpty(clear({foo: 'bar', num: 42}))).to.be(true); expect(isEmpty(clear({}))).to.be(true); @@ -61,8 +59,8 @@ describe('ol.obj.clear()', function() { describe('ol.obj.getValues()', function() { it('gets a list of property values from an object', function() { - expect(ol.obj.getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']); - expect(ol.obj.getValues(null)).to.eql([]); + expect(_ol_obj_.getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']); + expect(_ol_obj_.getValues(null)).to.eql([]); }); }); @@ -70,10 +68,10 @@ describe('ol.obj.getValues()', function() { describe('ol.obj.isEmpty()', function() { it('checks if an object has any properties', function() { - expect(ol.obj.isEmpty({})).to.be(true); - expect(ol.obj.isEmpty(null)).to.be(true); - expect(ol.obj.isEmpty({foo: 'bar'})).to.be(false); - expect(ol.obj.isEmpty({foo: false})).to.be(false); + expect(_ol_obj_.isEmpty({})).to.be(true); + expect(_ol_obj_.isEmpty(null)).to.be(true); + expect(_ol_obj_.isEmpty({foo: 'bar'})).to.be(false); + expect(_ol_obj_.isEmpty({foo: false})).to.be(false); }); }); diff --git a/test/spec/ol/observable.test.js b/test/spec/ol/observable.test.js index 42c1c84692..a9fb74fee1 100644 --- a/test/spec/ol/observable.test.js +++ b/test/spec/ol/observable.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.events.EventTarget'); -goog.require('ol.Observable'); +import _ol_events_EventTarget_ from '../../../src/ol/events/EventTarget.js'; +import _ol_Observable_ from '../../../src/ol/Observable.js'; describe('ol.Observable', function() { @@ -9,9 +7,9 @@ describe('ol.Observable', function() { describe('constructor', function() { it('creates a new observable', function() { - var observable = new ol.Observable(); - expect(observable).to.be.a(ol.Observable); - expect(observable).to.be.a(ol.events.EventTarget); + var observable = new _ol_Observable_(); + expect(observable).to.be.a(_ol_Observable_); + expect(observable).to.be.a(_ol_events_EventTarget_); }); }); @@ -19,7 +17,7 @@ describe('ol.Observable', function() { describe('#on()', function() { var observable, listener; beforeEach(function() { - observable = new ol.Observable(); + observable = new _ol_Observable_(); listener = sinon.spy(); }); @@ -63,7 +61,7 @@ describe('ol.Observable', function() { describe('#once()', function() { var observable, listener; beforeEach(function() { - observable = new ol.Observable(); + observable = new _ol_Observable_(); listener = sinon.spy(); }); @@ -128,7 +126,7 @@ describe('ol.Observable', function() { describe('#un()', function() { var observable, listener; beforeEach(function() { - observable = new ol.Observable(); + observable = new _ol_Observable_(); listener = sinon.spy(); }); @@ -166,7 +164,7 @@ describe('ol.Observable', function() { describe('ol.Observable.unByKey()', function() { var observable, listener; beforeEach(function() { - observable = new ol.Observable(); + observable = new _ol_Observable_(); listener = sinon.spy(); }); @@ -176,7 +174,7 @@ describe('ol.Observable', function() { observable.dispatchEvent('foo'); expect(listener.calledOnce).to.be(true); - ol.Observable.unByKey(key); + _ol_Observable_.unByKey(key); observable.dispatchEvent('foo'); expect(listener.callCount).to.be(1); }); diff --git a/test/spec/ol/overlay.test.js b/test/spec/ol/overlay.test.js index 0b8ffde2d6..ec25b13555 100644 --- a/test/spec/ol/overlay.test.js +++ b/test/spec/ol/overlay.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.Map'); -goog.require('ol.Overlay'); -goog.require('ol.View'); +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_Overlay_ from '../../../src/ol/Overlay.js'; +import _ol_View_ from '../../../src/ol/View.js'; describe('ol.Overlay', function() { @@ -22,9 +20,9 @@ describe('ol.Overlay', function() { style.height = height + 'px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ projection: 'EPSG:4326', center: [0, 0], resolution: 1 @@ -40,13 +38,13 @@ describe('ol.Overlay', function() { describe('constructor', function() { it('can be constructed with minimal arguments', function() { - var instance = new ol.Overlay({}); - expect(instance).to.be.an(ol.Overlay); + var instance = new _ol_Overlay_({}); + expect(instance).to.be.an(_ol_Overlay_); }); it('can be constructed with className', function() { - var instance = new ol.Overlay({className: 'my-class'}); - expect(instance).to.be.an(ol.Overlay); + var instance = new _ol_Overlay_({className: 'my-class'}); + expect(instance).to.be.an(_ol_Overlay_); expect(instance.element.className).to.be('my-class'); }); @@ -63,14 +61,14 @@ describe('ol.Overlay', function() { }); it('returns the overlay identifier', function() { - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ element: target, position: [0, 0] }); map.addOverlay(overlay); expect(overlay.getId()).to.be(undefined); map.removeOverlay(overlay); - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ id: 'foo', element: target, position: [0, 0] @@ -92,7 +90,7 @@ describe('ol.Overlay', function() { }); it('changes the CSS display value', function() { - overlay = new ol.Overlay({ + overlay = new _ol_Overlay_({ element: target, position: [0, 0] }); diff --git a/test/spec/ol/pointer/mousesource.test.js b/test/spec/ol/pointer/mousesource.test.js index d4ea9d264e..b5501d4b56 100644 --- a/test/spec/ol/pointer/mousesource.test.js +++ b/test/spec/ol/pointer/mousesource.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); -goog.require('ol.has'); -goog.require('ol.pointer.PointerEventHandler'); -goog.require('ol.pointer.TouchSource'); +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; +import _ol_has_ from '../../../../src/ol/has.js'; +import _ol_pointer_PointerEventHandler_ from '../../../../src/ol/pointer/PointerEventHandler.js'; +import _ol_pointer_TouchSource_ from '../../../../src/ol/pointer/TouchSource.js'; describe('ol.pointer.MouseSource', function() { @@ -15,14 +13,14 @@ describe('ol.pointer.MouseSource', function() { beforeEach(function() { clock = sinon.useFakeTimers(); - target = new ol.events.EventTarget(); + target = new _ol_events_EventTarget_(); // make sure that a mouse and touch event source is used - ol.has.POINTER = false; - ol.has.MSPOINTER = false; - ol.has.TOUCH = true; + _ol_has_.POINTER = false; + _ol_has_.MSPOINTER = false; + _ol_has_.TOUCH = true; - handler = new ol.pointer.PointerEventHandler(target); + handler = new _ol_pointer_PointerEventHandler_(target); eventSpy = sinon.spy(); }); @@ -33,7 +31,7 @@ describe('ol.pointer.MouseSource', function() { describe('simulated mouse events', function() { it('prevents simulated mouse events', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); // simulates that a mouse event is triggered from a touch simulateTouchEvent('touchstart', 10, 20); @@ -44,7 +42,7 @@ describe('ol.pointer.MouseSource', function() { }); it('dispatches real mouse events', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); // the two events are at different positions simulateTouchEvent('touchstart', 10, 20); @@ -55,9 +53,9 @@ describe('ol.pointer.MouseSource', function() { it('dispatches real mouse events after timeout', function() { // set the timeout to a lower value, to speed up the tests - ol.pointer.TouchSource.DEDUP_TIMEOUT = 100; + _ol_pointer_TouchSource_.DEDUP_TIMEOUT = 100; - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); // first simulate a touch event, then a mouse event // at the same position after a timeout diff --git a/test/spec/ol/pointer/pointereventhandler.test.js b/test/spec/ol/pointer/pointereventhandler.test.js index da493a1b14..47b6f76946 100644 --- a/test/spec/ol/pointer/pointereventhandler.test.js +++ b/test/spec/ol/pointer/pointereventhandler.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.events'); -goog.require('ol.events.EventTarget'); -goog.require('ol.has'); -goog.require('ol.pointer.MouseSource'); -goog.require('ol.pointer.PointerEvent'); -goog.require('ol.pointer.PointerEventHandler'); +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; +import _ol_has_ from '../../../../src/ol/has.js'; +import _ol_pointer_MouseSource_ from '../../../../src/ol/pointer/MouseSource.js'; +import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js'; +import _ol_pointer_PointerEventHandler_ from '../../../../src/ol/pointer/PointerEventHandler.js'; describe('ol.pointer.PointerEventHandler', function() { @@ -14,13 +12,13 @@ describe('ol.pointer.PointerEventHandler', function() { var eventSpy; beforeEach(function() { - target = new ol.events.EventTarget(); + target = new _ol_events_EventTarget_(); // make sure that a mouse event source is used - ol.has.POINTER = false; - ol.has.MSPOINTER = false; + _ol_has_.POINTER = false; + _ol_has_.MSPOINTER = false; - handler = new ol.pointer.PointerEventHandler(target); + handler = new _ol_pointer_PointerEventHandler_(target); eventSpy = sinon.spy(); }); @@ -32,7 +30,7 @@ describe('ol.pointer.PointerEventHandler', function() { describe('constructor', function() { it('registers a least one event source', function() { expect(handler.eventSourceList_.length).to.be.greaterThan(0); - expect(handler.eventSourceList_[0]).to.be.a(ol.pointer.MouseSource); + expect(handler.eventSourceList_[0]).to.be.a(_ol_pointer_MouseSource_); }); }); @@ -48,12 +46,12 @@ describe('ol.pointer.PointerEventHandler', function() { describe('pointer down', function() { it('fires pointerdown events', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); simulateEvent('mousedown', 0, 0); expect(eventSpy.calledOnce).to.be.ok(); var pointerEvent = eventSpy.firstCall.args[0]; - expect(pointerEvent).to.be.a(ol.pointer.PointerEvent); + expect(pointerEvent).to.be.a(_ol_pointer_PointerEvent_); expect(pointerEvent.type).to.be('pointerdown'); expect(pointerEvent.pointerId).to.be(1); expect(pointerEvent.pointerType).to.be('mouse'); @@ -62,7 +60,7 @@ describe('ol.pointer.PointerEventHandler', function() { describe('pointer up', function() { it('fires pointerup events', function() { - ol.events.listen(handler, 'pointerup', eventSpy); + _ol_events_.listen(handler, 'pointerup', eventSpy); simulateEvent('mousedown', 0, 0); simulateEvent('mouseup', 0, 0); expect(eventSpy.calledOnce).to.be.ok(); @@ -71,7 +69,7 @@ describe('ol.pointer.PointerEventHandler', function() { describe('pointer move', function() { it('fires pointermove events', function() { - ol.events.listen(handler, 'pointermove', eventSpy); + _ol_events_.listen(handler, 'pointermove', eventSpy); simulateEvent('mousemove', 0, 0); expect(eventSpy.calledOnce).to.be.ok(); }); @@ -82,8 +80,8 @@ describe('ol.pointer.PointerEventHandler', function() { var enterEventSpy = sinon.spy(); var overEventSpy = sinon.spy(); - ol.events.listen(handler, 'pointerenter', enterEventSpy); - ol.events.listen(handler, 'pointerover', overEventSpy); + _ol_events_.listen(handler, 'pointerenter', enterEventSpy); + _ol_events_.listen(handler, 'pointerover', overEventSpy); simulateEvent('mouseover', 0, 0); @@ -97,8 +95,8 @@ describe('ol.pointer.PointerEventHandler', function() { var leaveEventSpy = sinon.spy(); var outEventSpy = sinon.spy(); - ol.events.listen(handler, 'pointerleave', leaveEventSpy); - ol.events.listen(handler, 'pointerout', outEventSpy); + _ol_events_.listen(handler, 'pointerleave', leaveEventSpy); + _ol_events_.listen(handler, 'pointerout', outEventSpy); simulateEvent('mouseout', 0, 0); @@ -162,7 +160,7 @@ describe('ol.pointer.PointerEventHandler', function() { expect(pointerEvent.preventDefault).to.be.ok(); - expect(pointerEvent).to.be.a(ol.pointer.PointerEvent); + expect(pointerEvent).to.be.a(_ol_pointer_PointerEvent_); }); }); diff --git a/test/spec/ol/pointer/touchsource.test.js b/test/spec/ol/pointer/touchsource.test.js index 962ea474ff..0a79b0301c 100644 --- a/test/spec/ol/pointer/touchsource.test.js +++ b/test/spec/ol/pointer/touchsource.test.js @@ -1,25 +1,23 @@ - - -goog.require('ol.events'); -goog.require('ol.events.Event'); -goog.require('ol.events.EventTarget'); -goog.require('ol.has'); -goog.require('ol.obj'); -goog.require('ol.pointer.PointerEventHandler'); +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_events_Event_ from '../../../../src/ol/events/Event.js'; +import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js'; +import _ol_has_ from '../../../../src/ol/has.js'; +import _ol_obj_ from '../../../../src/ol/obj.js'; +import _ol_pointer_PointerEventHandler_ from '../../../../src/ol/pointer/PointerEventHandler.js'; describe('ol.pointer.TouchSource', function() { var handler; var target; var eventSpy; beforeEach(function() { - target = new ol.events.EventTarget(); + target = new _ol_events_EventTarget_(); // make sure that a mouse and touch event source is used - ol.has.POINTER = false; - ol.has.MSPOINTER = false; - ol.has.TOUCH = true; + _ol_has_.POINTER = false; + _ol_has_.MSPOINTER = false; + _ol_has_.TOUCH = true; - handler = new ol.pointer.PointerEventHandler(target); + handler = new _ol_pointer_PointerEventHandler_(target); eventSpy = sinon.spy(); }); @@ -29,7 +27,7 @@ describe('ol.pointer.TouchSource', function() { describe('pointer event creation', function() { it('generates pointer events for each touch contact', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); simulateTouchEvent('touchstart', [ {identifier: 3, clientX: 10, clientY: 11}, @@ -56,7 +54,7 @@ describe('ol.pointer.TouchSource', function() { }); it('creates the right pointer events', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); // first touch simulateTouchEvent('touchstart', [ @@ -75,7 +73,7 @@ describe('ol.pointer.TouchSource', function() { // first touch moves var moveEventSpy = sinon.spy(); - ol.events.listen(handler, 'pointermove', moveEventSpy); + _ol_events_.listen(handler, 'pointermove', moveEventSpy); simulateTouchEvent('touchmove', [ {identifier: 3, clientX: 15, clientY: 16} @@ -85,7 +83,7 @@ describe('ol.pointer.TouchSource', function() { // and then both touches go up var upEventSpy = sinon.spy(); - ol.events.listen(handler, 'pointerup', upEventSpy); + _ol_events_.listen(handler, 'pointerup', upEventSpy); simulateTouchEvent('touchend', [ {identifier: 3, clientX: 15, clientY: 16}, @@ -97,7 +95,7 @@ describe('ol.pointer.TouchSource', function() { }); it('handles flawed touches', function() { - ol.events.listen(handler, 'pointerdown', eventSpy); + _ol_events_.listen(handler, 'pointerdown', eventSpy); // first touch simulateTouchEvent('touchstart', [ @@ -108,7 +106,7 @@ describe('ol.pointer.TouchSource', function() { // second touch, but the first touch has disappeared var cancelEventSpy = sinon.spy(); - ol.events.listen(handler, 'pointercancel', cancelEventSpy); + _ol_events_.listen(handler, 'pointercancel', cancelEventSpy); simulateTouchEvent('touchstart', [ {identifier: 4, clientX: 30, clientY: 45} ], [{identifier: 4}] @@ -124,8 +122,8 @@ describe('ol.pointer.TouchSource', function() { function simulateTouchEvent(type, changedTouches, touches) { touches = touches !== undefined ? touches : changedTouches; - var event = new ol.events.Event(type); - ol.obj.assign(event, { + var event = new _ol_events_Event_(type); + _ol_obj_.assign(event, { touches: touches, changedTouches: changedTouches }); diff --git a/test/spec/ol/proj.test.js b/test/spec/ol/proj.test.js index 5e68cbb34f..ca46007fa0 100644 --- a/test/spec/ol/proj.test.js +++ b/test/spec/ol/proj.test.js @@ -1,14 +1,14 @@ -goog.require('ol.proj'); -goog.require('ol.proj.EPSG3857'); -goog.require('ol.proj.EPSG4326'); -goog.require('ol.proj.Projection'); +import _ol_proj_ from '../../../src/ol/proj.js'; +import _ol_proj_EPSG3857_ from '../../../src/ol/proj/EPSG3857.js'; +import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js'; +import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js'; describe('ol.proj', function() { afterEach(function() { - ol.proj.clearAllProjections(); - ol.proj.addCommon(); + _ol_proj_.clearAllProjections(); + _ol_proj_.addCommon(); }); describe('toLonLat()', function() { @@ -19,16 +19,16 @@ describe('ol.proj', function() { from: [-12356463.478053365, 5700582.732404122], to: [-111, 45.5] }, { - from: [2 * ol.proj.EPSG3857.HALF_SIZE - 12356463.478053365, 5700582.732404122], + from: [2 * _ol_proj_EPSG3857_.HALF_SIZE - 12356463.478053365, 5700582.732404122], to: [-111, 45.5] }, { - from: [-4 * ol.proj.EPSG3857.HALF_SIZE - 12356463.478053365, 5700582.732404122], + from: [-4 * _ol_proj_EPSG3857_.HALF_SIZE - 12356463.478053365, 5700582.732404122], to: [-111, 45.5] }]; cases.forEach(function(c) { it('works for ' + c.from.join(', '), function() { - var lonLat = ol.proj.toLonLat(c.from); + var lonLat = _ol_proj_.toLonLat(c.from); expect(lonLat[0]).to.roughlyEqual(c.to[0], 1e-9); expect(lonLat[1]).to.roughlyEqual(c.to[1], 1e-9); }); @@ -38,10 +38,10 @@ describe('ol.proj', function() { describe('projection equivalence', function() { function _testAllEquivalent(codes) { - var projections = codes.map(ol.proj.get); + var projections = codes.map(_ol_proj_.get); projections.forEach(function(source) { projections.forEach(function(destination) { - expect(ol.proj.equivalent(source, destination)).to.be.ok(); + expect(_ol_proj_.equivalent(source, destination)).to.be.ok(); }); }); } @@ -58,15 +58,15 @@ describe('ol.proj', function() { it('gives that custom 3413 is equivalent to self', function() { var code = 'EPSG:3413'; - var source = new ol.proj.Projection({ + var source = new _ol_proj_Projection_({ code: code }); - var destination = new ol.proj.Projection({ + var destination = new _ol_proj_Projection_({ code: code }); - expect(ol.proj.equivalent(source, destination)).to.be.ok(); + expect(_ol_proj_.equivalent(source, destination)).to.be.ok(); }); it('gives that default 3857 is equivalent to self', function() { @@ -88,15 +88,15 @@ describe('ol.proj', function() { it('requires code and units to be equal for projection evquivalence', function() { - var proj1 = new ol.proj.Projection({ + var proj1 = new _ol_proj_Projection_({ code: 'EPSG:3857', units: 'm' }); - var proj2 = new ol.proj.Projection({ + var proj2 = new _ol_proj_Projection_({ code: 'EPSG:3857', units: 'tile-pixels' }); - expect(ol.proj.equivalent(proj1, proj2)).to.not.be.ok(); + expect(_ol_proj_.equivalent(proj1, proj2)).to.not.be.ok(); }); }); @@ -104,10 +104,10 @@ describe('ol.proj', function() { describe('identify transform', function() { it('returns a new object, with same coord values', function() { - var epsg4326 = ol.proj.get('EPSG:4326'); + var epsg4326 = _ol_proj_.get('EPSG:4326'); var uniqueObject = {}; var sourcePoint = [uniqueObject, uniqueObject]; - var destinationPoint = ol.proj.transform( + var destinationPoint = _ol_proj_.transform( sourcePoint, epsg4326, epsg4326); expect(sourcePoint === destinationPoint).to.not.be(); expect(destinationPoint[0] === sourcePoint[0]).to.be.ok(); @@ -118,7 +118,7 @@ describe('ol.proj', function() { describe('transform 0,0 from 4326 to 3857', function() { it('returns expected value', function() { - var point = ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:3857'); + var point = _ol_proj_.transform([0, 0], 'EPSG:4326', 'EPSG:3857'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[1]).to.roughlyEqual(0, 1e-9); @@ -128,7 +128,7 @@ describe('ol.proj', function() { describe('transform 0,0 from 3857 to 4326', function() { it('returns expected value', function() { - var point = ol.proj.transform([0, 0], 'EPSG:3857', 'EPSG:4326'); + var point = _ol_proj_.transform([0, 0], 'EPSG:3857', 'EPSG:4326'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.eql(0); @@ -140,7 +140,7 @@ describe('ol.proj', function() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ it('returns expected value using ol.proj.transform', function() { - var point = ol.proj.transform( + var point = _ol_proj_.transform( [-5.625, 52.4827802220782], 'EPSG:4326', 'EPSG:900913'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); @@ -149,7 +149,7 @@ describe('ol.proj', function() { }); it('returns expected value using ol.proj.fromLonLat', function() { - var point = ol.proj.fromLonLat([-5.625, 52.4827802220782]); + var point = _ol_proj_.fromLonLat([-5.625, 52.4827802220782]); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9); @@ -161,7 +161,7 @@ describe('ol.proj', function() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ it('returns expected value using ol.proj.transform', function() { - var point = ol.proj.transform([-626172.13571216376, 6887893.4928337997], + var point = _ol_proj_.transform([-626172.13571216376, 6887893.4928337997], 'EPSG:900913', 'EPSG:4326'); expect(point).not.to.be(undefined); expect(point).not.to.be(null); @@ -170,7 +170,7 @@ describe('ol.proj', function() { }); it('returns expected value using ol.proj.toLonLat', function() { - var point = ol.proj.toLonLat([-626172.13571216376, 6887893.4928337997]); + var point = _ol_proj_.toLonLat([-626172.13571216376, 6887893.4928337997]); expect(point).not.to.be(undefined); expect(point).not.to.be(null); expect(point[0]).to.roughlyEqual(-5.625, 1e-9); @@ -181,14 +181,14 @@ describe('ol.proj', function() { describe('canWrapX()', function() { it('requires an extent for allowing wrapX', function() { - var proj = new ol.proj.Projection({ + var proj = new _ol_proj_Projection_({ code: 'foo', global: true }); expect(proj.canWrapX()).to.be(false); proj.setExtent([1, 2, 3, 4]); expect(proj.canWrapX()).to.be(true); - proj = new ol.proj.Projection({ + proj = new _ol_proj_Projection_({ code: 'foo', global: true, extent: [1, 2, 3, 4] @@ -199,14 +199,14 @@ describe('ol.proj', function() { }); it('requires global to be true for allowing wrapX', function() { - var proj = new ol.proj.Projection({ + var proj = new _ol_proj_Projection_({ code: 'foo', extent: [1, 2, 3, 4] }); expect(proj.canWrapX()).to.be(false); proj.setGlobal(true); expect(proj.canWrapX()).to.be(true); - proj = new ol.proj.Projection({ + proj = new _ol_proj_Projection_({ code: 'foo', global: true, extent: [1, 2, 3, 4] @@ -222,7 +222,7 @@ describe('ol.proj', function() { it('transforms an extent given projection identifiers', function() { var sourceExtent = [-15, -30, 45, 60]; - var destinationExtent = ol.proj.transformExtent( + var destinationExtent = _ol_proj_.transformExtent( sourceExtent, 'EPSG:4326', 'EPSG:3857'); expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(null); @@ -237,27 +237,27 @@ describe('ol.proj', function() { describe('getPointResolution()', function() { it('returns the correct point resolution for EPSG:4326', function() { - var pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 0]); + var pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 0]); expect (pointResolution).to.be(1); - pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 52]); + pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 52]); expect (pointResolution).to.be(1); }); it('returns the correct point resolution for EPSG:4326 with custom units', function() { - var pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 0], 'm'); + var pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 0], 'm'); expect(pointResolution).to.roughlyEqual(111195.0802335329, 1e-5); - pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 52], 'm'); + pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, [0, 52], 'm'); expect(pointResolution).to.roughlyEqual(89826.53390979706, 1e-5); }); it('returns the correct point resolution for EPSG:3857', function() { - var pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, [0, 0]); + var pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, [0, 0]); expect(pointResolution).to.be(1); - pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, ol.proj.fromLonLat([0, 52])); + pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, _ol_proj_.fromLonLat([0, 52])); expect(pointResolution).to.roughlyEqual(0.615661, 1e-5); }); it('returns the correct point resolution for EPSG:3857 with custom units', function() { - var pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, [0, 0], 'degrees'); + var pointResolution = _ol_proj_.getPointResolution('EPSG:3857', 1, [0, 0], 'degrees'); expect(pointResolution).to.be(1); - pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, ol.proj.fromLonLat([0, 52]), 'degrees'); + pointResolution = _ol_proj_.getPointResolution('EPSG:4326', 1, _ol_proj_.fromLonLat([0, 52]), 'degrees'); expect(pointResolution).to.be(1); }); }); @@ -269,7 +269,7 @@ describe('ol.proj', function() { afterEach(function() { delete proj4.defs['EPSG:21781']; window.proj4 = proj4; - ol.proj.setProj4(window.proj4); + _ol_proj_.setProj4(window.proj4); }); it('creates ol.proj.Projection instance from EPSG:21781', function() { @@ -277,7 +277,7 @@ describe('ol.proj', function() { '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); - var proj = ol.proj.get('EPSG:21781'); + var proj = _ol_proj_.get('EPSG:21781'); expect(proj.getCode()).to.eql('EPSG:21781'); expect(proj.getUnits()).to.eql('m'); expect(proj.getMetersPerUnit()).to.eql(1); @@ -287,12 +287,12 @@ describe('ol.proj', function() { var proj4 = window.proj4; var proj4new = proj4; delete window.proj4; - ol.proj.setProj4(proj4new); + _ol_proj_.setProj4(proj4new); proj4new.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); - var proj = ol.proj.get('EPSG:21781'); + var proj = _ol_proj_.get('EPSG:21781'); expect(proj.getCode()).to.eql('EPSG:21781'); expect(proj.getUnits()).to.eql('m'); expect(proj.getMetersPerUnit()).to.eql(1); @@ -303,7 +303,7 @@ describe('ol.proj', function() { '+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 ' + '+x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 ' + '+towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs'); - var proj = ol.proj.get('EPSG:3739'); + var proj = _ol_proj_.get('EPSG:3739'); expect(proj.getCode()).to.eql('EPSG:3739'); expect(proj.getUnits()).to.eql('us-ft'); expect(proj.getMetersPerUnit()).to.eql(1200 / 3937); @@ -312,7 +312,7 @@ describe('ol.proj', function() { }); it('allows Proj4js projections to be used transparently', function() { - var point = ol.proj.transform( + var point = _ol_proj_.transform( [-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84'); expect(point[0]).to.roughlyEqual(-5.625, 1e-9); expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9); @@ -323,7 +323,7 @@ describe('ol.proj', function() { '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); - var point = ol.proj.transform([7.439583333333333, 46.95240555555556], + var point = _ol_proj_.transform([7.439583333333333, 46.95240555555556], 'EPSG:4326', 'EPSG:21781'); expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[1]).to.roughlyEqual(200146.976, 1); @@ -335,10 +335,10 @@ describe('ol.proj', function() { '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); var lonLat = [7.439583333333333, 46.95240555555556]; - var point = ol.proj.fromLonLat(lonLat, 'EPSG:21781'); + var point = _ol_proj_.fromLonLat(lonLat, 'EPSG:21781'); expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[1]).to.roughlyEqual(200146.976, 1); - point = ol.proj.toLonLat(point, 'EPSG:21781'); + point = _ol_proj_.toLonLat(point, 'EPSG:21781'); expect(point[0]).to.roughlyEqual(lonLat[0], 1); expect(point[1]).to.roughlyEqual(lonLat[1], 1); }); @@ -351,50 +351,50 @@ describe('ol.proj', function() { var code = 'urn:ogc:def:crs:EPSG:21781'; var srsCode = 'EPSG:21781'; proj4.defs(code, proj4.defs(srsCode)); - var proj = ol.proj.get(code); - var proj2 = ol.proj.get(srsCode); - expect(ol.proj.equivalent(proj2, proj)).to.be(true); + var proj = _ol_proj_.get(code); + var proj2 = _ol_proj_.get(srsCode); + expect(_ol_proj_.equivalent(proj2, proj)).to.be(true); delete proj4.defs[code]; }); it('numerically estimates point scale at the equator', function() { - var googleProjection = ol.proj.get('GOOGLE'); - expect(ol.proj.getPointResolution(googleProjection, 1, [0, 0])). + var googleProjection = _ol_proj_.get('GOOGLE'); + expect(_ol_proj_.getPointResolution(googleProjection, 1, [0, 0])). to.roughlyEqual(1, 1e-1); }); it('numerically estimates point scale at various latitudes', function() { - var epsg3857Projection = ol.proj.get('EPSG:3857'); - var googleProjection = ol.proj.get('GOOGLE'); + var epsg3857Projection = _ol_proj_.get('EPSG:3857'); + var googleProjection = _ol_proj_.get('GOOGLE'); var point, y; for (y = -20; y <= 20; ++y) { point = [0, 1000000 * y]; - expect(ol.proj.getPointResolution(googleProjection, 1, point)).to.roughlyEqual( - ol.proj.getPointResolution(epsg3857Projection, 1, point), 1e-1); + expect(_ol_proj_.getPointResolution(googleProjection, 1, point)).to.roughlyEqual( + _ol_proj_.getPointResolution(epsg3857Projection, 1, point), 1e-1); } }); it('numerically estimates point scale at various points', function() { - var epsg3857Projection = ol.proj.get('EPSG:3857'); - var googleProjection = ol.proj.get('GOOGLE'); + var epsg3857Projection = _ol_proj_.get('EPSG:3857'); + var googleProjection = _ol_proj_.get('GOOGLE'); var point, x, y; for (x = -20; x <= 20; x += 2) { for (y = -20; y <= 20; y += 2) { point = [1000000 * x, 1000000 * y]; - expect(ol.proj.getPointResolution(googleProjection, 1, point)).to.roughlyEqual( - ol.proj.getPointResolution(epsg3857Projection, 1, point), 1e-1); + expect(_ol_proj_.getPointResolution(googleProjection, 1, point)).to.roughlyEqual( + _ol_proj_.getPointResolution(epsg3857Projection, 1, point), 1e-1); } } }); it('does not overwrite existing projections in the registry', function() { - var epsg4326 = ol.proj.get('EPSG:4326'); - new ol.proj.Projection({ + var epsg4326 = _ol_proj_.get('EPSG:4326'); + new _ol_proj_Projection_({ code: 'EPSG:4326', units: 'degrees', extent: [-45, -45, 45, 45] }); - expect(ol.proj.get('EPSG:4326')).to.equal(epsg4326); + expect(_ol_proj_.get('EPSG:4326')).to.equal(epsg4326); }); }); @@ -402,8 +402,8 @@ describe('ol.proj', function() { describe('ol.proj.getTransformFromProjections()', function() { it('returns a transform function', function() { - var transform = ol.proj.getTransformFromProjections(ol.proj.get('GOOGLE'), - ol.proj.get('EPSG:4326')); + var transform = _ol_proj_.getTransformFromProjections(_ol_proj_.get('GOOGLE'), + _ol_proj_.get('EPSG:4326')); expect(typeof transform).to.be('function'); var output = transform([-12000000, 5000000]); @@ -413,8 +413,8 @@ describe('ol.proj', function() { }); it('works for longer arrays', function() { - var transform = ol.proj.getTransformFromProjections(ol.proj.get('GOOGLE'), - ol.proj.get('EPSG:4326')); + var transform = _ol_proj_.getTransformFromProjections(_ol_proj_.get('GOOGLE'), + _ol_proj_.get('EPSG:4326')); expect(typeof transform).to.be('function'); var output = transform([-12000000, 5000000, -12000000, 5000000]); @@ -430,12 +430,12 @@ describe('ol.proj', function() { describe('ol.proj.getTransform()', function() { it('returns a function', function() { - var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); + var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); }); it('returns a transform function', function() { - var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); + var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var output = transform([-626172.13571216376, 6887893.4928337997]); @@ -446,7 +446,7 @@ describe('ol.proj', function() { }); it('works for longer arrays of coordinate values', function() { - var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); + var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var output = transform([ @@ -464,7 +464,7 @@ describe('ol.proj', function() { }); it('accepts an optional destination array', function() { - var transform = ol.proj.getTransform('EPSG:3857', 'EPSG:4326'); + var transform = _ol_proj_.getTransform('EPSG:3857', 'EPSG:4326'); var input = [-12000000, 5000000]; var output = []; @@ -478,7 +478,7 @@ describe('ol.proj', function() { }); it('accepts a dimension', function() { - var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326'); + var transform = _ol_proj_.getTransform('GOOGLE', 'EPSG:4326'); expect(typeof transform).to.be('function'); var dimension = 3; @@ -503,14 +503,14 @@ describe('ol.proj', function() { describe('ol.proj.transform()', function() { it('transforms a 2d coordinate', function() { - var got = ol.proj.transform([-10, -20], 'EPSG:4326', 'EPSG:3857'); + var got = _ol_proj_.transform([-10, -20], 'EPSG:4326', 'EPSG:3857'); expect(got).to.have.length(2); expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); }); it('transforms a 3d coordinate', function() { - var got = ol.proj.transform([-10, -20, 3], 'EPSG:4326', 'EPSG:3857'); + var got = _ol_proj_.transform([-10, -20, 3], 'EPSG:4326', 'EPSG:3857'); expect(got).to.have.length(3); expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); @@ -518,7 +518,7 @@ describe('ol.proj', function() { }); it('transforms a 4d coordinate', function() { - var got = ol.proj.transform([-10, -20, 3, 4], 'EPSG:4326', 'EPSG:3857'); + var got = _ol_proj_.transform([-10, -20, 3, 4], 'EPSG:4326', 'EPSG:3857'); expect(got).to.have.length(4); expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); @@ -532,7 +532,7 @@ describe('ol.proj', function() { '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'); - var got = ol.proj.transform([-111, 45.5, 123], 'EPSG:4326', 'custom'); + var got = _ol_proj_.transform([-111, 45.5, 123], 'EPSG:4326', 'custom'); expect(got).to.have.length(3); expect(got[0]).to.roughlyEqual(-6601512.194209638, 1); expect(got[1]).to.roughlyEqual(6145843.802742112, 1); @@ -579,26 +579,26 @@ describe('ol.proj', function() { }); it('returns value in meters', function() { - var epsg4326 = ol.proj.get('EPSG:4326'); + var epsg4326 = _ol_proj_.get('EPSG:4326'); expect(epsg4326.getMetersPerUnit()).to.eql( - ol.proj.EPSG4326.METERS_PER_UNIT); + _ol_proj_EPSG4326_.METERS_PER_UNIT); }); it('works for proj4js projections without units', function() { - var epsg26782 = ol.proj.get('EPSG:26782'); + var epsg26782 = _ol_proj_.get('EPSG:26782'); expect(epsg26782.getMetersPerUnit()).to.eql(0.3048006096012192); }); it('works for proj4js projections with units other than m', function() { - var epsg3739 = ol.proj.get('EPSG:3739'); + var epsg3739 = _ol_proj_.get('EPSG:3739'); expect(epsg3739.getMetersPerUnit()).to.eql(1200 / 3937); }); it('works for proj4js OGC WKT GEOGCS projections', function() { - var epsg4269 = ol.proj.get('EPSG:4269'); + var epsg4269 = _ol_proj_.get('EPSG:4269'); expect(epsg4269.getMetersPerUnit()).to.eql( 6378137 * 0.01745329251994328); - var epsg4279 = ol.proj.get('EPSG:4279'); + var epsg4279 = _ol_proj_.get('EPSG:4279'); expect(epsg4279.getMetersPerUnit()).to.eql( 6377563.396 * 0.01745329251994328); }); diff --git a/test/spec/ol/proj/epsg3857.test.js b/test/spec/ol/proj/epsg3857.test.js index 07edcb973a..6f8248c657 100644 --- a/test/spec/ol/proj/epsg3857.test.js +++ b/test/spec/ol/proj/epsg3857.test.js @@ -1,18 +1,18 @@ -goog.require('ol.proj'); -goog.require('ol.proj.EPSG3857'); +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; describe('ol.proj.EPSG3857', function() { afterEach(function() { - ol.proj.clearAllProjections(); - ol.proj.addCommon(); + _ol_proj_.clearAllProjections(); + _ol_proj_.addCommon(); }); describe('fromEPSG4326()', function() { it('transforms from geographic to Web Mercator', function() { - var forward = ol.proj.EPSG3857.fromEPSG4326; - var edge = ol.proj.EPSG3857.HALF_SIZE; + var forward = _ol_proj_EPSG3857_.fromEPSG4326; + var edge = _ol_proj_EPSG3857_.HALF_SIZE; var tolerance = 1e-5; @@ -44,33 +44,33 @@ describe('ol.proj.EPSG3857', function() { it('returns the correct point scale at the equator', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.proj.get('EPSG:3857'); + var epsg3857 = _ol_proj_.get('EPSG:3857'); var resolution = 19.11; var point = [0, 0]; - expect(ol.proj.getPointResolution(epsg3857, resolution, point)). + expect(_ol_proj_.getPointResolution(epsg3857, resolution, point)). to.roughlyEqual(19.11, 1e-1); }); it('returns the correct point scale at the latitude of Toronto', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.proj.get('EPSG:3857'); - var epsg4326 = ol.proj.get('EPSG:4326'); + var epsg3857 = _ol_proj_.get('EPSG:3857'); + var epsg4326 = _ol_proj_.get('EPSG:4326'); var resolution = 19.11; - var point = ol.proj.transform([0, 43.65], epsg4326, epsg3857); - expect(ol.proj.getPointResolution(epsg3857, resolution, point)). + var point = _ol_proj_.transform([0, 43.65], epsg4326, epsg3857); + expect(_ol_proj_.getPointResolution(epsg3857, resolution, point)). to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9); }); it('returns the correct point scale at various latitudes', function() { // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx - var epsg3857 = ol.proj.get('EPSG:3857'); - var epsg4326 = ol.proj.get('EPSG:4326'); + var epsg3857 = _ol_proj_.get('EPSG:3857'); + var epsg4326 = _ol_proj_.get('EPSG:4326'); var resolution = 19.11; var latitude; for (latitude = 0; latitude <= 85; ++latitude) { - var point = ol.proj.transform([0, latitude], epsg4326, epsg3857); - expect(ol.proj.getPointResolution(epsg3857, resolution, point)). + var point = _ol_proj_.transform([0, latitude], epsg4326, epsg3857); + expect(_ol_proj_.getPointResolution(epsg3857, resolution, point)). to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9); } }); diff --git a/test/spec/ol/proj/transforms.test.js b/test/spec/ol/proj/transforms.test.js index 85f47af813..ff947ea584 100644 --- a/test/spec/ol/proj/transforms.test.js +++ b/test/spec/ol/proj/transforms.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.proj.Projection'); -goog.require('ol.proj.transforms'); +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_proj_transforms_ from '../../../../src/ol/proj/transforms.js'; describe('ol.proj.transforms.remove()', function() { @@ -10,12 +8,12 @@ describe('ol.proj.transforms.remove()', function() { var units = 'degrees'; it('removes functions cached by ol.proj.transforms.add()', function() { - var foo = new ol.proj.Projection({ + var foo = new _ol_proj_Projection_({ code: 'foo', units: units, extent: extent }); - var bar = new ol.proj.Projection({ + var bar = new _ol_proj_Projection_({ code: 'bar', units: units, extent: extent @@ -23,13 +21,13 @@ describe('ol.proj.transforms.remove()', function() { var transform = function(input, output, dimension) { return input; }; - ol.proj.transforms.add(foo, bar, transform); - var cache = ol.proj.transforms.cache_; + _ol_proj_transforms_.add(foo, bar, transform); + var cache = _ol_proj_transforms_.cache_; expect(cache).not.to.be(undefined); expect(cache.foo).not.to.be(undefined); expect(cache.foo.bar).to.be(transform); - var removed = ol.proj.transforms.remove(foo, bar); + var removed = _ol_proj_transforms_.remove(foo, bar); expect(removed).to.be(transform); expect(cache.foo).to.be(undefined); }); diff --git a/test/spec/ol/render.test.js b/test/spec/ol/render.test.js index 5354fd0ca2..d0058abd8f 100644 --- a/test/spec/ol/render.test.js +++ b/test/spec/ol/render.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.array'); -goog.require('ol.has'); -goog.require('ol.render'); -goog.require('ol.render.canvas.Immediate'); -goog.require('ol.transform'); +import _ol_array_ from '../../../src/ol/array.js'; +import _ol_has_ from '../../../src/ol/has.js'; +import _ol_render_ from '../../../src/ol/render.js'; +import _ol_render_canvas_Immediate_ from '../../../src/ol/render/canvas/Immediate.js'; +import _ol_transform_ from '../../../src/ol/transform.js'; describe('ol.render', function() { @@ -13,25 +11,25 @@ describe('ol.render', function() { it('creates an ol.render.canvas.Immediate and sets defaults', function() { var canvas = document.createElement('canvas'); - var render = ol.render.toContext(canvas.getContext('2d')); - expect(render).to.be.a(ol.render.canvas.Immediate); - expect(render.pixelRatio_).to.be(ol.has.DEVICE_PIXEL_RATIO); + var render = _ol_render_.toContext(canvas.getContext('2d')); + expect(render).to.be.a(_ol_render_canvas_Immediate_); + expect(render.pixelRatio_).to.be(_ol_has_.DEVICE_PIXEL_RATIO); }); it('sets size and pixel ratio from options', function() { var canvas = document.createElement('canvas'); var pixelRatio = 1.5; var size = [100, 50]; - var render = ol.render.toContext(canvas.getContext('2d'), + var render = _ol_render_.toContext(canvas.getContext('2d'), {pixelRatio: pixelRatio, size: size}); expect(render.pixelRatio_).to.be(pixelRatio); expect(render.extent_).to.eql( [0, 0, size[0] * pixelRatio, size[1] * pixelRatio]); expect(canvas.style.width).to.be(size[0] + 'px'); expect(canvas.style.height).to.be(size[1] + 'px'); - var transform = ol.transform.scale(ol.transform.create(), + var transform = _ol_transform_.scale(_ol_transform_.create(), pixelRatio, pixelRatio); - expect(ol.array.equals(render.transform_, transform)).to.be.ok(); + expect(_ol_array_.equals(render.transform_, transform)).to.be.ok(); }); }); diff --git a/test/spec/ol/render/box.test.js b/test/spec/ol/render/box.test.js index 675fad69b3..92aad1d123 100644 --- a/test/spec/ol/render/box.test.js +++ b/test/spec/ol/render/box.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.Disposable'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.Box'); +import _ol_Disposable_ from '../../../../src/ol/Disposable.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_render_Box_ from '../../../../src/ol/render/Box.js'; describe('ol.render.Box', function() { @@ -12,14 +10,14 @@ describe('ol.render.Box', function() { var box, map, target; beforeEach(function() { - box = new ol.render.Box('test-box'); + box = new _ol_render_Box_('test-box'); target = document.createElement('div'); document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -35,9 +33,9 @@ describe('ol.render.Box', function() { describe('constructor', function() { it('creates an instance', function() { - var obj = new ol.render.Box('test-box'); - expect(obj).to.be.a(ol.render.Box); - expect(obj).to.be.a(ol.Disposable); + var obj = new _ol_render_Box_('test-box'); + expect(obj).to.be.a(_ol_render_Box_); + expect(obj).to.be.a(_ol_Disposable_); obj.dispose(); }); it('creates an absolutely positioned DIV with a className', function() { @@ -69,7 +67,7 @@ describe('ol.render.Box', function() { it('creates a polygon geometry', function() { expect(box.getGeometry()).to.be(null); box.setPixels([1, 2], [3, 4]); - expect(box.getGeometry()).to.be.a(ol.geom.Polygon); + expect(box.getGeometry()).to.be.a(_ol_geom_Polygon_); }); }); diff --git a/test/spec/ol/render/canvas/immediate.test.js b/test/spec/ol/render/canvas/immediate.test.js index 6db1177610..f5fc2abe4e 100644 --- a/test/spec/ol/render/canvas/immediate.test.js +++ b/test/spec/ol/render/canvas/immediate.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.geom.Circle'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.VectorContext'); -goog.require('ol.render.canvas.Immediate'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_geom_Circle_ from '../../../../../src/ol/geom/Circle.js'; +import _ol_geom_GeometryCollection_ from '../../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js'; +import _ol_render_VectorContext_ from '../../../../../src/ol/render/VectorContext.js'; +import _ol_render_canvas_Immediate_ from '../../../../../src/ol/render/canvas/Immediate.js'; +import _ol_style_Circle_ from '../../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; describe('ol.render.canvas.Immediate', function() { @@ -32,23 +30,23 @@ describe('ol.render.canvas.Immediate', function() { describe('constructor', function() { it('creates an instance', function() { - var instance = new ol.render.canvas.Immediate(); - expect(instance).to.be.a(ol.render.canvas.Immediate); - expect(instance).to.be.a(ol.render.VectorContext); + var instance = new _ol_render_canvas_Immediate_(); + expect(instance).to.be.a(_ol_render_canvas_Immediate_); + expect(instance).to.be.a(_ol_render_VectorContext_); }); }); describe('#setStyle()', function() { it('calls the more specific methods with style parts', function() { - var context = new ol.render.canvas.Immediate(); + var context = new _ol_render_canvas_Immediate_(); sinon.spy(context, 'setFillStrokeStyle'); sinon.spy(context, 'setImageStyle'); sinon.spy(context, 'setTextStyle'); - var fill = new ol.style.Fill({}); - var stroke = new ol.style.Stroke({}); - var text = new ol.style.Text({}); - var image = new ol.style.Circle({}); - var style = new ol.style.Style({ + var fill = new _ol_style_Fill_({}); + var stroke = new _ol_style_Stroke_({}); + var text = new _ol_style_Text_({}); + var image = new _ol_style_Circle_({}); + var style = new _ol_style_Style_({ fill: fill, stroke: stroke, image: image, @@ -70,77 +68,77 @@ describe('ol.render.canvas.Immediate', function() { var extent = [-10, -10, 10, 10]; it('calls drawPoint() with a Point', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawPoint'); - var geometry = new ol.geom.Point([1, 2]); + var geometry = new _ol_geom_Point_([1, 2]); context.drawGeometry(geometry); expect(context.drawPoint.calledOnce).to.be(true); expect(context.drawPoint.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawLineString() with a LineString', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawLineString'); - var geometry = new ol.geom.LineString([[1, 2], [3, 4]]); + var geometry = new _ol_geom_LineString_([[1, 2], [3, 4]]); context.drawGeometry(geometry); expect(context.drawLineString.calledOnce).to.be(true); expect(context.drawLineString.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawPolygon() with a Polygon', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawPolygon'); - var geometry = new ol.geom.Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]); + var geometry = new _ol_geom_Polygon_([[[1, 2], [3, 4], [5, 6], [1, 2]]]); context.drawGeometry(geometry); expect(context.drawPolygon.calledOnce).to.be(true); expect(context.drawPolygon.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawMultiPoint() with a MultiPoint', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawMultiPoint'); - var geometry = new ol.geom.MultiPoint([[1, 2], [3, 4]]); + var geometry = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]); context.drawGeometry(geometry); expect(context.drawMultiPoint.calledOnce).to.be(true); expect(context.drawMultiPoint.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawMultiLineString() with a MultiLineString', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawMultiLineString'); - var geometry = new ol.geom.MultiLineString([[[1, 2], [3, 4]]]); + var geometry = new _ol_geom_MultiLineString_([[[1, 2], [3, 4]]]); context.drawGeometry(geometry); expect(context.drawMultiLineString.calledOnce).to.be(true); expect(context.drawMultiLineString.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawMultiPolygon() with a MultiPolygon', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawMultiPolygon'); - var geometry = new ol.geom.MultiPolygon([[[[1, 2], [3, 4], [5, 6], [1, 2]]]]); + var geometry = new _ol_geom_MultiPolygon_([[[[1, 2], [3, 4], [5, 6], [1, 2]]]]); context.drawGeometry(geometry); expect(context.drawMultiPolygon.calledOnce).to.be(true); expect(context.drawMultiPolygon.firstCall.calledWithExactly(geometry)).to.be(true); }); it('calls drawGeometryCollection() with a GeometryCollection', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawGeometryCollection'); sinon.spy(context, 'drawPoint'); sinon.spy(context, 'drawLineString'); sinon.spy(context, 'drawPolygon'); - var point = new ol.geom.Point([1, 2]); - var linestring = new ol.geom.LineString([[1, 2], [3, 4]]); - var polygon = new ol.geom.Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]); + var point = new _ol_geom_Point_([1, 2]); + var linestring = new _ol_geom_LineString_([[1, 2], [3, 4]]); + var polygon = new _ol_geom_Polygon_([[[1, 2], [3, 4], [5, 6], [1, 2]]]); - var geometry = new ol.geom.GeometryCollection([point, linestring, polygon]); + var geometry = new _ol_geom_GeometryCollection_([point, linestring, polygon]); context.drawGeometry(geometry); expect(context.drawGeometryCollection.calledOnce).to.be(true); @@ -153,10 +151,10 @@ describe('ol.render.canvas.Immediate', function() { }); it('calls drawCircle() with a Circle', function() { - var context = new ol.render.canvas.Immediate(getMockContext(), 1, extent); + var context = new _ol_render_canvas_Immediate_(getMockContext(), 1, extent); sinon.spy(context, 'drawCircle'); - var geometry = new ol.geom.Circle([0, 0]); + var geometry = new _ol_geom_Circle_([0, 0]); context.drawGeometry(geometry); expect(context.drawCircle.calledOnce).to.be(true); @@ -225,7 +223,7 @@ describe('ol.render.canvas.Immediate', function() { -7572748.158493212, 3741317.9895594316 ]; - var canvas = new ol.render.canvas.Immediate(context, 1, extent, transform); + var canvas = new _ol_render_canvas_Immediate_(context, 1, extent, transform); canvas.strokeState_ = { lineCap: 'round', @@ -236,7 +234,7 @@ describe('ol.render.canvas.Immediate', function() { strokeStyle: '#00FFFF' }; - var multiPolygonGeometry = new ol.geom.MultiPolygon([[[ + var multiPolygonGeometry = new _ol_geom_MultiPolygon_([[[ // first polygon [-80.736061, 28.788576000000006, 0], // moveTo() [-80.763557, 28.821799999999996, 0], // lineTo() diff --git a/test/spec/ol/render/canvas/index.test.js b/test/spec/ol/render/canvas/index.test.js index ebe852b826..2094237f0e 100644 --- a/test/spec/ol/render/canvas/index.test.js +++ b/test/spec/ol/render/canvas/index.test.js @@ -1,6 +1,6 @@ -goog.require('ol.events'); -goog.require('ol.obj'); -goog.require('ol.render.canvas'); +import _ol_events_ from '../../../../../src/ol/events.js'; +import _ol_obj_ from '../../../../../src/ol/obj.js'; +import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js'; describe('ol.render.canvas', function() { @@ -13,25 +13,25 @@ describe('ol.render.canvas', function() { describe('ol.render.canvas.checkFont()', function() { beforeEach(function() { - ol.obj.clear(ol.render.canvas.checkedFonts_); - ol.render.canvas.getMeasureContext(); - ol.render.canvas.measureTextHeight('12px sans-serif'); + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); + _ol_render_canvas_.getMeasureContext(); + _ol_render_canvas_.measureTextHeight('12px sans-serif'); }); - var checkFont = ol.render.canvas.checkFont; + var checkFont = _ol_render_canvas_.checkFont; var retries = 60; it('does not clear label cache and measurements for unavailable fonts', function(done) { this.timeout(3000); var spy = sinon.spy(); - ol.events.listen(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy); var interval = setInterval(function() { - if (ol.render.canvas.checkedFonts_['foo'] == retries && ol.render.canvas.checkedFonts_['sans-serif'] == retries) { + if (_ol_render_canvas_.checkedFonts_['foo'] == retries && _ol_render_canvas_.checkedFonts_['sans-serif'] == retries) { clearInterval(interval); - ol.events.unlisten(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy); expect(spy.callCount).to.be(0); - expect(ol.render.canvas.measureContext_).to.not.be(null); - expect(ol.render.canvas.textHeights_).to.not.eql({}); + expect(_ol_render_canvas_.measureContext_).to.not.be(null); + expect(_ol_render_canvas_.textHeights_).to.not.eql({}); done(); } }, 32); @@ -40,14 +40,14 @@ describe('ol.render.canvas', function() { it('does not clear label cache and measurements for available fonts', function(done) { var spy = sinon.spy(); - ol.events.listen(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy); var interval = setInterval(function() { - if (ol.render.canvas.checkedFonts_['sans-serif'] == retries) { + if (_ol_render_canvas_.checkedFonts_['sans-serif'] == retries) { clearInterval(interval); - ol.events.unlisten(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy); expect(spy.callCount).to.be(0); - expect(ol.render.canvas.measureContext_).to.not.be(null); - expect(ol.render.canvas.textHeights_).to.not.eql({}); + expect(_ol_render_canvas_.measureContext_).to.not.be(null); + expect(_ol_render_canvas_.textHeights_).to.not.eql({}); done(); } }, 32); @@ -56,14 +56,14 @@ describe('ol.render.canvas', function() { it('does not clear label cache and measurements for the \'monospace\' font', function(done) { var spy = sinon.spy(); - ol.events.listen(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', spy); var interval = setInterval(function() { - if (ol.render.canvas.checkedFonts_['monospace'] == retries) { + if (_ol_render_canvas_.checkedFonts_['monospace'] == retries) { clearInterval(interval); - ol.events.unlisten(ol.render.canvas.labelCache, 'clear', spy); + _ol_events_.unlisten(_ol_render_canvas_.labelCache, 'clear', spy); expect(spy.callCount).to.be(0); - expect(ol.render.canvas.measureContext_).to.not.be(null); - expect(ol.render.canvas.textHeights_).to.not.eql({}); + expect(_ol_render_canvas_.measureContext_).to.not.be(null); + expect(_ol_render_canvas_.textHeights_).to.not.eql({}); done(); } }, 32); @@ -72,9 +72,9 @@ describe('ol.render.canvas', function() { it('clears label cache and measurements for fonts that become available', function(done) { head.appendChild(font); - ol.events.listen(ol.render.canvas.labelCache, 'clear', function() { - expect(ol.render.canvas.measureContext_).to.be(null); - expect(ol.render.canvas.textHeights_).to.eql({}); + _ol_events_.listen(_ol_render_canvas_.labelCache, 'clear', function() { + expect(_ol_render_canvas_.measureContext_).to.be(null); + expect(_ol_render_canvas_.textHeights_).to.eql({}); done(); }); checkFont('12px Abel'); @@ -89,7 +89,7 @@ describe('ol.render.canvas', function() { translate: sinon.spy(), rotate: sinon.spy() }; - ol.render.canvas.rotateAtOffset(context, Math.PI, 10, 10); + _ol_render_canvas_.rotateAtOffset(context, Math.PI, 10, 10); expect(context.translate.callCount).to.be(2); expect(context.translate.firstCall.args).to.eql([10, 10]); expect(context.translate.secondCall.args).to.eql([-10, -10]); diff --git a/test/spec/ol/render/canvas/replaygroup.test.js b/test/spec/ol/render/canvas/replaygroup.test.js index 8c86d217eb..210fa995ac 100644 --- a/test/spec/ol/render/canvas/replaygroup.test.js +++ b/test/spec/ol/render/canvas/replaygroup.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.render.canvas.ReplayGroup'); +import _ol_render_canvas_ReplayGroup_ from '../../../../../src/ol/render/canvas/ReplayGroup.js'; describe('ol.render.canvas.ReplayGroup', function() { @@ -10,7 +8,7 @@ describe('ol.render.canvas.ReplayGroup', function() { var radius = 10; var minRadiusSq = Math.pow(radius - Math.SQRT2, 2); var maxRadiusSq = Math.pow(radius + Math.SQRT2, 2); - var circleArray = ol.render.canvas.ReplayGroup.getCircleArray_(radius); + var circleArray = _ol_render_canvas_ReplayGroup_.getCircleArray_(radius); var size = radius * 2 + 1; expect(circleArray.length).to.be(size); diff --git a/test/spec/ol/render/canvas/textreplay.test.js b/test/spec/ol/render/canvas/textreplay.test.js index 730871f95f..cc63bbd6d4 100644 --- a/test/spec/ol/render/canvas/textreplay.test.js +++ b/test/spec/ol/render/canvas/textreplay.test.js @@ -1,23 +1,23 @@ -goog.require('ol.Feature'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.canvas.TextReplay'); -goog.require('ol.style.Text'); +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js'; +import _ol_render_canvas_TextReplay_ from '../../../../../src/ol/render/canvas/TextReplay.js'; +import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; describe('ol.render.canvas.TextReplay', function() { it('renders polygon labels only when they fit', function() { - var replay = new ol.render.canvas.TextReplay(1, [-180, -90, 180, 90], 0.02, 1, true); - var geometry = new ol.geom.Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]); - var feature = new ol.Feature(geometry); + var replay = new _ol_render_canvas_TextReplay_(1, [-180, -90, 180, 90], 0.02, 1, true); + var geometry = new _ol_geom_Polygon_([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]); + var feature = new _ol_Feature_(geometry); - replay.setTextStyle(new ol.style.Text({ + replay.setTextStyle(new _ol_style_Text_({ text: 'This is a long text' })); replay.drawText(geometry, feature); expect(replay.instructions.length).to.be(0); - replay.setTextStyle(new ol.style.Text({ + replay.setTextStyle(new _ol_style_Text_({ text: 'short' })); replay.drawText(geometry, feature); @@ -25,20 +25,20 @@ describe('ol.render.canvas.TextReplay', function() { }); it('renders multipolygon labels only when they fit', function() { - var replay = new ol.render.canvas.TextReplay(1, [-180, -90, 180, 90], 0.02, 1, true); - var geometry = new ol.geom.MultiPolygon([ + var replay = new _ol_render_canvas_TextReplay_(1, [-180, -90, 180, 90], 0.02, 1, true); + var geometry = new _ol_geom_MultiPolygon_([ [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], [[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]] ]); - var feature = new ol.Feature(geometry); + var feature = new _ol_Feature_(geometry); - replay.setTextStyle(new ol.style.Text({ + replay.setTextStyle(new _ol_style_Text_({ text: 'This is a long text' })); replay.drawText(geometry, feature); expect(replay.instructions.length).to.be(0); - replay.setTextStyle(new ol.style.Text({ + replay.setTextStyle(new _ol_style_Text_({ text: 'short' })); replay.drawText(geometry, feature); diff --git a/test/spec/ol/render/feature.test.js b/test/spec/ol/render/feature.test.js index 2618c54234..3c378cffe8 100644 --- a/test/spec/ol/render/feature.test.js +++ b/test/spec/ol/render/feature.test.js @@ -1,8 +1,8 @@ -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.Feature'); +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_render_Feature_ from '../../../../src/ol/render/Feature.js'; describe('ol.render.Feature', function() { @@ -16,8 +16,8 @@ describe('ol.render.Feature', function() { describe('Constructor', function() { it('creates an instance', function() { renderFeature = - new ol.render.Feature(type, flatCoordinates, ends, properties, 'foo'); - expect(renderFeature).to.be.a(ol.render.Feature); + new _ol_render_Feature_(type, flatCoordinates, ends, properties, 'foo'); + expect(renderFeature).to.be.a(_ol_render_Feature_); }); }); @@ -42,7 +42,7 @@ describe('ol.render.Feature', function() { }); it('returns the correct extent for a linestring', function() { var feature = - new ol.render.Feature('LineString', [-1, -2, 2, 1], null, {}); + new _ol_render_Feature_('LineString', [-1, -2, 2, 1], null, {}); expect(feature.getExtent()).to.eql([-1, -2, 2, 1]); }); }); @@ -55,8 +55,8 @@ describe('ol.render.Feature', function() { describe('#getFlatInteriorPoint()', function() { it('returns correct point and caches it', function() { - var polygon = new ol.geom.Polygon([[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]]); - var feature = new ol.render.Feature('Polygon', polygon.getOrientedFlatCoordinates(), + var polygon = new _ol_geom_Polygon_([[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]]); + var feature = new _ol_render_Feature_('Polygon', polygon.getOrientedFlatCoordinates(), polygon.getEnds()); expect(feature.getFlatInteriorPoint()).to.eql([5, 5, 10]); expect(feature.getFlatInteriorPoint()).to.be(feature.flatInteriorPoints_); @@ -65,11 +65,11 @@ describe('ol.render.Feature', function() { describe('#getFlatInteriorPoints()', function() { it('returns correct points and caches them', function() { - var polygon = new ol.geom.MultiPolygon([ + var polygon = new _ol_geom_MultiPolygon_([ [[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]], [[[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]]] ]); - var feature = new ol.render.Feature('MultiPolygon', polygon.getOrientedFlatCoordinates(), + var feature = new _ol_render_Feature_('MultiPolygon', polygon.getOrientedFlatCoordinates(), polygon.getEndss()); expect(feature.getFlatInteriorPoints()).to.eql([5, 5, 10, 15, 5, 10]); expect(feature.getFlatInteriorPoints()).to.be(feature.flatInteriorPoints_); @@ -78,8 +78,8 @@ describe('ol.render.Feature', function() { describe('#getFlatMidpoint()', function() { it('returns correct point', function() { - var line = new ol.geom.LineString([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]); - var feature = new ol.render.Feature('LineString', line.getFlatCoordinates()); + var line = new _ol_geom_LineString_([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]); + var feature = new _ol_render_Feature_('LineString', line.getFlatCoordinates()); expect(feature.getFlatMidpoint()).to.eql([10, 10]); expect(feature.getFlatMidpoint()).to.eql(feature.flatMidpoints_); }); @@ -87,11 +87,11 @@ describe('ol.render.Feature', function() { describe('#getFlatMidpoints()', function() { it('returns correct points and caches them', function() { - var line = new ol.geom.MultiLineString([ + var line = new _ol_geom_MultiLineString_([ [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]], [[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]] ]); - var feature = new ol.render.Feature('MultiLineString', line.getFlatCoordinates(), + var feature = new _ol_render_Feature_('MultiLineString', line.getFlatCoordinates(), line.getEnds()); expect(feature.getFlatMidpoints()).to.eql([10, 10, 20, 10]); expect(feature.getFlatMidpoints()).to.be(feature.flatMidpoints_); diff --git a/test/spec/ol/render/webgl/circlereplay.test.js b/test/spec/ol/render/webgl/circlereplay.test.js index 5a6d6f13d1..79d9939478 100644 --- a/test/spec/ol/render/webgl/circlereplay.test.js +++ b/test/spec/ol/render/webgl/circlereplay.test.js @@ -1,29 +1,27 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.geom.Circle'); -goog.require('ol.render.webgl.CircleReplay'); -goog.require('ol.render.webgl.circlereplay.defaultshader'); -goog.require('ol.render.webgl.circlereplay.defaultshader.Locations'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_Circle_ from '../../../../../src/ol/geom/Circle.js'; +import _ol_render_webgl_CircleReplay_ from '../../../../../src/ol/render/webgl/CircleReplay.js'; +import _ol_render_webgl_circlereplay_defaultshader_ from '../../../../../src/ol/render/webgl/circlereplay/defaultshader.js'; +import _ol_render_webgl_circlereplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/circlereplay/defaultshader/Locations.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; describe('ol.render.webgl.CircleReplay', function() { var replay; - var strokeStyle = new ol.style.Stroke({ + var strokeStyle = new _ol_style_Stroke_({ color: [0, 255, 0, 0.4] }); - var fillStyle = new ol.style.Fill({ + var fillStyle = new _ol_style_Fill_({ color: [255, 0, 0, 1] }); beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.CircleReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_CircleReplay_(tolerance, maxExtent); }); describe('#setFillStrokeStyle', function() { @@ -50,7 +48,7 @@ describe('ol.render.webgl.CircleReplay', function() { describe('#drawCircle', function() { it('sets the buffer data', function() { - var circle = new ol.geom.Circle([0, 0], 5000); + var circle = new _ol_geom_Circle_([0, 0], 5000); replay.setFillStrokeStyle(fillStyle, strokeStyle); replay.drawCircle(circle, null); @@ -63,7 +61,7 @@ describe('ol.render.webgl.CircleReplay', function() { }); it('does not draw if radius is zero', function() { - var circle = new ol.geom.Circle([0, 0], 0); + var circle = new _ol_geom_Circle_([0, 0], 0); replay.drawCircle(circle, null); expect(replay.vertices).to.have.length(0); @@ -73,7 +71,7 @@ describe('ol.render.webgl.CircleReplay', function() { }); it('resets state and removes style if it belongs to a zero radius circle', function() { - var circle = new ol.geom.Circle([0, 0], 0); + var circle = new _ol_geom_Circle_([0, 0], 0); replay.setFillStrokeStyle(fillStyle, strokeStyle); replay.setFillStrokeStyle(null, strokeStyle); @@ -118,7 +116,7 @@ describe('ol.render.webgl.CircleReplay', function() { it('returns the locations used by the shaders', function() { var locations = replay.setUpProgram(gl, context, [2, 2], 1); expect(locations).to.be.a( - ol.render.webgl.circlereplay.defaultshader.Locations); + _ol_render_webgl_circlereplay_defaultshader_Locations_); }); it('gets and compiles the shaders', function() { @@ -127,8 +125,8 @@ describe('ol.render.webgl.CircleReplay', function() { replay.setUpProgram(gl, context, [2, 2], 1); expect(context.getProgram.calledWithExactly( - ol.render.webgl.circlereplay.defaultshader.fragment, - ol.render.webgl.circlereplay.defaultshader.vertex)).to.be(true); + _ol_render_webgl_circlereplay_defaultshader_.fragment, + _ol_render_webgl_circlereplay_defaultshader_.vertex)).to.be(true); expect(context.useProgram.calledOnce).to.be(true); }); @@ -175,14 +173,14 @@ describe('ol.render.webgl.CircleReplay', function() { describe('#drawReplay', function() { var gl, context; - var feature1 = new ol.Feature({ - geometry: new ol.geom.Circle([0, 0], 5000) + var feature1 = new _ol_Feature_({ + geometry: new _ol_geom_Circle_([0, 0], 5000) }); - var feature2 = new ol.Feature({ - geometry: new ol.geom.Circle([10, 10], 5000) + var feature2 = new _ol_Feature_({ + geometry: new _ol_geom_Circle_([10, 10], 5000) }); - var feature3 = new ol.Feature({ - geometry: new ol.geom.Circle([20, 20], 5000) + var feature3 = new _ol_Feature_({ + geometry: new _ol_geom_Circle_([20, 20], 5000) }); beforeEach(function() { gl = {}; @@ -234,7 +232,7 @@ describe('ol.render.webgl.CircleReplay', function() { replay.drawCircle(feature3.getGeometry(), feature3); replay.startIndices.push(replay.indices.length); var skippedFeatHash = {}; - skippedFeatHash[ol.getUid(feature2).toString()] = true; + skippedFeatHash[_ol_.getUid(feature2).toString()] = true; replay.drawReplay(gl, context, skippedFeatHash, false); expect(replay.setFillStyle_.calledOnce).to.be(true); diff --git a/test/spec/ol/render/webgl/imagereplay.test.js b/test/spec/ol/render/webgl/imagereplay.test.js index f64b7c990b..328475816d 100644 --- a/test/spec/ol/render/webgl/imagereplay.test.js +++ b/test/spec/ol/render/webgl/imagereplay.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.Point'); -goog.require('ol.render.webgl.ImageReplay'); -goog.require('ol.style.Image'); +import _ol_geom_MultiPoint_ from '../../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_render_webgl_ImageReplay_ from '../../../../../src/ol/render/webgl/ImageReplay.js'; +import _ol_style_Image_ from '../../../../../src/ol/style/Image.js'; describe('ol.render.webgl.ImageReplay', function() { var replay; var createImageStyle = function(image) { - var imageStyle = new ol.style.Image({ + var imageStyle = new _ol_style_Image_({ opacity: 0.1, rotateWithView: true, rotation: 1.5, @@ -42,7 +40,7 @@ describe('ol.render.webgl.ImageReplay', function() { beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.ImageReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_ImageReplay_(tolerance, maxExtent); }); describe('#setImageStyle', function() { @@ -96,7 +94,7 @@ describe('ol.render.webgl.ImageReplay', function() { it('sets the buffer data', function() { var point; - point = new ol.geom.Point([1000, 2000]); + point = new _ol_geom_Point_([1000, 2000]); replay.drawPoint(point, null); expect(replay.vertices).to.have.length(32); expect(replay.indices).to.have.length(6); @@ -107,7 +105,7 @@ describe('ol.render.webgl.ImageReplay', function() { expect(replay.indices[4]).to.be(2); expect(replay.indices[5]).to.be(3); - point = new ol.geom.Point([2000, 3000]); + point = new _ol_geom_Point_([2000, 3000]); replay.drawPoint(point, null); expect(replay.vertices).to.have.length(64); expect(replay.indices).to.have.length(12); @@ -129,7 +127,7 @@ describe('ol.render.webgl.ImageReplay', function() { it('sets the buffer data', function() { var multiPoint; - multiPoint = new ol.geom.MultiPoint( + multiPoint = new _ol_geom_MultiPoint_( [[1000, 2000], [2000, 3000]]); replay.drawMultiPoint(multiPoint, null); expect(replay.vertices).to.have.length(64); @@ -147,7 +145,7 @@ describe('ol.render.webgl.ImageReplay', function() { expect(replay.indices[10]).to.be(6); expect(replay.indices[11]).to.be(7); - multiPoint = new ol.geom.MultiPoint( + multiPoint = new _ol_geom_MultiPoint_( [[3000, 4000], [4000, 5000]]); replay.drawMultiPoint(multiPoint, null); expect(replay.vertices).to.have.length(128); diff --git a/test/spec/ol/render/webgl/immediate.test.js b/test/spec/ol/render/webgl/immediate.test.js index 1b6b850a16..31af550a12 100644 --- a/test/spec/ol/render/webgl/immediate.test.js +++ b/test/spec/ol/render/webgl/immediate.test.js @@ -1,40 +1,38 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.webgl.CircleReplay'); -goog.require('ol.render.webgl.ImageReplay'); -goog.require('ol.render.webgl.Immediate'); -goog.require('ol.render.webgl.LineStringReplay'); -goog.require('ol.render.webgl.PolygonReplay'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_Circle_ from '../../../../../src/ol/geom/Circle.js'; +import _ol_geom_GeometryCollection_ from '../../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js'; +import _ol_render_webgl_CircleReplay_ from '../../../../../src/ol/render/webgl/CircleReplay.js'; +import _ol_render_webgl_ImageReplay_ from '../../../../../src/ol/render/webgl/ImageReplay.js'; +import _ol_render_webgl_Immediate_ from '../../../../../src/ol/render/webgl/Immediate.js'; +import _ol_render_webgl_LineStringReplay_ from '../../../../../src/ol/render/webgl/LineStringReplay.js'; +import _ol_render_webgl_PolygonReplay_ from '../../../../../src/ol/render/webgl/PolygonReplay.js'; +import _ol_style_Circle_ from '../../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; describe('ol.render.webgl.Immediate', function() { var context, style, circle, line, multiLine, point, multiPoint, polygon, multiPolygon; beforeEach(function() { - context = new ol.render.webgl.Immediate({}, [0, 0], 0, 0, [0, 0], [-180, -90, 180, 90], 1); - style = new ol.style.Style({ - image: new ol.style.Circle(), - fill: new ol.style.Fill(), - stroke: new ol.style.Stroke() + context = new _ol_render_webgl_Immediate_({}, [0, 0], 0, 0, [0, 0], [-180, -90, 180, 90], 1); + style = new _ol_style_Style_({ + image: new _ol_style_Circle_(), + fill: new _ol_style_Fill_(), + stroke: new _ol_style_Stroke_() }); - circle = new ol.geom.Circle([0, 0], 5); - line = new ol.geom.LineString([[0, 0], [5, 5]]); - multiLine = new ol.geom.MultiLineString([[[0, 0], [5, 5]]]); - point = new ol.geom.Point([0, 0]); - multiPoint = new ol.geom.MultiPoint([[0, 0]]); - polygon = new ol.geom.Polygon([[[0, 0], [5, 5], [5, 0], [0, 0]]]); - multiPolygon = new ol.geom.MultiPolygon([[[[0, 0], [5, 5], [5, 0], [0, 0]]]]); + circle = new _ol_geom_Circle_([0, 0], 5); + line = new _ol_geom_LineString_([[0, 0], [5, 5]]); + multiLine = new _ol_geom_MultiLineString_([[[0, 0], [5, 5]]]); + point = new _ol_geom_Point_([0, 0]); + multiPoint = new _ol_geom_MultiPoint_([[0, 0]]); + polygon = new _ol_geom_Polygon_([[[0, 0], [5, 5], [5, 0], [0, 0]]]); + multiPolygon = new _ol_geom_MultiPolygon_([[[[0, 0], [5, 5], [5, 0], [0, 0]]]]); }); describe('#setStyle', function() { @@ -49,7 +47,7 @@ describe('ol.render.webgl.Immediate', function() { describe('#drawFeature', function() { var feat; beforeEach(function() { - feat = new ol.Feature({ + feat = new _ol_Feature_({ geometry: circle }); context.setStyle = function() {}; @@ -69,15 +67,15 @@ describe('ol.render.webgl.Immediate', function() { }); it('does nothing if no geometry is provided', function() { - feat = new ol.Feature(); + feat = new _ol_Feature_(); context.drawFeature(feat, style); expect(context.setStyle.called).to.be(false); expect(context.drawGeometry.called).to.be(false); }); it('does nothing if geometry is out of bounds', function() { - feat = new ol.Feature({ - geometry: new ol.geom.Circle([540, 540], 1) + feat = new _ol_Feature_({ + geometry: new _ol_geom_Circle_([540, 540], 1) }); context.drawFeature(feat, style); expect(context.setStyle.called).to.be(false); @@ -88,7 +86,7 @@ describe('ol.render.webgl.Immediate', function() { describe('#drawGeometryCollection', function() { var geomColl; beforeEach(function() { - geomColl = new ol.geom.GeometryCollection([circle, point, multiPoint, + geomColl = new _ol_geom_GeometryCollection_([circle, point, multiPoint, line, multiLine, polygon, multiPolygon]); }); @@ -113,7 +111,7 @@ describe('ol.render.webgl.Immediate', function() { return function() {}; }); sinon.spy(ctor.prototype.getDeleteResourcesFunction); - if (ctor === ol.render.webgl.ImageReplay) { + if (ctor === _ol_render_webgl_ImageReplay_) { tmpObj.setImageStyle = ctor.prototype.setImageStyle; ctor.prototype.setImageStyle = sinon.spy(); } else { @@ -134,140 +132,140 @@ describe('ol.render.webgl.Immediate', function() { describe('#drawPoint', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.ImageReplay, 'drawPoint'); + tmpObj = mock(_ol_render_webgl_ImageReplay_, 'drawPoint'); }); it('draws a point', function() { context.drawGeometry(point); - expect(ol.render.webgl.ImageReplay.prototype.setImageStyle.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.drawPoint.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.setImageStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.drawPoint.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.ImageReplay, tmpObj); + restore(_ol_render_webgl_ImageReplay_, tmpObj); }); }); describe('#drawMultiPoint', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.ImageReplay, 'drawMultiPoint'); + tmpObj = mock(_ol_render_webgl_ImageReplay_, 'drawMultiPoint'); }); it('draws a multi point', function() { context.drawGeometry(multiPoint); - expect(ol.render.webgl.ImageReplay.prototype.setImageStyle.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.drawMultiPoint.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.setImageStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.drawMultiPoint.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_ImageReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.ImageReplay, tmpObj); + restore(_ol_render_webgl_ImageReplay_, tmpObj); }); }); describe('#drawLineString', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.LineStringReplay, 'drawLineString'); + tmpObj = mock(_ol_render_webgl_LineStringReplay_, 'drawLineString'); }); it('draws a line string', function() { context.drawGeometry(line); - expect(ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.drawLineString.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.setFillStrokeStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.drawLineString.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.LineStringReplay, tmpObj); + restore(_ol_render_webgl_LineStringReplay_, tmpObj); }); }); describe('#drawMultiLineString', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.LineStringReplay, 'drawMultiLineString'); + tmpObj = mock(_ol_render_webgl_LineStringReplay_, 'drawMultiLineString'); }); it('draws a multi line string', function() { context.drawGeometry(multiLine); - expect(ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.drawMultiLineString.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.setFillStrokeStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.drawMultiLineString.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_LineStringReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.LineStringReplay, tmpObj); + restore(_ol_render_webgl_LineStringReplay_, tmpObj); }); }); describe('#drawPolygon', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.PolygonReplay, 'drawPolygon'); + tmpObj = mock(_ol_render_webgl_PolygonReplay_, 'drawPolygon'); }); it('draws a polygon', function() { context.drawGeometry(polygon); - expect(ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.drawPolygon.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.setFillStrokeStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.drawPolygon.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.PolygonReplay, tmpObj); + restore(_ol_render_webgl_PolygonReplay_, tmpObj); }); }); describe('#drawMultiPolygon', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.PolygonReplay, 'drawMultiPolygon'); + tmpObj = mock(_ol_render_webgl_PolygonReplay_, 'drawMultiPolygon'); }); it('draws a multi polygon', function() { context.drawGeometry(multiPolygon); - expect(ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.setFillStrokeStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.drawMultiPolygon.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_PolygonReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.PolygonReplay, tmpObj); + restore(_ol_render_webgl_PolygonReplay_, tmpObj); }); }); describe('#drawCircle', function() { var tmpObj; beforeEach(function() { - tmpObj = mock(ol.render.webgl.CircleReplay, 'drawCircle'); + tmpObj = mock(_ol_render_webgl_CircleReplay_, 'drawCircle'); }); it('draws a circle', function() { context.drawGeometry(circle); - expect(ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true); - expect(ol.render.webgl.CircleReplay.prototype.drawCircle.calledOnce).to.be(true); - expect(ol.render.webgl.CircleReplay.prototype.finish.calledOnce).to.be(true); - expect(ol.render.webgl.CircleReplay.prototype.replay.calledOnce).to.be(true); - expect(ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); + expect(_ol_render_webgl_CircleReplay_.prototype.setFillStrokeStyle.calledOnce).to.be(true); + expect(_ol_render_webgl_CircleReplay_.prototype.drawCircle.calledOnce).to.be(true); + expect(_ol_render_webgl_CircleReplay_.prototype.finish.calledOnce).to.be(true); + expect(_ol_render_webgl_CircleReplay_.prototype.replay.calledOnce).to.be(true); + expect(_ol_render_webgl_CircleReplay_.prototype.getDeleteResourcesFunction.calledOnce).to.be(true); }); after(function() { - restore(ol.render.webgl.CircleReplay, tmpObj); + restore(_ol_render_webgl_CircleReplay_, tmpObj); }); }); }); diff --git a/test/spec/ol/render/webgl/index.test.js b/test/spec/ol/render/webgl/index.test.js index 5aff293b7c..eeef897d2e 100644 --- a/test/spec/ol/render/webgl/index.test.js +++ b/test/spec/ol/render/webgl/index.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.render.webgl.Replay'); +import _ol_render_webgl_Replay_ from '../../../../../src/ol/render/webgl/Replay.js'; describe('ol.render.Replay', function() { var replay; beforeEach(function() { - replay = new ol.render.webgl.Replay(5, [-180, -90, 180, 90]); + replay = new _ol_render_webgl_Replay_(5, [-180, -90, 180, 90]); }); diff --git a/test/spec/ol/render/webgl/linestringreplay.test.js b/test/spec/ol/render/webgl/linestringreplay.test.js index 0663b6b3e0..2e9eceb8d7 100644 --- a/test/spec/ol/render/webgl/linestringreplay.test.js +++ b/test/spec/ol/render/webgl/linestringreplay.test.js @@ -1,22 +1,20 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.render.webgl.LineStringReplay'); -goog.require('ol.render.webgl.linestringreplay.defaultshader'); -goog.require('ol.render.webgl.linestringreplay.defaultshader.Locations'); -goog.require('ol.style.Stroke'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../../src/ol/geom/MultiLineString.js'; +import _ol_render_webgl_LineStringReplay_ from '../../../../../src/ol/render/webgl/LineStringReplay.js'; +import _ol_render_webgl_linestringreplay_defaultshader_ from '../../../../../src/ol/render/webgl/linestringreplay/defaultshader.js'; +import _ol_render_webgl_linestringreplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/linestringreplay/defaultshader/Locations.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; describe('ol.render.webgl.LineStringReplay', function() { var replay; - var strokeStyle1 = new ol.style.Stroke({ + var strokeStyle1 = new _ol_style_Stroke_({ color: [0, 255, 0, 0.4] }); - var strokeStyle2 = new ol.style.Stroke({ + var strokeStyle2 = new _ol_style_Stroke_({ color: [255, 0, 0, 1], lineCap: 'square', lineJoin: 'miter' @@ -25,7 +23,7 @@ describe('ol.render.webgl.LineStringReplay', function() { beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.LineStringReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_LineStringReplay_(tolerance, maxExtent); }); describe('#setFillStrokeStyle', function() { @@ -58,7 +56,7 @@ describe('ol.render.webgl.LineStringReplay', function() { it('sets the buffer data', function() { var linestring; - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 2000], [2000, 3000]]); replay.setFillStrokeStyle(null, strokeStyle1); replay.drawLineString(linestring, null); @@ -68,7 +66,7 @@ describe('ol.render.webgl.LineStringReplay', function() { expect(replay.startIndices).to.have.length(1); expect(replay.startIndicesFeature).to.have.length(1); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 4000], [3000, 3000]]); replay.drawLineString(linestring, null); expect(replay.vertices).to.have.length(140); @@ -84,7 +82,7 @@ describe('ol.render.webgl.LineStringReplay', function() { it('sets the buffer data', function() { var multilinestring; - multilinestring = new ol.geom.MultiLineString( + multilinestring = new _ol_geom_MultiLineString_( [[[1000, 2000], [2000, 3000]], [[1000, 3000], [2000, 4000], [3000, 3000]]]); replay.setFillStrokeStyle(null, strokeStyle1); @@ -102,13 +100,13 @@ describe('ol.render.webgl.LineStringReplay', function() { it('triangulates linestrings', function() { var linestring; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: [0, 255, 0, 1], lineCap: 'butt', lineJoin: 'bevel' }); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 4000], [3000, 3000]]); var flatCoordinates = linestring.getFlatCoordinates(); replay.setFillStrokeStyle(null, stroke); @@ -123,12 +121,12 @@ describe('ol.render.webgl.LineStringReplay', function() { it('optionally creates miters', function() { var linestring; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: [0, 255, 0, 1], lineCap: 'butt' }); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 4000], [3000, 3000]]); var flatCoordinates = linestring.getFlatCoordinates(); replay.setFillStrokeStyle(null, stroke); @@ -143,11 +141,11 @@ describe('ol.render.webgl.LineStringReplay', function() { it('optionally creates caps', function() { var linestring; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: [0, 255, 0, 1] }); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 4000], [3000, 3000]]); var flatCoordinates = linestring.getFlatCoordinates(); replay.setFillStrokeStyle(null, stroke); @@ -164,13 +162,13 @@ describe('ol.render.webgl.LineStringReplay', function() { it('respects segment orientation', function() { var linestring; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: [0, 255, 0, 1], lineCap: 'butt', lineJoin: 'bevel' }); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 2000], [3000, 3000]]); var flatCoordinates = linestring.getFlatCoordinates(); replay.setFillStrokeStyle(null, stroke); @@ -185,13 +183,13 @@ describe('ol.render.webgl.LineStringReplay', function() { it('closes boundaries', function() { var linestring; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ color: [0, 255, 0, 1], lineCap: 'butt', lineJoin: 'bevel' }); - linestring = new ol.geom.LineString( + linestring = new _ol_geom_LineString_( [[1000, 3000], [2000, 4000], [3000, 3000], [1000, 3000]]); var flatCoordinates = linestring.getFlatCoordinates(); replay.setFillStrokeStyle(null, stroke); @@ -231,7 +229,7 @@ describe('ol.render.webgl.LineStringReplay', function() { it('returns the locations used by the shaders', function() { var locations = replay.setUpProgram(gl, context, [2, 2], 1); expect(locations).to.be.a( - ol.render.webgl.linestringreplay.defaultshader.Locations); + _ol_render_webgl_linestringreplay_defaultshader_Locations_); }); it('gets and compiles the shaders', function() { @@ -240,8 +238,8 @@ describe('ol.render.webgl.LineStringReplay', function() { replay.setUpProgram(gl, context, [2, 2], 1); expect(context.getProgram.calledWithExactly( - ol.render.webgl.linestringreplay.defaultshader.fragment, - ol.render.webgl.linestringreplay.defaultshader.vertex)).to.be(true); + _ol_render_webgl_linestringreplay_defaultshader_.fragment, + _ol_render_webgl_linestringreplay_defaultshader_.vertex)).to.be(true); expect(context.useProgram.calledOnce).to.be(true); }); @@ -288,14 +286,14 @@ describe('ol.render.webgl.LineStringReplay', function() { describe('#drawReplay', function() { var gl, context; - var feature1 = new ol.Feature({ - geometry: new ol.geom.LineString([[0, 0], [500, 500]]) + var feature1 = new _ol_Feature_({ + geometry: new _ol_geom_LineString_([[0, 0], [500, 500]]) }); - var feature2 = new ol.Feature({ - geometry: new ol.geom.LineString([[0, 0], [500, 500]]) + var feature2 = new _ol_Feature_({ + geometry: new _ol_geom_LineString_([[0, 0], [500, 500]]) }); - var feature3 = new ol.Feature({ - geometry: new ol.geom.LineString([[0, 0], [500, 500]]) + var feature3 = new _ol_Feature_({ + geometry: new _ol_geom_LineString_([[0, 0], [500, 500]]) }); beforeEach(function() { gl = { @@ -353,7 +351,7 @@ describe('ol.render.webgl.LineStringReplay', function() { replay.drawLineString(feature3.getGeometry(), feature3); replay.startIndices.push(replay.indices.length); var skippedFeatHash = {}; - skippedFeatHash[ol.getUid(feature2).toString()] = true; + skippedFeatHash[_ol_.getUid(feature2).toString()] = true; replay.drawReplay(gl, context, skippedFeatHash, false); expect(replay.setStrokeStyle_.calledOnce).to.be(true); diff --git a/test/spec/ol/render/webgl/polygonreplay.test.js b/test/spec/ol/render/webgl/polygonreplay.test.js index 74ecc40ea5..8f3241bdef 100644 --- a/test/spec/ol/render/webgl/polygonreplay.test.js +++ b/test/spec/ol/render/webgl/polygonreplay.test.js @@ -1,31 +1,29 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.webgl.PolygonReplay'); -goog.require('ol.render.webgl.polygonreplay.defaultshader'); -goog.require('ol.render.webgl.polygonreplay.defaultshader.Locations'); -goog.require('ol.structs.LinkedList'); -goog.require('ol.structs.RBush'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js'; +import _ol_render_webgl_PolygonReplay_ from '../../../../../src/ol/render/webgl/PolygonReplay.js'; +import _ol_render_webgl_polygonreplay_defaultshader_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader.js'; +import _ol_render_webgl_polygonreplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader/Locations.js'; +import _ol_structs_LinkedList_ from '../../../../../src/ol/structs/LinkedList.js'; +import _ol_structs_RBush_ from '../../../../../src/ol/structs/RBush.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; describe('ol.render.webgl.PolygonReplay', function() { var replay; - var fillStyle = new ol.style.Fill({ + var fillStyle = new _ol_style_Fill_({ color: [0, 0, 255, 0.5] }); - var strokeStyle = new ol.style.Stroke({ + var strokeStyle = new _ol_style_Stroke_({ color: [0, 255, 0, 0.4] }); beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.PolygonReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_PolygonReplay_(tolerance, maxExtent); }); describe('#drawPolygon', function() { @@ -34,7 +32,7 @@ describe('ol.render.webgl.PolygonReplay', function() { }); it('sets the buffer data', function() { - var polygon1 = new ol.geom.Polygon( + var polygon1 = new _ol_geom_Polygon_( [[[1000, 2000], [1200, 2000], [1200, 3000]]] ); replay.drawPolygon(polygon1, null); @@ -45,7 +43,7 @@ describe('ol.render.webgl.PolygonReplay', function() { 1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000]); expect(replay.indices).to.eql([2, 0, 1]); - var polygon2 = new ol.geom.Polygon( + var polygon2 = new _ol_geom_Polygon_( [[[4000, 2000], [4200, 2000], [4200, 3000]]] ); replay.drawPolygon(polygon2, null); @@ -66,7 +64,7 @@ describe('ol.render.webgl.PolygonReplay', function() { }); it('sets the buffer data', function() { - var multiPolygon = new ol.geom.MultiPolygon([ + var multiPolygon = new _ol_geom_MultiPolygon_([ [[[1000, 2000], [1200, 2000], [1200, 3000]]], [[[4000, 2000], [4200, 2000], [4200, 3000]]] ]); @@ -85,8 +83,8 @@ describe('ol.render.webgl.PolygonReplay', function() { describe('triangulating functions', function() { var list, rtree; beforeEach(function() { - list = new ol.structs.LinkedList(); - rtree = new ol.structs.RBush(); + list = new _ol_structs_LinkedList_(); + rtree = new _ol_structs_RBush_(); }); describe('#createPoint_', function() { @@ -340,7 +338,7 @@ describe('ol.render.webgl.PolygonReplay', function() { it('returns the locations used by the shaders', function() { var locations = replay.setUpProgram(gl, context, [2, 2], 1); expect(locations).to.be.a( - ol.render.webgl.polygonreplay.defaultshader.Locations); + _ol_render_webgl_polygonreplay_defaultshader_Locations_); }); it('gets and compiles the shaders', function() { @@ -349,8 +347,8 @@ describe('ol.render.webgl.PolygonReplay', function() { replay.setUpProgram(gl, context, [2, 2], 1); expect(context.getProgram.calledWithExactly( - ol.render.webgl.polygonreplay.defaultshader.fragment, - ol.render.webgl.polygonreplay.defaultshader.vertex)).to.be(true); + _ol_render_webgl_polygonreplay_defaultshader_.fragment, + _ol_render_webgl_polygonreplay_defaultshader_.vertex)).to.be(true); expect(context.useProgram.calledOnce).to.be(true); }); @@ -397,14 +395,14 @@ describe('ol.render.webgl.PolygonReplay', function() { describe('#drawReplay', function() { var gl, context; - var feature1 = new ol.Feature({ - geometry: new ol.geom.Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]]) + var feature1 = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([[[0, 0], [500, 500], [500, 0], [0, 0]]]) }); - var feature2 = new ol.Feature({ - geometry: new ol.geom.Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]]) + var feature2 = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([[[0, 0], [500, 500], [500, 0], [0, 0]]]) }); - var feature3 = new ol.Feature({ - geometry: new ol.geom.Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]]) + var feature3 = new _ol_Feature_({ + geometry: new _ol_geom_Polygon_([[[0, 0], [500, 500], [500, 0], [0, 0]]]) }); beforeEach(function() { gl = { @@ -437,7 +435,7 @@ describe('ol.render.webgl.PolygonReplay', function() { }); it('draws the elements in batches if there are multiple fill styles', function() { - var fillStyle2 = new ol.style.Fill({ + var fillStyle2 = new _ol_style_Fill_({ color: [0, 255, 0, 1] }); replay.setFillStrokeStyle(fillStyle, strokeStyle); @@ -462,7 +460,7 @@ describe('ol.render.webgl.PolygonReplay', function() { replay.drawPolygon(feature3.getGeometry(), feature3); replay.startIndices.push(replay.indices.length); var skippedFeatHash = {}; - skippedFeatHash[ol.getUid(feature2).toString()] = true; + skippedFeatHash[_ol_.getUid(feature2).toString()] = true; replay.drawReplay(gl, context, skippedFeatHash, false); expect(replay.setFillStyle_.calledOnce).to.be(true); diff --git a/test/spec/ol/render/webgl/textreplay.test.js b/test/spec/ol/render/webgl/textreplay.test.js index 6a33b886c5..0072a63258 100644 --- a/test/spec/ol/render/webgl/textreplay.test.js +++ b/test/spec/ol/render/webgl/textreplay.test.js @@ -1,15 +1,15 @@ -goog.require('ol.dom'); -goog.require('ol.geom.Point'); -goog.require('ol.render.webgl.TextReplay'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Text'); +import _ol_dom_ from '../../../../../src/ol/dom.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_render_webgl_TextReplay_ from '../../../../../src/ol/render/webgl/TextReplay.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; +import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; describe('ol.render.webgl.TextReplay', function() { var replay; var createTextStyle = function(fillStyle, strokeStyle, text) { - var textStyle = new ol.style.Text({ + var textStyle = new _ol_style_Text_({ rotateWithView: true, rotation: 1.5, scale: 2, @@ -28,7 +28,7 @@ describe('ol.render.webgl.TextReplay', function() { beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.TextReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_TextReplay_(tolerance, maxExtent); }); describe('#setTextStyle', function() { @@ -37,10 +37,10 @@ describe('ol.render.webgl.TextReplay', function() { beforeEach(function() { textStyle1 = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), - new ol.style.Stroke({ + new _ol_style_Stroke_({ width: 1, color: [0, 0, 0, 1], lineCap: 'butt', @@ -51,10 +51,10 @@ describe('ol.render.webgl.TextReplay', function() { }), 'someText'); textStyle2 = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [255, 255, 255, 1] }), - new ol.style.Stroke({ + new _ol_style_Stroke_({ width: 1, color: [255, 255, 255, 1] }), @@ -62,10 +62,10 @@ describe('ol.render.webgl.TextReplay', function() { ); textStyle3 = createTextStyle(null, null, 'someText'); textStyle4 = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), - new ol.style.Stroke({ + new _ol_style_Stroke_({ width: 1, color: [0, 0, 0, 1] }), @@ -115,7 +115,7 @@ describe('ol.render.webgl.TextReplay', function() { describe('#drawText', function() { beforeEach(function() { var textStyle = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), null, 'someText'); @@ -126,19 +126,19 @@ describe('ol.render.webgl.TextReplay', function() { var point; point = [1000, 2000]; - replay.drawText(new ol.geom.Point(point), null); + replay.drawText(new _ol_geom_Point_(point), null); expect(replay.vertices).to.have.length(256); expect(replay.indices).to.have.length(48); point = [2000, 3000]; - replay.drawText(new ol.geom.Point(point), null); + replay.drawText(new _ol_geom_Point_(point), null); expect(replay.vertices).to.have.length(512); expect(replay.indices).to.have.length(96); }); it('sets part of its state during drawing', function() { var point = [1000, 2000]; - replay.drawText(new ol.geom.Point(point), null); + replay.drawText(new _ol_geom_Point_(point), null); var height = replay.currAtlas_.height; var widths = replay.currAtlas_.width; @@ -162,7 +162,7 @@ describe('ol.render.webgl.TextReplay', function() { var point; point = [1000, 2000]; - replay.drawText(new ol.geom.Point(point), null); + replay.drawText(new _ol_geom_Point_(point), null); expect(replay.vertices).to.have.length(0); expect(replay.indices).to.have.length(0); }); @@ -171,7 +171,7 @@ describe('ol.render.webgl.TextReplay', function() { describe('#addCharToAtlas_', function() { beforeEach(function() { var textStyle = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), null, 'someText'); @@ -209,7 +209,7 @@ describe('ol.render.webgl.TextReplay', function() { describe('#getTextSize_', function() { beforeEach(function() { var textStyle = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), null, 'someText'); @@ -242,7 +242,7 @@ describe('ol.render.webgl.TextReplay', function() { it('returns the size of the label\'s bounding box in pixels', function() { var size; - var mCtx = ol.dom.createCanvasContext2D(0, 0); + var mCtx = _ol_dom_.createCanvasContext2D(0, 0); mCtx.font = '12px Arial'; var width = mCtx.measureText('someText').width; var width2 = mCtx.measureText('anEvenLongerLine').width; @@ -261,7 +261,7 @@ describe('ol.render.webgl.TextReplay', function() { describe('#getAtlas_', function() { beforeEach(function() { var textStyle = createTextStyle( - new ol.style.Fill({ + new _ol_style_Fill_({ color: [0, 0, 0, 1] }), null, 'someText'); diff --git a/test/spec/ol/render/webgl/texturereplay.test.js b/test/spec/ol/render/webgl/texturereplay.test.js index 330a6d12cc..e5b99eeda5 100644 --- a/test/spec/ol/render/webgl/texturereplay.test.js +++ b/test/spec/ol/render/webgl/texturereplay.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.render.webgl.TextureReplay'); -goog.require('ol.render.webgl.texturereplay.defaultshader'); -goog.require('ol.render.webgl.texturereplay.defaultshader.Locations'); +import _ol_render_webgl_TextureReplay_ from '../../../../../src/ol/render/webgl/TextureReplay.js'; +import _ol_render_webgl_texturereplay_defaultshader_ from '../../../../../src/ol/render/webgl/texturereplay/defaultshader.js'; +import _ol_render_webgl_texturereplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/texturereplay/defaultshader/Locations.js'; describe('ol.render.webgl.TextureReplay', function() { var replay; @@ -10,7 +8,7 @@ describe('ol.render.webgl.TextureReplay', function() { beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; - replay = new ol.render.webgl.TextureReplay(tolerance, maxExtent); + replay = new _ol_render_webgl_TextureReplay_(tolerance, maxExtent); }); describe('#setUpProgram', function() { @@ -33,7 +31,7 @@ describe('ol.render.webgl.TextureReplay', function() { it('returns the locations used by the shaders', function() { var locations = replay.setUpProgram(gl, context, [2, 2], 1); expect(locations).to.be.a( - ol.render.webgl.texturereplay.defaultshader.Locations); + _ol_render_webgl_texturereplay_defaultshader_Locations_); }); it('gets and compiles the shaders', function() { @@ -42,8 +40,8 @@ describe('ol.render.webgl.TextureReplay', function() { replay.setUpProgram(gl, context, [2, 2], 1); expect(context.getProgram.calledWithExactly( - ol.render.webgl.texturereplay.defaultshader.fragment, - ol.render.webgl.texturereplay.defaultshader.vertex)).to.be(true); + _ol_render_webgl_texturereplay_defaultshader_.fragment, + _ol_render_webgl_texturereplay_defaultshader_.vertex)).to.be(true); expect(context.useProgram.calledOnce).to.be(true); }); diff --git a/test/spec/ol/renderer/canvas/imagelayer.test.js b/test/spec/ol/renderer/canvas/imagelayer.test.js index 943fe7f609..0c64966ae2 100644 --- a/test/spec/ol/renderer/canvas/imagelayer.test.js +++ b/test/spec/ol/renderer/canvas/imagelayer.test.js @@ -1,8 +1,8 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.ImageStatic'); +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../../src/ol/View.js'; +import _ol_layer_Image_ from '../../../../../src/ol/layer/Image.js'; +import _ol_proj_Projection_ from '../../../../../src/ol/proj/Projection.js'; +import _ol_source_ImageStatic_ from '../../../../../src/ol/source/ImageStatic.js'; describe('ol.renderer.canvas.ImageLayer', function() { @@ -11,7 +11,7 @@ describe('ol.renderer.canvas.ImageLayer', function() { var map, target, source; beforeEach(function(done) { - var projection = new ol.proj.Projection({ + var projection = new _ol_proj_Projection_({ code: 'custom-image', units: 'pixels', extent: [0, 0, 200, 200] @@ -20,18 +20,18 @@ describe('ol.renderer.canvas.ImageLayer', function() { target.style.width = '100px'; target.style.height = '100px'; document.body.appendChild(target); - source = new ol.source.ImageStatic({ + source = new _ol_source_ImageStatic_({ url: 'spec/ol/data/dot.png', projection: projection, imageExtent: [0, 0, 20, 20] }); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: target, - layers: [new ol.layer.Image({ + layers: [new _ol_layer_Image_({ source: source })], - view: new ol.View({ + view: new _ol_View_({ projection: projection, center: [10, 10], zoom: 2, diff --git a/test/spec/ol/renderer/canvas/intermediatecanvas.test.js b/test/spec/ol/renderer/canvas/intermediatecanvas.test.js index 4fab3813a2..cb6c94eefc 100644 --- a/test/spec/ol/renderer/canvas/intermediatecanvas.test.js +++ b/test/spec/ol/renderer/canvas/intermediatecanvas.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.transform'); -goog.require('ol.layer.Image'); -goog.require('ol.renderer.Map'); -goog.require('ol.renderer.canvas.IntermediateCanvas'); +import _ol_transform_ from '../../../../../src/ol/transform.js'; +import _ol_layer_Image_ from '../../../../../src/ol/layer/Image.js'; +import _ol_renderer_Map_ from '../../../../../src/ol/renderer/Map.js'; +import _ol_renderer_canvas_IntermediateCanvas_ from '../../../../../src/ol/renderer/canvas/IntermediateCanvas.js'; describe('ol.renderer.canvas.IntermediateCanvas', function() { @@ -11,10 +9,10 @@ describe('ol.renderer.canvas.IntermediateCanvas', function() { describe('#composeFrame()', function() { var renderer, frameState, layerState, context; beforeEach(function() { - var layer = new ol.layer.Image({ + var layer = new _ol_layer_Image_({ extent: [1, 2, 3, 4] }); - renderer = new ol.renderer.canvas.IntermediateCanvas(layer); + renderer = new _ol_renderer_canvas_IntermediateCanvas_(layer); var image = new Image(); image.width = 3; image.height = 3; @@ -29,13 +27,13 @@ describe('ol.renderer.canvas.IntermediateCanvas', function() { }, size: [10, 10], pixelRatio: 1, - coordinateToPixelTransform: ol.transform.create(), - pixelToCoordinateTransform: ol.transform.create() + coordinateToPixelTransform: _ol_transform_.create(), + pixelToCoordinateTransform: _ol_transform_.create() }; renderer.getImageTransform = function() { - return ol.transform.create(); + return _ol_transform_.create(); }; - ol.renderer.Map.prototype.calculateMatrices2D(frameState); + _ol_renderer_Map_.prototype.calculateMatrices2D(frameState); layerState = layer.getLayerState(); context = { save: sinon.spy(), diff --git a/test/spec/ol/renderer/canvas/map.test.js b/test/spec/ol/renderer/canvas/map.test.js index 7cc2b27b90..74922b1b2e 100644 --- a/test/spec/ol/renderer/canvas/map.test.js +++ b/test/spec/ol/renderer/canvas/map.test.js @@ -1,28 +1,26 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); -goog.require('ol.renderer.canvas.Layer'); -goog.require('ol.renderer.canvas.Map'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Style'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../../src/ol/View.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_layer_Tile_ from '../../../../../src/ol/layer/Tile.js'; +import _ol_layer_Vector_ from '../../../../../src/ol/layer/Vector.js'; +import _ol_renderer_canvas_Layer_ from '../../../../../src/ol/renderer/canvas/Layer.js'; +import _ol_renderer_canvas_Map_ from '../../../../../src/ol/renderer/canvas/Map.js'; +import _ol_source_Vector_ from '../../../../../src/ol/source/Vector.js'; +import _ol_style_Icon_ from '../../../../../src/ol/style/Icon.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; describe('ol.renderer.canvas.Map', function() { describe('constructor', function() { it('creates a new instance', function() { - var map = new ol.Map({ + var map = new _ol_Map_({ target: document.createElement('div') }); - var renderer = new ol.renderer.canvas.Map(map.viewport_, map); - expect(renderer).to.be.a(ol.renderer.canvas.Map); + var renderer = new _ol_renderer_canvas_Map_(map.viewport_, map); + expect(renderer).to.be.a(_ol_renderer_canvas_Map_); }); }); @@ -36,10 +34,10 @@ describe('ol.renderer.canvas.Map', function() { target.style.width = '100px'; target.style.height = '100px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ pixelRatio: 1, target: target, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }) @@ -52,16 +50,16 @@ describe('ol.renderer.canvas.Map', function() { }; img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg=='; - layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [ - new ol.Feature({ - geometry: new ol.geom.Point([0, 0]) + new _ol_Feature_({ + geometry: new _ol_geom_Point_([0, 0]) }) ] }), - style: new ol.style.Style({ - image: new ol.style.Icon({ + style: new _ol_style_Style_({ + image: new _ol_style_Icon_({ img: img, imgSize: [1, 1] }) @@ -94,8 +92,8 @@ describe('ol.renderer.canvas.Map', function() { it('calls callback with main layer when skipped feature on unmanaged layer', function() { var feature = layer.getSource().getFeatures()[0]; - var managedLayer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var managedLayer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }) }); @@ -122,7 +120,7 @@ describe('ol.renderer.canvas.Map', function() { }); it('doesn\'t fail with layer with no source', function() { - map.addLayer(new ol.layer.Tile()); + map.addLayer(new _ol_layer_Tile_()); map.renderSync(); expect(function() { map.forEachFeatureAtPixel(map.getPixelFromCoordinate([0, 0]), @@ -169,21 +167,21 @@ describe('ol.renderer.canvas.Map', function() { var layer, map, renderer; beforeEach(function() { - map = new ol.Map({}); + map = new _ol_Map_({}); map.on('postcompose', function() {}); - layer = new ol.layer.Vector({ - source: new ol.source.Vector({wrapX: true}) + layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({wrapX: true}) }); renderer = map.getRenderer(); renderer.layerRenderers_ = {}; - var layerRenderer = new ol.renderer.canvas.Layer(layer); + var layerRenderer = new _ol_renderer_canvas_Layer_(layer); layerRenderer.prepareFrame = function() { return true; }; layerRenderer.getImage = function() { return null; }; - renderer.layerRenderers_[ol.getUid(layer)] = layerRenderer; + renderer.layerRenderers_[_ol_.getUid(layer)] = layerRenderer; }); }); diff --git a/test/spec/ol/renderer/canvas/replay.test.js b/test/spec/ol/renderer/canvas/replay.test.js index 429a7d52c6..9dcf9b92f6 100644 --- a/test/spec/ol/renderer/canvas/replay.test.js +++ b/test/spec/ol/renderer/canvas/replay.test.js @@ -1,23 +1,21 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.render.canvas.LineStringReplay'); -goog.require('ol.render.canvas.PolygonReplay'); -goog.require('ol.render.canvas.Replay'); -goog.require('ol.render.canvas.ReplayGroup'); -goog.require('ol.renderer.vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.transform'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_geom_GeometryCollection_ from '../../../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../../src/ol/geom/Polygon.js'; +import _ol_render_canvas_LineStringReplay_ from '../../../../../src/ol/render/canvas/LineStringReplay.js'; +import _ol_render_canvas_PolygonReplay_ from '../../../../../src/ol/render/canvas/PolygonReplay.js'; +import _ol_render_canvas_Replay_ from '../../../../../src/ol/render/canvas/Replay.js'; +import _ol_render_canvas_ReplayGroup_ from '../../../../../src/ol/render/canvas/ReplayGroup.js'; +import _ol_renderer_vector_ from '../../../../../src/ol/renderer/vector.js'; +import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; +import _ol_transform_ from '../../../../../src/ol/transform.js'; describe('ol.render.canvas.ReplayGroup', function() { @@ -29,29 +27,29 @@ describe('ol.render.canvas.ReplayGroup', function() { var fill0, fill1, style1, style2; beforeEach(function() { - transform = ol.transform.create(); - replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, 1, false); - feature0 = new ol.Feature(new ol.geom.Polygon( + transform = _ol_transform_.create(); + replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 1, false); + feature0 = new _ol_Feature_(new _ol_geom_Polygon_( [[[-90, 0], [-45, 45], [0, 0], [1, 1], [0, -45], [-90, 0]]])); - feature1 = new ol.Feature(new ol.geom.Polygon( + feature1 = new _ol_Feature_(new _ol_geom_Polygon_( [[[-90, -45], [-90, 0], [0, 0], [0, -45], [-90, -45]]])); - feature2 = new ol.Feature(new ol.geom.Polygon( + feature2 = new _ol_Feature_(new _ol_geom_Polygon_( [[[90, 45], [90, 0], [0, 0], [0, 45], [90, 45]]])); - feature3 = new ol.Feature(new ol.geom.Polygon( + feature3 = new _ol_Feature_(new _ol_geom_Polygon_( [[[-90, -45], [-90, 45], [90, 45], [90, -45], [-90, -45]]])); - fill0 = new ol.style.Style({ - fill: new ol.style.Fill({color: 'black'}) + fill0 = new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'black'}) }); - fill1 = new ol.style.Style({ - fill: new ol.style.Fill({color: 'red'}) + fill1 = new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'red'}) }); - style1 = new ol.style.Style({ - fill: new ol.style.Fill({color: 'black'}), - stroke: new ol.style.Stroke({color: 'white', width: 1}) + style1 = new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'black'}), + stroke: new _ol_style_Stroke_({color: 'white', width: 1}) }); - style2 = new ol.style.Style({ - fill: new ol.style.Fill({color: 'white'}), - stroke: new ol.style.Stroke({color: 'black', width: 1, lineDash: [3, 6], + style2 = new _ol_style_Style_({ + fill: new _ol_style_Fill_({color: 'white'}), + stroke: new _ol_style_Stroke_({color: 'black', width: 1, lineDash: [3, 6], lineDashOffset: 2}) }); fillCount = 0; @@ -90,26 +88,26 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('omits lineTo for repeated coordinates', function() { - ol.renderer.vector.renderFeature(replay, feature0, fill0, 1); + _ol_renderer_vector_.renderFeature(replay, feature0, fill0, 1); replay.replay(context, transform, 0, {}); expect(lineToCount).to.be(4); lineToCount = 0; - ol.transform.scale(transform, 0.25, 0.25); + _ol_transform_.scale(transform, 0.25, 0.25); replay.replay(context, transform, 0, {}); expect(lineToCount).to.be(3); }); it('does not omit moveTo for repeated coordinates', function() { - ol.renderer.vector.renderFeature(replay, feature0, fill0, 1); - ol.renderer.vector.renderFeature(replay, feature1, fill1, 1); + _ol_renderer_vector_.renderFeature(replay, feature0, fill0, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, fill1, 1); replay.replay(context, transform, 0, {}); expect(moveToCount).to.be(2); }); it('batches fill and stroke instructions for same style', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style1, 1); - ol.renderer.vector.renderFeature(replay, feature3, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style1, 1); replay.replay(context, transform, 0, {}); expect(fillCount).to.be(1); expect(strokeCount).to.be(1); @@ -117,9 +115,9 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('batches fill and stroke instructions for different styles', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style1, 1); - ol.renderer.vector.renderFeature(replay, feature3, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style2, 1); replay.replay(context, transform, 0, {}); expect(fillCount).to.be(2); expect(strokeCount).to.be(2); @@ -127,9 +125,9 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('batches fill and stroke instructions for changing styles', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style2, 1); - ol.renderer.vector.renderFeature(replay, feature3, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style1, 1); replay.replay(context, transform, 0, {}); expect(fillCount).to.be(3); expect(strokeCount).to.be(3); @@ -137,11 +135,11 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('batches fill and stroke instructions for skipped feature at the beginning', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style2, 1); - ol.renderer.vector.renderFeature(replay, feature3, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style2, 1); var skippedUids = {}; - skippedUids[ol.getUid(feature1)] = true; + skippedUids[_ol_.getUid(feature1)] = true; replay.replay(context, transform, 0, skippedUids); expect(fillCount).to.be(1); expect(strokeCount).to.be(1); @@ -149,11 +147,11 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('batches fill and stroke instructions for skipped feature at the end', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style1, 1); - ol.renderer.vector.renderFeature(replay, feature3, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style2, 1); var skippedUids = {}; - skippedUids[ol.getUid(feature3)] = true; + skippedUids[_ol_.getUid(feature3)] = true; replay.replay(context, transform, 0, skippedUids); expect(fillCount).to.be(1); expect(strokeCount).to.be(1); @@ -161,12 +159,12 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('batches fill and stroke instructions for skipped features', function() { - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style1, 1); - ol.renderer.vector.renderFeature(replay, feature3, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style2, 1); var skippedUids = {}; - skippedUids[ol.getUid(feature1)] = true; - skippedUids[ol.getUid(feature2)] = true; + skippedUids[_ol_.getUid(feature1)] = true; + skippedUids[_ol_.getUid(feature2)] = true; replay.replay(context, transform, 0, skippedUids); expect(fillCount).to.be(1); expect(strokeCount).to.be(1); @@ -174,10 +172,10 @@ describe('ol.render.canvas.ReplayGroup', function() { }); it('does not batch when overlaps is set to true', function() { - replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, 1, true); - ol.renderer.vector.renderFeature(replay, feature1, style1, 1); - ol.renderer.vector.renderFeature(replay, feature2, style1, 1); - ol.renderer.vector.renderFeature(replay, feature3, style1, 1); + replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 1, true); + _ol_renderer_vector_.renderFeature(replay, feature1, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style1, 1); + _ol_renderer_vector_.renderFeature(replay, feature3, style1, 1); replay.replay(context, transform, 0, {}); expect(fillCount).to.be(3); expect(strokeCount).to.be(3); @@ -186,7 +184,7 @@ describe('ol.render.canvas.ReplayGroup', function() { it('applies the pixelRatio to the linedash array and offset', function() { // replay with a pixelRatio of 2 - replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, 2, true); + replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 2, true); var lineDash, lineDashCount = 0, lineDashOffset, lineDashOffsetCount = 0; @@ -203,8 +201,8 @@ describe('ol.render.canvas.ReplayGroup', function() { } }); - ol.renderer.vector.renderFeature(replay, feature1, style2, 1); - ol.renderer.vector.renderFeature(replay, feature2, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature1, style2, 1); + _ol_renderer_vector_.renderFeature(replay, feature2, style2, 1); replay.replay(context, transform, 0, {}); expect(lineDashCount).to.be(1); @@ -218,7 +216,7 @@ describe('ol.render.canvas.ReplayGroup', function() { it('calls the renderer function configured for the style', function() { var calls = []; - var style = new ol.style.Style({ + var style = new _ol_style_Style_({ renderer: function(coords, state) { calls.push({ coords: coords, @@ -231,27 +229,27 @@ describe('ol.render.canvas.ReplayGroup', function() { }); } }); - var point = new ol.Feature(new ol.geom.Point([45, 90])); - var multipoint = new ol.Feature(new ol.geom.MultiPoint( + var point = new _ol_Feature_(new _ol_geom_Point_([45, 90])); + var multipoint = new _ol_Feature_(new _ol_geom_MultiPoint_( [[45, 90], [90, 45]])); - var linestring = new ol.Feature(new ol.geom.LineString( + var linestring = new _ol_Feature_(new _ol_geom_LineString_( [[45, 90], [45, 45], [90, 45]])); - var multilinestring = new ol.Feature(new ol.geom.MultiLineString( + var multilinestring = new _ol_Feature_(new _ol_geom_MultiLineString_( [linestring.getGeometry().getCoordinates(), linestring.getGeometry().getCoordinates()])); var polygon = feature1; - var multipolygon = new ol.Feature(new ol.geom.MultiPolygon( + var multipolygon = new _ol_Feature_(new _ol_geom_MultiPolygon_( [polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()])); - var geometrycollection = new ol.Feature(new ol.geom.GeometryCollection( + var geometrycollection = new _ol_Feature_(new _ol_geom_GeometryCollection_( [point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()])); - replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, 1, true); - ol.renderer.vector.renderFeature(replay, point, style, 1); - ol.renderer.vector.renderFeature(replay, multipoint, style, 1); - ol.renderer.vector.renderFeature(replay, linestring, style, 1); - ol.renderer.vector.renderFeature(replay, multilinestring, style, 1); - ol.renderer.vector.renderFeature(replay, polygon, style, 1); - ol.renderer.vector.renderFeature(replay, multipolygon, style, 1); - ol.renderer.vector.renderFeature(replay, geometrycollection, style, 1); - ol.transform.scale(transform, 0.1, 0.1); + replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 1, true); + _ol_renderer_vector_.renderFeature(replay, point, style, 1); + _ol_renderer_vector_.renderFeature(replay, multipoint, style, 1); + _ol_renderer_vector_.renderFeature(replay, linestring, style, 1); + _ol_renderer_vector_.renderFeature(replay, multilinestring, style, 1); + _ol_renderer_vector_.renderFeature(replay, polygon, style, 1); + _ol_renderer_vector_.renderFeature(replay, multipolygon, style, 1); + _ol_renderer_vector_.renderFeature(replay, geometrycollection, style, 1); + _ol_transform_.scale(transform, 0.1, 0.1); replay.replay(context, transform, 0, {}); expect(calls.length).to.be(9); expect(calls[0].geometry).to.be(point.getGeometry()); @@ -287,8 +285,8 @@ describe('ol.render.canvas.Replay', function() { it('creates a new replay batch', function() { var tolerance = 10; var extent = [-180, -90, 180, 90]; - var replay = new ol.render.canvas.Replay(tolerance, extent, 1, 1, true); - expect(replay).to.be.a(ol.render.canvas.Replay); + var replay = new _ol_render_canvas_Replay_(tolerance, extent, 1, 1, true); + expect(replay).to.be.a(_ol_render_canvas_Replay_); }); }); @@ -297,7 +295,7 @@ describe('ol.render.canvas.Replay', function() { var replay; beforeEach(function() { - replay = new ol.render.canvas.Replay(1, [-180, -90, 180, 90], 1, 1, true); + replay = new _ol_render_canvas_Replay_(1, [-180, -90, 180, 90], 1, 1, true); }); it('appends coordinates that are within the max extent', function() { @@ -448,9 +446,9 @@ describe('ol.render.canvas.LineStringReplay', function() { var tolerance = 1; var extent = [-180, -90, 180, 90]; var resolution = 10; - var replay = new ol.render.canvas.LineStringReplay(tolerance, extent, + var replay = new _ol_render_canvas_LineStringReplay_(tolerance, extent, resolution); - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ width: 2 }); replay.setFillStrokeStyle(null, stroke); @@ -470,7 +468,7 @@ describe('ol.render.canvas.PolygonReplay', function() { var tolerance = 1; var extent = [-180, -90, 180, 90]; var resolution = 10; - replay = new ol.render.canvas.PolygonReplay(tolerance, extent, + replay = new _ol_render_canvas_PolygonReplay_(tolerance, extent, resolution); }); @@ -478,7 +476,7 @@ describe('ol.render.canvas.PolygonReplay', function() { it('returns correct offset', function() { var coords = [1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2]; var ends = [7, 14]; - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ width: 5 }); replay.setFillStrokeStyle(null, stroke); @@ -493,7 +491,7 @@ describe('ol.render.canvas.PolygonReplay', function() { describe('#getBufferedMaxExtent()', function() { it('buffers the max extent to accommodate stroke width', function() { - var stroke = new ol.style.Stroke({ + var stroke = new _ol_style_Stroke_({ width: 5 }); replay.setFillStrokeStyle(null, stroke); diff --git a/test/spec/ol/renderer/canvas/tilelayer.test.js b/test/spec/ol/renderer/canvas/tilelayer.test.js index 94b824bf51..b96b1b1f5f 100644 --- a/test/spec/ol/renderer/canvas/tilelayer.test.js +++ b/test/spec/ol/renderer/canvas/tilelayer.test.js @@ -1,14 +1,12 @@ - - -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Tile'); -goog.require('ol.proj'); -goog.require('ol.renderer.Map'); -goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.source.TileWMS'); -goog.require('ol.source.XYZ'); -goog.require('ol.transform'); +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../../src/ol/View.js'; +import _ol_layer_Tile_ from '../../../../../src/ol/layer/Tile.js'; +import _ol_proj_ from '../../../../../src/ol/proj.js'; +import _ol_renderer_Map_ from '../../../../../src/ol/renderer/Map.js'; +import _ol_renderer_canvas_TileLayer_ from '../../../../../src/ol/renderer/canvas/TileLayer.js'; +import _ol_source_TileWMS_ from '../../../../../src/ol/source/TileWMS.js'; +import _ol_source_XYZ_ from '../../../../../src/ol/source/XYZ.js'; +import _ol_transform_ from '../../../../../src/ol/transform.js'; describe('ol.renderer.canvas.TileLayer', function() { @@ -21,7 +19,7 @@ describe('ol.renderer.canvas.TileLayer', function() { target.style.width = '100px'; target.style.height = '100px'; document.body.appendChild(target); - source = new ol.source.TileWMS({ + source = new _ol_source_TileWMS_({ url: 'spec/ol/data/osm-0-0-0.png', params: {LAYERS: 'foo', TIME: '0'} }); @@ -29,12 +27,12 @@ describe('ol.renderer.canvas.TileLayer', function() { tile = e.tile; done(); }); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - layers: [new ol.layer.Tile({ + layers: [new _ol_layer_Tile_({ source: source })], - view: new ol.View({ + view: new _ol_View_({ zoom: 0, center: [0, 0] }) @@ -72,34 +70,34 @@ describe('ol.renderer.canvas.TileLayer', function() { }); it('uses correct draw scale when rotating (HiDPI)', function() { - var layer = new ol.layer.Tile({ - source: new ol.source.XYZ({ + var layer = new _ol_layer_Tile_({ + source: new _ol_source_XYZ_({ tileSize: 1 }) }); - var renderer = new ol.renderer.canvas.TileLayer(layer); + var renderer = new _ol_renderer_canvas_TileLayer_(layer); renderer.renderedTiles = []; var frameState = { viewHints: [], time: Date.now(), viewState: { center: [10, 5], - projection: ol.proj.get('EPSG:3857'), + projection: _ol_proj_.get('EPSG:3857'), resolution: 1, rotation: Math.PI }, extent: [0, 0, 20, 10], size: [20, 10], pixelRatio: 2, - coordinateToPixelTransform: ol.transform.create(), - pixelToCoordinateTransform: ol.transform.create(), + coordinateToPixelTransform: _ol_transform_.create(), + pixelToCoordinateTransform: _ol_transform_.create(), usedTiles: {}, wantedTiles: {} }; renderer.getImageTransform = function() { - return ol.transform.create(); + return _ol_transform_.create(); }; - ol.renderer.Map.prototype.calculateMatrices2D(frameState); + _ol_renderer_Map_.prototype.calculateMatrices2D(frameState); var layerState = layer.getLayerState(); var canvas = document.createElement('canvas'); canvas.width = 200; diff --git a/test/spec/ol/renderer/canvas/vectorlayer.test.js b/test/spec/ol/renderer/canvas/vectorlayer.test.js index 098622aa55..540d373010 100644 --- a/test/spec/ol/renderer/canvas/vectorlayer.test.js +++ b/test/spec/ol/renderer/canvas/vectorlayer.test.js @@ -1,19 +1,17 @@ - - -goog.require('ol'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.Vector'); -goog.require('ol.obj'); -goog.require('ol.proj'); -goog.require('ol.render.canvas'); -goog.require('ol.renderer.canvas.VectorLayer'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../../src/ol/View.js'; +import _ol_extent_ from '../../../../../src/ol/extent.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_layer_Vector_ from '../../../../../src/ol/layer/Vector.js'; +import _ol_obj_ from '../../../../../src/ol/obj.js'; +import _ol_proj_ from '../../../../../src/ol/proj.js'; +import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js'; +import _ol_renderer_canvas_VectorLayer_ from '../../../../../src/ol/renderer/canvas/VectorLayer.js'; +import _ol_source_Vector_ from '../../../../../src/ol/source/Vector.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; describe('ol.renderer.canvas.VectorLayer', function() { @@ -39,11 +37,11 @@ describe('ol.renderer.canvas.VectorLayer', function() { }); it('creates a new instance', function() { - var layer = new ol.layer.Vector({ - source: new ol.source.Vector() + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_() }); - var renderer = new ol.renderer.canvas.VectorLayer(layer); - expect(renderer).to.be.a(ol.renderer.canvas.VectorLayer); + var renderer = new _ol_renderer_canvas_VectorLayer_(layer); + expect(renderer).to.be.a(_ol_renderer_canvas_VectorLayer_); }); it('gives precedence to feature styles over layer styles', function() { @@ -51,28 +49,28 @@ describe('ol.renderer.canvas.VectorLayer', function() { target.style.width = '256px'; target.style.height = '256px'; document.body.appendChild(target); - var map = new ol.Map({ - view: new ol.View({ + var map = new _ol_Map_({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), target: target }); - var layerStyle = [new ol.style.Style({ - text: new ol.style.Text({ + var layerStyle = [new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer' }) })]; - var featureStyle = [new ol.style.Style({ - text: new ol.style.Text({ + var featureStyle = [new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'feature' }) })]; - var feature1 = new ol.Feature(new ol.geom.Point([0, 0])); - var feature2 = new ol.Feature(new ol.geom.Point([0, 0])); + var feature1 = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + var feature2 = new _ol_Feature_(new _ol_geom_Point_([0, 0])); feature2.setStyle(featureStyle); - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature1, feature2] }), style: layerStyle @@ -87,24 +85,24 @@ describe('ol.renderer.canvas.VectorLayer', function() { }); it('does not re-render for unavailable fonts', function(done) { - ol.obj.clear(ol.render.canvas.checkedFonts_); - var map = new ol.Map({ - view: new ol.View({ + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); + var map = new _ol_Map_({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), target: target }); - var layerStyle = new ol.style.Style({ - text: new ol.style.Text({ + var layerStyle = new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer', font: '12px "Unavailable Font",sans-serif' }) }); - var feature = new ol.Feature(new ol.geom.Point([0, 0])); - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }), style: layerStyle @@ -118,24 +116,24 @@ describe('ol.renderer.canvas.VectorLayer', function() { }); it('does not re-render for available fonts', function(done) { - ol.obj.clear(ol.render.canvas.checkedFonts_); - var map = new ol.Map({ - view: new ol.View({ + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); + var map = new _ol_Map_({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), target: target }); - var layerStyle = new ol.style.Style({ - text: new ol.style.Text({ + var layerStyle = new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer', font: '12px sans-serif' }) }); - var feature = new ol.Feature(new ol.geom.Point([0, 0])); - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }), style: layerStyle @@ -149,25 +147,25 @@ describe('ol.renderer.canvas.VectorLayer', function() { }); it('re-renders for fonts that become available', function(done) { - ol.obj.clear(ol.render.canvas.checkedFonts_); + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); head.appendChild(font); - var map = new ol.Map({ - view: new ol.View({ + var map = new _ol_Map_({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), target: target }); - var layerStyle = new ol.style.Style({ - text: new ol.style.Text({ + var layerStyle = new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer', font: '12px "Droid Sans",sans-serif' }) }); - var feature = new ol.Feature(new ol.geom.Point([0, 0])); - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({ + var feature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({ features: [feature] }), style: layerStyle @@ -187,15 +185,15 @@ describe('ol.renderer.canvas.VectorLayer', function() { var layer, renderer; beforeEach(function() { - layer = new ol.layer.Vector({ - source: new ol.source.Vector() + layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_() }); - renderer = new ol.renderer.canvas.VectorLayer(layer); + renderer = new _ol_renderer_canvas_VectorLayer_(layer); var replayGroup = {}; renderer.replayGroup_ = replayGroup; replayGroup.forEachFeatureAtCoordinate = function(coordinate, resolution, rotation, hitTolerance, skippedFeaturesUids, callback) { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); callback(feature); callback(feature); }; @@ -212,7 +210,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { rotation: 0 } }; - frameState.layerStates[ol.getUid(layer)] = {}; + frameState.layerStates[_ol_.getUid(layer)] = {}; renderer.forEachFeatureAtCoordinate( coordinate, frameState, 0, spy, undefined); expect(spy.callCount).to.be(1); @@ -224,13 +222,13 @@ describe('ol.renderer.canvas.VectorLayer', function() { var frameState, projExtent, renderer, worldWidth, buffer; beforeEach(function() { - var layer = new ol.layer.Vector({ - source: new ol.source.Vector({wrapX: true}) + var layer = new _ol_layer_Vector_({ + source: new _ol_source_Vector_({wrapX: true}) }); - renderer = new ol.renderer.canvas.VectorLayer(layer); - var projection = ol.proj.get('EPSG:3857'); + renderer = new _ol_renderer_canvas_VectorLayer_(layer); + var projection = _ol_proj_.get('EPSG:3857'); projExtent = projection.getExtent(); - worldWidth = ol.extent.getWidth(projExtent); + worldWidth = _ol_extent_.getWidth(projExtent); buffer = layer.getRenderBuffer(); frameState = { skippedFeatureUids: {}, @@ -248,7 +246,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { frameState.extent = [projExtent[0] - 10000, -10000, projExtent[0] + 10000, 10000]; renderer.prepareFrame(frameState, {}); - expect(renderer.replayGroup_.maxExtent_).to.eql(ol.extent.buffer([ + expect(renderer.replayGroup_.maxExtent_).to.eql(_ol_extent_.buffer([ projExtent[0] - worldWidth + buffer, -10000, projExtent[2] + worldWidth - buffer, 10000 ], buffer)); @@ -260,7 +258,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { frameState.extent = [projExtent[0] - 10000, -10000, projExtent[1] - 10000, 10000]; renderer.prepareFrame(frameState, {}); - expect(renderer.replayGroup_.maxExtent_).to.eql(ol.extent.buffer([ + expect(renderer.replayGroup_.maxExtent_).to.eql(_ol_extent_.buffer([ projExtent[0] - worldWidth + buffer, -10000, projExtent[2] + worldWidth - buffer, 10000 ], buffer)); @@ -271,7 +269,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { frameState.extent = [2 * projExtent[0] - 10000, -10000, 2 * projExtent[1] + 10000, 10000]; renderer.prepareFrame(frameState, {}); - expect(renderer.replayGroup_.maxExtent_).to.eql(ol.extent.buffer([ + expect(renderer.replayGroup_.maxExtent_).to.eql(_ol_extent_.buffer([ projExtent[0] - worldWidth + buffer, -10000, projExtent[2] + worldWidth - buffer, 10000 ], buffer)); @@ -284,7 +282,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { -10000, projExtent[1] + 2 * worldWidth + 10000, 10000 ]; renderer.prepareFrame(frameState, {}); - expect(renderer.replayGroup_.maxExtent_).to.eql(ol.extent.buffer([ + expect(renderer.replayGroup_.maxExtent_).to.eql(_ol_extent_.buffer([ projExtent[0] - 2 * worldWidth - 10000, -10000, projExtent[2] + 2 * worldWidth + 10000, 10000 ], buffer)); diff --git a/test/spec/ol/renderer/canvas/vectortilelayer.test.js b/test/spec/ol/renderer/canvas/vectortilelayer.test.js index 6a686ff24e..3c9d19b044 100644 --- a/test/spec/ol/renderer/canvas/vectortilelayer.test.js +++ b/test/spec/ol/renderer/canvas/vectortilelayer.test.js @@ -1,24 +1,24 @@ -goog.require('ol'); -goog.require('ol.obj'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.TileState'); -goog.require('ol.VectorImageTile'); -goog.require('ol.VectorTile'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.format.MVT'); -goog.require('ol.geom.Point'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); -goog.require('ol.render.canvas'); -goog.require('ol.render.Feature'); -goog.require('ol.renderer.canvas.VectorTileLayer'); -goog.require('ol.source.VectorTile'); -goog.require('ol.style.Style'); -goog.require('ol.style.Text'); -goog.require('ol.tilegrid'); +import _ol_ from '../../../../../src/ol.js'; +import _ol_obj_ from '../../../../../src/ol/obj.js'; +import _ol_Feature_ from '../../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_TileState_ from '../../../../../src/ol/TileState.js'; +import _ol_VectorImageTile_ from '../../../../../src/ol/VectorImageTile.js'; +import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js'; +import _ol_View_ from '../../../../../src/ol/View.js'; +import _ol_extent_ from '../../../../../src/ol/extent.js'; +import _ol_format_MVT_ from '../../../../../src/ol/format/MVT.js'; +import _ol_geom_Point_ from '../../../../../src/ol/geom/Point.js'; +import _ol_layer_VectorTile_ from '../../../../../src/ol/layer/VectorTile.js'; +import _ol_proj_ from '../../../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../../../src/ol/proj/Projection.js'; +import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js'; +import _ol_render_Feature_ from '../../../../../src/ol/render/Feature.js'; +import _ol_renderer_canvas_VectorTileLayer_ from '../../../../../src/ol/renderer/canvas/VectorTileLayer.js'; +import _ol_source_VectorTile_ from '../../../../../src/ol/source/VectorTile.js'; +import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; +import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; +import _ol_tilegrid_ from '../../../../../src/ol/tilegrid.js'; describe('ol.renderer.canvas.VectorTileLayer', function() { @@ -38,46 +38,46 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { target.style.width = '256px'; target.style.height = '256px'; document.body.appendChild(target); - map = new ol.Map({ - view: new ol.View({ + map = new _ol_Map_({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), target: target }); - layerStyle = [new ol.style.Style({ - text: new ol.style.Text({ + layerStyle = [new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer' }) })]; - var featureStyle = [new ol.style.Style({ - text: new ol.style.Text({ + var featureStyle = [new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'feature' }) })]; - feature1 = new ol.Feature(new ol.geom.Point([1, -1])); - feature2 = new ol.Feature(new ol.geom.Point([0, 0])); - feature3 = new ol.render.Feature('Point', [1, -1], []); + feature1 = new _ol_Feature_(new _ol_geom_Point_([1, -1])); + feature2 = new _ol_Feature_(new _ol_geom_Point_([0, 0])); + feature3 = new _ol_render_Feature_('Point', [1, -1], []); feature2.setStyle(featureStyle); var TileClass = function() { - ol.VectorTile.apply(this, arguments); + _ol_VectorTile_.apply(this, arguments); this.setState('loaded'); this.setFeatures([feature1, feature2, feature3]); - this.setProjection(ol.proj.get('EPSG:4326')); + this.setProjection(_ol_proj_.get('EPSG:4326')); tileCallback(this); }; - ol.inherits(TileClass, ol.VectorTile); - source = new ol.source.VectorTile({ - format: new ol.format.MVT(), + _ol_.inherits(TileClass, _ol_VectorTile_); + source = new _ol_source_VectorTile_({ + format: new _ol_format_MVT_(), tileClass: TileClass, - tileGrid: ol.tilegrid.createXYZ() + tileGrid: _ol_tilegrid_.createXYZ() }); source.getTile = function() { - var tile = ol.source.VectorTile.prototype.getTile.apply(source, arguments); - tile.setState(ol.TileState.LOADED); + var tile = _ol_source_VectorTile_.prototype.getTile.apply(source, arguments); + tile.setState(_ol_TileState_.LOADED); return tile; }; - layer = new ol.layer.VectorTile({ + layer = new _ol_layer_VectorTile_({ source: source, style: layerStyle }); @@ -90,20 +90,20 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { }); it('creates a new instance', function() { - var renderer = new ol.renderer.canvas.VectorTileLayer(layer); - expect(renderer).to.be.a(ol.renderer.canvas.VectorTileLayer); + var renderer = new _ol_renderer_canvas_VectorTileLayer_(layer); + expect(renderer).to.be.a(_ol_renderer_canvas_VectorTileLayer_); expect(renderer.zDirection).to.be(0); }); it('uses lower resolution for pure vector rendering', function() { layer.renderMode_ = 'vector'; - var renderer = new ol.renderer.canvas.VectorTileLayer(layer); + var renderer = new _ol_renderer_canvas_VectorTileLayer_(layer); expect(renderer.zDirection).to.be(1); }); it('does not render images for pure vector rendering', function() { layer.renderMode_ = 'vector'; - var spy = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype, + var spy = sinon.spy(_ol_renderer_canvas_VectorTileLayer_.prototype, 'renderTileImage_'); map.renderSync(); expect(spy.callCount).to.be(0); @@ -112,7 +112,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { it('does not render replays for pure image rendering', function() { layer.renderMode_ = 'image'; - var spy = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype, + var spy = sinon.spy(_ol_renderer_canvas_VectorTileLayer_.prototype, 'getTransform'); map.renderSync(); expect(spy.callCount).to.be(0); @@ -120,9 +120,9 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { }); it('renders both replays and images for hybrid rendering', function() { - var spy1 = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype, + var spy1 = sinon.spy(_ol_renderer_canvas_VectorTileLayer_.prototype, 'getTransform'); - var spy2 = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype, + var spy2 = sinon.spy(_ol_renderer_canvas_VectorTileLayer_.prototype, 'renderTileImage_'); map.renderSync(); expect(spy1.callCount).to.be(1); @@ -133,10 +133,10 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { it('renders replays with custom renderers as direct replays', function() { layer.renderMode_ = 'image'; - layer.setStyle(new ol.style.Style({ + layer.setStyle(new _ol_style_Style_({ renderer: function() {} })); - var spy = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype, + var spy = sinon.spy(_ol_renderer_canvas_VectorTileLayer_.prototype, 'getTransform'); map.renderSync(); expect(spy.callCount).to.be(1); @@ -154,7 +154,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { it('does not re-render for unavailable fonts', function(done) { map.renderSync(); - ol.obj.clear(ol.render.canvas.checkedFonts_); + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); layerStyle[0].getText().setFont('12px "Unavailable font",sans-serif'); layer.changed(); var revision = layer.getRevision(); @@ -166,7 +166,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { it('does not re-render for available fonts', function(done) { map.renderSync(); - ol.obj.clear(ol.render.canvas.checkedFonts_); + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); layerStyle[0].getText().setFont('12px sans-serif'); layer.changed(); var revision = layer.getRevision(); @@ -178,7 +178,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { it('re-renders for fonts that become available', function(done) { map.renderSync(); - ol.obj.clear(ol.render.canvas.checkedFonts_); + _ol_obj_.clear(_ol_render_canvas_.checkedFonts_); head.appendChild(font); layerStyle[0].getText().setFont('12px "Dancing Script",sans-serif'); layer.changed(); @@ -196,38 +196,38 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { tile = t; }; map.renderSync(); - expect(tile.getProjection()).to.equal(ol.proj.get('EPSG:3857')); + expect(tile.getProjection()).to.equal(_ol_proj_.get('EPSG:3857')); expect(feature1.getGeometry().getCoordinates()).to.eql( - ol.proj.fromLonLat([1, -1])); + _ol_proj_.fromLonLat([1, -1])); }); it('Geometries are transformed from tile-pixels', function() { - var proj = new ol.proj.Projection({code: 'EPSG:3857', units: 'tile-pixels'}); + var proj = new _ol_proj_Projection_({code: 'EPSG:3857', units: 'tile-pixels'}); var tile; tileCallback = function(t) { t.setProjection(proj); tile = t; }; map.renderSync(); - expect(tile.getProjection()).to.equal(ol.proj.get('EPSG:3857')); + expect(tile.getProjection()).to.equal(_ol_proj_.get('EPSG:3857')); expect(feature1.getGeometry().getCoordinates()).to.eql([-20027724.40316874, 20047292.282409746]); expect(feature3.flatCoordinates_).to.eql([-20027724.40316874, 20047292.282409746]); }); it('works for multiple layers that use the same source', function() { - var layer2 = new ol.layer.VectorTile({ + var layer2 = new _ol_layer_VectorTile_({ source: source, - style: new ol.style.Style({ - text: new ol.style.Text({ + style: new _ol_style_Style_({ + text: new _ol_style_Text_({ text: 'layer2' }) }) }); map.addLayer(layer2); - var spy1 = sinon.spy(ol.VectorTile.prototype, + var spy1 = sinon.spy(_ol_VectorTile_.prototype, 'getReplayGroup'); - var spy2 = sinon.spy(ol.VectorTile.prototype, + var spy2 = sinon.spy(_ol_VectorTile_.prototype, 'setReplayGroup'); map.renderSync(); expect(spy1.callCount).to.be(4); @@ -240,31 +240,31 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { describe('#prepareFrame', function() { it('re-renders when layer changed', function() { - var layer = new ol.layer.VectorTile({ - source: new ol.source.VectorTile({ - tileGrid: ol.tilegrid.createXYZ(), + var layer = new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({ + tileGrid: _ol_tilegrid_.createXYZ(), transition: 0 }) }); - var sourceTile = new ol.VectorTile([0, 0, 0], 2); - sourceTile.setProjection(ol.proj.get('EPSG:3857')); + var sourceTile = new _ol_VectorTile_([0, 0, 0], 2); + sourceTile.setProjection(_ol_proj_.get('EPSG:3857')); sourceTile.features_ = []; sourceTile.getImage = function() { return document.createElement('canvas'); }; - var tile = new ol.VectorImageTile([0, 0, 0]); + var tile = new _ol_VectorImageTile_([0, 0, 0]); tile.transition_ = 0; tile.wrappedTileCoord = [0, 0, 0]; - tile.setState(ol.TileState.LOADED); + tile.setState(_ol_TileState_.LOADED); tile.getSourceTile = function() { return sourceTile; }; layer.getSource().getTile = function() { return tile; }; - var renderer = new ol.renderer.canvas.VectorTileLayer(layer); + var renderer = new _ol_renderer_canvas_VectorTileLayer_(layer); renderer.renderTileImage_ = sinon.spy(); - var proj = ol.proj.get('EPSG:3857'); + var proj = _ol_proj_.get('EPSG:3857'); var frameState = { extent: proj.getExtent(), pixelRatio: 1, @@ -292,10 +292,10 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { describe('#forEachFeatureAtCoordinate', function() { var layer, renderer, replayGroup; var TileClass = function() { - ol.VectorImageTile.apply(this, arguments); + _ol_VectorImageTile_.apply(this, arguments); this.setState('loaded'); - var sourceTile = new ol.VectorTile([0, 0, 0]); - sourceTile.setProjection(ol.proj.get('EPSG:3857')); + var sourceTile = new _ol_VectorTile_([0, 0, 0]); + sourceTile.setProjection(_ol_proj_.get('EPSG:3857')); sourceTile.getReplayGroup = function() { return replayGroup; }; @@ -305,20 +305,20 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { this.sourceTiles_[key] = sourceTile; this.wrappedTileCoord = arguments[0]; }; - ol.inherits(TileClass, ol.VectorImageTile); + _ol_.inherits(TileClass, _ol_VectorImageTile_); beforeEach(function() { replayGroup = {}; - layer = new ol.layer.VectorTile({ - source: new ol.source.VectorTile({ + layer = new _ol_layer_VectorTile_({ + source: new _ol_source_VectorTile_({ tileClass: TileClass, - tileGrid: ol.tilegrid.createXYZ() + tileGrid: _ol_tilegrid_.createXYZ() }) }); - renderer = new ol.renderer.canvas.VectorTileLayer(layer); + renderer = new _ol_renderer_canvas_VectorTileLayer_(layer); replayGroup.forEachFeatureAtCoordinate = function(coordinate, resolution, rotation, hitTolerance, skippedFeaturesUids, callback) { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); callback(feature); callback(feature); }; @@ -331,12 +331,12 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { layerStates: {}, skippedFeatureUids: {}, viewState: { - projection: ol.proj.get('EPSG:3857'), + projection: _ol_proj_.get('EPSG:3857'), resolution: 1, rotation: 0 } }; - frameState.layerStates[ol.getUid(layer)] = {}; + frameState.layerStates[_ol_.getUid(layer)] = {}; renderer.renderedTiles = [new TileClass([0, 0, -1])]; renderer.forEachFeatureAtCoordinate( coordinate, frameState, 0, spy, undefined); @@ -350,22 +350,22 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { target.style.height = '100px'; document.body.appendChild(target); var extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608]; - var source = new ol.source.VectorTile({ - format: new ol.format.MVT(), + var source = new _ol_source_VectorTile_({ + format: new _ol_format_MVT_(), url: 'spec/ol/data/14-8938-5680.vector.pbf', minZoom: 14, maxZoom: 14 }); - var map = new ol.Map({ + var map = new _ol_Map_({ target: target, layers: [ - new ol.layer.VectorTile({ + new _ol_layer_VectorTile_({ extent: extent, source: source }) ], - view: new ol.View({ - center: ol.extent.getCenter(extent), + view: new _ol_View_({ + center: _ol_extent_.getCenter(extent), zoom: 19 }) }); diff --git a/test/spec/ol/renderer/layer.test.js b/test/spec/ol/renderer/layer.test.js index a00fb9c291..e2ddcf5ed7 100644 --- a/test/spec/ol/renderer/layer.test.js +++ b/test/spec/ol/renderer/layer.test.js @@ -1,11 +1,11 @@ -goog.require('ol.Image'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.layer.Layer'); -goog.require('ol.layer.Tile'); -goog.require('ol.renderer.Layer'); -goog.require('ol.source.XYZ'); -goog.require('ol.tilecoord'); +import _ol_Image_ from '../../../../src/ol/Image.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Layer_ from '../../../../src/ol/layer/Layer.js'; +import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; +import _ol_renderer_Layer_ from '../../../../src/ol/renderer/Layer.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; +import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js'; describe('ol.renderer.Layer', function() { @@ -13,8 +13,8 @@ describe('ol.renderer.Layer', function() { var eventType = 'change'; beforeEach(function() { - var layer = new ol.layer.Layer({}); - renderer = new ol.renderer.Layer(layer); + var layer = new _ol_layer_Layer_({}); + renderer = new _ol_renderer_Layer_(layer); }); describe('#loadImage', function() { @@ -28,7 +28,7 @@ describe('ol.renderer.Layer', function() { var src = ''; var crossOrigin = ''; imageLoadFunction = sinon.spy(); - image = new ol.Image(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction); + image = new _ol_Image_(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction); }); describe('load IDLE image', function() { @@ -98,20 +98,20 @@ describe('ol.renderer.Layer', function() { }); document.body.appendChild(target); - view = new ol.View({ + view = new _ol_View_({ center: [0, 0], zoom: 0 }); - source = new ol.source.XYZ({ + source = new _ol_source_XYZ_({ url: '#{x}/{y}/{z}' }); - map = new ol.Map({ + map = new _ol_Map_({ target: target, view: view, layers: [ - new ol.layer.Tile({ + new _ol_layer_Tile_({ source: source }) ] @@ -129,13 +129,13 @@ describe('ol.renderer.Layer', function() { it('accesses tiles from current zoom level last', function(done) { // expect most recent tile in the cache to be from zoom level 0 var key = source.tileCache.peekFirstKey(); - var tileCoord = ol.tilecoord.fromKey(key); + var tileCoord = _ol_tilecoord_.fromKey(key); expect(tileCoord[0]).to.be(0); map.once('moveend', function() { // expect most recent tile in the cache to be from zoom level 4 var key = source.tileCache.peekFirstKey(); - var tileCoord = ol.tilecoord.fromKey(key); + var tileCoord = _ol_tilecoord_.fromKey(key); expect(tileCoord[0]).to.be(4); done(); }); diff --git a/test/spec/ol/renderer/map.test.js b/test/spec/ol/renderer/map.test.js index 361cf72d0a..a6386e4121 100644 --- a/test/spec/ol/renderer/map.test.js +++ b/test/spec/ol/renderer/map.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.Disposable'); -goog.require('ol.Map'); -goog.require('ol.renderer.Map'); +import _ol_Disposable_ from '../../../../src/ol/Disposable.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_renderer_Map_ from '../../../../src/ol/renderer/Map.js'; describe('ol.renderer.Map', function() { @@ -10,10 +8,10 @@ describe('ol.renderer.Map', function() { describe('constructor', function() { it('createst an instance', function() { - var map = new ol.Map({}); - var renderer = new ol.renderer.Map(null, map); - expect(renderer).to.be.a(ol.renderer.Map); - expect(renderer).to.be.a(ol.Disposable); + var map = new _ol_Map_({}); + var renderer = new _ol_renderer_Map_(null, map); + expect(renderer).to.be.a(_ol_renderer_Map_); + expect(renderer).to.be.a(_ol_Disposable_); renderer.dispose(); map.dispose(); }); diff --git a/test/spec/ol/renderer/vector.test.js b/test/spec/ol/renderer/vector.test.js index b795f755af..0710af7bcd 100644 --- a/test/spec/ol/renderer/vector.test.js +++ b/test/spec/ol/renderer/vector.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.MultiPolygon'); -goog.require('ol.render.canvas.ReplayGroup'); -goog.require('ol.renderer.vector'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Icon'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); -goog.require('ol.Feature'); +import _ol_ from '../../../../src/ol.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; +import _ol_render_canvas_ReplayGroup_ from '../../../../src/ol/render/canvas/ReplayGroup.js'; +import _ol_renderer_vector_ from '../../../../src/ol/renderer/vector.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; describe('ol.renderer.vector', function() { @@ -24,15 +22,15 @@ describe('ol.renderer.vector', function() { var iconStyleLoadSpy; beforeEach(function() { - replayGroup = new ol.render.canvas.ReplayGroup(1); - feature = new ol.Feature(); - iconStyle = new ol.style.Icon({ + replayGroup = new _ol_render_canvas_ReplayGroup_(1); + feature = new _ol_Feature_(); + iconStyle = new _ol_style_Icon_({ src: 'http://example.com/icon.png' }); - style = new ol.style.Style({ + style = new _ol_style_Style_({ image: iconStyle, - fill: new ol.style.Fill({}), - stroke: new ol.style.Stroke({}) + fill: new _ol_style_Fill_({}), + stroke: new _ol_style_Stroke_({}) }); squaredTolerance = 1; listener = function() {}; @@ -52,20 +50,20 @@ describe('ol.renderer.vector', function() { var listeners; // call #1 - ol.renderer.vector.renderFeature(replayGroup, feature, + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(iconStyleLoadSpy.calledOnce).to.be.ok(); - listeners = ol.events.getListeners( + listeners = _ol_events_.getListeners( iconStyle.iconImage_, 'change'); expect(listeners.length).to.eql(1); // call #2 - ol.renderer.vector.renderFeature(replayGroup, feature, + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(iconStyleLoadSpy.calledOnce).to.be.ok(); - listeners = ol.events.getListeners( + listeners = _ol_events_.getListeners( iconStyle.iconImage_, 'change'); expect(listeners.length).to.eql(1); }); @@ -75,12 +73,12 @@ describe('ol.renderer.vector', function() { describe('call renderFeature with a loading icon', function() { it('does not render the point', function() { - feature.setGeometry(new ol.geom.Point([0, 0])); + feature.setGeometry(new _ol_geom_Point_([0, 0])); var imageReplay = replayGroup.getReplay( style.getZIndex(), 'Image'); var setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle'); - var drawPointSpy = sinon.stub(imageReplay, 'drawPoint').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawPointSpy = sinon.stub(imageReplay, 'drawPoint').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setImageStyleSpy.called).to.be(false); setImageStyleSpy.restore(); @@ -88,12 +86,12 @@ describe('ol.renderer.vector', function() { }); it('does not render the multipoint', function() { - feature.setGeometry(new ol.geom.MultiPoint([[0, 0], [1, 1]])); + feature.setGeometry(new _ol_geom_MultiPoint_([[0, 0], [1, 1]])); var imageReplay = replayGroup.getReplay( style.getZIndex(), 'Image'); var setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle'); - var drawMultiPointSpy = sinon.stub(imageReplay, 'drawMultiPoint').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawMultiPointSpy = sinon.stub(imageReplay, 'drawMultiPoint').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setImageStyleSpy.called).to.be(false); setImageStyleSpy.restore(); @@ -101,13 +99,13 @@ describe('ol.renderer.vector', function() { }); it('does render the linestring', function() { - feature.setGeometry(new ol.geom.LineString([[0, 0], [1, 1]])); + feature.setGeometry(new _ol_geom_LineString_([[0, 0], [1, 1]])); var lineStringReplay = replayGroup.getReplay( style.getZIndex(), 'LineString'); var setFillStrokeStyleSpy = sinon.spy(lineStringReplay, 'setFillStrokeStyle'); - var drawLineStringSpy = sinon.stub(lineStringReplay, 'drawLineString').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawLineStringSpy = sinon.stub(lineStringReplay, 'drawLineString').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); expect(drawLineStringSpy.called).to.be(true); @@ -116,13 +114,13 @@ describe('ol.renderer.vector', function() { }); it('does render the multilinestring', function() { - feature.setGeometry(new ol.geom.MultiLineString([[[0, 0], [1, 1]]])); + feature.setGeometry(new _ol_geom_MultiLineString_([[[0, 0], [1, 1]]])); var lineStringReplay = replayGroup.getReplay( style.getZIndex(), 'LineString'); var setFillStrokeStyleSpy = sinon.spy(lineStringReplay, 'setFillStrokeStyle'); - var drawMultiLineStringSpy = sinon.stub(lineStringReplay, 'drawMultiLineString').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawMultiLineStringSpy = sinon.stub(lineStringReplay, 'drawMultiLineString').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); expect(drawMultiLineStringSpy.called).to.be(true); @@ -131,14 +129,14 @@ describe('ol.renderer.vector', function() { }); it('does render the polygon', function() { - feature.setGeometry(new ol.geom.Polygon( + feature.setGeometry(new _ol_geom_Polygon_( [[[0, 0], [1, 1], [1, 0], [0, 0]]])); var polygonReplay = replayGroup.getReplay( style.getZIndex(), 'Polygon'); var setFillStrokeStyleSpy = sinon.spy(polygonReplay, 'setFillStrokeStyle'); - var drawPolygonSpy = sinon.stub(polygonReplay, 'drawPolygon').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawPolygonSpy = sinon.stub(polygonReplay, 'drawPolygon').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); expect(drawPolygonSpy.called).to.be(true); @@ -147,14 +145,14 @@ describe('ol.renderer.vector', function() { }); it('does render the multipolygon', function() { - feature.setGeometry(new ol.geom.MultiPolygon( + feature.setGeometry(new _ol_geom_MultiPolygon_( [[[[0, 0], [1, 1], [1, 0], [0, 0]]]])); var polygonReplay = replayGroup.getReplay( style.getZIndex(), 'Polygon'); var setFillStrokeStyleSpy = sinon.spy(polygonReplay, 'setFillStrokeStyle'); - var drawMultiPolygonSpy = sinon.stub(polygonReplay, 'drawMultiPolygon').callsFake(ol.nullFunction); - ol.renderer.vector.renderFeature(replayGroup, feature, + var drawMultiPolygonSpy = sinon.stub(polygonReplay, 'drawMultiPolygon').callsFake(_ol_.nullFunction); + _ol_renderer_vector_.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); expect(drawMultiPolygonSpy.called).to.be(true); diff --git a/test/spec/ol/renderer/webgl/imagelayer.test.js b/test/spec/ol/renderer/webgl/imagelayer.test.js index a5f085536f..ff9b23b5eb 100644 --- a/test/spec/ol/renderer/webgl/imagelayer.test.js +++ b/test/spec/ol/renderer/webgl/imagelayer.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.transform'); -goog.require('ol.Map'); -goog.require('ol.layer.Image'); -goog.require('ol.source.Image'); -goog.require('ol.renderer.webgl.ImageLayer'); +import _ol_transform_ from '../../../../../src/ol/transform.js'; +import _ol_Map_ from '../../../../../src/ol/Map.js'; +import _ol_layer_Image_ from '../../../../../src/ol/layer/Image.js'; +import _ol_source_Image_ from '../../../../../src/ol/source/Image.js'; +import _ol_renderer_webgl_ImageLayer_ from '../../../../../src/ol/renderer/webgl/ImageLayer.js'; describe('ol.renderer.webgl.ImageLayer', function() { @@ -20,15 +18,15 @@ describe('ol.renderer.webgl.ImageLayer', function() { var imageExtent; beforeEach(function() { - map = new ol.Map({ + map = new _ol_Map_({ target: document.createElement('div') }); - var layer = new ol.layer.Image({ - source: new ol.source.Image({ + var layer = new _ol_layer_Image_({ + source: new _ol_source_Image_({ extent: [0, 0, 1, 1] }) }); - renderer = new ol.renderer.webgl.ImageLayer(map.renderer_, layer); + renderer = new _ol_renderer_webgl_ImageLayer_(map.renderer_, layer); // input params canvasWidth = 512; @@ -54,23 +52,23 @@ describe('ol.renderer.webgl.ImageLayer', function() { pixelRatio, viewCenter, viewResolution, viewRotation, imageExtent); var matrix = renderer.getProjectionMatrix(); - var output = ol.transform.apply(matrix, [-1, -1]); + var output = _ol_transform_.apply(matrix, [-1, -1]); expect(output[0]).to.eql(-6); expect(output[1]).to.eql(-6); - output = ol.transform.apply(matrix, [1, -1]); + output = _ol_transform_.apply(matrix, [1, -1]); expect(output[0]).to.eql(2); expect(output[1]).to.eql(-6); - output = ol.transform.apply(matrix, [-1, 1]); + output = _ol_transform_.apply(matrix, [-1, 1]); expect(output[0]).to.eql(-6); expect(output[1]).to.eql(6); - output = ol.transform.apply(matrix, [1, 1]); + output = _ol_transform_.apply(matrix, [1, 1]); expect(output[0]).to.eql(2); expect(output[1]).to.eql(6); - output = ol.transform.apply(matrix, [0, 0]); + output = _ol_transform_.apply(matrix, [0, 0]); expect(output[0]).to.eql(-2); expect(output[1]).to.eql(0); }); diff --git a/test/spec/ol/reproj/image.test.js b/test/spec/ol/reproj/image.test.js index 9467a5fcfa..ea898390d0 100644 --- a/test/spec/ol/reproj/image.test.js +++ b/test/spec/ol/reproj/image.test.js @@ -1,18 +1,16 @@ - - -goog.require('ol.Image'); -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.reproj.Image'); +import _ol_Image_ from '../../../../src/ol/Image.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_reproj_Image_ from '../../../../src/ol/reproj/Image.js'; describe('ol.reproj.Image', function() { function createImage(pixelRatio) { - return new ol.reproj.Image( - ol.proj.get('EPSG:3857'), ol.proj.get('EPSG:4326'), + return new _ol_reproj_Image_( + _ol_proj_.get('EPSG:3857'), _ol_proj_.get('EPSG:4326'), [-180, -85, 180, 85], 10, pixelRatio, function(extent, resolution, pixelRatio) { - return new ol.Image(extent, resolution, pixelRatio, + return new _ol_Image_(extent, resolution, pixelRatio, 'data:image/gif;base64,' + 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null, function(image, src) { @@ -24,7 +22,7 @@ describe('ol.reproj.Image', function() { it('changes state as expected', function(done) { var image = createImage(1); expect(image.getState()).to.be(0); // IDLE - ol.events.listen(image, 'change', function() { + _ol_events_.listen(image, 'change', function() { if (image.getState() == 2) { // LOADED done(); } @@ -34,7 +32,7 @@ describe('ol.reproj.Image', function() { it('returns correct canvas size', function(done) { var image = createImage(1); - ol.events.listen(image, 'change', function() { + _ol_events_.listen(image, 'change', function() { if (image.getState() == 2) { // LOADED var canvas = image.getImage(); expect(canvas.width).to.be(36); @@ -47,7 +45,7 @@ describe('ol.reproj.Image', function() { it('respects pixelRatio', function(done) { var image = createImage(2); - ol.events.listen(image, 'change', function() { + _ol_events_.listen(image, 'change', function() { if (image.getState() == 2) { // LOADED var canvas = image.getImage(); expect(canvas.width).to.be(72); diff --git a/test/spec/ol/reproj/reproj.test.js b/test/spec/ol/reproj/reproj.test.js index 45feda11c9..a60eeefeaf 100644 --- a/test/spec/ol/reproj/reproj.test.js +++ b/test/spec/ol/reproj/reproj.test.js @@ -1,30 +1,28 @@ - - -goog.require('ol.reproj'); -goog.require('ol.proj'); +import _ol_reproj_ from '../../../../src/ol/reproj.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.reproj', function() { describe('#calculateSourceResolution', function() { - var proj3857 = ol.proj.get('EPSG:3857'); - var proj4326 = ol.proj.get('EPSG:4326'); + var proj3857 = _ol_proj_.get('EPSG:3857'); + var proj4326 = _ol_proj_.get('EPSG:4326'); var origin = [0, 0]; var point3857 = [50, 40]; - var point4326 = ol.proj.transform(point3857, proj3857, proj4326); + var point4326 = _ol_proj_.transform(point3857, proj3857, proj4326); it('is identity for identical projection', function() { var result; var resolution = 500; - result = ol.reproj.calculateSourceResolution( + result = _ol_reproj_.calculateSourceResolution( proj3857, proj3857, origin, resolution); expect(result).to.be(resolution); - result = ol.reproj.calculateSourceResolution( + result = _ol_reproj_.calculateSourceResolution( proj3857, proj3857, point3857, resolution); expect(result).to.be(resolution); - result = ol.reproj.calculateSourceResolution( + result = _ol_reproj_.calculateSourceResolution( proj4326, proj4326, point4326, resolution); expect(result).to.be(resolution); }); @@ -32,13 +30,13 @@ describe('ol.reproj', function() { it('calculates correctly', function() { var resolution4326 = 5; - var resolution3857 = ol.reproj.calculateSourceResolution( + var resolution3857 = _ol_reproj_.calculateSourceResolution( proj3857, proj4326, point4326, resolution4326); expect(resolution3857).not.to.be(resolution4326); expect(resolution3857).to.roughlyEqual( 5 * proj4326.getMetersPerUnit(), 1e-4); - var result = ol.reproj.calculateSourceResolution( + var result = _ol_reproj_.calculateSourceResolution( proj4326, proj3857, point3857, resolution3857); expect(result).to.be(resolution4326); }); diff --git a/test/spec/ol/reproj/tile.test.js b/test/spec/ol/reproj/tile.test.js index e6eb2411b8..6789694496 100644 --- a/test/spec/ol/reproj/tile.test.js +++ b/test/spec/ol/reproj/tile.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.ImageTile'); -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.reproj.Tile'); -goog.require('ol.tilegrid'); +import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.reproj.Tile', function() { @@ -13,7 +11,7 @@ describe('ol.reproj.Tile', function() { '+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+units=m +no_defs'); - var proj27700 = ol.proj.get('EPSG:27700'); + var proj27700 = _ol_proj_.get('EPSG:27700'); proj27700.setExtent([0, 0, 700000, 1300000]); }); @@ -23,13 +21,13 @@ describe('ol.reproj.Tile', function() { function createTile(pixelRatio, opt_tileSize) { - var proj4326 = ol.proj.get('EPSG:4326'); - var proj3857 = ol.proj.get('EPSG:3857'); - return new ol.reproj.Tile( - proj3857, ol.tilegrid.createForProjection(proj3857), proj4326, - ol.tilegrid.createForProjection(proj4326, 3, opt_tileSize), + var proj4326 = _ol_proj_.get('EPSG:4326'); + var proj3857 = _ol_proj_.get('EPSG:3857'); + return new _ol_reproj_Tile_( + proj3857, _ol_tilegrid_.createForProjection(proj3857), proj4326, + _ol_tilegrid_.createForProjection(proj4326, 3, opt_tileSize), [3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) { - return new ol.ImageTile([z, x, y], 0, // IDLE + return new _ol_ImageTile_([z, x, y], 0, // IDLE 'data:image/gif;base64,' + 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null, function(tile, src) { @@ -41,7 +39,7 @@ describe('ol.reproj.Tile', function() { it('changes state as expected', function(done) { var tile = createTile(1); expect(tile.getState()).to.be(0); // IDLE - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED done(); } @@ -50,11 +48,11 @@ describe('ol.reproj.Tile', function() { }); it('is empty when outside target tile grid', function() { - var proj4326 = ol.proj.get('EPSG:4326'); - var proj3857 = ol.proj.get('EPSG:3857'); - var tile = new ol.reproj.Tile( - proj3857, ol.tilegrid.createForProjection(proj3857), - proj4326, ol.tilegrid.createForProjection(proj4326), + var proj4326 = _ol_proj_.get('EPSG:4326'); + var proj3857 = _ol_proj_.get('EPSG:3857'); + var tile = new _ol_reproj_Tile_( + proj3857, _ol_tilegrid_.createForProjection(proj3857), + proj4326, _ol_tilegrid_.createForProjection(proj4326), [0, -1, 0], null, 1, 0, function() { expect().fail('No tiles should be required'); }); @@ -62,11 +60,11 @@ describe('ol.reproj.Tile', function() { }); it('is empty when outside source tile grid', function() { - var proj4326 = ol.proj.get('EPSG:4326'); - var proj27700 = ol.proj.get('EPSG:27700'); - var tile = new ol.reproj.Tile( - proj27700, ol.tilegrid.createForProjection(proj27700), - proj4326, ol.tilegrid.createForProjection(proj4326), + var proj4326 = _ol_proj_.get('EPSG:4326'); + var proj27700 = _ol_proj_.get('EPSG:27700'); + var tile = new _ol_reproj_Tile_( + proj27700, _ol_tilegrid_.createForProjection(proj27700), + proj4326, _ol_tilegrid_.createForProjection(proj4326), [3, 2, -2], null, 1, 0, function() { expect().fail('No tiles should be required'); }); @@ -75,7 +73,7 @@ describe('ol.reproj.Tile', function() { it('respects tile size of target tile grid', function(done) { var tile = createTile(1, [100, 40]); - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED var canvas = tile.getImage(); expect(canvas.width).to.be(100); @@ -88,7 +86,7 @@ describe('ol.reproj.Tile', function() { it('respects pixelRatio', function(done) { var tile = createTile(3, [60, 20]); - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED var canvas = tile.getImage(); expect(canvas.width).to.be(180); diff --git a/test/spec/ol/reproj/triangulation.test.js b/test/spec/ol/reproj/triangulation.test.js index 815cc53ecd..d71935efd5 100644 --- a/test/spec/ol/reproj/triangulation.test.js +++ b/test/spec/ol/reproj/triangulation.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.proj'); -goog.require('ol.reproj.Triangulation'); +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_reproj_Triangulation_ from '../../../../src/ol/reproj/Triangulation.js'; describe('ol.reproj.Triangulation', function() { @@ -10,7 +8,7 @@ describe('ol.reproj.Triangulation', function() { '+k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+units=m +no_defs'); - var proj27700 = ol.proj.get('EPSG:27700'); + var proj27700 = _ol_proj_.get('EPSG:27700'); proj27700.setExtent([0, 0, 700000, 1300000]); }); @@ -20,23 +18,23 @@ describe('ol.reproj.Triangulation', function() { describe('constructor', function() { it('is trivial for identity', function() { - var proj4326 = ol.proj.get('EPSG:4326'); - var triangulation = new ol.reproj.Triangulation(proj4326, proj4326, + var proj4326 = _ol_proj_.get('EPSG:4326'); + var triangulation = new _ol_reproj_Triangulation_(proj4326, proj4326, [20, 20, 30, 30], [-180, -90, 180, 90], 0); expect(triangulation.getTriangles().length).to.be(2); }); it('is empty when outside source extent', function() { - var proj4326 = ol.proj.get('EPSG:4326'); - var proj27700 = ol.proj.get('EPSG:27700'); - var triangulation = new ol.reproj.Triangulation(proj27700, proj4326, + var proj4326 = _ol_proj_.get('EPSG:4326'); + var proj27700 = _ol_proj_.get('EPSG:27700'); + var triangulation = new _ol_reproj_Triangulation_(proj27700, proj4326, [0, 0, 10, 10], proj27700.getExtent(), 0); expect(triangulation.getTriangles().length).to.be(0); }); it('can handle null source extent', function() { - var proj4326 = ol.proj.get('EPSG:4326'); - var triangulation = new ol.reproj.Triangulation(proj4326, proj4326, + var proj4326 = _ol_proj_.get('EPSG:4326'); + var triangulation = new _ol_reproj_Triangulation_(proj4326, proj4326, [20, 20, 30, 30], null, 0); expect(triangulation.getTriangles().length).to.be(2); }); diff --git a/test/spec/ol/resolutionconstraint.test.js b/test/spec/ol/resolutionconstraint.test.js index fb4ebd176c..139f754e22 100644 --- a/test/spec/ol/resolutionconstraint.test.js +++ b/test/spec/ol/resolutionconstraint.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.ResolutionConstraint'); +import _ol_ResolutionConstraint_ from '../../../src/ol/ResolutionConstraint.js'; describe('ol.ResolutionConstraint', function() { @@ -10,7 +8,7 @@ describe('ol.ResolutionConstraint', function() { var resolutionConstraint; beforeEach(function() { - resolutionConstraint = ol.ResolutionConstraint.createSnapToResolutions( + resolutionConstraint = _ol_ResolutionConstraint_.createSnapToResolutions( [1000, 500, 250, 100]); }); @@ -48,7 +46,7 @@ describe('ol.ResolutionConstraint', function() { beforeEach(function() { resolutionConstraint = - ol.ResolutionConstraint.createSnapToResolutions( + _ol_ResolutionConstraint_.createSnapToResolutions( [1000, 500, 250, 100]); }); @@ -98,7 +96,7 @@ describe('ol.ResolutionConstraint', function() { beforeEach(function() { resolutionConstraint = - ol.ResolutionConstraint.createSnapToPower(2, 1024, 10); + _ol_ResolutionConstraint_.createSnapToPower(2, 1024, 10); }); describe('delta 0', function() { @@ -156,7 +154,7 @@ describe('ol.ResolutionConstraint', function() { beforeEach(function() { resolutionConstraint = - ol.ResolutionConstraint.createSnapToPower(2, 1024, 10); + _ol_ResolutionConstraint_.createSnapToPower(2, 1024, 10); }); describe('delta 0, direction 0', function() { diff --git a/test/spec/ol/rotationconstraint.test.js b/test/spec/ol/rotationconstraint.test.js index d225f7caef..5c0d7b0be3 100644 --- a/test/spec/ol/rotationconstraint.test.js +++ b/test/spec/ol/rotationconstraint.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.RotationConstraint'); +import _ol_RotationConstraint_ from '../../../src/ol/RotationConstraint.js'; describe('ol.RotationConstraint', function() { @@ -8,7 +6,7 @@ describe('ol.RotationConstraint', function() { describe('SnapToZero', function() { it('returns expected rotation value', function() { - var rotationConstraint = ol.RotationConstraint.createSnapToZero(0.3); + var rotationConstraint = _ol_RotationConstraint_.createSnapToZero(0.3); expect(rotationConstraint(0.1, 0)).to.eql(0); expect(rotationConstraint(0.2, 0)).to.eql(0); diff --git a/test/spec/ol/size.test.js b/test/spec/ol/size.test.js index 788dd1ea84..13c3d61c07 100644 --- a/test/spec/ol/size.test.js +++ b/test/spec/ol/size.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.size'); +import _ol_size_ from '../../../src/ol/size.js'; describe('ol.size', function() { @@ -9,14 +7,14 @@ describe('ol.size', function() { it('buffers a size', function() { var size = [50, 75]; - var bufferedSize = ol.size.buffer(size, 20); + var bufferedSize = _ol_size_.buffer(size, 20); expect(bufferedSize).to.eql([90, 115]); }); it('reuses an existing array', function() { var reuse = [0, 0]; var size = [50, 50]; - var bufferedSize = ol.size.buffer(size, 20, reuse); + var bufferedSize = _ol_size_.buffer(size, 20, reuse); expect(bufferedSize).to.equal(reuse); }); @@ -25,13 +23,13 @@ describe('ol.size', function() { describe('hasArea()', function() { it('determines if a size has a positive area', function() { - expect(ol.size.hasArea([50, 75])).to.equal(true); - expect(ol.size.hasArea([0, 75])).to.equal(false); - expect(ol.size.hasArea([50, 0])).to.equal(false); - expect(ol.size.hasArea([0, 0])).to.equal(false); - expect(ol.size.hasArea([-1, 75])).to.equal(false); - expect(ol.size.hasArea([50, -1])).to.equal(false); - expect(ol.size.hasArea([-1, -1])).to.equal(false); + expect(_ol_size_.hasArea([50, 75])).to.equal(true); + expect(_ol_size_.hasArea([0, 75])).to.equal(false); + expect(_ol_size_.hasArea([50, 0])).to.equal(false); + expect(_ol_size_.hasArea([0, 0])).to.equal(false); + expect(_ol_size_.hasArea([-1, 75])).to.equal(false); + expect(_ol_size_.hasArea([50, -1])).to.equal(false); + expect(_ol_size_.hasArea([-1, -1])).to.equal(false); }); }); @@ -40,14 +38,14 @@ describe('ol.size', function() { it('scales a size and rounds the result', function() { var size = [50, 75]; - var scaledSize = ol.size.scale(size, 1.75); + var scaledSize = _ol_size_.scale(size, 1.75); expect(scaledSize).to.eql([88, 131]); }); it('reuses an existing array', function() { var reuse = [0, 0]; var size = [50, 50]; - var scaledSize = ol.size.scale(size, 1.75, reuse); + var scaledSize = _ol_size_.scale(size, 1.75, reuse); expect(scaledSize).to.equal(reuse); }); @@ -56,21 +54,21 @@ describe('ol.size', function() { describe('toSize()', function() { it('creates a size array from a number', function() { - var size = ol.size.toSize(512); + var size = _ol_size_.toSize(512); expect(size).to.eql([512, 512]); }); it('reuses an existing array', function() { var sizeArray = [0, 0]; - var size = ol.size.toSize(512, sizeArray); + var size = _ol_size_.toSize(512, sizeArray); expect(size).to.equal(sizeArray); }); it('returns a size array unaltered', function() { var sizeArray = [512, 256]; - var size = ol.size.toSize(sizeArray); + var size = _ol_size_.toSize(sizeArray); expect(size).to.equal(sizeArray); - size = ol.size.toSize(sizeArray, [0, 0]); + size = _ol_size_.toSize(sizeArray, [0, 0]); expect(size).to.equal(sizeArray); }); diff --git a/test/spec/ol/source/bingmaps.test.js b/test/spec/ol/source/bingmaps.test.js index ec70abbf4d..04a9a7d6e2 100644 --- a/test/spec/ol/source/bingmaps.test.js +++ b/test/spec/ol/source/bingmaps.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.net'); -goog.require('ol.source.BingMaps'); -goog.require('ol.tilecoord'); -goog.require('ol.Observable'); +import _ol_net_ from '../../../../src/ol/net.js'; +import _ol_source_BingMaps_ from '../../../../src/ol/source/BingMaps.js'; +import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js'; +import _ol_Observable_ from '../../../../src/ol/Observable.js'; describe('ol.source.BingMaps', function() { @@ -13,9 +11,9 @@ describe('ol.source.BingMaps', function() { var source, tileGrid; beforeEach(function(done) { - var olNetJsonp = ol.net.jsonp; + var olNetJsonp = _ol_net_.jsonp; // mock ol.net.Jsonp (used in the ol.source.TileJSON constructor) - ol.net.jsonp = function(url, callback) { + _ol_net_.jsonp = function(url, callback) { var client = new XMLHttpRequest(); client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true); client.onload = function() { @@ -23,14 +21,14 @@ describe('ol.source.BingMaps', function() { }; client.send(); }; - source = new ol.source.BingMaps({ + source = new _ol_source_BingMaps_({ imagerySet: 'AerialWithLabels', key: '' }); - ol.net.jsonp = olNetJsonp; + _ol_net_.jsonp = olNetJsonp; var key = source.on('change', function() { if (source.getState() === 'ready') { - ol.Observable.unByKey(key); + _ol_Observable_.unByKey(key); tileGrid = source.getTileGrid(); done(); } @@ -54,28 +52,28 @@ describe('ol.source.BingMaps', function() { tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 1), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([1, 1, 0])); + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([1, 1, 0])); tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 2), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([2, 2, 1])); + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([2, 2, 1])); tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 3), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([3, 4, 2])); + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([3, 4, 2])); tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 4), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey([4, 8, 5])); + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey([4, 8, 5])); tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 5), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey( + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey( [5, 16, 11])); tileUrl = source.tileUrlFunction( tileGrid.getTileCoordForCoordAndZ(coordinate, 6), 1, projection); - expect(tileUrl.match(regex)[1]).to.equal(ol.tilecoord.quadKey( + expect(tileUrl.match(regex)[1]).to.equal(_ol_tilecoord_.quadKey( [6, 33, 22])); }); diff --git a/test/spec/ol/source/cartodb.test.js b/test/spec/ol/source/cartodb.test.js index 84f5142743..635a5dbdbf 100644 --- a/test/spec/ol/source/cartodb.test.js +++ b/test/spec/ol/source/cartodb.test.js @@ -1,18 +1,16 @@ - - -goog.require('ol.source.CartoDB'); -goog.require('ol.source.XYZ'); +import _ol_source_CartoDB_ from '../../../../src/ol/source/CartoDB.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; describe('ol.source.CartoDB', function() { describe('constructor', function() { it('returns a CartoDB source', function() { - var source = new ol.source.CartoDB({ + var source = new _ol_source_CartoDB_({ account: 'documentation', config: {} }); - expect(source).to.be.a(ol.source.XYZ); - expect(source).to.be.a(ol.source.CartoDB); + expect(source).to.be.a(_ol_source_XYZ_); + expect(source).to.be.a(_ol_source_CartoDB_); }); }); }); diff --git a/test/spec/ol/source/cluster.test.js b/test/spec/ol/source/cluster.test.js index ef450b0a41..bb94f3c518 100644 --- a/test/spec/ol/source/cluster.test.js +++ b/test/spec/ol/source/cluster.test.js @@ -1,37 +1,35 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.proj'); -goog.require('ol.source.Cluster'); -goog.require('ol.source.Source'); -goog.require('ol.source.Vector'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_Cluster_ from '../../../../src/ol/source/Cluster.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.source.Cluster', function() { describe('constructor', function() { it('returns a cluster source', function() { - var source = new ol.source.Cluster({ - projection: ol.proj.get('EPSG:4326'), - source: new ol.source.Vector() + var source = new _ol_source_Cluster_({ + projection: _ol_proj_.get('EPSG:4326'), + source: new _ol_source_Vector_() }); - expect(source).to.be.a(ol.source.Source); - expect(source).to.be.a(ol.source.Cluster); + expect(source).to.be.a(_ol_source_Source_); + expect(source).to.be.a(_ol_source_Cluster_); expect(source.getDistance()).to.be(20); }); }); describe('#loadFeatures', function() { var extent = [-1, -1, 1, 1]; - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); it('clusters a source with point features', function() { - var source = new ol.source.Cluster({ - source: new ol.source.Vector({ + var source = new _ol_source_Cluster_({ + source: new _ol_source_Vector_({ features: [ - new ol.Feature(new ol.geom.Point([0, 0])), - new ol.Feature(new ol.geom.Point([0, 0])) + new _ol_Feature_(new _ol_geom_Point_([0, 0])), + new _ol_Feature_(new _ol_geom_Point_([0, 0])) ] }) }); @@ -40,7 +38,7 @@ describe('ol.source.Cluster', function() { expect(source.getFeatures()[0].get('features').length).to.be(2); }); it('clusters with a custom geometryFunction', function() { - var source = new ol.source.Cluster({ + var source = new _ol_source_Cluster_({ geometryFunction: function(feature) { var geom = feature.getGeometry(); if (geom.getType() == 'Point') { @@ -50,11 +48,11 @@ describe('ol.source.Cluster', function() { } return null; }, - source: new ol.source.Vector({ + source: new _ol_source_Vector_({ features: [ - new ol.Feature(new ol.geom.Point([0, 0])), - new ol.Feature(new ol.geom.LineString([[0, 0], [1, 1]])), - new ol.Feature(new ol.geom.Polygon( + new _ol_Feature_(new _ol_geom_Point_([0, 0])), + new _ol_Feature_(new _ol_geom_LineString_([[0, 0], [1, 1]])), + new _ol_Feature_(new _ol_geom_Polygon_( [[[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]])) ] }) @@ -67,9 +65,9 @@ describe('ol.source.Cluster', function() { describe('#setDistance', function() { it('changes the distance value', function() { - var source = new ol.source.Cluster({ + var source = new _ol_source_Cluster_({ distance: 100, - source: new ol.source.Vector() + source: new _ol_source_Vector_() }); expect(source.getDistance()).to.be(100); source.setDistance(10); diff --git a/test/spec/ol/source/imagearcgisrest.test.js b/test/spec/ol/source/imagearcgisrest.test.js index f08a125657..aa631c4d45 100644 --- a/test/spec/ol/source/imagearcgisrest.test.js +++ b/test/spec/ol/source/imagearcgisrest.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.source.ImageArcGISRest'); -goog.require('ol.proj'); +import _ol_source_ImageArcGISRest_ from '../../../../src/ol/source/ImageArcGISRest.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.source.ImageArcGISRest', function() { @@ -9,8 +7,8 @@ describe('ol.source.ImageArcGISRest', function() { var pixelRatio, options, projection, proj3857, resolution; beforeEach(function() { pixelRatio = 1; - projection = ol.proj.get('EPSG:4326'); - proj3857 = ol.proj.get('EPSG:3857'); + projection = _ol_proj_.get('EPSG:4326'); + proj3857 = _ol_proj_.get('EPSG:3857'); resolution = 0.1; options = { params: {}, @@ -21,7 +19,7 @@ describe('ol.source.ImageArcGISRest', function() { describe('#getImage', function() { it('returns a image with the expected URL', function() { - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857); var uri = new URL(image.src_); expect(uri.protocol).to.be('http:'); @@ -37,7 +35,7 @@ describe('ol.source.ImageArcGISRest', function() { }); it('returns a non floating point DPI value', function() { - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var image = source.getImage([3, 2, -7, 1.12], resolution, 1.01, proj3857); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -46,7 +44,7 @@ describe('ol.source.ImageArcGISRest', function() { it('returns a image with the expected URL for ImageServer', function() { options.url = 'http://example.com/ImageServer'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857); var uri = new URL(image.src_); expect(uri.protocol).to.be('http:'); @@ -63,7 +61,7 @@ describe('ol.source.ImageArcGISRest', function() { it('allows various parameters to be overridden', function() { options.params.FORMAT = 'png'; options.params.TRANSPARENT = false; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -73,7 +71,7 @@ describe('ol.source.ImageArcGISRest', function() { it('allows adding rest option', function() { options.params.LAYERS = 'show:1,3,4'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, proj3857); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -84,7 +82,7 @@ describe('ol.source.ImageArcGISRest', function() { describe('#updateParams', function() { it('add a new param', function() { - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.updateParams({'TEST': 'value'}); var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857); @@ -96,7 +94,7 @@ describe('ol.source.ImageArcGISRest', function() { it('updates an existing param', function() { options.params.TEST = 'value'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.updateParams({'TEST': 'newValue'}); var image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857); @@ -111,7 +109,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify getting a param', function() { options.params.TEST = 'value'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var setParams = source.getParams(); @@ -121,7 +119,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify on adding a param', function() { options.params.TEST = 'value'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.updateParams({'TEST2': 'newValue'}); var setParams = source.getParams(); @@ -132,7 +130,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify on update a param', function() { options.params.TEST = 'value'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.updateParams({'TEST': 'newValue'}); var setParams = source.getParams(); @@ -147,7 +145,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify getting url', function() { options.url = 'http://test.com/MapServer'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); var url = source.getUrl(); @@ -161,7 +159,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify setting url when not set yet', function() { - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.setUrl('http://test.com/MapServer'); var url = source.getUrl(); @@ -172,7 +170,7 @@ describe('ol.source.ImageArcGISRest', function() { it('verify setting url with existing url', function() { options.url = 'http://test.com/MapServer'; - var source = new ol.source.ImageArcGISRest(options); + var source = new _ol_source_ImageArcGISRest_(options); source.setUrl('http://test2.com/MapServer'); var url = source.getUrl(); diff --git a/test/spec/ol/source/imagestatic.test.js b/test/spec/ol/source/imagestatic.test.js index 92ef2fc8f2..31fee2718f 100644 --- a/test/spec/ol/source/imagestatic.test.js +++ b/test/spec/ol/source/imagestatic.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.source.ImageStatic'); -goog.require('ol.proj'); +import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.source.ImageStatic', function() { @@ -12,14 +10,14 @@ describe('ol.source.ImageStatic', function() { -13637278.73946974, 4543799.13271362, -13617443.330629736, 4553927.038961405]; pixelRatio = 1; - projection = ol.proj.get('EPSG:3857'); + projection = _ol_proj_.get('EPSG:3857'); resolution = 38; }); describe('#getImage', function() { it('scales image to fit imageExtent', function(done) { - var source = new ol.source.ImageStatic({ + var source = new _ol_source_ImageStatic_({ url: 'spec/ol/source/images/12-655-1583.png', imageExtent: [ -13629027.891360067, 4539747.983913189, @@ -39,7 +37,7 @@ describe('ol.source.ImageStatic', function() { }); it('respects imageSize', function(done) { - var source = new ol.source.ImageStatic({ + var source = new _ol_source_ImageStatic_({ url: 'spec/ol/source/images/12-655-1583.png', imageExtent: [ -13629027.891360067, 4539747.983913189, @@ -60,7 +58,7 @@ describe('ol.source.ImageStatic', function() { }); it('triggers image load events', function(done) { - var source = new ol.source.ImageStatic({ + var source = new _ol_source_ImageStatic_({ url: 'spec/ol/source/images/12-655-1583.png', imageExtent: [ -13629027.891360067, 4539747.983913189, diff --git a/test/spec/ol/source/imagewms.test.js b/test/spec/ol/source/imagewms.test.js index a96a0e7ac7..f10a0c566d 100644 --- a/test/spec/ol/source/imagewms.test.js +++ b/test/spec/ol/source/imagewms.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.source.ImageWMS'); -goog.require('ol.proj'); +import _ol_source_ImageWMS_ from '../../../../src/ol/source/ImageWMS.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.source.ImageWMS', function() { @@ -10,7 +8,7 @@ describe('ol.source.ImageWMS', function() { beforeEach(function() { extent = [10, 20, 30, 40]; pixelRatio = 1; - projection = ol.proj.get('EPSG:4326'); + projection = _ol_proj_.get('EPSG:4326'); resolution = 0.1; options = { params: { @@ -33,7 +31,7 @@ describe('ol.source.ImageWMS', function() { it('returns the expected image URL', function() { options.ratio = 1.5; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -46,7 +44,7 @@ describe('ol.source.ImageWMS', function() { it('uses correct WIDTH and HEIGHT for HiDPI devices', function() { pixelRatio = 2; options.serverType = 'geoserver'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -58,7 +56,7 @@ describe('ol.source.ImageWMS', function() { it('requests integer WIDTH and HEIGHT', function() { options.ratio = 1.5; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -69,7 +67,7 @@ describe('ol.source.ImageWMS', function() { }); it('sets WIDTH and HEIGHT to match the aspect ratio of BBOX', function() { - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); expect(uri.protocol).to.be('http:'); @@ -93,7 +91,7 @@ describe('ol.source.ImageWMS', function() { it('sets the SRS query value instead of CRS if version < 1.3', function() { options.params.VERSION = '1.2'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -104,7 +102,7 @@ describe('ol.source.ImageWMS', function() { it('allows various parameters to be overridden', function() { options.params.FORMAT = 'image/jpeg'; options.params.TRANSPARENT = false; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -114,7 +112,7 @@ describe('ol.source.ImageWMS', function() { it('does not add a STYLES= option if one is specified', function() { options.params.STYLES = 'foo'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -122,8 +120,8 @@ describe('ol.source.ImageWMS', function() { }); it('changes the BBOX order for EN axis orientations', function() { - var source = new ol.source.ImageWMS(options); - projection = ol.proj.get('CRS:84'); + var source = new _ol_source_ImageWMS_(options); + projection = _ol_proj_.get('CRS:84'); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); var queryData = uri.searchParams; @@ -132,7 +130,7 @@ describe('ol.source.ImageWMS', function() { it('uses EN BBOX order if version < 1.3', function() { options.params.VERSION = '1.1.0'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -142,7 +140,7 @@ describe('ol.source.ImageWMS', function() { it('sets MAP_RESOLUTION when the server is MapServer', function() { options.serverType = 'mapserver'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -152,7 +150,7 @@ describe('ol.source.ImageWMS', function() { it('sets FORMAT_OPTIONS when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -162,7 +160,7 @@ describe('ol.source.ImageWMS', function() { it('extends FORMAT_OPTIONS if it is already present', function() { options.serverType = 'geoserver'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); options.params.FORMAT_OPTIONS = 'param1:value1'; pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); @@ -174,7 +172,7 @@ describe('ol.source.ImageWMS', function() { it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); pixelRatio = 1.325; var image = source.getImage(extent, resolution, pixelRatio, projection); @@ -185,7 +183,7 @@ describe('ol.source.ImageWMS', function() { it('sets DPI when the server is QGIS', function() { options.serverType = 'qgis'; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); pixelRatio = 2; var image = source.getImage(extent, resolution, pixelRatio, projection); var uri = new URL(image.src_); @@ -196,7 +194,7 @@ describe('ol.source.ImageWMS', function() { it('creates an image with a custom imageLoadFunction', function() { var imageLoadFunction = sinon.spy(); options.imageLoadFunction = imageLoadFunction; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image = source.getImage(extent, resolution, pixelRatio, projection); image.load(); expect(imageLoadFunction).to.be.called(); @@ -205,7 +203,7 @@ describe('ol.source.ImageWMS', function() { it('returns same image for consecutive calls with same args', function() { var extent = [10.01, 20, 30.01, 40]; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var image1 = source.getImage(extent, resolution, pixelRatio, projection); var image2 = source.getImage(extent, resolution, pixelRatio, projection); expect(image1).to.equal(image2); @@ -213,7 +211,7 @@ describe('ol.source.ImageWMS', function() { it('returns same image for calls with similar extents', function() { options.ratio = 1.5; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var extent = [10.01, 20, 30.01, 40]; var image1 = source.getImage(extent, resolution, pixelRatio, projection); extent = [10.01, 20.1, 30.01, 40.1]; @@ -223,7 +221,7 @@ describe('ol.source.ImageWMS', function() { it('calculates correct image size with ratio', function() { options.ratio = 1.5; - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var extent = [10, 5, 30, 45]; source.getImage(extent, resolution, pixelRatio, projection); expect(source.imageSize_).to.eql([300, 600]); @@ -234,7 +232,7 @@ describe('ol.source.ImageWMS', function() { describe('#getGetFeatureInfoUrl', function() { it('returns the expected GetFeatureInfo URL', function() { - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain'}); @@ -262,7 +260,7 @@ describe('ol.source.ImageWMS', function() { }); it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() { - var source = new ol.source.ImageWMS(optionsReproj); + var source = new _ol_source_ImageWMS_(optionsReproj); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain'}); @@ -290,7 +288,7 @@ describe('ol.source.ImageWMS', function() { }); it('sets the QUERY_LAYERS param as expected', function() { - var source = new ol.source.ImageWMS(options); + var source = new _ol_source_ImageWMS_(options); var url = source.getGetFeatureInfoUrl( [20, 30], resolution, projection, {INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'}); diff --git a/test/spec/ol/source/raster.test.js b/test/spec/ol/source/raster.test.js index 0bb6613fb4..e4a67f79d1 100644 --- a/test/spec/ol/source/raster.test.js +++ b/test/spec/ol/source/raster.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.Map'); -goog.require('ol.TileState'); -goog.require('ol.View'); -goog.require('ol.layer.Image'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.ImageStatic'); -goog.require('ol.source.Raster'); -goog.require('ol.source.Source'); -goog.require('ol.source.Tile'); -goog.require('ol.source.XYZ'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; +import _ol_source_Raster_ from '../../../../src/ol/source/Raster.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; +import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; var red = 'data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAA' + 'BAAEAAAICRAEAOw=='; @@ -37,22 +35,22 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { var extent = [-1, -1, 1, 1]; - redSource = new ol.source.ImageStatic({ + redSource = new _ol_source_ImageStatic_({ url: red, imageExtent: extent }); - greenSource = new ol.source.ImageStatic({ + greenSource = new _ol_source_ImageStatic_({ url: green, imageExtent: extent }); - blueSource = new ol.source.ImageStatic({ + blueSource = new _ol_source_ImageStatic_({ url: blue, imageExtent: extent }); - raster = new ol.source.Raster({ + raster = new _ol_source_Raster_({ threads: 0, sources: [redSource, greenSource, blueSource], operation: function(inputs) { @@ -60,18 +58,18 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { } }); - map = new ol.Map({ + map = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ resolutions: [1], - projection: new ol.proj.Projection({ + projection: new _ol_proj_Projection_({ code: 'image', units: 'pixels', extent: extent }) }), layers: [ - new ol.layer.Image({ + new _ol_layer_Image_({ source: raster }) ] @@ -92,19 +90,19 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { describe('constructor', function() { it('returns a tile source', function() { - var source = new ol.source.Raster({ + var source = new _ol_source_Raster_({ threads: 0, - sources: [new ol.source.Tile({})] + sources: [new _ol_source_Tile_({})] }); - expect(source).to.be.a(ol.source.Source); - expect(source).to.be.a(ol.source.Raster); + expect(source).to.be.a(_ol_source_Source_); + expect(source).to.be.a(_ol_source_Raster_); }); it('defaults to "pixel" operation', function(done) { var log = []; - var source = new ol.source.Raster({ + var source = new _ol_source_Raster_({ threads: 0, sources: [redSource, greenSource, blueSource], operation: function(inputs) { @@ -131,7 +129,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { it('allows operation type to be set to "image"', function(done) { var log = []; - var source = new ol.source.Raster({ + var source = new _ol_source_Raster_({ operationType: 'image', threads: 0, sources: [redSource, greenSource, blueSource], @@ -313,11 +311,11 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { it('is initiated on the underlying source', function(done) { - var source = new ol.source.XYZ({ + var source = new _ol_source_XYZ_({ url: 'spec/ol/data/osm-{z}-{x}-{y}.png' }); - raster = new ol.source.Raster({ + raster = new _ol_source_Raster_({ threads: 0, sources: [source], operation: function(inputs) { @@ -325,14 +323,14 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { } }); - map2 = new ol.Map({ + map2 = new _ol_Map_({ target: target, - view: new ol.View({ + view: new _ol_View_({ center: [0, 0], zoom: 0 }), layers: [ - new ol.layer.Image({ + new _ol_layer_Image_({ source: raster }) ] @@ -345,7 +343,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { map2.once('moveend', function() { expect(tileCache.getCount()).to.equal(1); var state = tileCache.peekLast().getState(); - expect(state === ol.TileState.LOADED || state === ol.TileState.LOADED).to.be(true); + expect(state === _ol_TileState_.LOADED || state === _ol_TileState_.LOADED).to.be(true); done(); }); diff --git a/test/spec/ol/source/source.test.js b/test/spec/ol/source/source.test.js index acebf4ff52..21d2085607 100644 --- a/test/spec/ol/source/source.test.js +++ b/test/spec/ol/source/source.test.js @@ -1,28 +1,28 @@ -goog.require('ol.Attribution'); -goog.require('ol.proj'); -goog.require('ol.source.Source'); +import _ol_Attribution_ from '../../../../src/ol/Attribution.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; describe('ol.source.Source', function() { describe('constructor', function() { it('returns a source', function() { - var source = new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + var source = new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }); - expect(source).to.be.a(ol.source.Source); + expect(source).to.be.a(_ol_source_Source_); }); }); describe('config option `attributions`', function() { it('accepts undefined', function() { - var source = new ol.source.Source({}); + var source = new _ol_source_Source_({}); var attributions = source.getAttributions2(); expect(attributions).to.be(null); }); it('accepts a single string', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: 'Humpty' }); var attributions = source.getAttributions2(); @@ -32,7 +32,7 @@ describe('ol.source.Source', function() { }); it('accepts an array of strings', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: ['Humpty', 'Dumpty'] }); var attributions = source.getAttributions2(); @@ -42,7 +42,7 @@ describe('ol.source.Source', function() { }); it('accepts a function that returns a string', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: function() { return 'Humpty'; } @@ -54,7 +54,7 @@ describe('ol.source.Source', function() { }); it('accepts a function that returns an array of strings', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: function() { return ['Humpty', 'Dumpty']; } @@ -68,8 +68,8 @@ describe('ol.source.Source', function() { describe('#refresh()', function() { it('dispatches the change event', function() { - var source = new ol.source.Source({ - projection: ol.proj.get('EPSG:4326') + var source = new _ol_source_Source_({ + projection: _ol_proj_.get('EPSG:4326') }); var changedSpy = sinon.spy(); source.on('change', changedSpy); @@ -80,49 +80,49 @@ describe('ol.source.Source', function() { describe('#getAttributions()', function() { it('maintains backwards compatibility for string option', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: 'foo' }); var attributions = source.getAttributions(); expect(attributions.length).to.be(1); - expect(attributions[0]).to.be.an(ol.Attribution); + expect(attributions[0]).to.be.an(_ol_Attribution_); expect(attributions[0].getHTML()).to.be('foo'); }); it('maintains backwards compatibility for array of strings option', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: ['foo', 'bar'] }); var attributions = source.getAttributions(); expect(attributions.length).to.be(2); - expect(attributions[0]).to.be.an(ol.Attribution); + expect(attributions[0]).to.be.an(_ol_Attribution_); expect(attributions[0].getHTML()).to.be('foo'); - expect(attributions[1]).to.be.an(ol.Attribution); + expect(attributions[1]).to.be.an(_ol_Attribution_); expect(attributions[1].getHTML()).to.be('bar'); }); it('maintains backwards compatibility for ol.Attribution option', function() { - var source = new ol.source.Source({ - attributions: new ol.Attribution({html: 'foo'}) + var source = new _ol_source_Source_({ + attributions: new _ol_Attribution_({html: 'foo'}) }); var attributions = source.getAttributions(); expect(attributions.length).to.be(1); - expect(attributions[0]).to.be.an(ol.Attribution); + expect(attributions[0]).to.be.an(_ol_Attribution_); expect(attributions[0].getHTML()).to.be('foo'); }); it('maintains backwards compatibility for array of strings option', function() { - var source = new ol.source.Source({ + var source = new _ol_source_Source_({ attributions: [ - new ol.Attribution({html: 'foo'}), - new ol.Attribution({html: 'bar'}) + new _ol_Attribution_({html: 'foo'}), + new _ol_Attribution_({html: 'bar'}) ] }); var attributions = source.getAttributions(); expect(attributions.length).to.be(2); - expect(attributions[0]).to.be.an(ol.Attribution); + expect(attributions[0]).to.be.an(_ol_Attribution_); expect(attributions[0].getHTML()).to.be('foo'); - expect(attributions[1]).to.be.an(ol.Attribution); + expect(attributions[1]).to.be.an(_ol_Attribution_); expect(attributions[1].getHTML()).to.be('bar'); }); }); @@ -131,7 +131,7 @@ describe('ol.source.Source', function() { var source = null; beforeEach(function() { - source = new ol.source.Source({ + source = new _ol_source_Source_({ attributions: 'before' }); }); diff --git a/test/spec/ol/source/stamen.test.js b/test/spec/ol/source/stamen.test.js index d2188f7f96..6b74c20072 100644 --- a/test/spec/ol/source/stamen.test.js +++ b/test/spec/ol/source/stamen.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.source.Stamen'); +import _ol_source_Stamen_ from '../../../../src/ol/source/Stamen.js'; describe('ol.source.Stamen', function() { @@ -8,7 +6,7 @@ describe('ol.source.Stamen', function() { describe('constructor', function() { it('can be constructed with a custom minZoom', function() { - var source = new ol.source.Stamen({ + var source = new _ol_source_Stamen_({ layer: 'watercolor', minZoom: 10 }); @@ -16,7 +14,7 @@ describe('ol.source.Stamen', function() { }); it('can be constructed with a custom maxZoom', function() { - var source = new ol.source.Stamen({ + var source = new _ol_source_Stamen_({ layer: 'watercolor', maxZoom: 8 }); diff --git a/test/spec/ol/source/tile.test.js b/test/spec/ol/source/tile.test.js index 5f04aac69f..2881eff258 100644 --- a/test/spec/ol/source/tile.test.js +++ b/test/spec/ol/source/tile.test.js @@ -1,12 +1,12 @@ -goog.require('ol'); -goog.require('ol.Tile'); -goog.require('ol.TileRange'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.Source'); -goog.require('ol.source.Tile'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_ from '../../../../src/ol.js'; +import _ol_Tile_ from '../../../../src/ol/Tile.js'; +import _ol_TileRange_ from '../../../../src/ol/TileRange.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; +import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js'; +import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; /** @@ -19,34 +19,34 @@ goog.require('ol.tilegrid.TileGrid'); * tile state. */ var MockTile = function(tileStates) { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256], origin: [-180, -180], tileSize: 256 }); - ol.source.Tile.call(this, { - projection: ol.proj.get('EPSG:4326'), + _ol_source_Tile_.call(this, { + projection: _ol_proj_.get('EPSG:4326'), tileGrid: tileGrid }); for (var key in tileStates) { - this.tileCache.set(key, new ol.Tile(key.split('/'), tileStates[key])); + this.tileCache.set(key, new _ol_Tile_(key.split('/'), tileStates[key])); } }; -ol.inherits(MockTile, ol.source.Tile); +_ol_.inherits(MockTile, _ol_source_Tile_); /** * @inheritDoc */ MockTile.prototype.getTile = function(z, x, y) { - var key = ol.tilecoord.getKeyZXY(z, x, y); + var key = _ol_tilecoord_.getKeyZXY(z, x, y); if (this.tileCache.containsKey(key)) { return /** @type {!ol.Tile} */ (this.tileCache.get(key)); } else { - var tile = new ol.Tile(key, 0); // IDLE + var tile = new _ol_Tile_(key, 0); // IDLE this.tileCache.set(key, tile); return tile; } @@ -56,15 +56,15 @@ describe('ol.source.Tile', function() { describe('constructor', function() { it('returns a tile source', function() { - var source = new ol.source.Tile({ - projection: ol.proj.get('EPSG:4326') + var source = new _ol_source_Tile_({ + projection: _ol_proj_.get('EPSG:4326') }); - expect(source).to.be.a(ol.source.Source); - expect(source).to.be.a(ol.source.Tile); + expect(source).to.be.a(_ol_source_Source_); + expect(source).to.be.a(_ol_source_Tile_); }); it('sets a custom cache size', function() { - var projection = ol.proj.get('EPSG:4326'); - var source = new ol.source.Tile({ + var projection = _ol_proj_.get('EPSG:4326'); + var source = new _ol_source_Tile_({ projection: projection, cacheSize: 42 }); @@ -74,7 +74,7 @@ describe('ol.source.Tile', function() { describe('#setKey()', function() { it('sets the source key', function() { - var source = new ol.source.Tile({}); + var source = new _ol_source_Tile_({}); expect(source.getKey()).to.equal(''); var key = 'foo'; @@ -85,7 +85,7 @@ describe('ol.source.Tile', function() { describe('#setKey()', function() { it('dispatches a change event', function(done) { - var source = new ol.source.Tile({}); + var source = new _ol_source_Tile_({}); var key = 'foo'; source.once('change', function() { @@ -95,7 +95,7 @@ describe('ol.source.Tile', function() { }); it('does not dispatch change if key does not change', function(done) { - var source = new ol.source.Tile({}); + var source = new _ol_source_Tile_({}); var key = 'foo'; source.once('change', function() { @@ -154,7 +154,7 @@ describe('ol.source.Tile', function() { }); var zoom = 1; - var range = new ol.TileRange(0, 1, 0, 1); + var range = new _ol_TileRange_(0, 1, 0, 1); source.forEachLoadedTile(source.getProjection(), zoom, range, callback); expect(callback.callCount).to.be(3); @@ -170,7 +170,7 @@ describe('ol.source.Tile', function() { }); var zoom = 1; - var range = new ol.TileRange(0, 1, 0, 1); + var range = new _ol_TileRange_(0, 1, 0, 1); var covered = source.forEachLoadedTile( source.getProjection(), zoom, range, @@ -190,7 +190,7 @@ describe('ol.source.Tile', function() { }); var zoom = 1; - var range = new ol.TileRange(0, 1, 0, 1); + var range = new _ol_TileRange_(0, 1, 0, 1); var covered = source.forEachLoadedTile( source.getProjection(), zoom, @@ -210,7 +210,7 @@ describe('ol.source.Tile', function() { }); var zoom = 1; - var range = new ol.TileRange(0, 1, 0, 1); + var range = new _ol_TileRange_(0, 1, 0, 1); var covered = source.forEachLoadedTile( source.getProjection(), zoom, range, @@ -225,7 +225,7 @@ describe('ol.source.Tile', function() { describe('#getTileCoordForTileUrlFunction()', function() { it('returns the expected tile coordinate - {wrapX: true}', function() { - var tileSource = new ol.source.Tile({ + var tileSource = new _ol_source_Tile_({ projection: 'EPSG:3857', wrapX: true }); @@ -241,7 +241,7 @@ describe('ol.source.Tile', function() { }); it('returns the expected tile coordinate - {wrapX: false}', function() { - var tileSource = new ol.source.Tile({ + var tileSource = new _ol_source_Tile_({ projection: 'EPSG:3857', wrapX: false }); @@ -257,8 +257,8 @@ describe('ol.source.Tile', function() { }); it('works with wrapX and custom projection without extent', function() { - var tileSource = new ol.source.Tile({ - projection: new ol.proj.Projection({ + var tileSource = new _ol_source_Tile_({ + projection: new _ol_proj_Projection_({ code: 'foo', global: true, units: 'm' @@ -279,7 +279,7 @@ describe('ol.source.Tile', function() { }); // check the loaded tile is there var tile = source.getTile(1, 0, 0); - expect(tile).to.be.a(ol.Tile); + expect(tile).to.be.a(_ol_Tile_); // check tile cache is filled expect(source.tileCache.getCount()).to.eql(1); // refresh the source @@ -297,7 +297,7 @@ describe('MockTile', function() { describe('constructor', function() { it('creates a tile source', function() { var source = new MockTile({}); - expect(source).to.be.a(ol.source.Tile); + expect(source).to.be.a(_ol_source_Tile_); expect(source).to.be.a(MockTile); }); }); @@ -312,17 +312,17 @@ describe('MockTile', function() { // check a loaded tile tile = source.getTile(0, 0, 0); - expect(tile).to.be.a(ol.Tile); + expect(tile).to.be.a(_ol_Tile_); expect(tile.state).to.be(2); // LOADED // check a tile that is not loaded tile = source.getTile(1, 0, -1); - expect(tile).to.be.a(ol.Tile); + expect(tile).to.be.a(_ol_Tile_); expect(tile.state).to.be(0); // IDLE // check another loaded tile tile = source.getTile(1, 0, 0); - expect(tile).to.be.a(ol.Tile); + expect(tile).to.be.a(_ol_Tile_); expect(tile.state).to.be(2); // LOADED }); diff --git a/test/spec/ol/source/tilearcgisrest.test.js b/test/spec/ol/source/tilearcgisrest.test.js index 8d67cee8ed..dc5d3aaeb5 100644 --- a/test/spec/ol/source/tilearcgisrest.test.js +++ b/test/spec/ol/source/tilearcgisrest.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.ImageTile'); -goog.require('ol.source.TileArcGISRest'); -goog.require('ol.proj'); +import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; +import _ol_source_TileArcGISRest_ from '../../../../src/ol/source/TileArcGISRest.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; describe('ol.source.TileArcGISRest', function() { @@ -18,9 +16,9 @@ describe('ol.source.TileArcGISRest', function() { describe('#getTile', function() { it('returns a tile with the expected URL', function() { - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.an(ol.ImageTile); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.an(_ol_ImageTile_); var uri = new URL(tile.src_); expect(uri.protocol).to.be('http:'); expect(uri.hostname).to.be('example.com'); @@ -40,8 +38,8 @@ describe('ol.source.TileArcGISRest', function() { }); it('returns a non floating point DPI value', function() { - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -7, 1.12, ol.proj.get('EPSG:3857')); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -7, 1.12, _ol_proj_.get('EPSG:3857')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('DPI')).to.be('101'); @@ -49,8 +47,8 @@ describe('ol.source.TileArcGISRest', function() { it('takes DPI from params if specified', function() { options.params.DPI = 96; - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -7, 1.12, ol.proj.get('EPSG:3857')); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -7, 1.12, _ol_proj_.get('EPSG:3857')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('DPI')).to.be('108'); @@ -60,10 +58,10 @@ describe('ol.source.TileArcGISRest', function() { it('returns a tile with the expected URL with url list', function() { options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer']; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.an(ol.ImageTile); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.an(_ol_ImageTile_); var uri = new URL(tile.src_); expect(uri.protocol).to.be('http:'); expect(uri.hostname).to.match(/test[12]\.com/); @@ -84,9 +82,9 @@ describe('ol.source.TileArcGISRest', function() { it('returns a tile with the expected URL for ImageServer', function() { options.url = 'http://example.com/ImageServer'; - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.an(ol.ImageTile); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.an(_ol_ImageTile_); var uri = new URL(tile.src_); expect(uri.protocol).to.be('http:'); expect(uri.hostname).to.be('example.com'); @@ -107,8 +105,8 @@ describe('ol.source.TileArcGISRest', function() { it('allows various parameters to be overridden', function() { options.params.FORMAT = 'png'; options.params.TRANSPARENT = false; - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('FORMAT')).to.be('png'); @@ -117,8 +115,8 @@ describe('ol.source.TileArcGISRest', function() { it('allows adding rest option', function() { options.params.LAYERS = 'show:1,3,4'; - var source = new ol.source.TileArcGISRest(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileArcGISRest_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('LAYERS')).to.be('show:1,3,4'); @@ -128,10 +126,10 @@ describe('ol.source.TileArcGISRest', function() { describe('#updateParams', function() { it('add a new param', function() { - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.updateParams({'TEST': 'value'}); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('TEST')).to.be('value'); @@ -140,10 +138,10 @@ describe('ol.source.TileArcGISRest', function() { it('updates an existing param', function() { options.params.TEST = 'value'; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.updateParams({'TEST': 'newValue'}); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('TEST')).to.be('newValue'); @@ -155,7 +153,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify getting a param', function() { options.params.TEST = 'value'; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); var setParams = source.getParams(); @@ -165,7 +163,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify on adding a param', function() { options.params.TEST = 'value'; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.updateParams({'TEST2': 'newValue'}); var setParams = source.getParams(); @@ -176,7 +174,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify on update a param', function() { options.params.TEST = 'value'; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.updateParams({'TEST': 'newValue'}); var setParams = source.getParams(); @@ -191,7 +189,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify getting array of urls', function() { options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer']; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); var urls = source.getUrls(); @@ -205,7 +203,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify setting urls when not set yet', function() { - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.setUrls(['http://test.com/MapServer', 'http://test2.com/MapServer']); var urls = source.getUrls(); @@ -216,7 +214,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify setting urls with existing list', function() { options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer']; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.setUrls(['http://test3.com/MapServer', 'http://test4.com/MapServer']); var urls = source.getUrls(); @@ -229,7 +227,7 @@ describe('ol.source.TileArcGISRest', function() { it('verify setting url with no urls', function() { - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.setUrl('http://test.com/MapServer'); var urls = source.getUrls(); @@ -240,14 +238,14 @@ describe('ol.source.TileArcGISRest', function() { it('verify setting url with list of urls', function() { options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer']; - var source = new ol.source.TileArcGISRest(options); + var source = new _ol_source_TileArcGISRest_(options); source.setUrl('http://test3.com/MapServer'); var urls = source.getUrls(); expect(urls).to.eql(['http://test3.com/MapServer']); - var tileUrl = source.tileUrlFunction([0, 0, 0], 1, ol.proj.get('EPSG:4326')); + var tileUrl = source.tileUrlFunction([0, 0, 0], 1, _ol_proj_.get('EPSG:4326')); expect(tileUrl.indexOf(urls[0])).to.be(0); }); diff --git a/test/spec/ol/source/tileimage.test.js b/test/spec/ol/source/tileimage.test.js index 9b9b98b185..a98f98b905 100644 --- a/test/spec/ol/source/tileimage.test.js +++ b/test/spec/ol/source/tileimage.test.js @@ -1,25 +1,25 @@ -goog.require('ol.ImageTile'); -goog.require('ol.TileState'); -goog.require('ol.TileUrlFunction'); -goog.require('ol.events'); -goog.require('ol.proj'); -goog.require('ol.proj.EPSG3857'); -goog.require('ol.proj.Projection'); -goog.require('ol.reproj.Tile'); -goog.require('ol.source.TileImage'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); +import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; +import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import _ol_TileUrlFunction_ from '../../../../src/ol/TileUrlFunction.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; +import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js'; +import _ol_tilecoord_ from '../../../../src/ol/tilecoord.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.source.TileImage', function() { function createSource(opt_proj, opt_tileGrid, opt_cacheSize) { var proj = opt_proj || 'EPSG:3857'; - return new ol.source.TileImage({ + return new _ol_source_TileImage_({ cacheSize: opt_cacheSize, projection: proj, tileGrid: opt_tileGrid || - ol.tilegrid.createForProjection(proj, undefined, [2, 2]), - tileUrlFunction: ol.TileUrlFunction.createFromTemplate( + _ol_tilegrid_.createForProjection(proj, undefined, [2, 2]), + tileUrlFunction: _ol_TileUrlFunction_.createFromTemplate( 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=') }); } @@ -27,7 +27,7 @@ describe('ol.source.TileImage', function() { describe('#getTileCacheForProjection', function() { it('uses the cacheSize for reprojected tile caches', function() { var source = createSource(undefined, undefined, 42); - var tileCache = source.getTileCacheForProjection(ol.proj.get('EPSG:4326')); + var tileCache = source.getTileCacheForProjection(_ol_proj_.get('EPSG:4326')); expect(tileCache.highWaterMark).to.be(42); expect(tileCache).to.not.equal(source.getTileCacheForProjection(source.getProjection())); }); @@ -36,9 +36,9 @@ describe('ol.source.TileImage', function() { describe('#setTileGridForProjection', function() { it('uses the tilegrid for given projection', function() { var source = createSource(); - var tileGrid = ol.tilegrid.createForProjection('EPSG:4326', 3, [10, 20]); + var tileGrid = _ol_tilegrid_.createForProjection('EPSG:4326', 3, [10, 20]); source.setTileGridForProjection('EPSG:4326', tileGrid); - var retrieved = source.getTileGridForProjection(ol.proj.get('EPSG:4326')); + var retrieved = source.getTileGridForProjection(_ol_proj_.get('EPSG:4326')); expect(retrieved).to.be(tileGrid); }); }); @@ -49,14 +49,14 @@ describe('ol.source.TileImage', function() { beforeEach(function() { source = createSource(); expect(source.getKey()).to.be(''); - source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857')); + source.getTileInternal(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); expect(source.tileCache.getCount()).to.be(1); - tile = source.tileCache.get(ol.tilecoord.getKeyZXY(0, 0, -1)); + tile = source.tileCache.get(_ol_tilecoord_.getKeyZXY(0, 0, -1)); }); it('gets the tile from the cache', function() { var returnedTile = source.getTileInternal( - 0, 0, -1, 1, ol.proj.get('EPSG:3857')); + 0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); expect(returnedTile).to.be(tile); }); @@ -68,7 +68,7 @@ describe('ol.source.TileImage', function() { return 'key0'; }; var returnedTile = source.getTileInternal( - 0, 0, -1, 1, ol.proj.get('EPSG:3857')); + 0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); expect(returnedTile).not.to.be(tile); expect(returnedTile.key).to.be('key0'); expect(returnedTile.interimTile).to.be(null); @@ -82,7 +82,7 @@ describe('ol.source.TileImage', function() { }; tile.state = 2; // LOADED var returnedTile = source.getTileInternal( - 0, 0, -1, 1, ol.proj.get('EPSG:3857')); + 0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); expect(returnedTile).not.to.be(tile); expect(returnedTile.key).to.be('key0'); expect(returnedTile.interimTile).to.be(tile); @@ -98,10 +98,10 @@ describe('ol.source.TileImage', function() { dynamicParamsKey = 'key0'; tile.state = 2; // LOADED returnedTile = source.getTileInternal( - 0, 0, -1, 1, ol.proj.get('EPSG:3857')); + 0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); dynamicParamsKey = 'key1'; returnedTile = source.getTileInternal( - 0, 0, -1, 1, ol.proj.get('EPSG:3857')); + 0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); expect(returnedTile).not.to.be(tile); expect(returnedTile.key).to.be('key1'); expect(returnedTile.interimTile).to.be(tile); @@ -115,18 +115,18 @@ describe('ol.source.TileImage', function() { describe('#getTile', function() { it('does not do reprojection for identity', function() { var source3857 = createSource('EPSG:3857'); - var tile3857 = source3857.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857')); - expect(tile3857).to.be.a(ol.ImageTile); - expect(tile3857).not.to.be.a(ol.reproj.Tile); + var tile3857 = source3857.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); + expect(tile3857).to.be.a(_ol_ImageTile_); + expect(tile3857).not.to.be.a(_ol_reproj_Tile_); - var projXXX = new ol.proj.Projection({ + var projXXX = new _ol_proj_Projection_({ code: 'XXX', units: 'degrees' }); var sourceXXX = createSource(projXXX); var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX); - expect(tileXXX).to.be.a(ol.ImageTile); - expect(tileXXX).not.to.be.a(ol.reproj.Tile); + expect(tileXXX).to.be.a(_ol_ImageTile_); + expect(tileXXX).not.to.be.a(_ol_reproj_Tile_); }); beforeEach(function() { @@ -138,14 +138,14 @@ describe('ol.source.TileImage', function() { }); it('can handle source projection without extent and units', function(done) { - var source = createSource('4326_noextentnounits', ol.tilegrid.createXYZ({ + var source = createSource('4326_noextentnounits', _ol_tilegrid_.createXYZ({ extent: [-180, -90, 180, 90], tileSize: [2, 2] })); - var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.a(ol.reproj.Tile); + var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.a(_ol_reproj_Tile_); - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED done(); } @@ -154,17 +154,17 @@ describe('ol.source.TileImage', function() { }); it('can handle target projection without extent and units', function(done) { - var proj = ol.proj.get('4326_noextentnounits'); + var proj = _ol_proj_.get('4326_noextentnounits'); var source = createSource(); source.setTileGridForProjection(proj, - ol.tilegrid.createXYZ({ - extent: ol.proj.EPSG3857.WORLD_EXTENT, + _ol_tilegrid_.createXYZ({ + extent: _ol_proj_EPSG3857_.WORLD_EXTENT, tileSize: [2, 2] })); var tile = source.getTile(0, 0, -1, 1, proj); - expect(tile).to.be.a(ol.reproj.Tile); + expect(tile).to.be.a(_ol_reproj_Tile_); - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED done(); } @@ -178,20 +178,20 @@ describe('ol.source.TileImage', function() { var source; beforeEach(function() { - source = new ol.source.TileImage({ + source = new _ol_source_TileImage_({ url: '{z}/{x}/{y}' }); }); it('dispatches tileloadstart and tileloadend events', function() { source.setTileLoadFunction(function(tile) { - tile.setState(ol.TileState.LOADED); + tile.setState(_ol_TileState_.LOADED); }); var startSpy = sinon.spy(); source.on('tileloadstart', startSpy); var endSpy = sinon.spy(); source.on('tileloadend', endSpy); - var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857')); + var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); tile.load(); expect(startSpy.callCount).to.be(1); expect(endSpy.callCount).to.be(1); @@ -200,15 +200,15 @@ describe('ol.source.TileImage', function() { it('works for loading-error-loading-loaded sequences', function(done) { source.setTileLoadFunction(function(tile) { tile.setState( - tile.state == ol.TileState.ERROR ? ol.TileState.LOADED : ol.TileState.ERROR); + tile.state == _ol_TileState_.ERROR ? _ol_TileState_.LOADED : _ol_TileState_.ERROR); }); var startSpy = sinon.spy(); source.on('tileloadstart', startSpy); var errorSpy = sinon.spy(); source.on('tileloaderror', function(e) { setTimeout(function() { - e.tile.setState(ol.TileState.LOADING); - e.tile.setState(ol.TileState.LOADED); + e.tile.setState(_ol_TileState_.LOADING); + e.tile.setState(_ol_TileState_.LOADED); }, 0); errorSpy(); }); @@ -217,7 +217,7 @@ describe('ol.source.TileImage', function() { expect(errorSpy.callCount).to.be(1); done(); }); - var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857')); + var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); tile.load(); }); @@ -227,7 +227,7 @@ describe('ol.source.TileImage', function() { source.on('tileloadstart', startSpy); var endSpy = sinon.spy(); source.on('tileloadend', endSpy); - var tile = source.getTile(0, 0, -1, 1, ol.proj.get('EPSG:3857')); + var tile = source.getTile(0, 0, -1, 1, _ol_proj_.get('EPSG:3857')); tile.load(); tile.dispose(); expect(startSpy.callCount).to.be(1); diff --git a/test/spec/ol/source/tilejson.test.js b/test/spec/ol/source/tilejson.test.js index 800aa780bb..879f7628b2 100644 --- a/test/spec/ol/source/tilejson.test.js +++ b/test/spec/ol/source/tilejson.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.source.Source'); -goog.require('ol.source.TileJSON'); -goog.require('ol.Observable'); +import _ol_source_Source_ from '../../../../src/ol/source/Source.js'; +import _ol_source_TileJSON_ from '../../../../src/ol/source/TileJSON.js'; +import _ol_Observable_ from '../../../../src/ol/Observable.js'; describe('ol.source.TileJSON', function() { @@ -10,18 +8,18 @@ describe('ol.source.TileJSON', function() { describe('constructor', function() { it('returns a tileJSON source', function() { - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ url: 'spec/ol/data/tilejson.json' }); - expect(source).to.be.a(ol.source.Source); - expect(source).to.be.a(ol.source.TileJSON); + expect(source).to.be.a(_ol_source_Source_); + expect(source).to.be.a(_ol_source_TileJSON_); }); }); describe('#getTileJSON', function() { it('parses the tilejson file', function() { - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ url: 'spec/ol/data/tilejson.json' }); source.on('change', function() { @@ -65,7 +63,7 @@ describe('ol.source.TileJSON', function() { version: '1.0.0', webpage: 'https://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html' }; - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ tileJSON: tileJSON }); expect(source.getState()).to.be('ready'); @@ -76,7 +74,7 @@ describe('ol.source.TileJSON', function() { describe('#getState', function() { it('returns error on HTTP 404', function() { - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ url: 'invalid.jsonp' }); source.on('change', function() { @@ -86,7 +84,7 @@ describe('ol.source.TileJSON', function() { }); it('returns error on CORS issues', function() { - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ url: 'http://example.com' }); source.on('change', function() { @@ -96,7 +94,7 @@ describe('ol.source.TileJSON', function() { }); it('returns error on JSON parsing issues', function() { - var source = new ol.source.TileJSON({ + var source = new _ol_source_TileJSON_({ url: '/' }); source.on('change', function() { @@ -112,12 +110,12 @@ describe('ol.source.TileJSON', function() { var source, tileGrid; beforeEach(function(done) { - source = new ol.source.TileJSON({ + source = new _ol_source_TileJSON_({ url: 'spec/ol/data/tilejson.json' }); var key = source.on('change', function() { if (source.getState() === 'ready') { - ol.Observable.unByKey(key); + _ol_Observable_.unByKey(key); tileGrid = source.getTileGrid(); done(); } diff --git a/test/spec/ol/source/tileutfgrid.test.js b/test/spec/ol/source/tileutfgrid.test.js index a9be33f74d..d99ac409c9 100644 --- a/test/spec/ol/source/tileutfgrid.test.js +++ b/test/spec/ol/source/tileutfgrid.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.proj'); -goog.require('ol.source.Tile'); -goog.require('ol.source.TileUTFGrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js'; +import _ol_source_TileUTFGrid_ from '../../../../src/ol/source/TileUTFGrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; describe('ol.source.TileUTFGrid', function() { @@ -30,7 +28,7 @@ describe('ol.source.TileUTFGrid', function() { }); function getTileUTFGrid() { - return new ol.source.TileUTFGrid({ + return new _ol_source_TileUTFGrid_({ url: url }); } @@ -39,28 +37,28 @@ describe('ol.source.TileUTFGrid', function() { it('needs to be constructed with url option', function() { - var source = new ol.source.TileUTFGrid({url: url}); - expect(source).to.be.an(ol.source.TileUTFGrid); - expect(source).to.be.an(ol.source.Tile); + var source = new _ol_source_TileUTFGrid_({url: url}); + expect(source).to.be.an(_ol_source_TileUTFGrid_); + expect(source).to.be.an(_ol_source_Tile_); expect(function() { // no options: will throw - return new ol.source.TileUTFGrid(); + return new _ol_source_TileUTFGrid_(); }).to.throwException(); expect(function() { // no url-option: will throw - return new ol.source.TileUTFGrid({}); + return new _ol_source_TileUTFGrid_({}); }).to.throwException(); - expect(getTileUTFGrid()).to.be.an(ol.source.TileUTFGrid); + expect(getTileUTFGrid()).to.be.an(_ol_source_TileUTFGrid_); }); }); describe('change event (ready)', function() { it('is fired when the source is ready', function(done) { - var source = new ol.source.TileUTFGrid({ + var source = new _ol_source_TileUTFGrid_({ url: url }); expect(source.getState()).to.be('loading'); @@ -68,7 +66,7 @@ describe('ol.source.TileUTFGrid', function() { source.on('change', function(event) { if (source.getState() === 'ready') { - expect(source.tileGrid).to.be.an(ol.tilegrid.TileGrid); + expect(source.tileGrid).to.be.an(_ol_tilegrid_TileGrid_); done(); } }); @@ -77,7 +75,7 @@ describe('ol.source.TileUTFGrid', function() { describe('change event (error)', function(done) { it('is fired when the source fails to initialize', function(done) { - var source = new ol.source.TileUTFGrid({ + var source = new _ol_source_TileUTFGrid_({ url: 'Bogus UTFGrid URL' }); expect(source.getState()).to.be('loading'); @@ -103,7 +101,7 @@ describe('ol.source.TileUTFGrid', function() { var tileGrid = source.getTileGrid(); expect(tileGrid).to.not.be(null); - expect(tileGrid).to.be.an(ol.tilegrid.TileGrid); + expect(tileGrid).to.be.an(_ol_tilegrid_TileGrid_); }); it('sets up a tilegrid with expected extent', function() { @@ -115,10 +113,10 @@ describe('ol.source.TileUTFGrid', function() { var tileGrid = source.getTileGrid(); var extent = tileGrid.getExtent(); - var proj4326 = ol.proj.get('EPSG:4326'); - var proj3857 = ol.proj.get('EPSG:3857'); + var proj4326 = _ol_proj_.get('EPSG:4326'); + var proj3857 = _ol_proj_.get('EPSG:3857'); var expectedExtent4326 = tileJson.bounds; - var expectedExtent3857 = ol.proj.transformExtent( + var expectedExtent3857 = _ol_proj_.transformExtent( expectedExtent4326, proj4326, proj3857 ); expect(extent).to.eql(proj3857.getExtent()); @@ -191,7 +189,7 @@ describe('ol.source.TileUTFGrid', function() { describe('#forDataAtCoordinateAndResolution', function() { var source = null; - var bonn3857 = ol.proj.fromLonLat([7.099814, 50.733992]); + var bonn3857 = _ol_proj_.fromLonLat([7.099814, 50.733992]); var noState3857 = [0, 0]; var resolutionZoom1 = 78271.51696402048; @@ -230,7 +228,7 @@ describe('ol.source.TileUTFGrid', function() { var urlTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection); var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection); - var tile = new ol.source.TileUTFGrid.Tile_( + var tile = new _ol_source_TileUTFGrid_.Tile_( tileCoord, tileUrl !== undefined ? 0 : 4, // IDLE : EMPTY tileUrl !== undefined ? tileUrl : '', diff --git a/test/spec/ol/source/tilewms.test.js b/test/spec/ol/source/tilewms.test.js index 885a0b6208..d265a3aca2 100644 --- a/test/spec/ol/source/tilewms.test.js +++ b/test/spec/ol/source/tilewms.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.ImageTile'); -goog.require('ol.proj'); -goog.require('ol.source.TileWMS'); -goog.require('ol.tilegrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_TileWMS_ from '../../../../src/ol/source/TileWMS.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; describe('ol.source.TileWMS', function() { @@ -28,20 +26,20 @@ describe('ol.source.TileWMS', function() { describe('constructor', function() { it('can be constructed without url or urls params', function() { - var source = new ol.source.TileWMS({ + var source = new _ol_source_TileWMS_({ projection: 'EPSG:3857', - tileGrid: ol.tilegrid.createXYZ({maxZoom: 6}) + tileGrid: _ol_tilegrid_.createXYZ({maxZoom: 6}) }); - expect(source).to.be.an(ol.source.TileWMS); + expect(source).to.be.an(_ol_source_TileWMS_); }); }); describe('#getTile', function() { it('returns a tile with the expected URL', function() { - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.an(ol.ImageTile); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.an(_ol_ImageTile_); var uri = new URL(tile.src_); expect(uri.protocol).to.be('http:'); expect(uri.hostname).to.be('example.com'); @@ -68,9 +66,9 @@ describe('ol.source.TileWMS', function() { it('returns a larger tile when a gutter is specified', function() { options.gutter = 16; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -7, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.an(ol.ImageTile); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -7, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.an(_ol_ImageTile_); var uri = new URL(tile.src_); var queryData = uri.searchParams; var bbox = queryData.get('BBOX').split(','); @@ -85,8 +83,8 @@ describe('ol.source.TileWMS', function() { it('sets the SRS query value instead of CRS if version < 1.3', function() { options.params.VERSION = '1.2'; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('CRS')).to.be(null); @@ -96,8 +94,8 @@ describe('ol.source.TileWMS', function() { it('allows various parameters to be overridden', function() { options.params.FORMAT = 'image/jpeg'; options.params.TRANSPARENT = false; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('FORMAT')).to.be('image/jpeg'); @@ -106,16 +104,16 @@ describe('ol.source.TileWMS', function() { it('does not add a STYLES= option if one is specified', function() { options.params.STYLES = 'foo'; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('STYLES')).to.be('foo'); }); it('changes the BBOX order for EN axis orientations', function() { - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('EPSG:4326')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('BBOX')).to.be('-45,-90,0,-45'); @@ -123,8 +121,8 @@ describe('ol.source.TileWMS', function() { it('uses EN BBOX order if version < 1.3', function() { options.params.VERSION = '1.1.0'; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1, ol.proj.get('CRS:84')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1, _ol_proj_.get('CRS:84')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('BBOX')).to.be('-90,-45,-45,0'); @@ -132,8 +130,8 @@ describe('ol.source.TileWMS', function() { it('sets FORMAT_OPTIONS when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 2, _ol_proj_.get('CRS:84')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:180'); @@ -141,9 +139,9 @@ describe('ol.source.TileWMS', function() { it('extends FORMAT_OPTIONS if it is already present', function() { options.serverType = 'geoserver'; - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); options.params.FORMAT_OPTIONS = 'param1:value1'; - var tile = source.getTile(3, 2, -3, 2, ol.proj.get('CRS:84')); + var tile = source.getTile(3, 2, -3, 2, _ol_proj_.get('CRS:84')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('FORMAT_OPTIONS')).to.be('param1:value1;dpi:180'); @@ -152,8 +150,8 @@ describe('ol.source.TileWMS', function() { it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer', function() { options.serverType = 'geoserver'; - var source = new ol.source.TileWMS(options); - var tile = source.getTile(3, 2, -3, 1.325, ol.proj.get('CRS:84')); + var source = new _ol_source_TileWMS_(options); + var tile = source.getTile(3, 2, -3, 1.325, _ol_proj_.get('CRS:84')); var uri = new URL(tile.src_); var queryData = uri.searchParams; expect(queryData.get('FORMAT_OPTIONS')).to.be('dpi:119'); @@ -165,9 +163,9 @@ describe('ol.source.TileWMS', function() { it('returns a tile if it is contained within layers extent', function() { options.extent = [-80, -40, -50, -10]; - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); var tileCoord = [3, 2, -3]; - var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326')); + var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(url); var queryData = uri.searchParams; expect(queryData.get('BBOX')).to.be('-45,-90,0,-45'); @@ -175,23 +173,23 @@ describe('ol.source.TileWMS', function() { it('returns a tile if it intersects layers extent', function() { options.extent = [-80, -40, -40, -10]; - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); var tileCoord = [3, 3, -3]; - var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326')); + var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(url); var queryData = uri.searchParams; expect(queryData.get('BBOX')).to.be('-45,-45,0,0'); }); it('works with non-square tiles', function() { - options.tileGrid = new ol.tilegrid.TileGrid({ + options.tileGrid = new _ol_tilegrid_TileGrid_({ tileSize: [640, 320], resolutions: [1.40625, 0.703125, 0.3515625, 0.17578125], origin: [-180, -90] }); - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); var tileCoord = [3, 3, -3]; - var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326')); + var url = source.tileUrlFunction(tileCoord, 1, _ol_proj_.get('EPSG:4326')); var uri = new URL(url); var queryData = uri.searchParams; expect(queryData.get('WIDTH')).to.be('640'); @@ -203,11 +201,11 @@ describe('ol.source.TileWMS', function() { describe('#getGetFeatureInfoUrl', function() { it('returns the expected GetFeatureInfo URL', function() { - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); source.pixelRatio_ = 1; var url = source.getGetFeatureInfoUrl( [-7000000, -12000000], - 19567.87924100512, ol.proj.get('EPSG:3857'), + 19567.87924100512, _ol_proj_.get('EPSG:3857'), {INFO_FORMAT: 'text/plain'}); var uri = new URL(url); expect(uri.protocol).to.be('http:'); @@ -237,11 +235,11 @@ describe('ol.source.TileWMS', function() { }); it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() { - var source = new ol.source.TileWMS(optionsReproj); + var source = new _ol_source_TileWMS_(optionsReproj); source.pixelRatio_ = 1; var url = source.getGetFeatureInfoUrl( [-7000000, -12000000], - 19567.87924100512, ol.proj.get('EPSG:3857'), + 19567.87924100512, _ol_proj_.get('EPSG:3857'), {INFO_FORMAT: 'text/plain'}); var uri = new URL(url); expect(uri.protocol).to.be('http:'); @@ -267,11 +265,11 @@ describe('ol.source.TileWMS', function() { }); it('sets the QUERY_LAYERS param as expected', function() { - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); source.pixelRatio_ = 1; var url = source.getGetFeatureInfoUrl( [-7000000, -12000000], - 19567.87924100512, ol.proj.get('EPSG:3857'), + 19567.87924100512, _ol_proj_.get('EPSG:3857'), {INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'}); var uri = new URL(url); expect(uri.protocol).to.be('http:'); @@ -303,17 +301,17 @@ describe('ol.source.TileWMS', function() { describe('#setUrl()', function() { it('sets the correct url', function() { - var source = new ol.source.TileWMS(options); + var source = new _ol_source_TileWMS_(options); var url = 'http://foo/'; source.setUrl(url); - var tileUrl = source.tileUrlFunction([0, 0, 0], 1, ol.proj.get('EPSG:4326')); + var tileUrl = source.tileUrlFunction([0, 0, 0], 1, _ol_proj_.get('EPSG:4326')); expect(tileUrl.indexOf(url)).to.be(0); }); }); describe('#setUrls()', function() { it ('updates the source key', function() { - var source = new ol.source.TileWMS({ + var source = new _ol_source_TileWMS_({ urls: ['u1', 'u2'] }); var originalKey = source.getKey(); diff --git a/test/spec/ol/source/urltile.test.js b/test/spec/ol/source/urltile.test.js index ba70e78a61..3cefd41432 100644 --- a/test/spec/ol/source/urltile.test.js +++ b/test/spec/ol/source/urltile.test.js @@ -1,15 +1,13 @@ - - -goog.require('ol.proj'); -goog.require('ol.source.UrlTile'); -goog.require('ol.tilegrid'); +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_UrlTile_ from '../../../../src/ol/source/UrlTile.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.source.UrlTile', function() { describe('#setUrl()', function() { it('sets the URL for the source', function() { - var source = new ol.source.UrlTile({}); + var source = new _ol_source_UrlTile_({}); var url = 'https://example.com/'; source.setUrl(url); @@ -18,7 +16,7 @@ describe('ol.source.UrlTile', function() { }); it('updates the key for the source', function() { - var source = new ol.source.UrlTile({}); + var source = new _ol_source_UrlTile_({}); var url = 'https://example.com/'; source.setUrl(url); @@ -29,7 +27,7 @@ describe('ol.source.UrlTile', function() { describe('#setUrls()', function() { it('sets the URL for the source', function() { - var source = new ol.source.UrlTile({}); + var source = new _ol_source_UrlTile_({}); var urls = [ 'https://a.example.com/', @@ -42,7 +40,7 @@ describe('ol.source.UrlTile', function() { }); it('updates the key for the source', function() { - var source = new ol.source.UrlTile({}); + var source = new _ol_source_UrlTile_({}); var urls = [ 'https://a.example.com/', @@ -57,7 +55,7 @@ describe('ol.source.UrlTile', function() { describe('url option', function() { it('expands url template', function() { - var tileSource = new ol.source.UrlTile({ + var tileSource = new _ol_source_UrlTile_({ url: '{1-3}' }); @@ -71,9 +69,9 @@ describe('ol.source.UrlTile', function() { var tileSource, tileGrid; beforeEach(function() { - tileSource = new ol.source.UrlTile({ + tileSource = new _ol_source_UrlTile_({ projection: 'EPSG:3857', - tileGrid: ol.tilegrid.createXYZ({maxZoom: 6}), + tileGrid: _ol_tilegrid_.createXYZ({maxZoom: 6}), url: '{z}/{x}/{y}', wrapX: true }); @@ -169,8 +167,8 @@ describe('ol.source.UrlTile', function() { beforeEach(function() { sourceOptions = { - tileGrid: ol.tilegrid.createXYZ({ - extent: ol.proj.get('EPSG:4326').getExtent() + tileGrid: _ol_tilegrid_.createXYZ({ + extent: _ol_proj_.get('EPSG:4326').getExtent() }) }; }); @@ -178,7 +176,7 @@ describe('ol.source.UrlTile', function() { describe('using a "url" option', function() { beforeEach(function() { sourceOptions.url = url; - source = new ol.source.UrlTile(sourceOptions); + source = new _ol_source_UrlTile_(sourceOptions); }); it('returns the XYZ URL', function() { @@ -191,7 +189,7 @@ describe('ol.source.UrlTile', function() { describe('using a "urls" option', function() { beforeEach(function() { sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2']; - source = new ol.source.UrlTile(sourceOptions); + source = new _ol_source_UrlTile_(sourceOptions); }); it('returns the XYZ URLs', function() { @@ -206,7 +204,7 @@ describe('ol.source.UrlTile', function() { sourceOptions.tileUrlFunction = function() { return 'some_xyz_url'; }; - source = new ol.source.UrlTile(sourceOptions); + source = new _ol_source_UrlTile_(sourceOptions); }); it('returns null', function() { diff --git a/test/spec/ol/source/vector.test.js b/test/spec/ol/source/vector.test.js index cfbc631608..bb1560dd2a 100644 --- a/test/spec/ol/source/vector.test.js +++ b/test/spec/ol/source/vector.test.js @@ -1,14 +1,14 @@ -goog.require('ol.events'); -goog.require('ol.Collection'); -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.LineString'); -goog.require('ol.layer.Vector'); -goog.require('ol.loadingstrategy'); -goog.require('ol.proj'); -goog.require('ol.source.Vector'); +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_Collection_ from '../../../../src/ol/Collection.js'; +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; +import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js'; +import _ol_loadingstrategy_ from '../../../../src/ol/loadingstrategy.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js'; describe('ol.source.Vector', function() { @@ -16,7 +16,7 @@ describe('ol.source.Vector', function() { var pointFeature; var infiniteExtent; beforeEach(function() { - pointFeature = new ol.Feature(new ol.geom.Point([0, 0])); + pointFeature = new _ol_Feature_(new _ol_geom_Point_([0, 0])); infiniteExtent = [-Infinity, -Infinity, Infinity, Infinity]; }); @@ -24,7 +24,7 @@ describe('ol.source.Vector', function() { var vectorSource; beforeEach(function() { - vectorSource = new ol.source.Vector(); + vectorSource = new _ol_source_Vector_(); }); describe('#forEachFeatureInExtent', function() { @@ -67,16 +67,16 @@ describe('ol.source.Vector', function() { it('fires a change event', function() { var listener = sinon.spy(); - ol.events.listen(vectorSource, 'change', listener); + _ol_events_.listen(vectorSource, 'change', listener); vectorSource.addFeature(pointFeature); expect(listener).to.be.called(); }); it('adds same id features only once', function() { - var source = new ol.source.Vector(); - var feature1 = new ol.Feature(); + var source = new _ol_source_Vector_(); + var feature1 = new _ol_Feature_(); feature1.setId('1'); - var feature2 = new ol.Feature(); + var feature2 = new _ol_Feature_(); feature2.setId('1'); source.addFeature(feature1); source.addFeature(feature2); @@ -92,10 +92,10 @@ describe('ol.source.Vector', function() { var features = []; var vectorSource; beforeEach(function() { - features.push(new ol.Feature(new ol.geom.LineString([[0, 0], [10, 10]]))); - features.push(new ol.Feature(new ol.geom.Point([0, 10]))); - features.push(new ol.Feature(new ol.geom.Point([10, 5]))); - vectorSource = new ol.source.Vector({ + features.push(new _ol_Feature_(new _ol_geom_LineString_([[0, 0], [10, 10]]))); + features.push(new _ol_Feature_(new _ol_geom_Point_([0, 10]))); + features.push(new _ol_Feature_(new _ol_geom_Point_([10, 5]))); + vectorSource = new _ol_source_Vector_({ features: features }); }); @@ -127,10 +127,10 @@ describe('ol.source.Vector', function() { var i; for (i = 0; i < 10; ++i) { features[i] = - new ol.Feature(new ol.geom.Point([Math.random(), Math.random()])); + new _ol_Feature_(new _ol_geom_Point_([Math.random(), Math.random()])); } - features.push(new ol.Feature(null)); - vectorSource = new ol.source.Vector({ + features.push(new _ol_Feature_(null)); + vectorSource = new _ol_source_Vector_({ features: features }); }); @@ -139,11 +139,11 @@ describe('ol.source.Vector', function() { it('removes all features using fast path', function() { var changeSpy = sinon.spy(); - ol.events.listen(vectorSource, 'change', changeSpy); + _ol_events_.listen(vectorSource, 'change', changeSpy); var removeFeatureSpy = sinon.spy(); - ol.events.listen(vectorSource, 'removefeature', removeFeatureSpy); + _ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy); var clearSourceSpy = sinon.spy(); - ol.events.listen(vectorSource, 'clear', clearSourceSpy); + _ol_events_.listen(vectorSource, 'clear', clearSourceSpy); vectorSource.clear(true); expect(vectorSource.getFeatures()).to.eql([]); expect(vectorSource.isEmpty()).to.be(true); @@ -157,11 +157,11 @@ describe('ol.source.Vector', function() { it('removes all features using slow path', function() { var changeSpy = sinon.spy(); - ol.events.listen(vectorSource, 'change', changeSpy); + _ol_events_.listen(vectorSource, 'change', changeSpy); var removeFeatureSpy = sinon.spy(); - ol.events.listen(vectorSource, 'removefeature', removeFeatureSpy); + _ol_events_.listen(vectorSource, 'removefeature', removeFeatureSpy); var clearSourceSpy = sinon.spy(); - ol.events.listen(vectorSource, 'clear', clearSourceSpy); + _ol_events_.listen(vectorSource, 'clear', clearSourceSpy); vectorSource.clear(); expect(vectorSource.getFeatures()).to.eql([]); expect(vectorSource.isEmpty()).to.be(true); @@ -225,7 +225,7 @@ describe('ol.source.Vector', function() { it('fires a change event', function() { var listener = sinon.spy(); - ol.events.listen(vectorSource, 'change', listener); + _ol_events_.listen(vectorSource, 'change', listener); vectorSource.removeFeature(features[0]); expect(listener).to.be.called(); }); @@ -252,7 +252,7 @@ describe('ol.source.Vector', function() { it('keeps the R-Tree index up to date', function() { expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])). to.have.length(10); - features[0].setGeometry(new ol.geom.Point([100, 100])); + features[0].setGeometry(new _ol_geom_Point_([100, 100])); expect(vectorSource.getFeaturesInExtent([0, 0, 1, 1])). to.have.length(9); }); @@ -265,11 +265,11 @@ describe('ol.source.Vector', function() { var vectorSource; beforeEach(function() { - vectorSource = new ol.source.Vector(); + vectorSource = new _ol_source_Vector_(); }); it('keeps its index up-to-date', function() { - var feature = new ol.Feature(new ol.geom.Point([1, 1])); + var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1])); vectorSource.addFeature(feature); expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])). to.eql([feature]); @@ -281,23 +281,23 @@ describe('ol.source.Vector', function() { }); it('handles features with null geometries', function() { - var feature = new ol.Feature(null); + var feature = new _ol_Feature_(null); vectorSource.addFeature(feature); expect(vectorSource.getFeatures()).to.eql([feature]); }); it('handles features with geometries changing from null', function() { - var feature = new ol.Feature(null); + var feature = new _ol_Feature_(null); vectorSource.addFeature(feature); expect(vectorSource.getFeatures()).to.eql([feature]); - feature.setGeometry(new ol.geom.Point([1, 1])); + feature.setGeometry(new _ol_geom_Point_([1, 1])); expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])). to.eql([feature]); expect(vectorSource.getFeatures()).to.eql([feature]); }); it('handles features with geometries changing to null', function() { - var feature = new ol.Feature(new ol.geom.Point([1, 1])); + var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1])); vectorSource.addFeature(feature); expect(vectorSource.getFeatures()).to.eql([feature]); expect(vectorSource.getFeaturesInExtent([0, 0, 2, 2])). @@ -308,16 +308,16 @@ describe('ol.source.Vector', function() { }); it('fires a change event when setting a feature\'s property', function() { - var feature = new ol.Feature(new ol.geom.Point([1, 1])); + var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1])); vectorSource.addFeature(feature); var listener = sinon.spy(); - ol.events.listen(vectorSource, 'change', listener); + _ol_events_.listen(vectorSource, 'change', listener); feature.set('foo', 'bar'); expect(listener).to.be.called(); }); it('fires a changefeature event when updating a feature', function() { - var feature = new ol.Feature(new ol.geom.Point([1, 1])); + var feature = new _ol_Feature_(new _ol_geom_Point_([1, 1])); vectorSource.addFeature(feature); var listener = sinon.spy(function(event) { expect(event.feature).to.be(feature); @@ -332,18 +332,18 @@ describe('ol.source.Vector', function() { describe('#getFeatureById()', function() { var source; beforeEach(function() { - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('returns a feature by id', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(feature); }); it('returns a feature by id (set after add)', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(null); feature.setId('foo'); @@ -351,14 +351,14 @@ describe('ol.source.Vector', function() { }); it('returns null when no feature is found', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('bar')).to.be(null); }); it('returns null after removing feature', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(feature); @@ -367,7 +367,7 @@ describe('ol.source.Vector', function() { }); it('returns null after unsetting id', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(feature); @@ -376,7 +376,7 @@ describe('ol.source.Vector', function() { }); it('returns null after clear', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(feature); @@ -386,19 +386,19 @@ describe('ol.source.Vector', function() { it('returns null when no features are indexed', function() { expect(source.getFeatureById('foo')).to.be(null); - source.addFeature(new ol.Feature()); + source.addFeature(new _ol_Feature_()); expect(source.getFeatureById('foo')).to.be(null); }); it('returns correct feature after add/remove/add', function() { expect(source.getFeatureById('foo')).to.be(null); - var first = new ol.Feature(); + var first = new _ol_Feature_(); first.setId('foo'); source.addFeature(first); expect(source.getFeatureById('foo')).to.be(first); source.removeFeature(first); expect(source.getFeatureById('foo')).to.be(null); - var second = new ol.Feature(); + var second = new _ol_Feature_(); second.setId('foo'); source.addFeature(second); expect(source.getFeatureById('foo')).to.be(second); @@ -406,7 +406,7 @@ describe('ol.source.Vector', function() { it('returns correct feature after add/change', function() { expect(source.getFeatureById('foo')).to.be(null); - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); expect(source.getFeatureById('foo')).to.be(feature); @@ -424,11 +424,11 @@ describe('ol.source.Vector', function() { it('requests the view extent plus render buffer', function(done) { var center = [-97.6114, 38.8403]; - var source = new ol.source.Vector({ - strategy: ol.loadingstrategy.bbox, + var source = new _ol_source_Vector_({ + strategy: _ol_loadingstrategy_.bbox, loader: function(extent) { setTimeout(function() { - var lonLatExtent = ol.proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326'); + var lonLatExtent = _ol_proj_.transformExtent(extent, 'EPSG:3857', 'EPSG:4326'); expect(lonLatExtent[0]).to.roughlyEqual(-99.261474609, 1e-9); expect(lonLatExtent[2]).to.roughlyEqual(-95.965576171, 1e-9); done(); @@ -438,15 +438,15 @@ describe('ol.source.Vector', function() { var div = document.createElement('div'); div.style.width = div.style.height = '100px'; document.body.appendChild(div); - var map = new ol.Map({ + var map = new _ol_Map_({ target: div, layers: [ - new ol.layer.Vector({ + new _ol_layer_Vector_({ source: source }) ], - view: new ol.View({ - center: ol.proj.fromLonLat(center), + view: new _ol_View_({ + center: _ol_proj_.fromLonLat(center), zoom: 7 }) }); @@ -460,9 +460,9 @@ describe('ol.source.Vector', function() { describe('with no loader and the "all" strategy', function() { it('stores the infinity extent in the Rtree', function() { - var source = new ol.source.Vector(); + var source = new _ol_source_Vector_(); source.loadFeatures([-10000, -10000, 10000, 10000], 1, - ol.proj.get('EPSG:3857')); + _ol_proj_.get('EPSG:3857')); var loadedExtents = source.loadedExtentsRtree_.getAll(); expect(loadedExtents).to.have.length(1); expect(loadedExtents[0].extent).to.eql( @@ -481,19 +481,19 @@ describe('ol.source.Vector', function() { var loader2 = function(bbox, resolution, projection) { count2++; }; - var source = new ol.source.Vector({loader: loader1}); + var source = new _ol_source_Vector_({loader: loader1}); source.loadFeatures([-10000, -10000, 10000, 10000], 1, - ol.proj.get('EPSG:3857')); + _ol_proj_.get('EPSG:3857')); source.setLoader(loader2); source.clear(); source.loadFeatures([-10000, -10000, 10000, 10000], 1, - ol.proj.get('EPSG:3857')); + _ol_proj_.get('EPSG:3857')); expect(count1).to.eql(1); expect(count2).to.eql(1); }); it('removes extents with #removeLoadedExtent()', function(done) { - var source = new ol.source.Vector(); + var source = new _ol_source_Vector_(); source.setLoader(function(bbox, resolution, projection) { setTimeout(function() { expect(source.loadedExtentsRtree_.getAll()).to.have.length(1); @@ -502,7 +502,7 @@ describe('ol.source.Vector', function() { done(); }, 0); }); - source.loadFeatures([-10000, -10000, 10000, 10000], 1, ol.proj.get('EPSG:3857')); + source.loadFeatures([-10000, -10000, 10000, 10000], 1, _ol_proj_.get('EPSG:3857')); }); }); @@ -511,14 +511,14 @@ describe('ol.source.Vector', function() { describe('the feature id index', function() { var source; beforeEach(function() { - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('ignores features with the same id', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); feature.setId('foo'); source.addFeature(feature); - var dupe = new ol.Feature(); + var dupe = new _ol_Feature_(); dupe.setId('foo'); source.addFeature(dupe); expect(source.getFeatures()).to.have.length(1); @@ -526,10 +526,10 @@ describe('ol.source.Vector', function() { }); it('allows changing feature and set the same id', function() { - var foo = new ol.Feature(); + var foo = new _ol_Feature_(); foo.setId('foo'); source.addFeature(foo); - var bar = new ol.Feature(); + var bar = new _ol_Feature_(); bar.setId('bar'); source.addFeature(bar); bar.setId('foo'); @@ -541,11 +541,11 @@ describe('ol.source.Vector', function() { describe('the undefined feature id index', function() { var source; beforeEach(function() { - source = new ol.source.Vector(); + source = new _ol_source_Vector_(); }); it('disallows adding the same feature twice', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeature(feature); expect(function() { source.addFeature(feature); @@ -556,15 +556,15 @@ describe('ol.source.Vector', function() { describe('with useSpatialIndex set to false', function() { var source; beforeEach(function() { - source = new ol.source.Vector({useSpatialIndex: false}); + source = new _ol_source_Vector_({useSpatialIndex: false}); }); it('returns a features collection', function() { - expect(source.getFeaturesCollection()).to.be.a(ol.Collection); + expect(source.getFeaturesCollection()).to.be.a(_ol_Collection_); }); it('#forEachFeatureInExtent loops through all features', function() { - source.addFeatures([new ol.Feature(), new ol.Feature()]); + source.addFeatures([new _ol_Feature_(), new _ol_Feature_()]); var spy = sinon.spy(); source.forEachFeatureInExtent([0, 0, 0, 0], spy); expect(spy.callCount).to.be(2); @@ -575,7 +575,7 @@ describe('ol.source.Vector', function() { describe('with a collection of features', function() { var collection, source; beforeEach(function() { - source = new ol.source.Vector({ + source = new _ol_source_Vector_({ useSpatialIndex: false }); collection = source.getFeaturesCollection(); @@ -586,7 +586,7 @@ describe('ol.source.Vector', function() { }); it('adding/removing features keeps the collection in sync', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeature(feature); expect(collection.getLength()).to.be(1); source.removeFeature(feature); @@ -594,7 +594,7 @@ describe('ol.source.Vector', function() { }); it('#clear() features keeps the collection in sync', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeatures([feature]); expect(collection.getLength()).to.be(1); source.clear(); @@ -606,7 +606,7 @@ describe('ol.source.Vector', function() { }); it('keeps the source\'s features in sync with the collection', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); collection.push(feature); expect(source.getFeatures().length).to.be(1); collection.remove(feature); @@ -622,8 +622,8 @@ describe('ol.source.Vector', function() { describe('with a collection of features plus spatial index', function() { var collection, source; beforeEach(function() { - collection = new ol.Collection(); - source = new ol.source.Vector({ + collection = new _ol_Collection_(); + source = new _ol_source_Vector_({ features: collection }); }); @@ -633,7 +633,7 @@ describe('ol.source.Vector', function() { }); it('adding/removing features keeps the collection in sync', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeature(feature); expect(collection.getLength()).to.be(1); source.removeFeature(feature); @@ -641,7 +641,7 @@ describe('ol.source.Vector', function() { }); it('#clear() features keeps the collection in sync', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); source.addFeatures([feature]); expect(collection.getLength()).to.be(1); source.clear(); @@ -653,7 +653,7 @@ describe('ol.source.Vector', function() { }); it('keeps the source\'s features in sync with the collection', function() { - var feature = new ol.Feature(); + var feature = new _ol_Feature_(); collection.push(feature); expect(source.getFeatures().length).to.be(1); collection.remove(feature); diff --git a/test/spec/ol/source/vectortile.test.js b/test/spec/ol/source/vectortile.test.js index 8106d85b08..9127bb726b 100644 --- a/test/spec/ol/source/vectortile.test.js +++ b/test/spec/ol/source/vectortile.test.js @@ -1,18 +1,18 @@ -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.VectorImageTile'); -goog.require('ol.VectorTile'); -goog.require('ol.format.MVT'); -goog.require('ol.layer.VectorTile'); -goog.require('ol.proj'); -goog.require('ol.source.VectorTile'); -goog.require('ol.tilegrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_Map_ from '../../../../src/ol/Map.js'; +import _ol_View_ from '../../../../src/ol/View.js'; +import _ol_VectorImageTile_ from '../../../../src/ol/VectorImageTile.js'; +import _ol_VectorTile_ from '../../../../src/ol/VectorTile.js'; +import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js'; +import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; describe('ol.source.VectorTile', function() { - var format = new ol.format.MVT(); - var source = new ol.source.VectorTile({ + var format = new _ol_format_MVT_(); + var source = new _ol_source_VectorTile_({ format: format, tilePixelRatio: 8, url: 'spec/ol/data/{z}-{x}-{y}.vector.pbf' @@ -25,11 +25,11 @@ describe('ol.source.VectorTile', function() { }); it('uses ol.VectorTile as default tileClass', function() { - expect(source.tileClass).to.equal(ol.VectorTile); + expect(source.tileClass).to.equal(_ol_VectorTile_); }); it('creates a 512 XYZ tilegrid by default', function() { - var tileGrid = ol.tilegrid.createXYZ({tileSize: 512}); + var tileGrid = _ol_tilegrid_.createXYZ({tileSize: 512}); expect(source.tileGrid.tileSize_).to.equal(tileGrid.tileSize_); expect(source.tileGrid.extent_).to.equal(tileGrid.extent_); }); @@ -37,35 +37,35 @@ describe('ol.source.VectorTile', function() { describe('#getTile()', function() { it('creates a tile with the correct tile class', function() { - tile = source.getTile(0, 0, 0, 1, ol.proj.get('EPSG:3857')); - expect(tile).to.be.a(ol.VectorImageTile); + tile = source.getTile(0, 0, 0, 1, _ol_proj_.get('EPSG:3857')); + expect(tile).to.be.a(_ol_VectorImageTile_); }); it('sets the correct tileCoord on the created tile', function() { expect(tile.getTileCoord()).to.eql([0, 0, 0]); }); it('fetches tile from cache when requested again', function() { - expect(source.getTile(0, 0, 0, 1, ol.proj.get('EPSG:3857'))) + expect(source.getTile(0, 0, 0, 1, _ol_proj_.get('EPSG:3857'))) .to.equal(tile); }); }); describe('#getTileGridForProjection', function() { it('creates a tile grid with the source tile grid\'s tile size', function() { - var tileGrid = source.getTileGridForProjection(ol.proj.get('EPSG:3857')); + var tileGrid = source.getTileGridForProjection(_ol_proj_.get('EPSG:3857')); expect(tileGrid.getTileSize(0)).to.be(512); }); }); describe('Tile load events', function() { it('triggers tileloadstart and tileloadend with ol.VectorTile', function(done) { - tile = source.getTile(14, 8938, -5681, 1, ol.proj.get('EPSG:3857')); + tile = source.getTile(14, 8938, -5681, 1, _ol_proj_.get('EPSG:3857')); var started = false; source.on('tileloadstart', function() { started = true; }); source.on('tileloadend', function(e) { expect(started).to.be(true); - expect(e.tile).to.be.a(ol.VectorTile); + expect(e.tile).to.be.a(_ol_VectorTile_); expect(e.tile.getFeatures().length).to.be(1327); done(); }); @@ -96,8 +96,8 @@ describe('ol.source.VectorTile', function() { var extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755]; - source = new ol.source.VectorTile({ - tileGrid: new ol.tilegrid.TileGrid({ + source = new _ol_source_VectorTile_({ + tileGrid: new _ol_tilegrid_TileGrid_({ origin: [218128, 6126002], resolutions: [4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5] }), @@ -109,15 +109,15 @@ describe('ol.source.VectorTile', function() { target.style.width = target.style.height = '100px'; document.body.appendChild(target); - map = new ol.Map({ + map = new _ol_Map_({ layers: [ - new ol.layer.VectorTile({ + new _ol_layer_VectorTile_({ extent: extent, source: source }) ], target: target, - view: new ol.View({ + view: new _ol_View_({ zoom: 11, center: [666373.1624999996, 7034265.3572] }) diff --git a/test/spec/ol/source/wmts.test.js b/test/spec/ol/source/wmts.test.js index a6c2d8dbb5..c7d11977b8 100644 --- a/test/spec/ol/source/wmts.test.js +++ b/test/spec/ol/source/wmts.test.js @@ -1,16 +1,14 @@ - - -goog.require('ol.format.WMTSCapabilities'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); -goog.require('ol.tilegrid.WMTS'); -goog.require('ol.source.WMTS'); +import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabilities.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_tilegrid_WMTS_ from '../../../../src/ol/tilegrid/WMTS.js'; +import _ol_source_WMTS_ from '../../../../src/ol/source/WMTS.js'; describe('ol.source.WMTS', function() { describe('when creating options from capabilities', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities, content; before(function(done) { afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) { @@ -25,7 +23,7 @@ describe('ol.source.WMTS', function() { }); it('returns null if the layer was not found in the capabilities', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'invalid' }); @@ -33,7 +31,7 @@ describe('ol.source.WMTS', function() { }); it('passes the crossOrigin option', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857', crossOrigin: '' @@ -44,7 +42,7 @@ describe('ol.source.WMTS', function() { it('can create KVP options from spec/ol/format/wmts/ogcsample.xml', function() { - var options = ol.source.WMTS.optionsFromCapabilities( + var options = _ol_source_WMTS_.optionsFromCapabilities( capabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); @@ -59,12 +57,12 @@ describe('ol.source.WMTS', function() { expect(options.format).to.be.eql('image/jpeg'); - expect(options.projection).to.be.a(ol.proj.Projection); - expect(options.projection).to.be.eql(ol.proj.get('EPSG:3857')); + expect(options.projection).to.be.a(_ol_proj_Projection_); + expect(options.projection).to.be.eql(_ol_proj_.get('EPSG:3857')); expect(options.requestEncoding).to.be.eql('KVP'); - expect(options.tileGrid).to.be.a(ol.tilegrid.WMTS); + expect(options.tileGrid).to.be.a(_ol_tilegrid_WMTS_); expect(options.style).to.be.eql('DarkBlue'); @@ -76,7 +74,7 @@ describe('ol.source.WMTS', function() { it('can create REST options from spec/ol/format/wmts/ogcsample.xml', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857', requestEncoding: 'REST' @@ -93,12 +91,12 @@ describe('ol.source.WMTS', function() { expect(options.format).to.be.eql('image/png'); - expect(options.projection).to.be.a(ol.proj.Projection); - expect(options.projection).to.be.eql(ol.proj.get('EPSG:3857')); + expect(options.projection).to.be.a(_ol_proj_Projection_); + expect(options.projection).to.be.eql(_ol_proj_.get('EPSG:3857')); expect(options.requestEncoding).to.be.eql('REST'); - expect(options.tileGrid).to.be.a(ol.tilegrid.WMTS); + expect(options.tileGrid).to.be.a(_ol_tilegrid_WMTS_); expect(options.style).to.be.eql('DarkBlue'); @@ -107,7 +105,7 @@ describe('ol.source.WMTS', function() { }); it('can find a MatrixSet by SRS identifier', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', projection: 'EPSG:3857', requestEncoding: 'REST' @@ -118,7 +116,7 @@ describe('ol.source.WMTS', function() { }); it('can find a MatrixSet by equivalent SRS identifier', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', projection: 'EPSG:900913', requestEncoding: 'REST' @@ -129,7 +127,7 @@ describe('ol.source.WMTS', function() { }); it('can find the default MatrixSet', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', requestEncoding: 'REST' }); @@ -139,9 +137,9 @@ describe('ol.source.WMTS', function() { }); it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() { - var options = ol.source.WMTS.optionsFromCapabilities(capabilities, { + var options = _ol_source_WMTS_.optionsFromCapabilities(capabilities, { layer: 'BlueMarbleNextGeneration', - projection: new ol.proj.Projection({ + projection: new _ol_proj_Projection_({ code: 'EPSG:2056', units: 'm' }) @@ -155,7 +153,7 @@ describe('ol.source.WMTS', function() { var tmpXml = content.replace(//g, ''); var tmpCapabilities = parser.read(tmpXml); expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined); - var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities, + var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); expect(options.layer).to.be.eql('BlueMarbleNextGeneration'); expect(options.matrixSet).to.be.eql('google3857'); @@ -168,7 +166,7 @@ describe('ol.source.WMTS', function() { var tmpCapabilities = parser.read(tmpXml); expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined); expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined); - var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities, + var options = _ol_source_WMTS_.optionsFromCapabilities(tmpCapabilities, {layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'}); expect(options.layer).to.be.eql('BlueMarbleNextGeneration'); expect(options.matrixSet).to.be.eql('google3857'); @@ -182,14 +180,14 @@ describe('ol.source.WMTS', function() { it('can replace lowercase REST parameters', function() { - var source = new ol.source.WMTS({ + var source = new _ol_source_WMTS_({ layer: 'layer', style: 'default', urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' + '{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'], matrixSet: 'EPSG:3857', requestEncoding: 'REST', - tileGrid: new ol.tilegrid.WMTS({ + tileGrid: new _ol_tilegrid_WMTS_({ origin: [-20037508.342789244, 20037508.342789244], resolutions: [559082264.029 * 0.28E-3, 279541132.015 * 0.28E-3, @@ -198,7 +196,7 @@ describe('ol.source.WMTS', function() { }) }); - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); var url = source.tileUrlFunction( source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection); expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' + @@ -208,14 +206,14 @@ describe('ol.source.WMTS', function() { it('can replace camelcase REST parameters', function() { - var source = new ol.source.WMTS({ + var source = new _ol_source_WMTS_({ layer: 'layer', style: 'default', urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' + '{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'], matrixSet: 'EPSG:3857', requestEncoding: 'REST', - tileGrid: new ol.tilegrid.WMTS({ + tileGrid: new _ol_tilegrid_WMTS_({ origin: [-20037508.342789244, 20037508.342789244], resolutions: [559082264.029 * 0.28E-3, 279541132.015 * 0.28E-3, @@ -224,7 +222,7 @@ describe('ol.source.WMTS', function() { }) }); - var projection = ol.proj.get('EPSG:3857'); + var projection = _ol_proj_.get('EPSG:3857'); var url = source.tileUrlFunction( source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection); expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' + @@ -234,7 +232,7 @@ describe('ol.source.WMTS', function() { }); describe('when creating options from Esri capabilities', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wmts/arcgis.xml', function(xml) { @@ -249,7 +247,7 @@ describe('ol.source.WMTS', function() { it('can create KVP options from spec/ol/format/wmts/arcgis.xml', function() { - var options = ol.source.WMTS.optionsFromCapabilities( + var options = _ol_source_WMTS_.optionsFromCapabilities( capabilities, { layer: 'Demographics_USA_Population_Density', requestEncoding: 'KVP', @@ -265,7 +263,7 @@ describe('ol.source.WMTS', function() { it('can create REST options from spec/ol/format/wmts/arcgis.xml', function() { - var options = ol.source.WMTS.optionsFromCapabilities( + var options = _ol_source_WMTS_.optionsFromCapabilities( capabilities, { layer: 'Demographics_USA_Population_Density', matrixSet: 'default028mm' @@ -283,7 +281,7 @@ describe('ol.source.WMTS', function() { describe('#setUrls()', function() { it('sets the URL for the source', function() { - var source = new ol.source.WMTS({}); + var source = new _ol_source_WMTS_({}); var urls = [ 'https://a.example.com/', @@ -296,7 +294,7 @@ describe('ol.source.WMTS', function() { }); it('updates the key for the source', function() { - var source = new ol.source.WMTS({}); + var source = new _ol_source_WMTS_({}); var urls = [ 'https://a.example.com/', @@ -309,15 +307,15 @@ describe('ol.source.WMTS', function() { }); it('generates the correct tileUrlFunction during application of setUrl()', function() { - var projection = ol.proj.get('EPSG:3857'); - var source = new ol.source.WMTS({ + var projection = _ol_proj_.get('EPSG:3857'); + var source = new _ol_source_WMTS_({ projection: projection, requestEncoding: 'REST', urls: [ 'http://1.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg', 'http://2.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg' ], - tileGrid: new ol.tilegrid.WMTS({ + tileGrid: new _ol_tilegrid_WMTS_({ matrixIds: [0, 1, 2, 3, 4, 5, 6, 7], origin: [2690000, 1285000], resolutions: [4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250] @@ -336,7 +334,7 @@ describe('ol.source.WMTS', function() { describe('url option', function() { it('expands url template', function() { - var tileSource = new ol.source.WMTS({ + var tileSource = new _ol_source_WMTS_({ url: '{1-3}' }); @@ -356,7 +354,7 @@ describe('ol.source.WMTS', function() { style: 'default', matrixSet: 'foo', requestEncoding: 'REST', - tileGrid: new ol.tilegrid.WMTS({ + tileGrid: new _ol_tilegrid_WMTS_({ origin: [0, 0], resolutions: [], matrixIds: [] @@ -367,7 +365,7 @@ describe('ol.source.WMTS', function() { describe('using a "url" option', function() { beforeEach(function() { sourceOptions.url = 'some_wmts_url'; - source = new ol.source.WMTS(sourceOptions); + source = new _ol_source_WMTS_(sourceOptions); }); it('returns the WMTS URLs', function() { @@ -380,7 +378,7 @@ describe('ol.source.WMTS', function() { describe('using a "urls" option', function() { beforeEach(function() { sourceOptions.urls = ['some_wmts_url1', 'some_wmts_url2']; - source = new ol.source.WMTS(sourceOptions); + source = new _ol_source_WMTS_(sourceOptions); }); it('returns the WMTS URLs', function() { @@ -397,12 +395,12 @@ describe('ol.source.WMTS', function() { var source; beforeEach(function() { - source = new ol.source.WMTS({ + source = new _ol_source_WMTS_({ layer: 'layer', style: 'default', matrixSet: 'foo', requestEncoding: 'REST', - tileGrid: new ol.tilegrid.WMTS({ + tileGrid: new _ol_tilegrid_WMTS_({ origin: [0, 0], resolutions: [], matrixIds: [] diff --git a/test/spec/ol/source/xyz.test.js b/test/spec/ol/source/xyz.test.js index f148d2e1fe..d08190bed7 100644 --- a/test/spec/ol/source/xyz.test.js +++ b/test/spec/ol/source/xyz.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol.source.Tile'); -goog.require('ol.source.TileImage'); -goog.require('ol.source.UrlTile'); -goog.require('ol.source.XYZ'); -goog.require('ol.tilegrid'); +import _ol_source_Tile_ from '../../../../src/ol/source/Tile.js'; +import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js'; +import _ol_source_UrlTile_ from '../../../../src/ol/source/UrlTile.js'; +import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; describe('ol.source.XYZ', function() { @@ -12,30 +10,30 @@ describe('ol.source.XYZ', function() { describe('constructor', function() { it('can be constructed without options', function() { - var source = new ol.source.XYZ(); - expect(source).to.be.an(ol.source.XYZ); - expect(source).to.be.an(ol.source.TileImage); - expect(source).to.be.an(ol.source.UrlTile); - expect(source).to.be.an(ol.source.Tile); + var source = new _ol_source_XYZ_(); + expect(source).to.be.an(_ol_source_XYZ_); + expect(source).to.be.an(_ol_source_TileImage_); + expect(source).to.be.an(_ol_source_UrlTile_); + expect(source).to.be.an(_ol_source_Tile_); }); it('can be constructed with a custom tile grid', function() { - var tileGrid = ol.tilegrid.createXYZ(); - var tileSource = new ol.source.XYZ({ + var tileGrid = _ol_tilegrid_.createXYZ(); + var tileSource = new _ol_source_XYZ_({ tileGrid: tileGrid }); expect(tileSource.getTileGrid()).to.be(tileGrid); }); it('can be constructed with a custom tile size', function() { - var tileSource = new ol.source.XYZ({ + var tileSource = new _ol_source_XYZ_({ tileSize: 512 }); expect(tileSource.getTileGrid().getTileSize(0)).to.be(512); }); it('can be constructed with a custom min zoom', function() { - var tileSource = new ol.source.XYZ({ + var tileSource = new _ol_source_XYZ_({ minZoom: 2 }); expect(tileSource.getTileGrid().getMinZoom()).to.be(2); @@ -48,7 +46,7 @@ describe('ol.source.XYZ', function() { var xyzTileSource, tileGrid; beforeEach(function() { - xyzTileSource = new ol.source.XYZ({ + xyzTileSource = new _ol_source_XYZ_({ maxZoom: 6, url: '{z}/{x}/{y}' }); @@ -151,7 +149,7 @@ describe('ol.source.XYZ', function() { describe('using a "url" option', function() { beforeEach(function() { sourceOptions.url = url; - source = new ol.source.XYZ(sourceOptions); + source = new _ol_source_XYZ_(sourceOptions); }); it('returns the XYZ URL', function() { @@ -164,7 +162,7 @@ describe('ol.source.XYZ', function() { describe('using a "urls" option', function() { beforeEach(function() { sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2']; - source = new ol.source.XYZ(sourceOptions); + source = new _ol_source_XYZ_(sourceOptions); }); it('returns the XYZ URLs', function() { @@ -179,7 +177,7 @@ describe('ol.source.XYZ', function() { sourceOptions.tileUrlFunction = function() { return 'some_xyz_url'; }; - source = new ol.source.XYZ(sourceOptions); + source = new _ol_source_XYZ_(sourceOptions); }); it('returns null', function() { diff --git a/test/spec/ol/source/zoomify.test.js b/test/spec/ol/source/zoomify.test.js index b3e78553d9..9063773590 100644 --- a/test/spec/ol/source/zoomify.test.js +++ b/test/spec/ol/source/zoomify.test.js @@ -1,10 +1,8 @@ - - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.proj.Projection'); -goog.require('ol.source.Zoomify'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_ from '../../../../src/ol.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_source_Zoomify_ from '../../../../src/ol/source/Zoomify.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; describe('ol.source.Zoomify', function() { @@ -13,32 +11,32 @@ describe('ol.source.Zoomify', function() { var size = [w, h]; var zoomifyUrl = 'spec/ol/source/images/zoomify/{TileGroup}/{z}-{x}-{y}.jpg'; var iipUrl = 'spec/ol/source/images/zoomify?JTL={z},{tileIndex}'; - var proj = new ol.proj.Projection({ + var proj = new _ol_proj_Projection_({ code: 'ZOOMIFY', units: 'pixels', extent: [0, 0, w, h] }); function getZoomifySource() { - return new ol.source.Zoomify({ + return new _ol_source_Zoomify_({ url: zoomifyUrl, size: size }); } function getZoomifySourceWithExtentInFirstQuadrant() { - return new ol.source.Zoomify({ + return new _ol_source_Zoomify_({ url: zoomifyUrl, size: size, extent: [0, 0, size[0], size[1]] }); } function getIIPSource() { - return new ol.source.Zoomify({ + return new _ol_source_Zoomify_({ url: iipUrl, size: size }); } function getZoomifySourceWith1024pxTiles() { - return new ol.source.Zoomify({ + return new _ol_source_Zoomify_({ url: zoomifyUrl, size: size, tileSize: 1024 @@ -52,29 +50,29 @@ describe('ol.source.Zoomify', function() { // undefined config object expect(function() { - source = new ol.source.Zoomify(); + source = new _ol_source_Zoomify_(); }).to.throwException(); // empty object as config object expect(function() { - source = new ol.source.Zoomify({}); + source = new _ol_source_Zoomify_({}); }).to.throwException(); // not passing "size" in config object expect(function() { - source = new ol.source.Zoomify({ + source = new _ol_source_Zoomify_({ url: 'some-url' }); }).to.throwException(); // passing "size" in config object expect(function() { - source = new ol.source.Zoomify({ + source = new _ol_source_Zoomify_({ size: [47, 11] }); }).to.not.throwException(); // we got a source - expect(source).to.be.a(ol.source.Zoomify); + expect(source).to.be.a(_ol_source_Zoomify_); // also test our helper methods from above expect(function() { @@ -84,12 +82,12 @@ describe('ol.source.Zoomify', function() { source = getIIPSource(); }).to.not.throwException(); // we got a source - expect(source).to.be.a(ol.source.Zoomify); + expect(source).to.be.a(_ol_source_Zoomify_); }); it('does not need "tierSizeCalculation" option', function() { expect(function() { - new ol.source.Zoomify({ + new _ol_source_Zoomify_({ size: [47, 11] }); }).to.not.throwException(); @@ -97,7 +95,7 @@ describe('ol.source.Zoomify', function() { it('accepts "tierSizeCalculation" option "default"', function() { expect(function() { - new ol.source.Zoomify({ + new _ol_source_Zoomify_({ size: [47, 11], tierSizeCalculation: 'default' }); @@ -106,7 +104,7 @@ describe('ol.source.Zoomify', function() { it('accepts "tierSizeCalculation" option "truncated"', function() { expect(function() { - new ol.source.Zoomify({ + new _ol_source_Zoomify_({ size: [47, 11], tierSizeCalculation: 'truncated' }); @@ -116,7 +114,7 @@ describe('ol.source.Zoomify', function() { it('throws on unexpected "tierSizeCalculation" ', function() { // passing unknown string will throw expect(function() { - new ol.source.Zoomify({ + new _ol_source_Zoomify_({ size: [47, 11], tierSizeCalculation: 'ace-of-spades' }); @@ -127,7 +125,7 @@ describe('ol.source.Zoomify', function() { var sources = [getZoomifySource(), getIIPSource()]; for (var i = 0; i < sources.length; i++) { var tileGrid = sources[i].getTileGrid(); - expect(tileGrid).to.be.a(ol.tilegrid.TileGrid); + expect(tileGrid).to.be.a(_ol_tilegrid_TileGrid_); } }); @@ -164,7 +162,7 @@ describe('ol.source.Zoomify', function() { it('has expected tileSize', function() { var sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()]; - var expectedTileSizes = [ol.DEFAULT_TILE_SIZE, 1024]; + var expectedTileSizes = [_ol_.DEFAULT_TILE_SIZE, 1024]; for (var i = 0; i < sources.length; i++) { var tileGrid = sources[i].getTileGrid(); expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]); @@ -201,14 +199,14 @@ describe('ol.source.Zoomify', function() { it('influences resolutions', function() { // not configured at all - var source = new ol.source.Zoomify({ + var source = new _ol_source_Zoomify_({ url: zoomifyUrl, size: [513, 256] }); var tileGrid = source.getTileGrid(); // explicitly set as 'default' - var sourceDefault = new ol.source.Zoomify({ + var sourceDefault = new _ol_source_Zoomify_({ url: zoomifyUrl, size: [513, 256], tierSizeCalculation: 'default' @@ -216,7 +214,7 @@ describe('ol.source.Zoomify', function() { var tileGridDefault = sourceDefault.getTileGrid(); // explicitly set to 'truncated' - var sourceTruncated = new ol.source.Zoomify({ + var sourceTruncated = new _ol_source_Zoomify_({ url: zoomifyUrl, size: [513, 256], tierSizeCalculation: 'truncated' @@ -256,7 +254,7 @@ describe('ol.source.Zoomify', function() { }); it('creates an expected tileUrlFunction without template', function() { - var source = new ol.source.Zoomify({ + var source = new _ol_source_Zoomify_({ url: 'spec/ol/source/images/zoomify/', size: size }); @@ -282,7 +280,7 @@ describe('ol.source.Zoomify', function() { it('returns expected tileClass instances via "getTile"', function() { var source = getZoomifySource(); var tile = source.getTile(0, 0, -1, 1, proj); - expect(tile).to.be.an(ol.source.Zoomify.Tile_); + expect(tile).to.be.an(_ol_source_Zoomify_.Tile_); }); it('"tile.getImage" returns and caches an unloaded image', function() { @@ -303,7 +301,7 @@ describe('ol.source.Zoomify', function() { var tile = source.getTile(0, 0, -1, 1, proj); - ol.events.listen(tile, 'change', function() { + _ol_events_.listen(tile, 'change', function() { if (tile.getState() == 2) { // LOADED var img = tile.getImage(); expect(img).to.be.a(HTMLCanvasElement); diff --git a/test/spec/ol/sphere.test.js b/test/spec/ol/sphere.test.js index 41e3fcc4b1..8e734fa221 100644 --- a/test/spec/ol/sphere.test.js +++ b/test/spec/ol/sphere.test.js @@ -2,19 +2,19 @@ // FIXME add tests for offset -goog.require('ol.Sphere'); -goog.require('ol.format.WKT'); -goog.require('ol.geom.GeometryCollection'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.MultiLineString'); -goog.require('ol.geom.MultiPoint'); -goog.require('ol.geom.Point'); -goog.require('ol.proj.EPSG4326'); +import _ol_Sphere_ from '../../../src/ol/Sphere.js'; +import _ol_format_WKT_ from '../../../src/ol/format/WKT.js'; +import _ol_geom_GeometryCollection_ from '../../../src/ol/geom/GeometryCollection.js'; +import _ol_geom_LineString_ from '../../../src/ol/geom/LineString.js'; +import _ol_geom_MultiLineString_ from '../../../src/ol/geom/MultiLineString.js'; +import _ol_geom_MultiPoint_ from '../../../src/ol/geom/MultiPoint.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; +import _ol_proj_EPSG4326_ from '../../../src/ol/proj/EPSG4326.js'; describe('ol.Sphere', function() { - var sphere = new ol.Sphere(6371); + var sphere = new _ol_Sphere_(6371); var expected = [{ c1: [0, 0], c2: [0, 0], @@ -95,7 +95,7 @@ describe('ol.Sphere', function() { before(function(done) { afterLoadText('spec/ol/format/wkt/illinois.wkt', function(wkt) { try { - var format = new ol.format.WKT(); + var format = new _ol_format_WKT_(); geometry = format.readGeometry(wkt); } catch (e) { done(e); @@ -106,7 +106,7 @@ describe('ol.Sphere', function() { it('results match the expected area of Ilinois', function() { var coords = geometry.getPolygon(0).getLinearRing(0).getCoordinates(); - var sphere = new ol.Sphere(ol.proj.EPSG4326.RADIUS); + var sphere = new _ol_Sphere_(_ol_proj_EPSG4326_.RADIUS); expect(sphere.geodesicArea(coords)).to.equal(145978332359.37125); }); }); @@ -115,13 +115,13 @@ describe('ol.Sphere', function() { describe('ol.Sphere.getLength()', function() { var cases = [{ - geometry: new ol.geom.Point([0, 0]), + geometry: new _ol_geom_Point_([0, 0]), length: 0 }, { - geometry: new ol.geom.MultiPoint([[0, 0], [1, 1]]), + geometry: new _ol_geom_MultiPoint_([[0, 0], [1, 1]]), length: 0 }, { - geometry: new ol.geom.LineString([ + geometry: new _ol_geom_LineString_([ [12801741.441226462, -3763310.627144653], [14582853.293918837, -2511525.2348457114], [15918687.18343812, -2875744.624352243], @@ -129,7 +129,7 @@ describe('ol.Sphere.getLength()', function() { ]), length: 4407939.124914191 }, { - geometry: new ol.geom.LineString([ + geometry: new _ol_geom_LineString_([ [115, -32], [131, -22], [143, -25], @@ -138,7 +138,7 @@ describe('ol.Sphere.getLength()', function() { options: {projection: 'EPSG:4326'}, length: 4407939.124914191 }, { - geometry: new ol.geom.MultiLineString([ + geometry: new _ol_geom_MultiLineString_([ [ [115, -32], [131, -22], @@ -154,14 +154,14 @@ describe('ol.Sphere.getLength()', function() { options: {projection: 'EPSG:4326'}, length: 2 * 4407939.124914191 }, { - geometry: new ol.geom.GeometryCollection([ - new ol.geom.LineString([ + geometry: new _ol_geom_GeometryCollection_([ + new _ol_geom_LineString_([ [115, -32], [131, -22], [143, -25], [150, -34] ]), - new ol.geom.LineString([ + new _ol_geom_LineString_([ [115, -32], [131, -22], [143, -25], @@ -175,7 +175,7 @@ describe('ol.Sphere.getLength()', function() { cases.forEach(function(c, i) { it('works for case ' + i, function() { var c = cases[i]; - var length = ol.Sphere.getLength(c.geometry, c.options); + var length = _ol_Sphere_.getLength(c.geometry, c.options); expect(length).to.roughlyEqual(c.length, 1e-8); }); }); @@ -187,7 +187,7 @@ describe('ol.Sphere.getArea()', function() { before(function(done) { afterLoadText('spec/ol/format/wkt/illinois.wkt', function(wkt) { try { - var format = new ol.format.WKT(); + var format = new _ol_format_WKT_(); geometry = format.readGeometry(wkt); } catch (e) { done(e); @@ -197,7 +197,7 @@ describe('ol.Sphere.getArea()', function() { }); it('calculates the area of Ilinois', function() { - var area = ol.Sphere.getArea(geometry, {projection: 'EPSG:4326'}); + var area = _ol_Sphere_.getArea(geometry, {projection: 'EPSG:4326'}); expect(area).to.equal(145652224192.4434); }); }); diff --git a/test/spec/ol/string.test.js b/test/spec/ol/string.test.js index 61094e9c1a..bc7249568d 100644 --- a/test/spec/ol/string.test.js +++ b/test/spec/ol/string.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.string'); +import _ol_string_ from '../../../src/ol/string.js'; describe('ol.string', function() { @@ -8,37 +6,37 @@ describe('ol.string', function() { describe('ol.string.padNumber', function() { it('returns the correct padding without precision', function() { - expect(ol.string.padNumber(6.5, 2)).to.be('06.5'); - expect(ol.string.padNumber(6.5, 3)).to.be('006.5'); - expect(ol.string.padNumber(1.25, 2)).to.be('01.25'); - expect(ol.string.padNumber(5, 3)).to.be('005'); + expect(_ol_string_.padNumber(6.5, 2)).to.be('06.5'); + expect(_ol_string_.padNumber(6.5, 3)).to.be('006.5'); + expect(_ol_string_.padNumber(1.25, 2)).to.be('01.25'); + expect(_ol_string_.padNumber(5, 3)).to.be('005'); }); it('returns the same string when padding is less than length', function() { - expect(ol.string.padNumber(6.5, 0)).to.be('6.5'); - expect(ol.string.padNumber(6.5, 1)).to.be('6.5'); - expect(ol.string.padNumber(1.25, 0)).to.be('1.25'); - expect(ol.string.padNumber(5, 0)).to.be('5'); - expect(ol.string.padNumber(5, 1)).to.be('5'); + expect(_ol_string_.padNumber(6.5, 0)).to.be('6.5'); + expect(_ol_string_.padNumber(6.5, 1)).to.be('6.5'); + expect(_ol_string_.padNumber(1.25, 0)).to.be('1.25'); + expect(_ol_string_.padNumber(5, 0)).to.be('5'); + expect(_ol_string_.padNumber(5, 1)).to.be('5'); }); it('returns the correct string precision is given', function() { - expect(ol.string.padNumber(6.5, 0, 2)).to.be('6.50'); - expect(ol.string.padNumber(6.5, 1, 2)).to.be('6.50'); - expect(ol.string.padNumber(6.5, 2, 2)).to.be('06.50'); - expect(ol.string.padNumber(1.25, 2, 3)).to.be('01.250'); - expect(ol.string.padNumber(1.25, 2, 1)).to.be('01.3'); - expect(ol.string.padNumber(9.9, 2, 0)).to.be('10'); - expect(ol.string.padNumber(5, 0, 0)).to.be('5'); - expect(ol.string.padNumber(5, 1, 1)).to.be('5.0'); - expect(ol.string.padNumber(5, 2, 1)).to.be('05.0'); - expect(ol.string.padNumber(5, 2, 0)).to.be('05'); + expect(_ol_string_.padNumber(6.5, 0, 2)).to.be('6.50'); + expect(_ol_string_.padNumber(6.5, 1, 2)).to.be('6.50'); + expect(_ol_string_.padNumber(6.5, 2, 2)).to.be('06.50'); + expect(_ol_string_.padNumber(1.25, 2, 3)).to.be('01.250'); + expect(_ol_string_.padNumber(1.25, 2, 1)).to.be('01.3'); + expect(_ol_string_.padNumber(9.9, 2, 0)).to.be('10'); + expect(_ol_string_.padNumber(5, 0, 0)).to.be('5'); + expect(_ol_string_.padNumber(5, 1, 1)).to.be('5.0'); + expect(_ol_string_.padNumber(5, 2, 1)).to.be('05.0'); + expect(_ol_string_.padNumber(5, 2, 0)).to.be('05'); }); }); describe('ol.string.compareVersions', function() { - var f = ol.string.compareVersions; + var f = _ol_string_.compareVersions; it('should return the correct value for number input', function() { expect(f(1, 1)).to.be(0); expect(f(1.0, 1.1)).to.be.below(0); diff --git a/test/spec/ol/structs/linkedlist.test.js b/test/spec/ol/structs/linkedlist.test.js index 1572b06417..93ed4367c3 100644 --- a/test/spec/ol/structs/linkedlist.test.js +++ b/test/spec/ol/structs/linkedlist.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.structs.LinkedList'); +import _ol_structs_LinkedList_ from '../../../../src/ol/structs/LinkedList.js'; describe('ol.structs.LinkedList', function() { var ll; var item = {}; var item2 = {}; beforeEach(function() { - ll = new ol.structs.LinkedList(); + ll = new _ol_structs_LinkedList_(); }); it('defaults to circular', function() { @@ -61,7 +59,7 @@ describe('ol.structs.LinkedList', function() { }); it('otherwise sets the cursor to the prevous item', function() { - ll = new ol.structs.LinkedList(false); + ll = new _ol_structs_LinkedList_(false); ll.insertItem(item); ll.insertItem(item2); ll.insertItem(item3); @@ -70,7 +68,7 @@ describe('ol.structs.LinkedList', function() { }); it('empties a list with only one item', function() { - ll = new ol.structs.LinkedList(); + ll = new _ol_structs_LinkedList_(); ll.insertItem(item); ll.removeItem(); expect(ll.length_).to.be(0); @@ -204,7 +202,7 @@ describe('ol.structs.LinkedList', function() { var ll2, item3; beforeEach(function() { item3 = {}; - ll2 = new ol.structs.LinkedList(); + ll2 = new _ol_structs_LinkedList_(); ll2.insertItem(item); ll2.insertItem(item2); ll2.insertItem(item3); @@ -244,7 +242,7 @@ describe('ol.structs.LinkedList', function() { describe('when circular', function() { beforeEach(function() { - ll = new ol.structs.LinkedList(); + ll = new _ol_structs_LinkedList_(); ll.insertItem(item); }); diff --git a/test/spec/ol/structs/lrucache.test.js b/test/spec/ol/structs/lrucache.test.js index 3b4453bee3..6e4f3d2bea 100644 --- a/test/spec/ol/structs/lrucache.test.js +++ b/test/spec/ol/structs/lrucache.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.structs.LRUCache'); +import _ol_structs_LRUCache_ from '../../../../src/ol/structs/LRUCache.js'; describe('ol.structs.LRUCache', function() { @@ -15,7 +13,7 @@ describe('ol.structs.LRUCache', function() { } beforeEach(function() { - lruCache = new ol.structs.LRUCache(); + lruCache = new _ol_structs_LRUCache_(); }); describe('empty cache', function() { @@ -166,7 +164,7 @@ describe('ol.structs.LRUCache', function() { describe('#peekFirstKey()', function() { it('returns the newest key in the cache', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('oldest', 'oldest'); cache.set('oldish', 'oldish'); cache.set('newish', 'newish'); @@ -175,13 +173,13 @@ describe('ol.structs.LRUCache', function() { }); it('works if the cache has one item', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('key', 'value'); expect(cache.peekFirstKey()).to.eql('key'); }); it('throws if the cache is empty', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); expect(function() { cache.peekFirstKey(); }).to.throwException(); @@ -214,7 +212,7 @@ describe('ol.structs.LRUCache', function() { describe('#remove()', function() { it('removes an item from the cache', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('oldest', 'oldest'); cache.set('oldish', 'oldish'); cache.set('newish', 'newish'); @@ -226,7 +224,7 @@ describe('ol.structs.LRUCache', function() { }); it('works when removing the oldest item', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('oldest', 'oldest'); cache.set('oldish', 'oldish'); cache.set('newish', 'newish'); @@ -239,7 +237,7 @@ describe('ol.structs.LRUCache', function() { }); it('works when removing the newest item', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('oldest', 'oldest'); cache.set('oldish', 'oldish'); cache.set('newish', 'newish'); @@ -252,7 +250,7 @@ describe('ol.structs.LRUCache', function() { }); it('returns the removed item', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); var item = {}; cache.set('key', item); @@ -261,7 +259,7 @@ describe('ol.structs.LRUCache', function() { }); it('throws if the key does not exist', function() { - var cache = new ol.structs.LRUCache(); + var cache = new _ol_structs_LRUCache_(); cache.set('foo', 'foo'); cache.set('bar', 'bar'); diff --git a/test/spec/ol/structs/priorityqueue.test.js b/test/spec/ol/structs/priorityqueue.test.js index 0db7810b20..ecd5868cfa 100644 --- a/test/spec/ol/structs/priorityqueue.test.js +++ b/test/spec/ol/structs/priorityqueue.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.structs.PriorityQueue'); +import _ol_structs_PriorityQueue_ from '../../../../src/ol/structs/PriorityQueue.js'; describe('ol.structs.PriorityQueue', function() { @@ -13,7 +11,7 @@ describe('ol.structs.PriorityQueue', function() { var pq; beforeEach(function() { - pq = new ol.structs.PriorityQueue(identity, identity); + pq = new _ol_structs_PriorityQueue_(identity, identity); }); it('is empty', function() { @@ -41,7 +39,7 @@ describe('ol.structs.PriorityQueue', function() { var elements, pq; beforeEach(function() { elements = []; - pq = new ol.structs.PriorityQueue( + pq = new _ol_structs_PriorityQueue_( identity, identity); var element, i; for (i = 0; i < 32; ++i) { @@ -67,7 +65,7 @@ describe('ol.structs.PriorityQueue', function() { var pq, target; beforeEach(function() { target = 0.5; - pq = new ol.structs.PriorityQueue(function(element) { + pq = new _ol_structs_PriorityQueue_(function(element) { return Math.abs(element - target); }, identity); var i; @@ -105,7 +103,7 @@ describe('ol.structs.PriorityQueue', function() { if (i++ % 2 === 0) { return Math.abs(element - target); } else { - return ol.structs.PriorityQueue.DROP; + return _ol_structs_PriorityQueue_.DROP; } }; pq.reprioritize(); @@ -125,7 +123,7 @@ describe('ol.structs.PriorityQueue', function() { var pq; beforeEach(function() { - pq = new ol.structs.PriorityQueue( + pq = new _ol_structs_PriorityQueue_( identity, identity); pq.enqueue('a'); pq.enqueue('b'); diff --git a/test/spec/ol/structs/rbush.test.js b/test/spec/ol/structs/rbush.test.js index 4dbf486f2f..5da83b290e 100644 --- a/test/spec/ol/structs/rbush.test.js +++ b/test/spec/ol/structs/rbush.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.structs.RBush'); +import _ol_structs_RBush_ from '../../../../src/ol/structs/RBush.js'; describe('ol.structs.RBush', function() { var rBush; beforeEach(function() { - rBush = new ol.structs.RBush(); + rBush = new _ol_structs_RBush_(); }); describe('when empty', function() { @@ -318,7 +316,7 @@ describe('ol.structs.RBush', function() { it('concatenates two RBush objects', function() { var obj1 = {}; var obj2 = {}; - var rBush2 = new ol.structs.RBush(); + var rBush2 = new _ol_structs_RBush_(); rBush.insert([0, 0, 1, 1], obj1); rBush2.insert([0, 0, 2, 2], obj2); rBush.concat(rBush2); @@ -329,7 +327,7 @@ describe('ol.structs.RBush', function() { it('preserves the concatenated object\'s references', function() { var obj1 = {}; var obj2 = {}; - var rBush2 = new ol.structs.RBush(); + var rBush2 = new _ol_structs_RBush_(); rBush.insert([0, 0, 1, 1], obj1); rBush2.insert([0, 0, 2, 2], obj2); rBush.concat(rBush2); diff --git a/test/spec/ol/style/atlasmanager.test.js b/test/spec/ol/style/atlasmanager.test.js index f2cfb150b5..be06e9151f 100644 --- a/test/spec/ol/style/atlasmanager.test.js +++ b/test/spec/ol/style/atlasmanager.test.js @@ -1,7 +1,5 @@ - - -goog.require('ol.style.Atlas'); -goog.require('ol.style.AtlasManager'); +import _ol_style_Atlas_ from '../../../../src/ol/style/Atlas.js'; +import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js'; describe('ol.style.Atlas', function() { @@ -12,7 +10,7 @@ describe('ol.style.Atlas', function() { describe('#constructor', function() { it('inits the atlas', function() { - var atlas = new ol.style.Atlas(256, 1); + var atlas = new _ol_style_Atlas_(256, 1); expect(atlas.emptyBlocks_).to.eql( [{x: 0, y: 0, width: 256, height: 256}]); }); @@ -21,7 +19,7 @@ describe('ol.style.Atlas', function() { describe('#add (squares with same size)', function() { it('adds one entry', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); var info = atlas.add('1', 32, 32, defaultRender); expect(info).to.eql( @@ -31,7 +29,7 @@ describe('ol.style.Atlas', function() { }); it('adds two entries', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); atlas.add('1', 32, 32, defaultRender); var info = atlas.add('2', 32, 32, defaultRender); @@ -43,7 +41,7 @@ describe('ol.style.Atlas', function() { }); it('adds three entries', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -56,7 +54,7 @@ describe('ol.style.Atlas', function() { }); it('adds four entries (new row)', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -70,7 +68,7 @@ describe('ol.style.Atlas', function() { }); it('returns null when an entry is too big', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -81,7 +79,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); for (var i = 1; i <= 16; i++) { expect(atlas.add(i.toString(), 28, 28, defaultRender)).to.be.ok(); @@ -95,7 +93,7 @@ describe('ol.style.Atlas', function() { describe('#add (rectangles with different sizes)', function() { it('adds a bunch of rectangles', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); expect(atlas.add('1', 64, 32, defaultRender)).to.eql( {offsetX: 1, offsetY: 1, image: atlas.canvas_}); @@ -118,7 +116,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas (rectangles in portrait format)', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); for (var i = 1; i <= 32; i++) { expect(atlas.add(i.toString(), 28, 14, defaultRender)).to.be.ok(); @@ -129,7 +127,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas (rectangles in landscape format)', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); for (var i = 1; i <= 32; i++) { expect(atlas.add(i.toString(), 14, 28, defaultRender)).to.be.ok(); @@ -143,7 +141,7 @@ describe('ol.style.Atlas', function() { describe('#add (rendering)', function() { it('calls the render callback with the right values', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); var rendererCallback = sinon.spy(); atlas.add('1', 32, 32, rendererCallback); @@ -158,7 +156,7 @@ describe('ol.style.Atlas', function() { }); it('is possible to actually draw on the canvas', function() { - var atlas = new ol.style.Atlas(128, 1); + var atlas = new _ol_style_Atlas_(128, 1); var rendererCallback = function(context, x, y) { context.fillStyle = '#FFA500'; @@ -181,7 +179,7 @@ describe('ol.style.AtlasManager', function() { describe('#constructor', function() { it('inits the atlas manager', function() { - var manager = new ol.style.AtlasManager(); + var manager = new _ol_style_AtlasManager_(); expect(manager.atlases_).to.not.be.empty(); }); }); @@ -189,7 +187,7 @@ describe('ol.style.AtlasManager', function() { describe('#add', function() { it('adds one entry', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); var info = manager.add('1', 32, 32, defaultRender); expect(info).to.eql({ @@ -200,7 +198,7 @@ describe('ol.style.AtlasManager', function() { }); it('adds one entry (also to the hit detection atlas)', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); var info = manager.add('1', 32, 32, defaultRender, defaultRender); expect(info).to.eql({ @@ -211,7 +209,7 @@ describe('ol.style.AtlasManager', function() { }); it('creates a new atlas if needed', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); expect(manager.add('1', 100, 100, defaultRender, defaultRender)) .to.be.ok(); var info = manager.add('2', 100, 100, defaultRender, defaultRender); @@ -223,7 +221,7 @@ describe('ol.style.AtlasManager', function() { }); it('creates new atlases until one is large enough', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); expect(manager.add('1', 100, 100, defaultRender, defaultRender)) .to.be.ok(); expect(manager.atlases_).to.have.length(1); @@ -237,7 +235,7 @@ describe('ol.style.AtlasManager', function() { }); it('checks all existing atlases and create a new if needed', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); expect(manager.add('1', 100, 100, defaultRender, defaultRender)) .to.be.ok(); expect(manager.add('2', 100, 100, defaultRender, defaultRender)) @@ -253,7 +251,7 @@ describe('ol.style.AtlasManager', function() { }); it('returns null if the size exceeds the maximum size', function() { - var manager = new ol.style.AtlasManager( + var manager = new _ol_style_AtlasManager_( {initialSize: 128, maxSize: 2048}); expect(manager.add('1', 100, 100, defaultRender, defaultRender)) .to.be.ok(); @@ -262,7 +260,7 @@ describe('ol.style.AtlasManager', function() { }); it('always has the same offset for the hit-detection', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); // add one image without hit-detection callback var info = manager.add('1', 32, 32, defaultRender); // add then one with hit-detection callback @@ -279,7 +277,7 @@ describe('ol.style.AtlasManager', function() { describe('#getInfo', function() { it('returns null if no entry for the given id', function() { - var manager = new ol.style.AtlasManager({initialSize: 128}); + var manager = new _ol_style_AtlasManager_({initialSize: 128}); expect(manager.getInfo('123456')).to.eql(null); }); }); diff --git a/test/spec/ol/style/circle.test.js b/test/spec/ol/style/circle.test.js index 272090913b..a69e586459 100644 --- a/test/spec/ol/style/circle.test.js +++ b/test/spec/ol/style/circle.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.style.AtlasManager'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); +import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.style.Circle', function() { @@ -11,7 +9,7 @@ describe('ol.style.Circle', function() { describe('#constructor', function() { it('creates a canvas if no atlas is used (no fill-style)', function() { - var style = new ol.style.Circle({radius: 10}); + var style = new _ol_style_Circle_({radius: 10}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); expect(style.getImageSize()).to.eql([21, 21]); @@ -24,9 +22,9 @@ describe('ol.style.Circle', function() { }); it('creates a canvas if no atlas is used (fill-style)', function() { - var style = new ol.style.Circle({ + var style = new _ol_style_Circle_({ radius: 10, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#FFFF00' }) }); @@ -42,8 +40,8 @@ describe('ol.style.Circle', function() { }); it('adds itself to an atlas manager (no fill-style)', function() { - var atlasManager = new ol.style.AtlasManager({initialSize: 512}); - var style = new ol.style.Circle({radius: 10, atlasManager: atlasManager}); + var atlasManager = new _ol_style_AtlasManager_({initialSize: 512}); + var style = new _ol_style_Circle_({radius: 10, atlasManager: atlasManager}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); expect(style.getImageSize()).to.eql([512, 512]); @@ -56,11 +54,11 @@ describe('ol.style.Circle', function() { }); it('adds itself to an atlas manager (fill-style)', function() { - var atlasManager = new ol.style.AtlasManager({initialSize: 512}); - var style = new ol.style.Circle({ + var atlasManager = new _ol_style_AtlasManager_({initialSize: 512}); + var style = new _ol_style_Circle_({ radius: 10, atlasManager: atlasManager, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#FFFF00' }) }); @@ -79,18 +77,18 @@ describe('ol.style.Circle', function() { describe('#clone', function() { it('creates a new ol.style.Circle', function() { - var original = new ol.style.Circle(); + var original = new _ol_style_Circle_(); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Circle); + expect(clone).to.be.an(_ol_style_Circle_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.Circle({ - fill: new ol.style.Fill({ + var original = new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }), radius: 5, @@ -108,11 +106,11 @@ describe('ol.style.Circle', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Circle({ - fill: new ol.style.Fill({ + var original = new _ol_style_Circle_({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -131,39 +129,39 @@ describe('ol.style.Circle', function() { describe('#getChecksum', function() { it('calculates the same hash code for default options', function() { - var style1 = new ol.style.Circle(); - var style2 = new ol.style.Circle(); + var style1 = new _ol_style_Circle_(); + var style2 = new _ol_style_Circle_(); expect(style1.getChecksum()).to.eql(style2.getChecksum()); }); it('calculates not the same hash code (radius)', function() { - var style1 = new ol.style.Circle(); - var style2 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_(); + var style2 = new _ol_style_Circle_({ radius: 5 }); expect(style1.getChecksum()).to.not.eql(style2.getChecksum()); }); it('calculates the same hash code (radius)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5 }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5 }); expect(style1.getChecksum()).to.eql(style2.getChecksum()); }); it('calculates not the same hash code (color)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }) }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -171,12 +169,12 @@ describe('ol.style.Circle', function() { }); it('calculates the same hash code (everything set)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -185,12 +183,12 @@ describe('ol.style.Circle', function() { width: 2 }) }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -203,12 +201,12 @@ describe('ol.style.Circle', function() { }); it('calculates not the same hash code (stroke width differs)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -217,12 +215,12 @@ describe('ol.style.Circle', function() { width: 3 }) }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -235,21 +233,21 @@ describe('ol.style.Circle', function() { }); it('invalidates a cached checksum if values change (fill)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -260,21 +258,21 @@ describe('ol.style.Circle', function() { }); it('invalidates a cached checksum if values change (stroke)', function() { - var style1 = new ol.style.Circle({ + var style1 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); - var style2 = new ol.style.Circle({ + var style2 = new _ol_style_Circle_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -288,9 +286,9 @@ describe('ol.style.Circle', function() { describe('#setRadius', function() { it('changes the circle radius', function() { - var style = new ol.style.Circle({ + var style = new _ol_style_Circle_({ radius: 10, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#FFFF00' }) }); diff --git a/test/spec/ol/style/fill.test.js b/test/spec/ol/style/fill.test.js index a7d86b90ba..cf5b151eda 100644 --- a/test/spec/ol/style/fill.test.js +++ b/test/spec/ol/style/fill.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.style.Fill'); +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; describe('ol.style.Fill', function() { describe('#clone', function() { it('creates a new ol.style.Fill', function() { - var original = new ol.style.Fill(); + var original = new _ol_style_Fill_(); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Fill); + expect(clone).to.be.an(_ol_style_Fill_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.Fill({ + var original = new _ol_style_Fill_({ color: '#319FD3' }); var clone = original.clone(); @@ -22,7 +20,7 @@ describe('ol.style.Fill', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Fill({ + var original = new _ol_style_Fill_({ color: [63, 255, 127, 0.7] }); var clone = original.clone(); diff --git a/test/spec/ol/style/icon.test.js b/test/spec/ol/style/icon.test.js index e162916744..b1783cc3f2 100644 --- a/test/spec/ol/style/icon.test.js +++ b/test/spec/ol/style/icon.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol'); -goog.require('ol.style'); -goog.require('ol.style.Icon'); -goog.require('ol.style.IconImage'); +import _ol_ from '../../../../src/ol.js'; +import _ol_style_ from '../../../../src/ol/style.js'; +import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; +import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js'; describe('ol.style.Icon', function() { @@ -15,16 +13,16 @@ describe('ol.style.Icon', function() { it('caches canvas images with a uid as src', function() { var canvas = document.createElement('canvas'); - new ol.style.Icon({ + new _ol_style_Icon_({ img: canvas, imgSize: size }); - expect(ol.style.IconImage.get( - canvas, ol.getUid(canvas), size, '').getImage()).to.eql(canvas); + expect(_ol_style_IconImage_.get( + canvas, _ol_.getUid(canvas), size, '').getImage()).to.eql(canvas); }); it('imgSize overrides img.width and img.height', function(done) { - var style = new ol.style.Icon({ + var style = new _ol_style_Icon_({ src: src, imgSize: size }); @@ -41,17 +39,17 @@ describe('ol.style.Icon', function() { describe('#clone', function() { it('creates a new ol.style.Icon', function() { - var original = new ol.style.Icon({ + var original = new _ol_style_Icon_({ src: src }); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Icon); + expect(clone).to.be.an(_ol_style_Icon_); expect(clone).to.not.be(original); }); it('copies all values ', function() { var canvas = document.createElement('canvas'); - var original = new ol.style.Icon({ + var original = new _ol_style_Icon_({ anchor: [1, 0], anchorOrigin: 'bottom-right', anchorXUnits: 'pixels', @@ -87,7 +85,7 @@ describe('ol.style.Icon', function() { expect(original.getRotateWithView()).to.eql(clone.getRotateWithView()); expect(original.getSnapToPixel()).to.eql(clone.getSnapToPixel()); - var original2 = new ol.style.Icon({ + var original2 = new _ol_style_Icon_({ src: src }); var clone2 = original2.clone(); @@ -97,7 +95,7 @@ describe('ol.style.Icon', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Icon({ + var original = new _ol_style_Icon_({ anchor: [1, 0], color: [1, 2, 3, 0.4], src: src, @@ -125,7 +123,7 @@ describe('ol.style.Icon', function() { var fractionAnchor = [0.25, 0.25]; it('uses fractional units by default', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, anchor: fractionAnchor @@ -134,7 +132,7 @@ describe('ol.style.Icon', function() { }); it('uses pixels units', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, anchor: [2, 18], @@ -145,7 +143,7 @@ describe('ol.style.Icon', function() { }); it('uses a bottom left anchor origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, anchor: fractionAnchor, @@ -155,7 +153,7 @@ describe('ol.style.Icon', function() { }); it('uses a bottom right anchor origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, anchor: fractionAnchor, @@ -165,7 +163,7 @@ describe('ol.style.Icon', function() { }); it('uses a top right anchor origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, anchor: fractionAnchor, @@ -180,7 +178,7 @@ describe('ol.style.Icon', function() { var imageSize = [144, 192]; it('uses a top left offset origin (default)', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, offset: offset @@ -189,7 +187,7 @@ describe('ol.style.Icon', function() { }); it('uses a bottom left offset origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, offset: offset, @@ -200,7 +198,7 @@ describe('ol.style.Icon', function() { }); it('uses a bottom right offset origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, offset: offset, @@ -211,7 +209,7 @@ describe('ol.style.Icon', function() { }); it('uses a top right offset origin', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png', size: size, offset: offset, @@ -228,19 +226,19 @@ describe('ol.style.Icon', function() { it('takes the real image size', function() { // pretend that the image is already in the cache, // this image will be used for the icon. - var cache = ol.style.iconImageCache; + var cache = _ol_style_.iconImageCache; var src = 'test.png'; - var iconImage = new ol.style.IconImage(null, 'test.png', imgSize); + var iconImage = new _ol_style_IconImage_(null, 'test.png', imgSize); cache.set(src, null, null, iconImage); - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ src: 'test.png' }); expect(iconStyle.getImageSize()).to.eql(imgSize); }); it('uses the given image size', function() { - var iconStyle = new ol.style.Icon({ + var iconStyle = new _ol_style_Icon_({ img: {src: 'test.png'}, imgSize: imgSize }); diff --git a/test/spec/ol/style/iconimagecache.test.js b/test/spec/ol/style/iconimagecache.test.js index bb3daa3321..a41dbbb486 100644 --- a/test/spec/ol/style/iconimagecache.test.js +++ b/test/spec/ol/style/iconimagecache.test.js @@ -1,35 +1,33 @@ - - -goog.require('ol'); -goog.require('ol.events'); -goog.require('ol.style'); -goog.require('ol.style.IconImage'); +import _ol_ from '../../../../src/ol.js'; +import _ol_events_ from '../../../../src/ol/events.js'; +import _ol_style_ from '../../../../src/ol/style.js'; +import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js'; describe('ol.style.IconImageCache', function() { var originalMaxCacheSize; beforeEach(function() { - var cache = ol.style.iconImageCache; + var cache = _ol_style_.iconImageCache; cache.clear(); originalMaxCacheSize = cache.maxCacheSize; cache.maxCacheSize_ = 4; }); afterEach(function() { - var cache = ol.style.iconImageCache; + var cache = _ol_style_.iconImageCache; cache.maxCacheSize_ = originalMaxCacheSize; cache.clear(); }); describe('#expire', function() { it('expires images when expected', function() { - var cache = ol.style.iconImageCache; + var cache = _ol_style_.iconImageCache; var i, src, iconImage; for (i = 0; i < 4; ++i) { src = i + ''; - iconImage = new ol.style.IconImage(null, src); + iconImage = new _ol_style_IconImage_(null, src); cache.set(src, null, null, iconImage); } @@ -39,7 +37,7 @@ describe('ol.style.IconImageCache', function() { expect(cache.cacheSize_).to.eql(4); src = '4'; - iconImage = new ol.style.IconImage(null, src); + iconImage = new _ol_style_IconImage_(null, src); cache.set(src, null, null, iconImage); expect(cache.cacheSize_).to.eql(5); @@ -47,16 +45,16 @@ describe('ol.style.IconImageCache', function() { expect(cache.cacheSize_).to.eql(3); src = '0'; - iconImage = new ol.style.IconImage(null, src); - ol.events.listen(iconImage, 'change', - ol.nullFunction, false); + iconImage = new _ol_style_IconImage_(null, src); + _ol_events_.listen(iconImage, 'change', + _ol_.nullFunction, false); cache.set(src, null, null, iconImage); expect(cache.cacheSize_).to.eql(4); src = '4'; - iconImage = new ol.style.IconImage(null, src); - ol.events.listen(iconImage, 'change', - ol.nullFunction, false); + iconImage = new _ol_style_IconImage_(null, src); + _ol_events_.listen(iconImage, 'change', + _ol_.nullFunction, false); cache.set(src, null, null, iconImage); expect(cache.cacheSize_).to.eql(5); @@ -69,13 +67,13 @@ describe('ol.style.IconImageCache', function() { describe('#setSize', function() { it('sets max cache size and expires cache', function() { - var cache = ol.style.iconImageCache; + var cache = _ol_style_.iconImageCache; var i, src, iconImage; for (i = 0; i < 3; ++i) { src = i + ''; - iconImage = new ol.style.IconImage(null, src); + iconImage = new _ol_style_IconImage_(null, src); cache.set(src, null, null, iconImage); } diff --git a/test/spec/ol/style/regularshape.test.js b/test/spec/ol/style/regularshape.test.js index a2a7be8bfa..9442bdd189 100644 --- a/test/spec/ol/style/regularshape.test.js +++ b/test/spec/ol/style/regularshape.test.js @@ -1,9 +1,7 @@ - - -goog.require('ol.style.AtlasManager'); -goog.require('ol.style.RegularShape'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); +import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js'; +import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.style.RegularShape', function() { @@ -11,7 +9,7 @@ describe('ol.style.RegularShape', function() { describe('#constructor', function() { it('can use rotateWithView', function() { - var style = new ol.style.RegularShape({ + var style = new _ol_style_RegularShape_({ rotateWithView: true, radius: 0 }); @@ -19,7 +17,7 @@ describe('ol.style.RegularShape', function() { }); it('can use radius', function() { - var style = new ol.style.RegularShape({ + var style = new _ol_style_RegularShape_({ radius: 5, radius2: 10 }); @@ -28,7 +26,7 @@ describe('ol.style.RegularShape', function() { }); it('can use radius1 as an alias for radius', function() { - var style = new ol.style.RegularShape({ + var style = new _ol_style_RegularShape_({ radius1: 5, radius2: 10 }); @@ -37,7 +35,7 @@ describe('ol.style.RegularShape', function() { }); it('creates a canvas if no atlas is used (no fill-style)', function() { - var style = new ol.style.RegularShape({radius: 10}); + var style = new _ol_style_RegularShape_({radius: 10}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); expect(style.getImageSize()).to.eql([21, 21]); @@ -50,9 +48,9 @@ describe('ol.style.RegularShape', function() { }); it('creates a canvas if no atlas is used (fill-style)', function() { - var style = new ol.style.RegularShape({ + var style = new _ol_style_RegularShape_({ radius: 10, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#FFFF00' }) }); @@ -68,8 +66,8 @@ describe('ol.style.RegularShape', function() { }); it('adds itself to an atlas manager (no fill-style)', function() { - var atlasManager = new ol.style.AtlasManager({initialSize: 512}); - var style = new ol.style.RegularShape( + var atlasManager = new _ol_style_AtlasManager_({initialSize: 512}); + var style = new _ol_style_RegularShape_( {radius: 10, atlasManager: atlasManager}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); @@ -83,11 +81,11 @@ describe('ol.style.RegularShape', function() { }); it('adds itself to an atlas manager (fill-style)', function() { - var atlasManager = new ol.style.AtlasManager({initialSize: 512}); - var style = new ol.style.RegularShape({ + var atlasManager = new _ol_style_AtlasManager_({initialSize: 512}); + var style = new _ol_style_RegularShape_({ radius: 10, atlasManager: atlasManager, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#FFFF00' }) }); @@ -106,17 +104,17 @@ describe('ol.style.RegularShape', function() { describe('#clone', function() { it('creates a new ol.style.RegularShape', function() { - var original = new ol.style.RegularShape({ + var original = new _ol_style_RegularShape_({ points: 5 }); var clone = original.clone(); - expect(clone).to.be.an(ol.style.RegularShape); + expect(clone).to.be.an(_ol_style_RegularShape_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.RegularShape({ - fill: new ol.style.Fill({ + var original = new _ol_style_RegularShape_({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), points: 5, @@ -124,7 +122,7 @@ describe('ol.style.RegularShape', function() { radius2: 6, angle: 1, snapToPixel: false, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }), rotation: 2, @@ -147,11 +145,11 @@ describe('ol.style.RegularShape', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.RegularShape({ - fill: new ol.style.Fill({ + var original = new _ol_style_RegularShape_({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -170,11 +168,11 @@ describe('ol.style.RegularShape', function() { describe('#getChecksum', function() { it('calculates not the same hash code (radius)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 4, radius2: 5 }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 3, radius2: 5 }); @@ -182,11 +180,11 @@ describe('ol.style.RegularShape', function() { }); it('calculates not the same hash code (radius2)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 4, radius2: 5 }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 4, radius2: 6 }); @@ -194,25 +192,25 @@ describe('ol.style.RegularShape', function() { }); it('calculates the same hash code (radius)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5 }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5 }); expect(style1.getChecksum()).to.eql(style2.getChecksum()); }); it('calculates not the same hash code (color)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }) }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5, - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -220,15 +218,15 @@ describe('ol.style.RegularShape', function() { }); it('calculates the same hash code (everything set)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5, radius2: 3, angle: 1.41, points: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -237,15 +235,15 @@ describe('ol.style.RegularShape', function() { width: 2 }) }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5, radius2: 3, angle: 1.41, points: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -258,15 +256,15 @@ describe('ol.style.RegularShape', function() { }); it('calculates not the same hash code (stroke width differs)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5, radius2: 3, angle: 1.41, points: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -275,15 +273,15 @@ describe('ol.style.RegularShape', function() { width: 3 }) }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5, radius2: 3, angle: 1.41, points: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'round', lineDash: [5, 15, 25], @@ -296,21 +294,21 @@ describe('ol.style.RegularShape', function() { }); it('invalidates a cached checksum if values change (fill)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -321,21 +319,21 @@ describe('ol.style.RegularShape', function() { }); it('invalidates a cached checksum if values change (stroke)', function() { - var style1 = new ol.style.RegularShape({ + var style1 = new _ol_style_RegularShape_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); - var style2 = new ol.style.RegularShape({ + var style2 = new _ol_style_RegularShape_({ radius: 5, - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); diff --git a/test/spec/ol/style/stroke.test.js b/test/spec/ol/style/stroke.test.js index d7a12db386..d16f42094a 100644 --- a/test/spec/ol/style/stroke.test.js +++ b/test/spec/ol/style/stroke.test.js @@ -1,20 +1,18 @@ - - -goog.require('ol.style.Stroke'); +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; describe('ol.style.Stroke', function() { describe('#clone', function() { it('creates a new ol.style.Stroke', function() { - var original = new ol.style.Stroke(); + var original = new _ol_style_Stroke_(); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Stroke); + expect(clone).to.be.an(_ol_style_Stroke_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.Stroke({ + var original = new _ol_style_Stroke_({ color: '#319FD3', lineCap: 'square', lineJoin: 'miter', @@ -34,7 +32,7 @@ describe('ol.style.Stroke', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Stroke({ + var original = new _ol_style_Stroke_({ color: [1, 2, 3, 0.4], lineDash: [1, 2, 3] }); diff --git a/test/spec/ol/style/style.test.js b/test/spec/ol/style/style.test.js index 51659a53df..ea97bd14a6 100644 --- a/test/spec/ol/style/style.test.js +++ b/test/spec/ol/style/style.test.js @@ -1,62 +1,60 @@ - - -goog.require('ol.Feature'); -goog.require('ol.geom.Point'); -goog.require('ol.style.Style'); -goog.require('ol.style.Fill'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Text'); +import _ol_Feature_ from '../../../../src/ol/Feature.js'; +import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; +import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; describe('ol.style.Style', function() { - var testFill = new ol.style.Fill({ + var testFill = new _ol_style_Fill_({ color: 'rgba(255, 255, 255, 0.6)' }); - var testStroke = new ol.style.Stroke({ + var testStroke = new _ol_style_Stroke_({ color: '#319FD3', width: 1 }); - var testText = new ol.style.Text({ + var testText = new _ol_style_Text_({ font: '12px Calibri,sans-serif', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#000' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#fff', width: 3 }) }); - var testImage = new ol.style.Circle({ + var testImage = new _ol_style_Circle_({ radius: 5 }); describe('#clone', function() { it('creates a new ol.style.Style', function() { - var original = new ol.style.Style(); + var original = new _ol_style_Style_(); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Style); + expect(clone).to.be.an(_ol_style_Style_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.Style({ - geometry: new ol.geom.Point([0, 0, 0]), - fill: new ol.style.Fill({ + var original = new _ol_style_Style_({ + geometry: new _ol_geom_Point_([0, 0, 0]), + fill: new _ol_style_Fill_({ color: '#319FD3' }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 5 }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: 'test' }), zIndex: 2 @@ -71,18 +69,18 @@ describe('ol.style.Style', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Style({ - geometry: new ol.geom .Point([0, 0, 0]), - fill: new ol.style.Fill({ + var original = new _ol_style_Style_({ + geometry: new _ol_geom_Point_([0, 0, 0]), + fill: new _ol_style_Fill_({ color: '#319FD3' }), - image: new ol.style.Circle({ + image: new _ol_style_Circle_({ radius: 5 }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }), - text: new ol.style.Text({ + text: new _ol_style_Text_({ text: 'test' }) }); @@ -109,7 +107,7 @@ describe('ol.style.Style', function() { describe('#setZIndex', function() { it('sets the zIndex', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); style.setZIndex(0.7); expect(style.getZIndex()).to.be(0.7); @@ -117,7 +115,7 @@ describe('ol.style.Style', function() { }); describe('#getFill', function() { - var style = new ol.style.Style({ + var style = new _ol_style_Style_({ fill: testFill }); @@ -127,7 +125,7 @@ describe('ol.style.Style', function() { }); describe('#setFill', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('sets the fill style of a style', function() { style.setFill(testFill); @@ -136,7 +134,7 @@ describe('ol.style.Style', function() { }); describe('#getImage', function() { - var style = new ol.style.Style({ + var style = new _ol_style_Style_({ image: testImage }); @@ -146,7 +144,7 @@ describe('ol.style.Style', function() { }); describe('#setImage', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('sets the image style of a style', function() { style.setImage(testImage); @@ -155,7 +153,7 @@ describe('ol.style.Style', function() { }); describe('#getStroke', function() { - var style = new ol.style.Style({ + var style = new _ol_style_Style_({ stroke: testStroke }); @@ -165,7 +163,7 @@ describe('ol.style.Style', function() { }); describe('#setStroke', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('sets the stroke style of a style', function() { style.setStroke(testStroke); @@ -174,7 +172,7 @@ describe('ol.style.Style', function() { }); describe('#getText', function() { - var style = new ol.style.Style({ + var style = new _ol_style_Style_({ text: testText }); @@ -184,7 +182,7 @@ describe('ol.style.Style', function() { }); describe('#setText', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('sets the text style of a style', function() { style.setText(testText); @@ -193,25 +191,25 @@ describe('ol.style.Style', function() { }); describe('#setGeometry', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('creates a geometry function from a string', function() { - var feature = new ol.Feature(); - feature.set('myGeom', new ol.geom.Point([0, 0])); + var feature = new _ol_Feature_(); + feature.set('myGeom', new _ol_geom_Point_([0, 0])); style.setGeometry('myGeom'); expect(style.getGeometryFunction()(feature)) .to.eql(feature.get('myGeom')); }); it('creates a geometry function from a geometry', function() { - var geom = new ol.geom.Point([0, 0]); + var geom = new _ol_geom_Point_([0, 0]); style.setGeometry(geom); expect(style.getGeometryFunction()()) .to.eql(geom); }); it('returns the configured geometry function', function() { - var geom = new ol.geom.Point([0, 0]); + var geom = new _ol_geom_Point_([0, 0]); style.setGeometry(function() { return geom; }); @@ -223,10 +221,10 @@ describe('ol.style.Style', function() { describe('#getGeometry', function() { it('returns whatever was passed to setGeometry', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); style.setGeometry('foo'); expect(style.getGeometry()).to.eql('foo'); - var geom = new ol.geom.Point([1, 2]); + var geom = new _ol_geom_Point_([1, 2]); style.setGeometry(geom); expect(style.getGeometry()).to.eql(geom); var fn = function() { @@ -243,15 +241,15 @@ describe('ol.style.Style', function() { }); describe('ol.style.Style.createFunction()', function() { - var style = new ol.style.Style(); + var style = new _ol_style_Style_(); it('creates a style function from a single style', function() { - var styleFunction = ol.style.Style.createFunction(style); + var styleFunction = _ol_style_Style_.createFunction(style); expect(styleFunction()).to.eql([style]); }); it('creates a style function from an array of styles', function() { - var styleFunction = ol.style.Style.createFunction([style]); + var styleFunction = _ol_style_Style_.createFunction([style]); expect(styleFunction()).to.eql([style]); }); @@ -259,13 +257,13 @@ describe('ol.style.Style.createFunction()', function() { var original = function() { return [style]; }; - var styleFunction = ol.style.Style.createFunction(original); + var styleFunction = _ol_style_Style_.createFunction(original); expect(styleFunction).to.be(original); }); it('throws on (some) unexpected input', function() { expect(function() { - ol.style.Style.createFunction({bogus: 'input'}); + _ol_style_Style_.createFunction({bogus: 'input'}); }).to.throwException(); }); diff --git a/test/spec/ol/style/text.test.js b/test/spec/ol/style/text.test.js index 61a22637eb..412c89a8c0 100644 --- a/test/spec/ol/style/text.test.js +++ b/test/spec/ol/style/text.test.js @@ -1,8 +1,6 @@ - - -goog.require('ol.style.Fill'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Text'); +import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; +import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; +import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; describe('ol.style.Text', function() { @@ -10,19 +8,19 @@ describe('ol.style.Text', function() { describe('#constructor', function() { it('uses a default fill style if none passed', function() { - var style = new ol.style.Text(); + var style = new _ol_style_Text_(); expect(style.getFill().getColor()).to.be('#333'); }); it('uses a provided fill style if one passed', function() { - var style = new ol.style.Text({ - fill: new ol.style.Fill({color: '#123456'}) + var style = new _ol_style_Text_({ + fill: new _ol_style_Fill_({color: '#123456'}) }); expect(style.getFill().getColor()).to.be('#123456'); }); it('can always be resetted to no color', function() { - var style = new ol.style.Text(); + var style = new _ol_style_Text_(); style.getFill().setColor(); expect(style.getFill().getColor()).to.be(undefined); }); @@ -32,14 +30,14 @@ describe('ol.style.Text', function() { describe('#clone', function() { it('creates a new ol.style.Text', function() { - var original = new ol.style.Text(); + var original = new _ol_style_Text_(); var clone = original.clone(); - expect(clone).to.be.an(ol.style.Text); + expect(clone).to.be.an(_ol_style_Text_); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new ol.style.Text({ + var original = new _ol_style_Text_({ font: '12px serif', offsetX: 4, offsetY: 10, @@ -49,10 +47,10 @@ describe('ol.style.Text', function() { text: 'test', textAlign: 'center', textBaseline: 'top', - fill: new ol.style.Fill({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); @@ -71,11 +69,11 @@ describe('ol.style.Text', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new ol.style.Text({ - fill: new ol.style.Fill({ + var original = new _ol_style_Text_({ + fill: new _ol_style_Fill_({ color: '#319FD3' }), - stroke: new ol.style.Stroke({ + stroke: new _ol_style_Stroke_({ color: '#319FD3' }) }); diff --git a/test/spec/ol/tile.test.js b/test/spec/ol/tile.test.js index a8d2b39115..cda9d3ad97 100644 --- a/test/spec/ol/tile.test.js +++ b/test/spec/ol/tile.test.js @@ -1,21 +1,21 @@ -goog.require('ol'); -goog.require('ol.ImageTile'); -goog.require('ol.Tile'); -goog.require('ol.TileState'); +import _ol_ from '../../../src/ol.js'; +import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; +import _ol_Tile_ from '../../../src/ol/Tile.js'; +import _ol_TileState_ from '../../../src/ol/TileState.js'; describe('ol.Tile', function() { describe('constructor', function() { it('sets a default transition', function() { var coord = [0, 0, 0]; - var tile = new ol.Tile(coord, ol.TileState.IDLE); + var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); expect(tile.transition_).to.equal(250); }); it('allows the transition to be set', function() { var coord = [0, 0, 0]; var transition = 500; - var tile = new ol.Tile(coord, ol.TileState.IDLE, {transition: transition}); + var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE, {transition: transition}); expect(tile.transition_).to.equal(transition); }); }); @@ -23,7 +23,7 @@ describe('ol.Tile', function() { describe('#getAlpha()', function() { it('returns the alpha value for a tile in transition', function() { var coord = [0, 0, 0]; - var tile = new ol.Tile(coord, ol.TileState.IDLE); + var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); var id = 'test'; var time = Date.now(); @@ -45,7 +45,7 @@ describe('ol.Tile', function() { describe('#inTransition()', function() { it('determines if the tile is in transition', function() { var coord = [0, 0, 0]; - var tile = new ol.Tile(coord, ol.TileState.IDLE); + var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); var id = 'test'; expect(tile.inTransition(id)).to.be(true); @@ -58,24 +58,24 @@ describe('ol.Tile', function() { var head, renderTile; beforeEach(function() { var tileCoord = [0, 0, 0]; - head = new ol.ImageTile(tileCoord, ol.TileState.IDLE); - ol.getUid(head); + head = new _ol_ImageTile_(tileCoord, _ol_TileState_.IDLE); + _ol_.getUid(head); var addToChain = function(tile, state) { - var next = new ol.ImageTile(tileCoord, state); - ol.getUid(next); + var next = new _ol_ImageTile_(tileCoord, state); + _ol_.getUid(next); tile.interimTile = next; return next; }; - var tail = addToChain(head, ol.TileState.IDLE); //discard, deprecated by head - tail = addToChain(tail, ol.TileState.LOADING); //keep, request already going - tail = addToChain(tail, ol.TileState.IDLE); //discard, deprecated by head - tail = addToChain(tail, ol.TileState.LOADED); //keep, use for rendering + var tail = addToChain(head, _ol_TileState_.IDLE); //discard, deprecated by head + tail = addToChain(tail, _ol_TileState_.LOADING); //keep, request already going + tail = addToChain(tail, _ol_TileState_.IDLE); //discard, deprecated by head + tail = addToChain(tail, _ol_TileState_.LOADED); //keep, use for rendering renderTile = tail; //store this tile for later tests - tail = addToChain(tail, ol.TileState.IDLE); //rest of list outdated by tile above - tail = addToChain(tail, ol.TileState.LOADED); - tail = addToChain(tail, ol.TileState.LOADING); - tail = addToChain(tail, ol.TileState.LOADED); + tail = addToChain(tail, _ol_TileState_.IDLE); //rest of list outdated by tile above + tail = addToChain(tail, _ol_TileState_.LOADED); + tail = addToChain(tail, _ol_TileState_.LOADING); + tail = addToChain(tail, _ol_TileState_.LOADED); }); @@ -112,7 +112,7 @@ describe('ol.Tile', function() { head.refreshInterimChain(); while (head.interimTile !== null) { //use property of ol.getUid returning increasing id's. - expect(ol.getUid(head) < ol.getUid(head.interimTile)); + expect(_ol_.getUid(head) < _ol_.getUid(head.interimTile)); head = head.interimTile; } done(); diff --git a/test/spec/ol/tilecache.test.js b/test/spec/ol/tilecache.test.js index d0ab6b7c54..f1f4735b4e 100644 --- a/test/spec/ol/tilecache.test.js +++ b/test/spec/ol/tilecache.test.js @@ -1,6 +1,6 @@ -goog.require('ol.Tile'); -goog.require('ol.TileCache'); -goog.require('ol.tilecoord'); +import _ol_Tile_ from '../../../src/ol/Tile.js'; +import _ol_TileCache_ from '../../../src/ol/TileCache.js'; +import _ol_tilecoord_ from '../../../src/ol/tilecoord.js'; describe('ol.TileCache', function() { @@ -8,20 +8,20 @@ describe('ol.TileCache', function() { describe('#pruneExceptNewestZ()', function() { it('gets rid of all entries that are not at the newest z', function() { var tiles = [ - new ol.Tile([0, 0, 0]), - new ol.Tile([1, 0, 0]), - new ol.Tile([1, 1, 0]), - new ol.Tile([2, 0, 0]), - new ol.Tile([2, 1, 0]), - new ol.Tile([2, 2, 0]), - new ol.Tile([2, 3, 0]) // newest tile at z: 2 + new _ol_Tile_([0, 0, 0]), + new _ol_Tile_([1, 0, 0]), + new _ol_Tile_([1, 1, 0]), + new _ol_Tile_([2, 0, 0]), + new _ol_Tile_([2, 1, 0]), + new _ol_Tile_([2, 2, 0]), + new _ol_Tile_([2, 3, 0]) // newest tile at z: 2 ]; - var cache = new ol.TileCache(); + var cache = new _ol_TileCache_(); sinon.spy(tiles[0], 'dispose'); tiles.forEach(function(tile) { - cache.set(ol.tilecoord.getKey(tile.tileCoord), tile); + cache.set(_ol_tilecoord_.getKey(tile.tileCoord), tile); }); cache.pruneExceptNewestZ(); diff --git a/test/spec/ol/tilecoord.test.js b/test/spec/ol/tilecoord.test.js index f1e4cd44fa..cfd61acfd5 100644 --- a/test/spec/ol/tilecoord.test.js +++ b/test/spec/ol/tilecoord.test.js @@ -1,5 +1,5 @@ -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_tilecoord_ from '../../../src/ol/tilecoord.js'; +import _ol_tilegrid_TileGrid_ from '../../../src/ol/tilegrid/TileGrid.js'; describe('ol.TileCoord', function() { @@ -16,14 +16,14 @@ describe('ol.TileCoord', function() { describe('call quadKey', function() { it('returns expected string', function() { var tileCoord = [3, 3, 5]; - var s = ol.tilecoord.quadKey(tileCoord); + var s = _ol_tilecoord_.quadKey(tileCoord); expect(s).to.eql('213'); }); }); describe('getKey()', function() { it('returns a key for a tile coord', function() { - var key = ol.tilecoord.getKey([1, 2, 3]); + var key = _ol_tilecoord_.getKey([1, 2, 3]); expect(key).to.eql('1/2/3'); }); }); @@ -31,9 +31,9 @@ describe('ol.TileCoord', function() { describe('fromKey()', function() { it('returns a tile coord given a key', function() { var tileCoord = [1, 2, 3]; - var key = ol.tilecoord.getKey(tileCoord); + var key = _ol_tilecoord_.getKey(tileCoord); - var returned = ol.tilecoord.fromKey(key); + var returned = _ol_tilecoord_.fromKey(key); expect(returned).to.eql(tileCoord); }); }); @@ -42,80 +42,80 @@ describe('ol.TileCoord', function() { it('produces different hashes for different tile coords', function() { var tileCoord1 = [3, 2, 1]; var tileCoord2 = [3, 1, 1]; - expect(ol.tilecoord.hash(tileCoord1)).not.to.eql( - ol.tilecoord.hash(tileCoord2)); + expect(_ol_tilecoord_.hash(tileCoord1)).not.to.eql( + _ol_tilecoord_.hash(tileCoord2)); }); }); describe('withinExtentAndZ', function() { it('restricts by z', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ extent: [10, 20, 30, 40], tileSize: 10, resolutions: [2, 1], minZoom: 1 }); - expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([1, 0, -1], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([2, 0, -1], tileGrid)).to.be(false); }); it('restricts by extent when extent defines tile ranges', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ extent: [10, 20, 30, 40], sizes: [[3, -3]], tileSize: 10, resolutions: [1] }); - expect(ol.tilecoord.withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 1, -2], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([0, 2, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -3], tileGrid)).to.be(false); }); it('restricts by extent when sizes define tile ranges', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 20], sizes: [[3, 3]], tileSize: 10, resolutions: [1] }); - expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false); }); it('restricts by extent when sizes (neg y) define tile ranges', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 40], sizes: [[3, -3]], tileSize: 10, resolutions: [1] }); - expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false); - expect(ol.tilecoord.withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([0, -1, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 2, -3], tileGrid)).to.be(true); + expect(_ol_tilecoord_.withinExtentAndZ([0, 3, -1], tileGrid)).to.be(false); + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, -4], tileGrid)).to.be(false); }); it('does not restrict by extent with no extent or sizes', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 20], tileSize: 10, resolutions: [1] }); - expect(ol.tilecoord.withinExtentAndZ([0, Infinity, 0], tileGrid)) + expect(_ol_tilecoord_.withinExtentAndZ([0, Infinity, 0], tileGrid)) .to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, 0, Infinity], tileGrid)) + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, Infinity], tileGrid)) .to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, -Infinity, 0], tileGrid)) + expect(_ol_tilecoord_.withinExtentAndZ([0, -Infinity, 0], tileGrid)) .to.be(true); - expect(ol.tilecoord.withinExtentAndZ([0, 0, Infinity], tileGrid)) + expect(_ol_tilecoord_.withinExtentAndZ([0, 0, Infinity], tileGrid)) .to.be(true); }); }); diff --git a/test/spec/ol/tilegrid/tilegrid.test.js b/test/spec/ol/tilegrid/tilegrid.test.js index 21ac5e381b..6888aea045 100644 --- a/test/spec/ol/tilegrid/tilegrid.test.js +++ b/test/spec/ol/tilegrid/tilegrid.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol'); -goog.require('ol.TileRange'); -goog.require('ol.extent'); -goog.require('ol.proj'); -goog.require('ol.proj.EPSG3857'); -goog.require('ol.proj.Projection'); -goog.require('ol.tilegrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_ from '../../../../src/ol.js'; +import _ol_TileRange_ from '../../../../src/ol/TileRange.js'; +import _ol_extent_ from '../../../../src/ol/extent.js'; +import _ol_proj_ from '../../../../src/ol/proj.js'; +import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; +import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; +import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js'; describe('ol.tilegrid.TileGrid', function() { @@ -24,7 +22,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create valid', function() { it('does not throw an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -36,7 +34,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with duplicate resolutions', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 50, 25, 10], origin: origin, tileSize: tileSize @@ -49,7 +47,7 @@ describe('ol.tilegrid.TileGrid', function() { it('throws an exception', function() { var resolutions = [100, 25, 50, 10]; expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -61,7 +59,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with multiple origins', function() { it('does not throw an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], origins: [origin, origin, origin, origin], tileSize: tileSize @@ -73,7 +71,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with both origin and multiple origins', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], origins: [origin, origin, origin, origin], origin: origin, @@ -86,7 +84,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with too few origins', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], origins: [origin, origin, origin], tileSize: tileSize @@ -98,7 +96,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with too many origins', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], origins: [origin, origin, origin, origin, origin], tileSize: tileSize @@ -110,7 +108,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with multiple tileSizes', function() { it('does not throw an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], tileSizes: [tileSize, tileSize, tileSize, tileSize], origin: origin @@ -122,7 +120,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with both tileSize and multiple tileSizes', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], tileSizes: [tileSize, tileSize, tileSize, tileSize], tileSize: tileSize, @@ -135,7 +133,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with too few tileSizes', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], tileSizes: [tileSize, tileSize, tileSize], origin: origin @@ -147,7 +145,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with too many tileSizes', function() { it('throws an exception', function() { expect(function() { - return new ol.tilegrid.TileGrid({ + return new _ol_tilegrid_TileGrid_({ resolutions: [100, 50, 25, 10], tileSizes: [tileSize, tileSize, tileSize, tileSize, tileSize], origin: origin @@ -159,7 +157,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with origin', function() { var tileGrid; beforeEach(function() { - tileGrid = new ol.tilegrid.TileGrid({ + tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 20], tileSize: 10, resolutions: [1] @@ -182,7 +180,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with extent', function() { var tileGrid; beforeEach(function() { - tileGrid = new ol.tilegrid.TileGrid({ + tileGrid = new _ol_tilegrid_TileGrid_({ extent: [10, 20, 30, 40], tileSize: 10, resolutions: [1] @@ -205,7 +203,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with extent and sizes', function() { var tileGrid; beforeEach(function() { - tileGrid = new ol.tilegrid.TileGrid({ + tileGrid = new _ol_tilegrid_TileGrid_({ extent: [10, 20, 30, 40], sizes: [[3, -3]], tileSize: 10, @@ -229,7 +227,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with top-left origin and sizes', function() { var tileGrid; beforeEach(function() { - tileGrid = new ol.tilegrid.TileGrid({ + tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 40], sizes: [[3, -3]], tileSize: 10, @@ -247,7 +245,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with bottom-left origin and sizes', function() { var tileGrid; beforeEach(function() { - tileGrid = new ol.tilegrid.TileGrid({ + tileGrid = new _ol_tilegrid_TileGrid_({ origin: [10, 10], sizes: [[3, 3]], tileSize: 10, @@ -264,7 +262,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('create with extent and origin', function() { it('uses both origin and extent', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ origin: [0, 0], extent: [10, 20, 30, 40], tileSize: 10, @@ -277,19 +275,19 @@ describe('ol.tilegrid.TileGrid', function() { describe('createForExtent', function() { it('allows creation of tile grid from extent', function() { - var extent = ol.extent.createOrUpdate(-100, -100, 100, 100); - var grid = ol.tilegrid.createForExtent(extent); - expect(grid).to.be.a(ol.tilegrid.TileGrid); + var extent = _ol_extent_.createOrUpdate(-100, -100, 100, 100); + var grid = _ol_tilegrid_.createForExtent(extent); + expect(grid).to.be.a(_ol_tilegrid_TileGrid_); var resolutions = grid.getResolutions(); - expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1); + expect(resolutions.length).to.be(_ol_.DEFAULT_MAX_ZOOM + 1); expect(grid.getOrigin()).to.eql([-100, 100]); }); }); describe('#zoomFactor_', function() { it('is set for a consistent zoom factor', function() { - var grid = new ol.tilegrid.TileGrid({ + var grid = new _ol_tilegrid_TileGrid_({ resolutions: [10, 5, 2.5, 1.25], origin: origin, tileSize: tileSize @@ -298,7 +296,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('is not set for an inconsistent zoom factor', function() { - var grid = new ol.tilegrid.TileGrid({ + var grid = new _ol_tilegrid_TileGrid_({ resolutions: [10, 5, 3, 1.25], origin: origin, tileSize: tileSize @@ -310,83 +308,83 @@ describe('ol.tilegrid.TileGrid', function() { describe('createForProjection', function() { it('allows easier creation of a tile grid', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection(projection); - expect(grid).to.be.a(ol.tilegrid.TileGrid); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection(projection); + expect(grid).to.be.a(_ol_tilegrid_TileGrid_); var resolutions = grid.getResolutions(); - expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1); + expect(resolutions.length).to.be(_ol_.DEFAULT_MAX_ZOOM + 1); }); it('accepts a number of zoom levels', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection(projection, 18); - expect(grid).to.be.a(ol.tilegrid.TileGrid); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection(projection, 18); + expect(grid).to.be.a(_ol_tilegrid_TileGrid_); var resolutions = grid.getResolutions(); expect(resolutions.length).to.be(19); }); it('accepts a big number of zoom levels', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection(projection, 23); - expect(grid).to.be.a(ol.tilegrid.TileGrid); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection(projection, 23); + expect(grid).to.be.a(_ol_tilegrid_TileGrid_); var resolutions = grid.getResolutions(); expect(resolutions.length).to.be(24); }); it('works for projections unknown to the client', function() { - var projection = new ol.proj.Projection( + var projection = new _ol_proj_Projection_( {code: 'EPSG:31287', units: 'm'}); - var grid = ol.tilegrid.createForProjection(projection); + var grid = _ol_tilegrid_.createForProjection(projection); var resolutions = grid.getResolutions(); expect(resolutions[5]).to.be( - 360 * ol.proj.METERS_PER_UNIT['degrees'] / - ol.DEFAULT_TILE_SIZE / Math.pow(2, 5)); + 360 * _ol_proj_.METERS_PER_UNIT['degrees'] / + _ol_.DEFAULT_TILE_SIZE / Math.pow(2, 5)); }); it('assumes origin is top-left', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection(projection); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection(projection); var origin = grid.getOrigin(); - var half = ol.proj.EPSG3857.HALF_SIZE; + var half = _ol_proj_EPSG3857_.HALF_SIZE; expect(origin).to.eql([-half, half]); }); it('accepts bottom-left as corner', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection( + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection( projection, undefined, undefined, 'bottom-left'); var origin = grid.getOrigin(); - var half = ol.proj.EPSG3857.HALF_SIZE; + var half = _ol_proj_EPSG3857_.HALF_SIZE; expect(origin).to.eql([-half, -half]); }); it('accepts bottom-right as corner', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection( + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection( projection, undefined, undefined, 'bottom-right'); var origin = grid.getOrigin(); - var half = ol.proj.EPSG3857.HALF_SIZE; + var half = _ol_proj_EPSG3857_.HALF_SIZE; expect(origin).to.eql([half, -half]); }); it('accepts top-left as corner', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection( + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection( projection, undefined, undefined, 'top-left'); var origin = grid.getOrigin(); - var half = ol.proj.EPSG3857.HALF_SIZE; + var half = _ol_proj_EPSG3857_.HALF_SIZE; expect(origin).to.eql([-half, half]); }); it('accepts top-right as corner', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.createForProjection( + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.createForProjection( projection, undefined, undefined, 'top-right'); var origin = grid.getOrigin(); - var half = ol.proj.EPSG3857.HALF_SIZE; + var half = _ol_proj_EPSG3857_.HALF_SIZE; expect(origin).to.eql([half, half]); }); @@ -395,16 +393,16 @@ describe('ol.tilegrid.TileGrid', function() { describe('createXYZ()', function() { it('uses defaults', function() { - var tileGrid = ol.tilegrid.createXYZ(); + var tileGrid = _ol_tilegrid_.createXYZ(); expect(tileGrid.getExtent()).to.eql( - ol.proj.get('EPSG:3857').getExtent()); + _ol_proj_.get('EPSG:3857').getExtent()); expect(tileGrid.getMinZoom()).to.equal(0); - expect(tileGrid.getMaxZoom()).to.equal(ol.DEFAULT_MAX_ZOOM); - expect(tileGrid.getTileSize()).to.equal(ol.DEFAULT_TILE_SIZE); + expect(tileGrid.getMaxZoom()).to.equal(_ol_.DEFAULT_MAX_ZOOM); + expect(tileGrid.getTileSize()).to.equal(_ol_.DEFAULT_TILE_SIZE); }); it('respects configuration options', function() { - var tileGrid = ol.tilegrid.createXYZ({ + var tileGrid = _ol_tilegrid_.createXYZ({ extent: [10, 20, 30, 40], minZoom: 1, maxZoom: 2, @@ -421,19 +419,19 @@ describe('ol.tilegrid.TileGrid', function() { describe('getForProjection', function() { it('gets the default tile grid for a projection', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.getForProjection(projection); - expect(grid).to.be.a(ol.tilegrid.TileGrid); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.getForProjection(projection); + expect(grid).to.be.a(_ol_tilegrid_TileGrid_); var resolutions = grid.getResolutions(); - expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1); + expect(resolutions.length).to.be(_ol_.DEFAULT_MAX_ZOOM + 1); expect(grid.getTileSize()).to.eql(256); }); it('stores the default tile grid on a projection', function() { - var projection = ol.proj.get('EPSG:3857'); - var grid = ol.tilegrid.getForProjection(projection); - var gridAgain = ol.tilegrid.getForProjection(projection); + var projection = _ol_proj_.get('EPSG:3857'); + var grid = _ol_tilegrid_.getForProjection(projection); + var gridAgain = _ol_tilegrid_.getForProjection(projection); expect(grid).to.be(gridAgain); }); @@ -444,8 +442,8 @@ describe('ol.tilegrid.TileGrid', function() { var tileGrid; beforeEach(function() { - tileGrid = ol.tilegrid.createForExtent( - ol.proj.get('EPSG:3857').getExtent(), 22); + tileGrid = _ol_tilegrid_.createForExtent( + _ol_proj_.get('EPSG:3857').getExtent(), 22); }); it('returns the tile range for one zoom level deeper', function() { @@ -494,8 +492,8 @@ describe('ol.tilegrid.TileGrid', function() { var tileGrid; beforeEach(function() { - tileGrid = ol.tilegrid.createForExtent( - ol.proj.get('EPSG:3857').getExtent(), 22); + tileGrid = _ol_tilegrid_.createForExtent( + _ol_proj_.get('EPSG:3857').getExtent(), 22); }); it('iterates as expected', function() { @@ -506,7 +504,7 @@ describe('ol.tilegrid.TileGrid', function() { tileCoord, function(z, tileRange) { zs.push(z); - tileRanges.push(new ol.TileRange( + tileRanges.push(new _ol_TileRange_( tileRange.minX, tileRange.maxX, tileRange.minY, tileRange.maxY)); return false; @@ -553,8 +551,8 @@ describe('ol.tilegrid.TileGrid', function() { var tileGrid; beforeEach(function() { - tileGrid = ol.tilegrid.createForExtent( - ol.proj.get('EPSG:3857').getExtent(), 22); + tileGrid = _ol_tilegrid_.createForExtent( + _ol_proj_.get('EPSG:3857').getExtent(), 22); }); it('returns the correct resolution at the equator', function() { @@ -588,7 +586,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('Y North, X East', function() { it('returns the expected TileCoord', function() { origin = [0, 0]; - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -620,7 +618,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('Y South, X East', function() { it('returns the expected TileCoord', function() { origin = [0, 100000]; - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -653,7 +651,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getTileCoordForCoordAndResolution', function() { it('returns the expected TileCoord', function() { var tileSize = 256; - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: [10], origin: origin, tileSize: tileSize @@ -730,7 +728,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getTileCoordForXYAndResolution_', function() { it('returns higher tile coord for intersections by default', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -755,7 +753,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('handles alt intersection policy', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -783,7 +781,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getTileCoordCenter', function() { it('returns the expected center', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -806,7 +804,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getTileCoordExtent', function() { it('returns the expected extend', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -835,7 +833,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getTileRangeForExtentAndZ', function() { it('returns the expected TileRange', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -875,7 +873,7 @@ describe('ol.tilegrid.TileGrid', function() { var origin = [0, 0]; it('works with one tile size as number', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ tileSize: 256, resolutions: resolutions, origin: origin @@ -885,7 +883,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('works with one tile size as array', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ tileSize: [512, 256], resolutions: resolutions, origin: origin @@ -895,7 +893,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('works with multiple tile sizes as number', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ tileSizes: [256, 256, 256, 512], resolutions: resolutions, origin: origin @@ -905,7 +903,7 @@ describe('ol.tilegrid.TileGrid', function() { }); it('works with multiple tile sizes as array', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ tileSizes: [[512, 256], [512, 256], [512, 256], [640, 320]], resolutions: resolutions, origin: origin @@ -918,7 +916,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('forEachTileCoord', function() { it('calls the provided function with each tile coordinate', function() { - var tileGrid = ol.tilegrid.createXYZ({extent: [-180, -90, 180, 90]}); + var tileGrid = _ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90]}); var tileCoords = []; tileGrid.forEachTileCoord([15, 47, 16, 48], 8, function(tileCoord) { tileCoords.push(tileCoord); @@ -934,7 +932,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('forEachTileCoordParentTileRange', function() { it('iterates as expected', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -974,7 +972,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getZForResolution (exact)', function() { it('returns the expected z value', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -989,7 +987,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getZForResolution (approximate)', function() { it('returns the expected z value', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -1013,7 +1011,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getZForResolution (lower)', function() { it('returns the expected z value', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize @@ -1037,7 +1035,7 @@ describe('ol.tilegrid.TileGrid', function() { describe('getZForResolution (higher)', function() { it('returns the expected z value', function() { - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: resolutions, origin: origin, tileSize: tileSize diff --git a/test/spec/ol/tilegrid/wmts.test.js b/test/spec/ol/tilegrid/wmts.test.js index cd24479365..188bb75d7f 100644 --- a/test/spec/ol/tilegrid/wmts.test.js +++ b/test/spec/ol/tilegrid/wmts.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.format.WMTSCapabilities'); -goog.require('ol.tilegrid.WMTS'); +import _ol_format_WMTSCapabilities_ from '../../../../src/ol/format/WMTSCapabilities.js'; +import _ol_tilegrid_WMTS_ from '../../../../src/ol/tilegrid/WMTS.js'; describe('ol.tilegrid.WMTS', function() { describe('when creating tileGrid from capabilities', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) { @@ -24,7 +22,7 @@ describe('ol.tilegrid.WMTS', function() { function() { var matrixSetObj = capabilities.Contents.TileMatrixSet[0]; var tileGrid; - tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( + tileGrid = _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet( matrixSetObj); expect(tileGrid.matrixIds_).to.be.an('array'); expect(tileGrid.matrixIds_).to.have.length(20); @@ -62,7 +60,7 @@ describe('ol.tilegrid.WMTS', function() { describe('when creating tileGrid from capabilities with and without TileMatrixSetLimits', function() { - var parser = new ol.format.WMTSCapabilities(); + var parser = new _ol_format_WMTSCapabilities_(); var capabilities; before(function(done) { afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) { @@ -79,7 +77,7 @@ describe('ol.tilegrid.WMTS', function() { function() { var matrixSetObj = capabilities.Contents.TileMatrixSet[0]; var tileGrid; - tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( + tileGrid = _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet( matrixSetObj); expect(tileGrid.matrixIds_).to.be.an('array'); expect(tileGrid.matrixIds_).to.have.length(22); @@ -120,7 +118,7 @@ describe('ol.tilegrid.WMTS', function() { var matrixLimitArray = capabilities.Contents.Layer[0] .TileMatrixSetLink[0].TileMatrixSetLimits; var tileGrid; - tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( + tileGrid = _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet( matrixSetObj, undefined, matrixLimitArray); expect(tileGrid.matrixIds_).to.be.an('array'); expect(tileGrid.matrixIds_).to.have.length(20); diff --git a/test/spec/ol/tilequeue.test.js b/test/spec/ol/tilequeue.test.js index 5c01615663..afd5512135 100644 --- a/test/spec/ol/tilequeue.test.js +++ b/test/spec/ol/tilequeue.test.js @@ -1,11 +1,9 @@ - - -goog.require('ol.ImageTile'); -goog.require('ol.Tile'); -goog.require('ol.TileQueue'); -goog.require('ol.TileState'); -goog.require('ol.source.Image'); -goog.require('ol.structs.PriorityQueue'); +import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; +import _ol_Tile_ from '../../../src/ol/Tile.js'; +import _ol_TileQueue_ from '../../../src/ol/TileQueue.js'; +import _ol_TileState_ from '../../../src/ol/TileState.js'; +import _ol_source_Image_ from '../../../src/ol/source/Image.js'; +import _ol_structs_PriorityQueue_ from '../../../src/ol/structs/PriorityQueue.js'; describe('ol.TileQueue', function() { @@ -13,7 +11,7 @@ describe('ol.TileQueue', function() { function addRandomPriorityTiles(tq, num) { var i, tile, priority; for (i = 0; i < num; i++) { - tile = new ol.Tile(); + tile = new _ol_Tile_(); priority = Math.floor(Math.random() * 100); tq.elements_.push([tile, '', [0, 0]]); tq.priorities_.push(priority); @@ -34,16 +32,16 @@ describe('ol.TileQueue', function() { 'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='; var tileLoadFunction = opt_tileLoadFunction ? - opt_tileLoadFunction : ol.source.Image.defaultImageLoadFunction; - return new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction); + opt_tileLoadFunction : _ol_source_Image_.defaultImageLoadFunction; + return new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); } describe('#loadMoreTiles()', function() { var noop = function() {}; it('works when tile queues share tiles', function(done) { - var q1 = new ol.TileQueue(noop, noop); - var q2 = new ol.TileQueue(noop, noop); + var q1 = new _ol_TileQueue_(noop, noop); + var q2 = new _ol_TileQueue_(noop, noop); var numTiles = 20; for (var i = 0; i < numTiles; ++i) { @@ -93,11 +91,11 @@ describe('ol.TileQueue', function() { it('calls #tileChangeCallback_ when all wanted tiles are aborted', function() { var tileChangeCallback = sinon.spy(); - var queue = new ol.TileQueue(noop, tileChangeCallback); + var queue = new _ol_TileQueue_(noop, tileChangeCallback); var numTiles = 20; for (var i = 0; i < numTiles; ++i) { var tile = createImageTile(); - tile.state = ol.TileState.ABORT; + tile.state = _ol_TileState_.ABORT; queue.enqueue([tile]); } var maxLoading = numTiles / 2; @@ -110,7 +108,7 @@ describe('ol.TileQueue', function() { describe('heapify', function() { it('does convert an arbitrary array into a heap', function() { - var tq = new ol.TileQueue(function() {}); + var tq = new _ol_TileQueue_(function() {}); addRandomPriorityTiles(tq, 100); tq.heapify_(); @@ -120,7 +118,7 @@ describe('ol.TileQueue', function() { describe('reprioritize', function() { it('does reprioritize the array', function() { - var tq = new ol.TileQueue(function() {}); + var tq = new _ol_TileQueue_(function() {}); addRandomPriorityTiles(tq, 100); tq.heapify_(); @@ -131,7 +129,7 @@ describe('ol.TileQueue', function() { var i = 0; tq.priorityFunction_ = function() { if ((i++) % 2 === 0) { - return ol.structs.PriorityQueue.DROP; + return _ol_structs_PriorityQueue_.DROP; } return Math.floor(Math.random() * 100); }; @@ -147,7 +145,7 @@ describe('ol.TileQueue', function() { var noop = function() {}; it('abort queued tiles', function() { - var tq = new ol.TileQueue(noop, noop); + var tq = new _ol_TileQueue_(noop, noop); var tile = createImageTile(); expect(tile.hasListener('change')).to.be(false); @@ -160,7 +158,7 @@ describe('ol.TileQueue', function() { }); it('abort loading tiles', function() { - var tq = new ol.TileQueue(noop, noop); + var tq = new _ol_TileQueue_(noop, noop); var tile = createImageTile(noop); tq.enqueue([tile]); diff --git a/test/spec/ol/tilerange.test.js b/test/spec/ol/tilerange.test.js index a658a34886..81a4748871 100644 --- a/test/spec/ol/tilerange.test.js +++ b/test/spec/ol/tilerange.test.js @@ -1,19 +1,17 @@ - - -goog.require('ol.TileRange'); +import _ol_TileRange_ from '../../../src/ol/TileRange.js'; describe('ol.TileRange', function() { describe('constructor', function() { it('creates a range', function() { - var range = new ol.TileRange(1, 3, 2, 4); - expect(range).to.be.a(ol.TileRange); + var range = new _ol_TileRange_(1, 3, 2, 4); + expect(range).to.be.a(_ol_TileRange_); }); it('can represent a range of one tile', function() { - var range = new ol.TileRange(2, 2, 3, 3); - expect(range).to.be.a(ol.TileRange); + var range = new _ol_TileRange_(2, 2, 3, 3); + expect(range).to.be.a(_ol_TileRange_); expect(range.getHeight()).to.be(1); expect(range.getWidth()).to.be(1); }); @@ -21,7 +19,7 @@ describe('ol.TileRange', function() { describe('contains', function() { it('returns the expected value', function() { - var tileRange = new ol.TileRange(1, 3, 1, 3); + var tileRange = new _ol_TileRange_(1, 3, 1, 3); expect(tileRange.contains([0, 0, 0])).to.not.be(); expect(tileRange.contains([0, 0, 1])).to.not.be(); expect(tileRange.contains([0, 0, 2])).to.not.be(); @@ -52,12 +50,12 @@ describe('ol.TileRange', function() { describe('equals', function() { it('determines equivalence of two ranges', function() { - var one = new ol.TileRange(0, 2, 1, 4); - var same = new ol.TileRange(0, 2, 1, 4); - var diff1 = new ol.TileRange(0, 2, 1, 5); - var diff2 = new ol.TileRange(0, 3, 1, 4); - var diff3 = new ol.TileRange(0, 2, 2, 4); - var diff4 = new ol.TileRange(1, 2, 1, 4); + var one = new _ol_TileRange_(0, 2, 1, 4); + var same = new _ol_TileRange_(0, 2, 1, 4); + var diff1 = new _ol_TileRange_(0, 2, 1, 5); + var diff2 = new _ol_TileRange_(0, 3, 1, 4); + var diff3 = new _ol_TileRange_(0, 2, 2, 4); + var diff4 = new _ol_TileRange_(1, 2, 1, 4); expect(one.equals(same)).to.be(true); expect(one.equals(diff1)).to.be(false); expect(one.equals(diff2)).to.be(false); @@ -68,8 +66,8 @@ describe('ol.TileRange', function() { describe('extent', function() { it('modifies range so it includes another', function() { - var one = new ol.TileRange(0, 2, 1, 4); - var other = new ol.TileRange(-1, -3, 10, 12); + var one = new _ol_TileRange_(0, 2, 1, 4); + var other = new _ol_TileRange_(-1, -3, 10, 12); one.extend(other); expect(one.minX).to.be(-1); @@ -82,7 +80,7 @@ describe('ol.TileRange', function() { describe('getSize', function() { it('returns the expected size', function() { - var tileRange = new ol.TileRange(0, 2, 1, 4); + var tileRange = new _ol_TileRange_(0, 2, 1, 4); var size = tileRange.getSize(); expect(size).to.eql([3, 4]); }); @@ -90,20 +88,20 @@ describe('ol.TileRange', function() { describe('intersects', function() { it('determines if two ranges overlap', function() { - var one = new ol.TileRange(0, 2, 1, 4); - var overlapsRight = new ol.TileRange(2, 4, 1, 4); - var overlapsLeft = new ol.TileRange(-3, 0, 1, 4); - var overlapsTop = new ol.TileRange(0, 2, 4, 5); - var overlapsBottom = new ol.TileRange(0, 2, -3, 1); + var one = new _ol_TileRange_(0, 2, 1, 4); + var overlapsRight = new _ol_TileRange_(2, 4, 1, 4); + var overlapsLeft = new _ol_TileRange_(-3, 0, 1, 4); + var overlapsTop = new _ol_TileRange_(0, 2, 4, 5); + var overlapsBottom = new _ol_TileRange_(0, 2, -3, 1); expect(one.intersects(overlapsLeft)).to.be(true); expect(one.intersects(overlapsRight)).to.be(true); expect(one.intersects(overlapsTop)).to.be(true); expect(one.intersects(overlapsBottom)).to.be(true); - var right = new ol.TileRange(3, 5, 1, 4); - var left = new ol.TileRange(-3, -1, 1, 4); - var above = new ol.TileRange(0, 2, 5, 6); - var below = new ol.TileRange(0, 2, -3, 0); + var right = new _ol_TileRange_(3, 5, 1, 4); + var left = new _ol_TileRange_(-3, -1, 1, 4); + var above = new _ol_TileRange_(0, 2, 5, 6); + var below = new _ol_TileRange_(0, 2, -3, 0); expect(one.intersects(right)).to.be(false); expect(one.intersects(left)).to.be(false); expect(one.intersects(above)).to.be(false); diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index e06258847a..05babaaac6 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -1,7 +1,7 @@ -goog.require('ol.TileUrlFunction'); -goog.require('ol.tilecoord'); -goog.require('ol.tilegrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_TileUrlFunction_ from '../../../src/ol/TileUrlFunction.js'; +import _ol_tilecoord_ from '../../../src/ol/tilecoord.js'; +import _ol_tilegrid_ from '../../../src/ol/tilegrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../src/ol/tilegrid/TileGrid.js'; describe('ol.TileUrlFunction', function() { @@ -9,7 +9,7 @@ describe('ol.TileUrlFunction', function() { describe('with number range', function() { it('creates expected URLs', function() { var template = 'http://tile-{1-3}/{z}/{x}/{y}'; - var urls = ol.TileUrlFunction.expandUrl(template); + var urls = _ol_TileUrlFunction_.expandUrl(template); expect(urls).to.eql([ 'http://tile-1/{z}/{x}/{y}', 'http://tile-2/{z}/{x}/{y}', @@ -18,7 +18,7 @@ describe('ol.TileUrlFunction', function() { }); it('creates expected URLs', function() { var template = 'http://tile-{9-11}/{z}/{x}/{y}'; - var urls = ol.TileUrlFunction.expandUrl(template); + var urls = _ol_TileUrlFunction_.expandUrl(template); expect(urls).to.eql([ 'http://tile-9/{z}/{x}/{y}', 'http://tile-10/{z}/{x}/{y}', @@ -29,7 +29,7 @@ describe('ol.TileUrlFunction', function() { describe('with character range', function() { it('creates expected URLs', function() { var template = 'http://tile-{c-e}/{z}/{x}/{y}'; - var urls = ol.TileUrlFunction.expandUrl(template); + var urls = _ol_TileUrlFunction_.expandUrl(template); expect(urls).to.eql([ 'http://tile-c/{z}/{x}/{y}', 'http://tile-d/{z}/{x}/{y}', @@ -40,7 +40,7 @@ describe('ol.TileUrlFunction', function() { describe('without range', function() { it('creates expected URLs', function() { var template = 'http://tiles.example.com/{z}/{x}/{y}'; - var urls = ol.TileUrlFunction.expandUrl(template); + var urls = _ol_TileUrlFunction_.expandUrl(template); expect(urls).to.eql([ 'http://tiles.example.com/{z}/{x}/{y}' ]); @@ -49,75 +49,75 @@ describe('ol.TileUrlFunction', function() { }); describe('createFromTemplate', function() { - var tileGrid = ol.tilegrid.createXYZ(); + var tileGrid = _ol_tilegrid_.createXYZ(); it('creates expected URL', function() { - var tileUrl = ol.TileUrlFunction.createFromTemplate( + var tileUrl = _ol_TileUrlFunction_.createFromTemplate( '{z}/{x}/{y}', tileGrid); expect(tileUrl([3, 2, -2])).to.eql('3/2/1'); expect(tileUrl(null)).to.be(undefined); }); it('accepts {-y} placeholder', function() { - var tileUrl = ol.TileUrlFunction.createFromTemplate( + var tileUrl = _ol_TileUrlFunction_.createFromTemplate( '{z}/{x}/{-y}', tileGrid); expect(tileUrl([3, 2, -3])).to.eql('3/2/5'); }); it('returns correct value for {-y} with custom tile grids', function() { - var customTileGrid = new ol.tilegrid.TileGrid({ + var customTileGrid = new _ol_tilegrid_TileGrid_({ extent: [-180, -90, 180, 90], origin: [-180, -90], resolutions: [360 / 256, 360 / 512, 360 / 1024, 360 / 2048] }); - var tileUrl = ol.TileUrlFunction.createFromTemplate( + var tileUrl = _ol_TileUrlFunction_.createFromTemplate( '{z}/{x}/{-y}', customTileGrid); expect(tileUrl([3, 2, -3])).to.eql('3/2/1'); }); it('replaces multiple placeholder occurrences', function() { - var tileUrl = ol.TileUrlFunction.createFromTemplate( + var tileUrl = _ol_TileUrlFunction_.createFromTemplate( '{z}/{z}{x}{y}', tileGrid); expect(tileUrl([3, 2, -2])).to.eql('3/321'); }); }); describe('createFromTemplates', function() { - var tileGrid = ol.tilegrid.createXYZ(); + var tileGrid = _ol_tilegrid_.createXYZ(); it('creates expected URL', function() { var templates = [ 'http://tile-1/{z}/{x}/{y}', 'http://tile-2/{z}/{x}/{y}', 'http://tile-3/{z}/{x}/{y}' ]; - var tileUrlFunction = ol.TileUrlFunction.createFromTemplates( + var tileUrlFunction = _ol_TileUrlFunction_.createFromTemplates( templates, tileGrid); var tileCoord = [3, 2, -2]; /* eslint-disable openlayers-internal/no-missing-requires */ - sinon.stub(ol.tilecoord, 'hash').callsFake(function() { + sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() { return 3; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1'); - ol.tilecoord.hash.restore(); + _ol_tilecoord_.hash.restore(); - sinon.stub(ol.tilecoord, 'hash').callsFake(function() { + sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() { return 2; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-3/3/2/1'); - ol.tilecoord.hash.restore(); + _ol_tilecoord_.hash.restore(); - sinon.stub(ol.tilecoord, 'hash').callsFake(function() { + sinon.stub(_ol_tilecoord_, 'hash').callsFake(function() { return 1; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-2/3/2/1'); - ol.tilecoord.hash.restore(); + _ol_tilecoord_.hash.restore(); /* eslint-enable */ }); }); describe('createFromTileUrlFunctions', function() { - var tileGrid = ol.tilegrid.createXYZ(); + var tileGrid = _ol_tilegrid_.createXYZ(); it('creates expected URL', function() { - var tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([ - ol.TileUrlFunction.createFromTemplate('a', tileGrid), - ol.TileUrlFunction.createFromTemplate('b', tileGrid) + var tileUrl = _ol_TileUrlFunction_.createFromTileUrlFunctions([ + _ol_TileUrlFunction_.createFromTemplate('a', tileGrid), + _ol_TileUrlFunction_.createFromTemplate('b', tileGrid) ]); var tileUrl1 = tileUrl([1, 0, 0]); var tileUrl2 = tileUrl([1, 0, 1]); diff --git a/test/spec/ol/transform.test.js b/test/spec/ol/transform.test.js index 97f5acef19..d21bcbb565 100644 --- a/test/spec/ol/transform.test.js +++ b/test/spec/ol/transform.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.transform'); +import _ol_transform_ from '../../../src/ol/transform.js'; describe('ol.transform', function() { @@ -13,55 +11,55 @@ describe('ol.transform', function() { describe('ol.transform.create()', function() { it('creates an identity transform', function() { - expect(ol.transform.create()).to.eql([1, 0, 0, 1, 0, 0]); + expect(_ol_transform_.create()).to.eql([1, 0, 0, 1, 0, 0]); }); }); describe('ol.transform.reset()', function() { it('resets tansform to an identity transform', function() { var transform = [1, 2, 3, 4, 5, 6]; - expect(ol.transform.reset(transform)).to.eql([1, 0, 0, 1, 0, 0]); + expect(_ol_transform_.reset(transform)).to.eql([1, 0, 0, 1, 0, 0]); expect(transform).to.eql([1, 0, 0, 1, 0, 0]); }); }); describe('ol.transform.set()', function() { it('sets the given values', function() { - var transform = ol.transform.create(); - expect(ol.transform.set(transform, 1, 2, 3, 4, 5, 6)).to.eql([1, 2, 3, 4, 5, 6]); + var transform = _ol_transform_.create(); + expect(_ol_transform_.set(transform, 1, 2, 3, 4, 5, 6)).to.eql([1, 2, 3, 4, 5, 6]); expect(transform).to.eql([1, 2, 3, 4, 5, 6]); }); }); describe('ol.transform.setFromArray()', function() { it('sets values of 2nd transform on 1st transform', function() { - var transform1 = ol.transform.create(); + var transform1 = _ol_transform_.create(); var transform2 = [1, 2, 3, 4, 5, 6]; - expect(ol.transform.setFromArray(transform1, transform2)).to.eql(transform2); + expect(_ol_transform_.setFromArray(transform1, transform2)).to.eql(transform2); expect(transform1).to.eql(transform2); }); }); describe('ol.transform.translate()', function() { it('applies translation to a transform', function() { - var transform = ol.transform.create(); - expect(ol.transform.translate(transform, 3, 4)).to.eql([1, 0, 0, 1, 3, 4]); + var transform = _ol_transform_.create(); + expect(_ol_transform_.translate(transform, 3, 4)).to.eql([1, 0, 0, 1, 3, 4]); expect(transform).to.eql([1, 0, 0, 1, 3, 4]); }); }); describe('ol.transform.scale()', function() { it('applies scaling to a transform', function() { - var transform = ol.transform.create(); - expect(ol.transform.scale(transform, 3, 4)).to.eql([3, 0, 0, 4, 0, 0]); + var transform = _ol_transform_.create(); + expect(_ol_transform_.scale(transform, 3, 4)).to.eql([3, 0, 0, 4, 0, 0]); expect(transform).to.eql([3, 0, 0, 4, 0, 0]); }); }); describe('ol.transform.rotate()', function() { it('applies rotation to a transform', function() { - var transform = ol.transform.create(); - assertRoughlyEqual(ol.transform.rotate(transform, Math.PI / 2), [0, 1, -1, 0, 0, 0]); + var transform = _ol_transform_.create(); + assertRoughlyEqual(_ol_transform_.rotate(transform, Math.PI / 2), [0, 1, -1, 0, 0, 0]); assertRoughlyEqual(transform, [0, 1, -1, 0, 0, 0]); }); }); @@ -70,7 +68,7 @@ describe('ol.transform', function() { it('multiplies two transforms', function() { var transform1 = [1, 2, 1, 2, 1, 2]; var transform2 = [1, 2, 1, 2, 1, 2]; - expect(ol.transform.multiply(transform1, transform2)).to.eql([3, 6, 3, 6, 4, 8]); + expect(_ol_transform_.multiply(transform1, transform2)).to.eql([3, 6, 3, 6, 4, 8]); expect(transform1).to.eql([3, 6, 3, 6, 4, 8]); }); }); @@ -85,14 +83,14 @@ describe('ol.transform', function() { var dx2 = -dx1 / 2; var dy2 = -dy1 / 2; - var expected = ol.transform.create(); - ol.transform.translate(expected, dx1, dy1); - ol.transform.scale(expected, sx, sy); - ol.transform.rotate(expected, angle); - ol.transform.translate(expected, dx2, dy2); + var expected = _ol_transform_.create(); + _ol_transform_.translate(expected, dx1, dy1); + _ol_transform_.scale(expected, sx, sy); + _ol_transform_.rotate(expected, angle); + _ol_transform_.translate(expected, dx2, dy2); - var composed = ol.transform.create(); - var composedReturn = ol.transform.compose(composed, dx1, dy1, sx, sy, angle, dx2, dy2); + var composed = _ol_transform_.create(); + var composedReturn = _ol_transform_.compose(composed, dx1, dy1, sx, sy, angle, dx2, dy2); expect(composed).to.equal(composedReturn); expect(composed).to.eql(expected); }); @@ -102,19 +100,19 @@ describe('ol.transform', function() { it('inverts a transform', function() { var transform = [1, 0, 1, 0, 1, 0]; expect(function() { - ol.transform.invert(transform); + _ol_transform_.invert(transform); }).to.throwException(); transform = [1, 1, 1, 2, 2, 0]; - expect(ol.transform.invert(transform)).to.eql([2, -1, -1, 1, -4, 2]); + expect(_ol_transform_.invert(transform)).to.eql([2, -1, -1, 1, -4, 2]); expect(transform).to.eql([2, -1, -1, 1, -4, 2]); }); }); describe('ol.transform.apply()', function() { it('applies a transform to a 2d vector', function() { - var transform = ol.transform.translate(ol.transform.create(), 2, 3); + var transform = _ol_transform_.translate(_ol_transform_.create(), 2, 3); var point = [1, 2]; - expect(ol.transform.apply(transform, point)).to.eql([3, 5]); + expect(_ol_transform_.apply(transform, point)).to.eql([3, 5]); expect(point).to.eql([3, 5]); }); }); diff --git a/test/spec/ol/uri.test.js b/test/spec/ol/uri.test.js index 9c29a775f1..580d992180 100644 --- a/test/spec/ol/uri.test.js +++ b/test/spec/ol/uri.test.js @@ -1,12 +1,10 @@ - - -goog.require('ol.uri'); +import _ol_uri_ from '../../../src/ol/uri.js'; describe('ol.uri.appendParams()', function() { it('should append empty STYLES with =', function() { - var url = ol.uri.appendParams('http://example.com/foo', { + var url = _ol_uri_.appendParams('http://example.com/foo', { SERVICE: 'WMS', STYLES: '' }); @@ -14,56 +12,56 @@ describe('ol.uri.appendParams()', function() { }); it('should URL encode values but not names', function() { - var url = ol.uri.appendParams('http://example.com/foo', { + var url = _ol_uri_.appendParams('http://example.com/foo', { 'k ': 'v ' }); expect(url).to.equal('http://example.com/foo?k =v%20'); }); it('should append to simple base URL', function() { - var url = ol.uri.appendParams('http://example.com/foo', { + var url = _ol_uri_.appendParams('http://example.com/foo', { k: 'v' }); expect(url).to.equal('http://example.com/foo?k=v'); }); it('should append to base URL with ?', function() { - var url = ol.uri.appendParams('http://example.com/foo?', { + var url = _ol_uri_.appendParams('http://example.com/foo?', { k: 'v' }); expect(url).to.equal('http://example.com/foo?k=v'); }); it('should append to base URL with single existing param', function() { - var url = ol.uri.appendParams('http://example.com/foo?bar=bam', { + var url = _ol_uri_.appendParams('http://example.com/foo?bar=bam', { k: 'v' }); expect(url).to.equal('http://example.com/foo?bar=bam&k=v'); }); it('should append to base URL with single existing param and extraneous &', function() { - var url = ol.uri.appendParams('http://example.com/foo?bar=bam&', { + var url = _ol_uri_.appendParams('http://example.com/foo?bar=bam&', { k: 'v' }); expect(url).to.equal('http://example.com/foo?bar=bam&k=v'); }); it('should append to base URL with two existing params', function() { - var url = ol.uri.appendParams('http://example.com/foo?bar=bam&baz=bat', { + var url = _ol_uri_.appendParams('http://example.com/foo?bar=bam&baz=bat', { k: 'v' }); expect(url).to.equal('http://example.com/foo?bar=bam&baz=bat&k=v'); }); it('should append to base URL with three existing params last one empty', function() { - var url = ol.uri.appendParams('http://example.com/foo?bar=bam&baz=bat&bop=', { + var url = _ol_uri_.appendParams('http://example.com/foo?bar=bam&baz=bat&bop=', { k: 'v' }); expect(url).to.equal('http://example.com/foo?bar=bam&baz=bat&bop=&k=v'); }); it('should not append null or undefined parameters to the url', function() { - var url = ol.uri.appendParams('http://example.com/foo', { + var url = _ol_uri_.appendParams('http://example.com/foo', { a: '1', b: null, c: undefined diff --git a/test/spec/ol/vec/mat4.test.js b/test/spec/ol/vec/mat4.test.js index 3e28c582aa..7109131c5b 100644 --- a/test/spec/ol/vec/mat4.test.js +++ b/test/spec/ol/vec/mat4.test.js @@ -1,13 +1,11 @@ - - -goog.require('ol.vec.Mat4'); +import _ol_vec_Mat4_ from '../../../../src/ol/vec/Mat4.js'; describe('ol.vec.Mat4', function() { describe('ol.vec.Mat4.create()', function() { it('returns the expected matrix', function() { - expect(ol.vec.Mat4.create()).to.eql( + expect(_ol_vec_Mat4_.create()).to.eql( [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); }); }); @@ -15,8 +13,8 @@ describe('ol.vec.Mat4', function() { describe('ol.vec.Mat4.fromTransform()', function() { it('sets the expected transform on the matrix', function() { var transform = [1, 2, 3, 4, 5, 6]; - var result = ol.vec.Mat4.create(); - expect(ol.vec.Mat4.fromTransform(result, transform)).to.eql( + var result = _ol_vec_Mat4_.create(); + expect(_ol_vec_Mat4_.fromTransform(result, transform)).to.eql( [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]); expect(result).to.eql( [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]); diff --git a/test/spec/ol/vectorimagetile.test.js b/test/spec/ol/vectorimagetile.test.js index 98823000fb..5d58f0ee31 100644 --- a/test/spec/ol/vectorimagetile.test.js +++ b/test/spec/ol/vectorimagetile.test.js @@ -1,156 +1,154 @@ - - -goog.require('ol.TileState'); -goog.require('ol.VectorImageTile'); -goog.require('ol.VectorTile'); -goog.require('ol.events'); -goog.require('ol.format.GeoJSON'); -goog.require('ol.proj'); -goog.require('ol.tilegrid'); -goog.require('ol.tilegrid.TileGrid'); +import _ol_TileState_ from '../../../src/ol/TileState.js'; +import _ol_VectorImageTile_ from '../../../src/ol/VectorImageTile.js'; +import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_format_GeoJSON_ from '../../../src/ol/format/GeoJSON.js'; +import _ol_proj_ from '../../../src/ol/proj.js'; +import _ol_tilegrid_ from '../../../src/ol/tilegrid.js'; +import _ol_tilegrid_TileGrid_ from '../../../src/ol/tilegrid/TileGrid.js'; describe('ol.VectorImageTile', function() { it('configures loader that sets features on the source tile', function(done) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/point.json'; - var tile = new ol.VectorImageTile([0, 0, -1], 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { + var tile = new _ol_VectorImageTile_([0, 0, -1], 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [0, 0, -1], function() { return url; - }, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); var sourceTile = tile.getTile(tile.tileKeys[0]); var loader = sourceTile.loader_; expect(typeof loader).to.be('function'); - ol.events.listen(sourceTile, 'change', function(e) { + _ol_events_.listen(sourceTile, 'change', function(e) { expect(sourceTile.getFeatures().length).to.be.greaterThan(0); done(); }); }); it('sets LOADED state when previously failed source tiles are loaded', function(done) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/unavailable.json'; var sourceTile; - var tile = new ol.VectorImageTile([0, 0, 0] /* one world away */, 0, url, format, + var tile = new _ol_VectorImageTile_([0, 0, 0] /* one world away */, 0, url, format, function(tile, url) { sourceTile = tile; - ol.VectorImageTile.defaultLoadFunction(tile, url); + _ol_VectorImageTile_.defaultLoadFunction(tile, url); }, [0, 0, -1], function() { return url; - }, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); var calls = 0; - ol.events.listen(tile, 'change', function(e) { + _ol_events_.listen(tile, 'change', function(e) { ++calls; - expect(tile.getState()).to.be(calls == 2 ? ol.TileState.LOADED : ol.TileState.ERROR); + expect(tile.getState()).to.be(calls == 2 ? _ol_TileState_.LOADED : _ol_TileState_.ERROR); if (calls == 2) { done(); } else { setTimeout(function() { - sourceTile.setState(ol.TileState.LOADED); + sourceTile.setState(_ol_TileState_.LOADED); }, 0); } }); }); it('sets ERROR state when source tiles fail to load', function(done) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/unavailable.json'; - var tile = new ol.VectorImageTile([0, 0, -1], 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { + var tile = new _ol_VectorImageTile_([0, 0, -1], 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [0, 0, -1], function() { return url; - }, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); - ol.events.listen(tile, 'change', function(e) { - expect(tile.getState()).to.be(ol.TileState.ERROR); + _ol_events_.listen(tile, 'change', function(e) { + expect(tile.getState()).to.be(_ol_TileState_.ERROR); done(); }); }); it('sets EMPTY state when tile has only empty source tiles', function(done) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = ''; - var tile = new ol.VectorImageTile([0, 0, -1], 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {}, - ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ(), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + var tile = new _ol_VectorImageTile_([0, 0, -1], 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [0, 0, -1], function() {}, + _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); - ol.events.listen(tile, 'change', function() { - expect(tile.getState()).to.be(ol.TileState.EMPTY); + _ol_events_.listen(tile, 'change', function() { + expect(tile.getState()).to.be(_ol_TileState_.EMPTY); done(); }); }); it('only loads tiles within the source tileGrid\'s extent', function() { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/point.json'; - var tileGrid = new ol.tilegrid.TileGrid({ + var tileGrid = new _ol_tilegrid_TileGrid_({ resolutions: [0.02197265625, 0.010986328125, 0.0054931640625], origin: [-180, 90], extent: [-88, 35, -87, 36] }); var sourceTiles = {}; - var tile = new ol.VectorImageTile([1, 0, -1], 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [1, 0, -1], function(zxy) { + var tile = new _ol_VectorImageTile_([1, 0, -1], 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [1, 0, -1], function(zxy) { return url; }, tileGrid, - ol.tilegrid.createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}), - sourceTiles, 1, ol.proj.get('EPSG:4326'), ol.VectorTile, function() {}); + _ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}), + sourceTiles, 1, _ol_proj_.get('EPSG:4326'), _ol_VectorTile_, function() {}); tile.load(); expect(tile.tileKeys.length).to.be(1); expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, -10]); }); it('#dispose() while loading', function() { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/point.json'; - var tile = new ol.VectorImageTile([0, 0, 0] /* one world away */, 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { + var tile = new _ol_VectorImageTile_([0, 0, 0] /* one world away */, 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [0, 0, -1], function() { return url; - }, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ({tileSize: 512}), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); expect(tile.loadListenerKeys_.length).to.be(4); expect(tile.tileKeys.length).to.be(4); - expect(tile.getState()).to.be(ol.TileState.LOADING); + expect(tile.getState()).to.be(_ol_TileState_.LOADING); tile.dispose(); expect(tile.loadListenerKeys_.length).to.be(0); expect(tile.tileKeys.length).to.be(0); expect(tile.sourceTiles_).to.be(null); - expect(tile.getState()).to.be(ol.TileState.ABORT); + expect(tile.getState()).to.be(_ol_TileState_.ABORT); }); it('#dispose() when loaded', function(done) { - var format = new ol.format.GeoJSON(); + var format = new _ol_format_GeoJSON_(); var url = 'spec/ol/data/point.json'; - var tile = new ol.VectorImageTile([0, 0, -1], 0, url, format, - ol.VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { + var tile = new _ol_VectorImageTile_([0, 0, -1], 0, url, format, + _ol_VectorImageTile_.defaultLoadFunction, [0, 0, -1], function() { return url; - }, ol.tilegrid.createXYZ(), ol.tilegrid.createXYZ({tileSize: 512}), {}, - 1, ol.proj.get('EPSG:3857'), ol.VectorTile, function() {}); + }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {}, + 1, _ol_proj_.get('EPSG:3857'), _ol_VectorTile_, function() {}); tile.load(); - ol.events.listenOnce(tile, 'change', function() { - expect(tile.getState()).to.be(ol.TileState.LOADED); + _ol_events_.listenOnce(tile, 'change', function() { + expect(tile.getState()).to.be(_ol_TileState_.LOADED); expect(tile.loadListenerKeys_.length).to.be(0); expect(tile.tileKeys.length).to.be(4); tile.dispose(); expect(tile.tileKeys.length).to.be(0); expect(tile.sourceTiles_).to.be(null); - expect(tile.getState()).to.be(ol.TileState.ABORT); + expect(tile.getState()).to.be(_ol_TileState_.ABORT); done(); }); }); diff --git a/test/spec/ol/vectortile.test.js b/test/spec/ol/vectortile.test.js index 5656050f37..428bbdf04f 100644 --- a/test/spec/ol/vectortile.test.js +++ b/test/spec/ol/vectortile.test.js @@ -1,40 +1,38 @@ - - -goog.require('ol.Feature'); -goog.require('ol.VectorImageTile'); -goog.require('ol.VectorTile'); -goog.require('ol.events'); -goog.require('ol.format.TextFeature'); -goog.require('ol.proj'); -goog.require('ol.proj.Projection'); +import _ol_Feature_ from '../../../src/ol/Feature.js'; +import _ol_VectorImageTile_ from '../../../src/ol/VectorImageTile.js'; +import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; +import _ol_events_ from '../../../src/ol/events.js'; +import _ol_format_TextFeature_ from '../../../src/ol/format/TextFeature.js'; +import _ol_proj_ from '../../../src/ol/proj.js'; +import _ol_proj_Projection_ from '../../../src/ol/proj/Projection.js'; describe('ol.VectorTile', function() { it('loader sets features on the tile and updates proj units', function(done) { // mock format that return a tile-pixels feature - var format = new ol.format.TextFeature(); + var format = new _ol_format_TextFeature_(); format.readProjection = function(source) { - return new ol.proj.Projection({ + return new _ol_proj_Projection_({ code: '', units: 'tile-pixels' }); }; format.readFeatures = function(source, options) { - return [new ol.Feature()]; + return [new _ol_Feature_()]; }; - var tile = new ol.VectorTile([0, 0, 0], null, null, format); + var tile = new _ol_VectorTile_([0, 0, 0], null, null, format); var url = 'spec/ol/data/point.json'; - ol.VectorImageTile.defaultLoadFunction(tile, url); + _ol_VectorImageTile_.defaultLoadFunction(tile, url); var loader = tile.loader_; - ol.events.listen(tile, 'change', function(e) { + _ol_events_.listen(tile, 'change', function(e) { expect(tile.getFeatures().length).to.be.greaterThan(0); expect(tile.getProjection().getUnits()).to.be('tile-pixels'); done(); }); - loader.call(tile, [], 1, ol.proj.get('EPSG:3857')); + loader.call(tile, [], 1, _ol_proj_.get('EPSG:3857')); }); }); diff --git a/test/spec/ol/view.test.js b/test/spec/ol/view.test.js index 2ee3aeeeba..111cde4d5f 100644 --- a/test/spec/ol/view.test.js +++ b/test/spec/ol/view.test.js @@ -1,11 +1,11 @@ -goog.require('ol'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.ViewHint'); -goog.require('ol.extent'); -goog.require('ol.geom.Circle'); -goog.require('ol.geom.LineString'); -goog.require('ol.geom.Point'); +import _ol_ from '../../../src/ol.js'; +import _ol_Map_ from '../../../src/ol/Map.js'; +import _ol_View_ from '../../../src/ol/View.js'; +import _ol_ViewHint_ from '../../../src/ol/ViewHint.js'; +import _ol_extent_ from '../../../src/ol/extent.js'; +import _ol_geom_Circle_ from '../../../src/ol/geom/Circle.js'; +import _ol_geom_LineString_ from '../../../src/ol/geom/LineString.js'; +import _ol_geom_Point_ from '../../../src/ol/geom/Point.js'; describe('ol.View', function() { @@ -13,11 +13,11 @@ describe('ol.View', function() { var view; beforeEach(function() { - view = new ol.View(); + view = new _ol_View_(); }); it('creates an instance', function() { - expect(view).to.be.a(ol.View); + expect(view).to.be.a(_ol_View_); }); it('provides default rotation', function() { @@ -33,7 +33,7 @@ describe('ol.View', function() { describe('with no options', function() { it('gives a correct center constraint function', function() { var options = {}; - var fn = ol.View.createCenterConstraint_(options); + var fn = _ol_View_.createCenterConstraint_(options); expect(fn([0, 0])).to.eql([0, 0]); expect(fn(undefined)).to.eql(undefined); expect(fn([42, -100])).to.eql([42, -100]); @@ -45,7 +45,7 @@ describe('ol.View', function() { var options = { extent: [0, 0, 1, 1] }; - var fn = ol.View.createCenterConstraint_(options); + var fn = _ol_View_.createCenterConstraint_(options); expect(fn([0, 0])).to.eql([0, 0]); expect(fn([-10, 0])).to.eql([0, 0]); expect(fn([100, 100])).to.eql([1, 1]); @@ -59,7 +59,7 @@ describe('ol.View', function() { describe('with no options', function() { it('gives a correct resolution constraint function', function() { var options = {}; - var fn = ol.View.createResolutionConstraint_(options).constraint; + var fn = _ol_View_.createResolutionConstraint_(options).constraint; expect(fn(156543.03392804097, 0, 0)) .to.roughlyEqual(156543.03392804097, 1e-9); expect(fn(78271.51696402048, 0, 0)) @@ -75,7 +75,7 @@ describe('ol.View', function() { maxZoom: 3, zoomFactor: 3 }; - var info = ol.View.createResolutionConstraint_(options); + var info = _ol_View_.createResolutionConstraint_(options); var maxResolution = info.maxResolution; expect(maxResolution).to.eql(81); var minResolution = info.minResolution; @@ -95,7 +95,7 @@ describe('ol.View', function() { var options = { resolutions: [97, 76, 65, 54, 0.45] }; - var info = ol.View.createResolutionConstraint_(options); + var info = _ol_View_.createResolutionConstraint_(options); var maxResolution = info.maxResolution; expect(maxResolution).to.eql(97); var minResolution = info.minResolution; @@ -113,7 +113,7 @@ describe('ol.View', function() { var defaultMaxRes = 156543.03392804097; function getConstraint(options) { - return ol.View.createResolutionConstraint_(options).constraint; + return _ol_View_.createResolutionConstraint_(options).constraint; } it('works with only maxZoom', function() { @@ -180,7 +180,7 @@ describe('ol.View', function() { var defaultMaxRes = 156543.03392804097; function getConstraint(options) { - return ol.View.createResolutionConstraint_(options).constraint; + return _ol_View_.createResolutionConstraint_(options).constraint; } it('works with only maxResolution', function() { @@ -249,7 +249,7 @@ describe('ol.View', function() { var defaultMaxRes = 156543.03392804097; function getConstraint(options) { - return ol.View.createResolutionConstraint_(options).constraint; + return _ol_View_.createResolutionConstraint_(options).constraint; } it('respects maxResolution over minZoom', function() { @@ -293,7 +293,7 @@ describe('ol.View', function() { describe('create rotation constraint', function() { it('gives a correct rotation constraint function', function() { var options = {}; - var fn = ol.View.createRotationConstraint_(options); + var fn = _ol_View_.createRotationConstraint_(options); expect(fn(0.01, 0)).to.eql(0); expect(fn(0.15, 0)).to.eql(0.15); }); @@ -304,7 +304,7 @@ describe('ol.View', function() { describe('#setHint()', function() { it('changes a view hint', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -312,13 +312,13 @@ describe('ol.View', function() { expect(view.getHints()).to.eql([0, 0]); expect(view.getInteracting()).to.eql(false); - view.setHint(ol.ViewHint.INTERACTING, 1); + view.setHint(_ol_ViewHint_.INTERACTING, 1); expect(view.getHints()).to.eql([0, 1]); expect(view.getInteracting()).to.eql(true); }); it('triggers the change event', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -328,7 +328,7 @@ describe('ol.View', function() { expect(view.getInteracting()).to.eql(true); done(); }); - view.setHint(ol.ViewHint.INTERACTING, 1); + view.setHint(_ol_ViewHint_.INTERACTING, 1); }); }); @@ -336,7 +336,7 @@ describe('ol.View', function() { describe('#getUpdatedOptions_()', function() { it('applies minZoom to constructor options', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], minZoom: 2, zoom: 10 @@ -349,7 +349,7 @@ describe('ol.View', function() { }); it('applies the current zoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 10 }); @@ -361,7 +361,7 @@ describe('ol.View', function() { }); it('applies the current resolution if resolution was originally supplied', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], resolution: 1000 }); @@ -373,7 +373,7 @@ describe('ol.View', function() { }); it('applies the current center', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 10 }); @@ -385,7 +385,7 @@ describe('ol.View', function() { }); it('applies the current rotation', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 10 }); @@ -419,7 +419,7 @@ describe('ol.View', function() { }); it('can be called to animate view properties', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 5 }); @@ -439,7 +439,7 @@ describe('ol.View', function() { }); it('allows duration to be zero', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 5 }); @@ -458,7 +458,7 @@ describe('ol.View', function() { }); it('immediately completes for no-op animations', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 5 }); @@ -472,7 +472,7 @@ describe('ol.View', function() { }); it('immediately completes if view is not defined before', function() { - var view = new ol.View(); + var view = new _ol_View_(); var center = [1, 2]; var zoom = 3; var rotation = 0.4; @@ -490,7 +490,7 @@ describe('ol.View', function() { }); it('sets final animation state if view is not defined before', function() { - var view = new ol.View(); + var view = new _ol_View_(); var center = [1, 2]; var zoom = 3; @@ -515,7 +515,7 @@ describe('ol.View', function() { }); it('prefers zoom over resolution', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 5 }); @@ -533,7 +533,7 @@ describe('ol.View', function() { it('avoids going under minResolution', function(done) { var maxZoom = 14; - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, maxZoom: maxZoom @@ -552,7 +552,7 @@ describe('ol.View', function() { }); it('takes the shortest arc to the target rotation', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: Math.PI / 180 * 1 @@ -567,7 +567,7 @@ describe('ol.View', function() { }); it('normalizes rotation to angles between -180 and 180 degrees after the anmiation', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: Math.PI / 180 * 1 @@ -582,7 +582,7 @@ describe('ol.View', function() { }); it('calls a callback when animation completes', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -597,7 +597,7 @@ describe('ol.View', function() { }); it('calls callback with false when animation is interrupted', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -614,7 +614,7 @@ describe('ol.View', function() { }); it('calls a callback even if animation is a no-op', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -629,7 +629,7 @@ describe('ol.View', function() { }); it('calls a callback if view is not defined before', function(done) { - var view = new ol.View(); + var view = new _ol_View_(); view.animate({ zoom: 10, @@ -642,7 +642,7 @@ describe('ol.View', function() { }); it('can run multiple animations in series', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -671,7 +671,7 @@ describe('ol.View', function() { }); it('properly sets the ANIMATING hint', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -681,7 +681,7 @@ describe('ol.View', function() { function decrement() { --count; if (count === 0) { - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(0); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(0); done(); } } @@ -689,24 +689,24 @@ describe('ol.View', function() { center: [1, 2], duration: 25 }, decrement); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(1); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(1); view.animate({ zoom: 1, duration: 25 }, decrement); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(2); view.animate({ rotation: Math.PI, duration: 25 }, decrement); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(3); }); it('clears the ANIMATING hint when animations are cancelled', function() { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -716,29 +716,29 @@ describe('ol.View', function() { center: [1, 2], duration: 25 }); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(1); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(1); view.animate({ zoom: 1, duration: 25 }); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(2); view.animate({ rotation: Math.PI, duration: 25 }); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(3); // cancel animations view.setCenter([10, 20]); - expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(0); + expect(view.getHints()[_ol_ViewHint_.ANIMATING]).to.be(0); }); it('completes multiple staggered animations run in parallel', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -771,7 +771,7 @@ describe('ol.View', function() { it('completes complex animation using resolution', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], resolution: 2 }); @@ -842,7 +842,7 @@ describe('ol.View', function() { }); it('cancels a currently running animation', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -864,7 +864,7 @@ describe('ol.View', function() { }); it('cancels a multiple animations', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0, rotation: 0 @@ -894,7 +894,7 @@ describe('ol.View', function() { }); it('calls callbacks with false to indicate animations did not complete', function(done) { - var view = new ol.View({ + var view = new _ol_View_({ center: [0, 0], zoom: 0 }); @@ -921,14 +921,14 @@ describe('ol.View', function() { var resolutions = [512, 256, 128, 64, 32, 16]; it('returns correct resolutions', function() { - view = new ol.View({ + view = new _ol_View_({ resolutions: resolutions }); expect(view.getResolutions()).to.be(resolutions); }); it('returns resolutions as undefined', function() { - view = new ol.View(); + view = new _ol_View_(); expect(view.getResolutions()).to.be(undefined); }); }); @@ -936,7 +936,7 @@ describe('ol.View', function() { describe('#getZoom', function() { var view; beforeEach(function() { - view = new ol.View({ + view = new _ol_View_({ resolutions: [512, 256, 128, 64, 32, 16] }); }); @@ -968,7 +968,7 @@ describe('ol.View', function() { }); it('works for resolution arrays with variable zoom factors', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [10, 5, 2, 1] }); @@ -992,7 +992,7 @@ describe('ol.View', function() { describe('#getZoom() - constrained', function() { it('returns correct zoom levels', function() { - var view = new ol.View({ + var view = new _ol_View_({ minZoom: 10, maxZoom: 20 }); @@ -1018,16 +1018,16 @@ describe('ol.View', function() { }); describe('#getZoom() - custom ol.DEFAULT_MIN_ZOOM', function() { - var defaultMinZoom = ol.DEFAULT_MIN_ZOOM; + var defaultMinZoom = _ol_.DEFAULT_MIN_ZOOM; afterEach(function() { - ol.DEFAULT_MIN_ZOOM = defaultMinZoom; + _ol_.DEFAULT_MIN_ZOOM = defaultMinZoom; }); it('respects custom ol.DEFAULT_MIN_ZOOM', function() { - ol.DEFAULT_MIN_ZOOM = 2; + _ol_.DEFAULT_MIN_ZOOM = 2; - var view = new ol.View(); + var view = new _ol_View_(); view.setZoom(1); expect(view.getZoom()).to.be(2); @@ -1044,7 +1044,7 @@ describe('ol.View', function() { it('gives maxResolution precedence over minZoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ maxResolution: 100, minZoom: 2 // this should get ignored }); @@ -1060,7 +1060,7 @@ describe('ol.View', function() { describe('#getZoomForResolution', function() { it('returns correct zoom levels', function() { - var view = new ol.View(); + var view = new _ol_View_(); var max = view.getMaxResolution(); expect(view.getZoomForResolution(max)).to.be(0); @@ -1073,7 +1073,7 @@ describe('ol.View', function() { }); it('returns correct zoom levels for specifically configured resolutions', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [10, 8, 6, 4, 2] }); @@ -1093,7 +1093,7 @@ describe('ol.View', function() { describe('#getResolutionForZoom', function() { it('returns correct zoom resolution', function() { - var view = new ol.View(); + var view = new _ol_View_(); var max = view.getMaxZoom(); var min = view.getMinZoom(); @@ -1102,7 +1102,7 @@ describe('ol.View', function() { }); it('returns correct zoom levels for specifically configured resolutions', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [10, 8, 6, 4, 2] }); @@ -1118,12 +1118,12 @@ describe('ol.View', function() { describe('#getMaxZoom', function() { it('returns the zoom level for the min resolution', function() { - var view = new ol.View(); + var view = new _ol_View_(); expect(view.getMaxZoom()).to.be(view.getZoomForResolution(view.getMinResolution())); }); it('works for a view configured with a maxZoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ maxZoom: 10 }); expect(view.getMaxZoom()).to.be(10); @@ -1134,12 +1134,12 @@ describe('ol.View', function() { describe('#getMinZoom', function() { it('returns the zoom level for the max resolution', function() { - var view = new ol.View(); + var view = new _ol_View_(); expect(view.getMinZoom()).to.be(view.getZoomForResolution(view.getMaxResolution())); }); it('works for views configured with a minZoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ minZoom: 3 }); expect(view.getMinZoom()).to.be(3); @@ -1150,7 +1150,7 @@ describe('ol.View', function() { describe('#setMaxZoom', function() { describe('with resolutions property in view', function() { it('changes the zoom level when the level is over max zoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [100000, 50000, 25000, 12500, 6250, 3125], zoom: 4 }); @@ -1162,7 +1162,7 @@ describe('ol.View', function() { describe('with no resolutions property in view', function() { it('changes the zoom level when the level is over max zoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ zoom: 4 }); @@ -1175,7 +1175,7 @@ describe('ol.View', function() { describe('#setMinZoom', function() { describe('with resolutions property in view', function() { it('changes the zoom level when the level is under min zoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [100000, 50000, 25000, 12500, 6250, 3125], zoom: 4 }); @@ -1187,7 +1187,7 @@ describe('ol.View', function() { describe('with no resolutions property in view', function() { it('changes the zoom level when the level is under min zoom', function() { - var view = new ol.View({ + var view = new _ol_View_({ zoom: 4 }); @@ -1199,7 +1199,7 @@ describe('ol.View', function() { describe('#calculateExtent', function() { it('returns the expected extent', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [512], zoom: 0, center: [0, 0] @@ -1212,7 +1212,7 @@ describe('ol.View', function() { expect(extent[3]).to.be(51200); }); it('returns the expected extent with rotation', function() { - var view = new ol.View({ + var view = new _ol_View_({ resolutions: [512], zoom: 0, center: [0, 0], @@ -1232,7 +1232,7 @@ describe('ol.View', function() { target = document.createElement('div'); target.style.width = '200px'; target.style.height = '150px'; - map = new ol.Map({ + map = new _ol_Map_({ target: target }); document.body.appendChild(target); @@ -1268,7 +1268,7 @@ describe('ol.View', function() { var view; beforeEach(function() { - view = new ol.View({ + view = new _ol_View_({ center: [0, 0], resolutions: [200, 100, 50, 20, 10, 5, 2, 1], zoom: 5 @@ -1276,35 +1276,35 @@ describe('ol.View', function() { }); it('fits correctly to the geometry', function() { view.fit( - new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), + new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), {size: [200, 200], padding: [100, 0, 0, 100], constrainResolution: false}); expect(view.getResolution()).to.be(11); expect(view.getCenter()[0]).to.be(5950); expect(view.getCenter()[1]).to.be(47100); view.fit( - new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), + new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), {size: [200, 200], padding: [100, 0, 0, 100]}); expect(view.getResolution()).to.be(20); expect(view.getCenter()[0]).to.be(5500); expect(view.getCenter()[1]).to.be(47550); view.fit( - new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), + new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), {size: [200, 200], padding: [100, 0, 0, 100], nearest: true}); expect(view.getResolution()).to.be(10); expect(view.getCenter()[0]).to.be(6000); expect(view.getCenter()[1]).to.be(47050); view.fit( - new ol.geom.Point([6000, 46000]), + new _ol_geom_Point_([6000, 46000]), {size: [200, 200], padding: [100, 0, 0, 100], minResolution: 2}); expect(view.getResolution()).to.be(2); expect(view.getCenter()[0]).to.be(5900); expect(view.getCenter()[1]).to.be(46100); view.fit( - new ol.geom.Point([6000, 46000]), + new _ol_geom_Point_([6000, 46000]), {size: [200, 200], padding: [100, 0, 0, 100], maxZoom: 6}); expect(view.getResolution()).to.be(2); expect(view.getZoom()).to.be(6); @@ -1312,7 +1312,7 @@ describe('ol.View', function() { expect(view.getCenter()[1]).to.be(46100); view.fit( - new ol.geom.Circle([6000, 46000], 1000), + new _ol_geom_Circle_([6000, 46000], 1000), {size: [200, 200], constrainResolution: false}); expect(view.getResolution()).to.be(10); expect(view.getCenter()[0]).to.be(6000); @@ -1320,7 +1320,7 @@ describe('ol.View', function() { view.setRotation(Math.PI / 8); view.fit( - new ol.geom.Circle([6000, 46000], 1000), + new _ol_geom_Circle_([6000, 46000], 1000), {size: [200, 200], constrainResolution: false}); expect(view.getResolution()).to.roughlyEqual(10, 1e-9); expect(view.getCenter()[0]).to.roughlyEqual(6000, 1e-9); @@ -1328,7 +1328,7 @@ describe('ol.View', function() { view.setRotation(Math.PI / 4); view.fit( - new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), + new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), {size: [200, 200], padding: [100, 0, 0, 100], constrainResolution: false}); expect(view.getResolution()).to.roughlyEqual(14.849242404917458, 1e-9); expect(view.getCenter()[0]).to.roughlyEqual(5200, 1e-9); @@ -1347,12 +1347,12 @@ describe('ol.View', function() { }); it('throws on empty extent', function() { expect(function() { - view.fit(ol.extent.createEmpty()); + view.fit(_ol_extent_.createEmpty()); }).to.throwException(); }); it('animates when duration is defined', function(done) { view.fit( - new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), + new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), { size: [200, 200], padding: [100, 0, 0, 100], @@ -1372,7 +1372,7 @@ describe('ol.View', function() { }); it('calls a callback when duration is not defined', function(done) { - view.fit(new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), { + view.fit(new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), { callback: function(complete) { expect(complete).to.be(true); done(); @@ -1380,7 +1380,7 @@ describe('ol.View', function() { }); }); it('calls a callback when animation completes', function(done) { - view.fit(new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), { + view.fit(new _ol_geom_LineString_([[6000, 46000], [6000, 47100], [7000, 46000]]), { duration: 25, callback: function(complete) { expect(complete).to.be(true); @@ -1394,7 +1394,7 @@ describe('ol.View', function() { describe('centerOn', function() { var view; beforeEach(function() { - view = new ol.View({ + view = new _ol_View_({ resolutions: [200, 100, 50, 20, 10, 5, 2, 1] }); }); @@ -1484,7 +1484,7 @@ describe('ol.View.isNoopAnimation()', function() { cases.forEach(function(c, i) { it('works for case ' + i, function() { - var noop = ol.View.isNoopAnimation(c.animation); + var noop = _ol_View_.isNoopAnimation(c.animation); expect(noop).to.equal(c.noop); }); }); diff --git a/test/spec/ol/webgl/buffer.test.js b/test/spec/ol/webgl/buffer.test.js index 45346bd369..a7dfcd1a96 100644 --- a/test/spec/ol/webgl/buffer.test.js +++ b/test/spec/ol/webgl/buffer.test.js @@ -1,6 +1,4 @@ - - -goog.require('ol.webgl.Buffer'); +import _ol_webgl_Buffer_ from '../../../../src/ol/webgl/Buffer.js'; describe('ol.webgl.Buffer', function() { @@ -11,7 +9,7 @@ describe('ol.webgl.Buffer', function() { var b; beforeEach(function() { - b = new ol.webgl.Buffer(); + b = new _ol_webgl_Buffer_(); }); it('constructs an empty instance', function() { @@ -24,7 +22,7 @@ describe('ol.webgl.Buffer', function() { var b; beforeEach(function() { - b = new ol.webgl.Buffer([0, 1, 2, 3]); + b = new _ol_webgl_Buffer_([0, 1, 2, 3]); }); it('constructs a populated instance', function() { @@ -39,7 +37,7 @@ describe('ol.webgl.Buffer', function() { var b; beforeEach(function() { - b = new ol.webgl.Buffer(); + b = new _ol_webgl_Buffer_(); }); describe('getArray', function() { diff --git a/test/test-extensions.js b/test/test-extensions.js index 52f70574f1..589b765dfb 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -1,5 +1,5 @@ -goog.require('ol.array'); -goog.require('ol.has'); +import _ol_array_ from '../src/ol/array.js'; +import _ol_has_ from '../src/ol/has.js'; // avoid importing anything that results in an instanceof check // since these extensions are global, instanceof checks fail with modules @@ -317,7 +317,7 @@ goog.require('ol.has'); */ expect.Assertion.prototype.arreql = function(obj) { this.assert( - ol.array.equals(this.obj, obj), + _ol_array_.equals(this.obj, obj), function() { return 'expected ' + expect.stringify(this.obj) + ' to sort of equal ' + expect.stringify(obj); @@ -377,7 +377,7 @@ goog.require('ol.has'); }; global.assertWebGL = function(map) { - if (!ol.has.WEBGL) { + if (!_ol_has_.WEBGL) { expect().fail('No WebGL support!'); } };