ol3 is now internal, ol is now external
As discussed with @ahocevar, @elemoine and @tschaub.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,8 +1,8 @@
|
|||||||
/apidoc_config/Data/
|
/apidoc_config/Data/
|
||||||
/bin/plovr*.jar
|
/bin/plovr*.jar
|
||||||
/build/OpenLayers.js
|
/build/OpenLayers.js
|
||||||
|
/build/ol.js
|
||||||
/build/ol3.js
|
/build/ol3.js
|
||||||
/build/ol3-api.js
|
|
||||||
/build/ol3-compiled.js
|
/build/ol3-compiled.js
|
||||||
/demos/*/advanced-optimizations.*
|
/demos/*/advanced-optimizations.*
|
||||||
/demos/*/build.html
|
/demos/*/build.html
|
||||||
|
|||||||
44
Makefile
44
Makefile
@@ -1,6 +1,6 @@
|
|||||||
PLOVR_JAR=bin/plovr-4b3caf2b7d84.jar
|
PLOVR_JAR=bin/plovr-4b3caf2b7d84.jar
|
||||||
SRC = $(shell find externs src/ol -name \*.js)
|
SRC_OL = $(shell find src/ol -name \*.js)
|
||||||
API = $(shell find src/api -name \*.js)
|
SRC_OL3 = $(shell find externs src/ol3 -name \*.js)
|
||||||
TARGETS = $(shell find demos -name advanced-optimizations.js -o -name simple-optimizations.js)
|
TARGETS = $(shell find demos -name advanced-optimizations.js -o -name simple-optimizations.js)
|
||||||
comma := ,
|
comma := ,
|
||||||
empty :=
|
empty :=
|
||||||
@@ -10,49 +10,49 @@ space := $(empty) $(empty)
|
|||||||
all: build demos webgl-debug.js
|
all: build demos webgl-debug.js
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: build/ol3-api.js build/ol3-compiled.js
|
build: build/ol.js build/ol3-compiled.js
|
||||||
|
|
||||||
build/ol3-api.js: $(PLOVR_JAR) $(SRC) base.json \
|
build/ol.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
build/ol3-api.json src/api/api.js
|
build/ol.json src/ol/ol.js
|
||||||
java -jar $(PLOVR_JAR) build build/ol3-api.json >$@
|
java -jar $(PLOVR_JAR) build build/ol.json >$@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
||||||
|
|
||||||
build/ol3-compiled.js: $(PLOVR_JAR) $(SRC) base.json \
|
build/ol3-compiled.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
build/ol3.json build/ol3.js
|
build/ol3.json build/ol3.js
|
||||||
java -jar $(PLOVR_JAR) build build/ol3.json >$@
|
java -jar $(PLOVR_JAR) build build/ol3.json >$@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
||||||
|
|
||||||
build/ol3.js: $(SRC)
|
build/ol3.js: $(SRC_OL3)
|
||||||
( echo "goog.require('goog.dom');" ; find src/ol -name \*.js | xargs grep -rh ^goog.provide | sort | uniq | sed -e 's/provide/require/g' ) > $@
|
( echo "goog.require('goog.dom');" ; find src/ol3 -name \*.js | xargs grep -rh ^goog.provide | sort | uniq | sed -e 's/provide/require/g' ) > $@
|
||||||
|
|
||||||
.PHONY: demos
|
.PHONY: demos
|
||||||
demos: demos/api1 demos/proj4js demos/side-by-side demos/two-layers
|
demos: demos/api1 demos/proj4js demos/side-by-side demos/two-layers
|
||||||
|
|
||||||
.PHONY: demos/api1
|
.PHONY: demos/api1
|
||||||
demos/api1: \
|
demos/api1: \
|
||||||
build/ol3-api.js \
|
build/ol.js \
|
||||||
demos/api1/build.html \
|
demos/api1/build.html \
|
||||||
demos/api1/debug.html
|
demos/api1/debug.html
|
||||||
|
|
||||||
demos/api1/build.html: demos/api1/index.html.in
|
demos/api1/build.html: demos/api1/index.html.in
|
||||||
sed -e 's|@SRC@|../../build/ol3-api.js|' $< > $@
|
sed -e 's|@SRC@|../../build/ol.js|' $< > $@
|
||||||
|
|
||||||
demos/api1/debug.html: demos/api1/index.html.in
|
demos/api1/debug.html: demos/api1/index.html.in
|
||||||
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol3-api|' $< > $@
|
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol|' $< > $@
|
||||||
|
|
||||||
.PHONY: demos/proj4js
|
.PHONY: demos/proj4js
|
||||||
demos/proj4js: \
|
demos/proj4js: \
|
||||||
build/ol3-api.js \
|
build/ol.js \
|
||||||
demos/proj4js/build.html \
|
demos/proj4js/build.html \
|
||||||
demos/proj4js/debug.html
|
demos/proj4js/debug.html
|
||||||
|
|
||||||
demos/proj4js/build.html: demos/proj4js/index.html.in
|
demos/proj4js/build.html: demos/proj4js/index.html.in
|
||||||
sed -e 's|@SRC@|../../build/ol3-api.js|' $< > $@
|
sed -e 's|@SRC@|../../build/ol.js|' $< > $@
|
||||||
|
|
||||||
demos/proj4js/debug.html: demos/proj4js/index.html.in
|
demos/proj4js/debug.html: demos/proj4js/index.html.in
|
||||||
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol3-api|' $< > $@
|
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol|' $< > $@
|
||||||
|
|
||||||
.PHONY: demos/side-by-side
|
.PHONY: demos/side-by-side
|
||||||
demos/side-by-side: \
|
demos/side-by-side: \
|
||||||
@@ -65,7 +65,7 @@ demos/side-by-side: \
|
|||||||
demos/side-by-side/advanced-optimizations.html: demos/side-by-side/index.html.in
|
demos/side-by-side/advanced-optimizations.html: demos/side-by-side/index.html.in
|
||||||
sed -e 's|@SRC@|advanced-optimizations.js|' $< > $@
|
sed -e 's|@SRC@|advanced-optimizations.js|' $< > $@
|
||||||
|
|
||||||
demos/side-by-side/advanced-optimizations.js: $(PLOVR_JAR) $(SRC) base.json \
|
demos/side-by-side/advanced-optimizations.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
demos/side-by-side/side-by-side.json demos/side-by-side/side-by-side.js
|
demos/side-by-side/side-by-side.json demos/side-by-side/side-by-side.js
|
||||||
java -jar $(PLOVR_JAR) build demos/side-by-side/side-by-side.json >$@
|
java -jar $(PLOVR_JAR) build demos/side-by-side/side-by-side.json >$@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@@ -78,7 +78,7 @@ demos/side-by-side/simple-optimizations.html: demos/side-by-side/index.html.in
|
|||||||
sed -e 's|@SRC@|simple-optimizations.js|' $< > $@
|
sed -e 's|@SRC@|simple-optimizations.js|' $< > $@
|
||||||
|
|
||||||
# FIXME invoke plovr directly, rather than assuming that the server is running
|
# FIXME invoke plovr directly, rather than assuming that the server is running
|
||||||
demos/side-by-side/simple-optimizations.js: $(PLOVR_JAR) $(SRC) base.json \
|
demos/side-by-side/simple-optimizations.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
demos/side-by-side/side-by-side.json demos/side-by-side/side-by-side.js
|
demos/side-by-side/side-by-side.json demos/side-by-side/side-by-side.js
|
||||||
curl 'http://localhost:9810/compile?id=demo-side-by-side&mode=SIMPLE' > $@
|
curl 'http://localhost:9810/compile?id=demo-side-by-side&mode=SIMPLE' > $@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@@ -95,7 +95,7 @@ demos/two-layers: \
|
|||||||
demos/two-layers/advanced-optimizations.html: demos/two-layers/index.html.in
|
demos/two-layers/advanced-optimizations.html: demos/two-layers/index.html.in
|
||||||
sed -e 's|@SRC@|advanced-optimizations.js|' $< > $@
|
sed -e 's|@SRC@|advanced-optimizations.js|' $< > $@
|
||||||
|
|
||||||
demos/two-layers/advanced-optimizations.js: $(PLOVR_JAR) $(SRC) base.json \
|
demos/two-layers/advanced-optimizations.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
demos/two-layers/two-layers.json demos/two-layers/two-layers.js
|
demos/two-layers/two-layers.json demos/two-layers/two-layers.js
|
||||||
java -jar $(PLOVR_JAR) build demos/two-layers/two-layers.json >$@
|
java -jar $(PLOVR_JAR) build demos/two-layers/two-layers.json >$@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@@ -108,7 +108,7 @@ demos/two-layers/simple-optimizations.html: demos/two-layers/index.html.in
|
|||||||
sed -e 's|@SRC@|simple-optimizations.js|' $< > $@
|
sed -e 's|@SRC@|simple-optimizations.js|' $< > $@
|
||||||
|
|
||||||
# FIXME invoke plovr directly, rather than assuming that the server is running
|
# FIXME invoke plovr directly, rather than assuming that the server is running
|
||||||
demos/two-layers/simple-optimizations.js: $(PLOVR_JAR) $(SRC) base.json \
|
demos/two-layers/simple-optimizations.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
|
||||||
demos/two-layers/two-layers.json demos/two-layers/two-layers.js
|
demos/two-layers/two-layers.json demos/two-layers/two-layers.js
|
||||||
curl 'http://localhost:9810/compile?id=demo-two-layers&mode=SIMPLE' > $@
|
curl 'http://localhost:9810/compile?id=demo-two-layers&mode=SIMPLE' > $@
|
||||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||||
@@ -116,11 +116,11 @@ demos/two-layers/simple-optimizations.js: $(PLOVR_JAR) $(SRC) base.json \
|
|||||||
|
|
||||||
.PHONY: serve
|
.PHONY: serve
|
||||||
serve: $(PLOVR_JAR)
|
serve: $(PLOVR_JAR)
|
||||||
java -jar $(PLOVR_JAR) serve build/ol3.json build/ol3-api.json demos/*/*.json
|
java -jar $(PLOVR_JAR) serve build/ol.json build/ol3.json demos/*/*.json
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC) $(API) $(filter-out $(TARGETS),$(shell find demos -name \*.js))
|
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC_OL3) $(SRC_OL) $(filter-out $(TARGETS),$(shell find demos -name \*.js))
|
||||||
|
|
||||||
webgl-debug.js:
|
webgl-debug.js:
|
||||||
curl https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/debug/webgl-debug.js > $@
|
curl https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/debug/webgl-debug.js > $@
|
||||||
@@ -130,7 +130,9 @@ $(PLOVR_JAR):
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f build/all.js
|
rm -f build/all.js
|
||||||
|
rm -f build/ol.js
|
||||||
rm -f build/ol3.js
|
rm -f build/ol3.js
|
||||||
|
rm -f build/ol3-compiled.js
|
||||||
rm -f demos/*/*.html
|
rm -f demos/*/*.html
|
||||||
rm -f demos/*/advanced-optimizations.*
|
rm -f demos/*/advanced-optimizations.*
|
||||||
rm -f demos/*/simple-optimizations.*
|
rm -f demos/*/simple-optimizations.*
|
||||||
|
|||||||
9
build/ol.json
Normal file
9
build/ol.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
"id": "ol",
|
||||||
|
|
||||||
|
"inherits": "../base.json",
|
||||||
|
|
||||||
|
"inputs": "src/ol/ol.js"
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
|
|
||||||
"id": "ol3-api",
|
|
||||||
|
|
||||||
"inherits": "../base.json",
|
|
||||||
|
|
||||||
"inputs": "src/api/api.js"
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
var map = ol3.map({
|
var map = ol.map({
|
||||||
renderTo: 'map',
|
renderTo: 'map',
|
||||||
layers: [ol3.layer.osm()],
|
layers: [ol.layer.osm()],
|
||||||
center: [45, 5],
|
center: [45, 5],
|
||||||
zoom: 10
|
zoom: 10
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol3.Projection');
|
||||||
|
|
||||||
|
|
||||||
var outputElement = document.getElementById('output');
|
var outputElement = document.getElementById('output');
|
||||||
|
|
||||||
var point, transformedPoint;
|
var point, transformedPoint;
|
||||||
|
|
||||||
point = new ol.Coordinate(-626172.13571216376, 6887893.4928337997);
|
point = new ol3.Coordinate(-626172.13571216376, 6887893.4928337997);
|
||||||
transformedPoint = ol.Projection.transformWithCodes(
|
transformedPoint = ol3.Projection.transformWithCodes(
|
||||||
point, 'GOOGLE', 'WGS84');
|
point, 'GOOGLE', 'WGS84');
|
||||||
outputElement.appendChild(goog.dom.createTextNode(transformedPoint.toString()));
|
outputElement.appendChild(goog.dom.createTextNode(transformedPoint.toString()));
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ Proj4js.defs['EPSG:21781'] =
|
|||||||
'+x_0=600000 +y_0=200000 +ellps=bessel ' +
|
'+x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||||
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
||||||
|
|
||||||
point = new ol.Coordinate(7.439583333333333, 46.95240555555556);
|
point = new ol3.Coordinate(7.439583333333333, 46.95240555555556);
|
||||||
transformedPoint = ol.Projection.transformWithCodes(
|
transformedPoint = ol3.Projection.transformWithCodes(
|
||||||
point, 'EPSG:4326', 'EPSG:21781');
|
point, 'EPSG:4326', 'EPSG:21781');
|
||||||
outputElement.appendChild(goog.dom.createTextNode(transformedPoint.toString()));
|
outputElement.appendChild(goog.dom.createTextNode(transformedPoint.toString()));
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.require('goog.debug.Console');
|
goog.require('goog.debug.Console');
|
||||||
goog.require('goog.debug.Logger');
|
goog.require('goog.debug.Logger');
|
||||||
goog.require('goog.debug.Logger.Level');
|
goog.require('goog.debug.Logger.Level');
|
||||||
goog.require('ol.CoordinateFormat');
|
goog.require('ol3.CoordinateFormat');
|
||||||
goog.require('ol.RendererHint');
|
goog.require('ol3.RendererHint');
|
||||||
goog.require('ol.control.Attribution');
|
goog.require('ol3.control.Attribution');
|
||||||
goog.require('ol.control.MousePosition');
|
goog.require('ol3.control.MousePosition');
|
||||||
goog.require('ol.createMap');
|
goog.require('ol3.createMap');
|
||||||
goog.require('ol.interaction.Keyboard');
|
goog.require('ol3.interaction.Keyboard');
|
||||||
goog.require('ol.layer.MapQuestOpenAerial');
|
goog.require('ol3.layer.MapQuestOpenAerial');
|
||||||
|
|
||||||
|
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
@@ -17,22 +17,22 @@ if (goog.DEBUG) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var layer = new ol.layer.MapQuestOpenAerial();
|
var layer = new ol3.layer.MapQuestOpenAerial();
|
||||||
|
|
||||||
var layers = new ol.Collection();
|
var layers = new ol3.Collection();
|
||||||
layers.push(layer);
|
layers.push(layer);
|
||||||
|
|
||||||
var domMap = ol.createMap(
|
var domMap = ol3.createMap(
|
||||||
document.getElementById('domMap'),
|
document.getElementById('domMap'),
|
||||||
{'layers': layers},
|
{'layers': layers},
|
||||||
ol.RendererHint.DOM);
|
ol3.RendererHint.DOM);
|
||||||
domMap.setCenter(new ol.Coordinate(0, 0));
|
domMap.setCenter(new ol3.Coordinate(0, 0));
|
||||||
domMap.setResolution(layer.getStore().getResolutions()[0]);
|
domMap.setResolution(layer.getStore().getResolutions()[0]);
|
||||||
|
|
||||||
var webglMap = ol.createMap(
|
var webglMap = ol3.createMap(
|
||||||
document.getElementById('webglMap'),
|
document.getElementById('webglMap'),
|
||||||
{},
|
{},
|
||||||
ol.RendererHint.WEBGL);
|
ol3.RendererHint.WEBGL);
|
||||||
if (!goog.isNull(webglMap)) {
|
if (!goog.isNull(webglMap)) {
|
||||||
webglMap.bindTo('center', domMap);
|
webglMap.bindTo('center', domMap);
|
||||||
webglMap.bindTo('layers', domMap);
|
webglMap.bindTo('layers', domMap);
|
||||||
@@ -40,21 +40,23 @@ if (!goog.isNull(webglMap)) {
|
|||||||
webglMap.bindTo('rotation', domMap);
|
webglMap.bindTo('rotation', domMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributionControl = new ol.control.Attribution(domMap);
|
var attributionControl = new ol3.control.Attribution(domMap);
|
||||||
document.getElementById('attribution').appendChild(
|
document.getElementById('attribution').appendChild(
|
||||||
attributionControl.getElement());
|
attributionControl.getElement());
|
||||||
|
|
||||||
var domMousePositionControl = new ol.control.MousePosition(domMap,
|
var domMousePositionControl = new ol3.control.MousePosition(domMap,
|
||||||
ol.Projection.getFromCode('EPSG:4326'), ol.CoordinateFormat.hdms, ' ');
|
ol3.Projection.getFromCode('EPSG:4326'), ol3.CoordinateFormat.hdms,
|
||||||
|
' ');
|
||||||
document.getElementById('domMousePosition').appendChild(
|
document.getElementById('domMousePosition').appendChild(
|
||||||
domMousePositionControl.getElement());
|
domMousePositionControl.getElement());
|
||||||
|
|
||||||
var webglMousePositionControl = new ol.control.MousePosition(webglMap,
|
var webglMousePositionControl = new ol3.control.MousePosition(webglMap,
|
||||||
ol.Projection.getFromCode('EPSG:4326'), ol.CoordinateFormat.hdms, ' ');
|
ol3.Projection.getFromCode('EPSG:4326'), ol3.CoordinateFormat.hdms,
|
||||||
|
' ');
|
||||||
document.getElementById('webglMousePosition').appendChild(
|
document.getElementById('webglMousePosition').appendChild(
|
||||||
webglMousePositionControl.getElement());
|
webglMousePositionControl.getElement());
|
||||||
|
|
||||||
var keyboardInteraction = new ol.interaction.Keyboard();
|
var keyboardInteraction = new ol3.interaction.Keyboard();
|
||||||
keyboardInteraction.addCallback('0', function() {
|
keyboardInteraction.addCallback('0', function() {
|
||||||
layer.setBrightness(0);
|
layer.setBrightness(0);
|
||||||
layer.setContrast(0);
|
layer.setContrast(0);
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.RendererHint');
|
goog.require('ol3.RendererHint');
|
||||||
goog.require('ol.control.Attribution');
|
goog.require('ol3.control.Attribution');
|
||||||
goog.require('ol.createMap');
|
goog.require('ol3.createMap');
|
||||||
goog.require('ol.layer.BingMaps');
|
goog.require('ol3.layer.BingMaps');
|
||||||
goog.require('ol.layer.TileJSON');
|
goog.require('ol3.layer.TileJSON');
|
||||||
|
|
||||||
|
|
||||||
var layer1 = new ol.layer.BingMaps(
|
var layer1 = new ol3.layer.BingMaps(
|
||||||
ol.BingMapsStyle.AERIAL,
|
ol3.BingMapsStyle.AERIAL,
|
||||||
'AheP841R-MsLErKQChaTba_xDoOCl40-EeTubD9uNhNAyQTePwFY9iVD1_pyqqlE');
|
'AheP841R-MsLErKQChaTba_xDoOCl40-EeTubD9uNhNAyQTePwFY9iVD1_pyqqlE');
|
||||||
var layer2 = new ol.layer.TileJSON(
|
var layer2 = new ol3.layer.TileJSON(
|
||||||
'http://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.jsonp');
|
'http://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.jsonp');
|
||||||
|
|
||||||
var layers = new ol.Collection([layer1, layer2]);
|
var layers = new ol3.Collection([layer1, layer2]);
|
||||||
|
|
||||||
var webglMap = ol.createMap(
|
var webglMap = ol3.createMap(
|
||||||
document.getElementById('webglMap'),
|
document.getElementById('webglMap'),
|
||||||
{'layers': new ol.Collection([layer1, layer2])},
|
{'layers': new ol3.Collection([layer1, layer2])},
|
||||||
ol.RendererHint.WEBGL);
|
ol3.RendererHint.WEBGL);
|
||||||
|
|
||||||
goog.events.listen(layer2, goog.events.EventType.LOAD, function() {
|
goog.events.listen(layer2, goog.events.EventType.LOAD, function() {
|
||||||
webglMap.setUserCenter(new ol.Coordinate(-77.93254999999999, 37.9555));
|
webglMap.setUserCenter(new ol3.Coordinate(-77.93254999999999, 37.9555));
|
||||||
webglMap.setResolution(layer2.getStore().getResolutions()[5]);
|
webglMap.setResolution(layer2.getStore().getResolutions()[5]);
|
||||||
});
|
});
|
||||||
|
|
||||||
var domMap = ol.createMap(
|
var domMap = ol3.createMap(
|
||||||
document.getElementById('domMap'),
|
document.getElementById('domMap'),
|
||||||
{},
|
{},
|
||||||
ol.RendererHint.DOM);
|
ol3.RendererHint.DOM);
|
||||||
domMap.bindTo('center', webglMap);
|
domMap.bindTo('center', webglMap);
|
||||||
domMap.bindTo('layers', webglMap);
|
domMap.bindTo('layers', webglMap);
|
||||||
domMap.bindTo('resolution', webglMap);
|
domMap.bindTo('resolution', webglMap);
|
||||||
domMap.bindTo('rotation', webglMap);
|
domMap.bindTo('rotation', webglMap);
|
||||||
|
|
||||||
var attributionControl = new ol.control.Attribution(webglMap);
|
var attributionControl = new ol3.control.Attribution(webglMap);
|
||||||
document.getElementById('attribution').appendChild(
|
document.getElementById('attribution').appendChild(
|
||||||
attributionControl.getElement());
|
attributionControl.getElement());
|
||||||
|
|
||||||
|
|||||||
168
src/api/api.js
168
src/api/api.js
@@ -1,168 +0,0 @@
|
|||||||
goog.provide('ol3');
|
|
||||||
goog.provide('ol3.layer');
|
|
||||||
|
|
||||||
goog.require('goog.dom');
|
|
||||||
goog.require('ol.Collection');
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Layer');
|
|
||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.Object');
|
|
||||||
goog.require('ol.Projection');
|
|
||||||
goog.require('ol.createMap');
|
|
||||||
goog.require('ol.layer.OpenStreetMap');
|
|
||||||
|
|
||||||
|
|
||||||
goog.exportSymbol('ol3', ol3);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Array|ol.Collection}
|
|
||||||
*/
|
|
||||||
ol3.Collection;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Array.<number>|ol.Coordinate|{x: number, y: number}}
|
|
||||||
*/
|
|
||||||
ol3.Coordinate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {{center: (ol3.Coordinate|undefined),
|
|
||||||
* layers: (ol3.Collection|undefined),
|
|
||||||
* renderTo: (Element|string|undefined),
|
|
||||||
* resolution: (number|undefined),
|
|
||||||
* zoom: (number|undefined)}}
|
|
||||||
*/
|
|
||||||
ol3.MapOptions;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object|ol.Object}
|
|
||||||
*/
|
|
||||||
ol3.Object;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {ol.Projection|string}
|
|
||||||
*/
|
|
||||||
ol3.Projection;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol3.Collection} collection Collection.
|
|
||||||
* @return {ol.Collection} Collection.
|
|
||||||
*/
|
|
||||||
ol3.collection = function(collection) {
|
|
||||||
if (collection instanceof ol.Collection) {
|
|
||||||
return collection;
|
|
||||||
} else if (goog.isArray(collection)) {
|
|
||||||
var array = /** @type {Array} */ collection;
|
|
||||||
return new ol.Collection(collection);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3, 'collection', ol3.collection);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol3.Coordinate} coordinate Coordinate.
|
|
||||||
* @return {ol.Coordinate} Coordinate.
|
|
||||||
*/
|
|
||||||
ol3.coordinate = function(coordinate) {
|
|
||||||
if (coordinate instanceof ol.Coordinate) {
|
|
||||||
return coordinate;
|
|
||||||
} else if (goog.isArray(coordinate)) {
|
|
||||||
var array = /** @type {Array.<number>} */ coordinate;
|
|
||||||
return new ol.Coordinate(array[1], array[0]);
|
|
||||||
} else if (goog.isObject(coordinate)) {
|
|
||||||
var object = /** @type {{x: number, y: number}} */ coordinate;
|
|
||||||
return new ol.Coordinate(object.x, object.y);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3, 'coordinate', ol3.coordinate);
|
|
||||||
|
|
||||||
|
|
||||||
goog.exportProperty(ol3, 'layer', ol3.layer);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Layer} Layer.
|
|
||||||
*/
|
|
||||||
ol3.layer.osm = function() {
|
|
||||||
return new ol.layer.OpenStreetMap();
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3.layer, 'osm', ol3.layer.osm);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol3.MapOptions=} opt_mapOptions Options.
|
|
||||||
* @return {ol.Map} Map.
|
|
||||||
*/
|
|
||||||
ol3.map = function(opt_mapOptions) {
|
|
||||||
var options = opt_mapOptions || {};
|
|
||||||
var center = ol3.coordinate(/** @type {ol3.Coordinate} */
|
|
||||||
(goog.object.get(options, 'center', null)));
|
|
||||||
var layers = ol3.collection(/** @type {ol3.Collection} */
|
|
||||||
(goog.object.get(options, 'layers', null)));
|
|
||||||
var projection = ol3.projection(/** @type {ol3.Projection} */
|
|
||||||
(goog.object.get(options, 'projection', 'EPSG:3857')));
|
|
||||||
var resolution = /** @type {number|undefined} */
|
|
||||||
goog.object.get(options, 'resolution');
|
|
||||||
if (!goog.isDef(resolution) && goog.object.containsKey(options, 'zoom')) {
|
|
||||||
var zoom = /** @type {number} */ goog.object.get(options, 'zoom');
|
|
||||||
resolution = ol.Projection.EPSG_3857_HALF_SIZE / (128 << zoom);
|
|
||||||
}
|
|
||||||
var target = goog.dom.getElement(/** @type {Element|string} */
|
|
||||||
(goog.object.get(options, 'renderTo', 'map')));
|
|
||||||
var userProjection = ol3.projection(/** @type {ol3.Projection} */
|
|
||||||
(goog.object.get(options, 'userProjection', 'EPSG:4326')));
|
|
||||||
var map = ol.createMap(target, {
|
|
||||||
'layers': layers,
|
|
||||||
'projection': projection,
|
|
||||||
'resolution': resolution,
|
|
||||||
'userProjection': userProjection
|
|
||||||
});
|
|
||||||
if (!goog.isNull(center)) {
|
|
||||||
map.setUserCenter(center);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3, 'map', ol3.map);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol3.Object} object Object.
|
|
||||||
* @return {ol.Object} Object.
|
|
||||||
*/
|
|
||||||
ol3.object = function(object) {
|
|
||||||
if (object instanceof ol.Object) {
|
|
||||||
return object;
|
|
||||||
} else if (goog.isObject(object)) {
|
|
||||||
var values = /** @type {Object} */ object;
|
|
||||||
return new ol.Object(values);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3, 'object', ol3.object);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol3.Projection} projection Projection.
|
|
||||||
* @return {ol.Projection} Projection.
|
|
||||||
*/
|
|
||||||
ol3.projection = function(projection) {
|
|
||||||
if (projection instanceof ol.Projection) {
|
|
||||||
return projection;
|
|
||||||
} else if (goog.isString(projection)) {
|
|
||||||
var code = /** @type {string} */ projection;
|
|
||||||
return ol.Projection.getFromCode(code);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(ol3, 'projection', ol3.projection);
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
|
||||||
goog.require('ol.array');
|
|
||||||
|
|
||||||
|
|
||||||
function testBinaryFindNearest() {
|
|
||||||
var arr = [1000, 500, 100];
|
|
||||||
|
|
||||||
assertEquals(0, ol.array.binaryFindNearest(arr, 10000));
|
|
||||||
assertEquals(0, ol.array.binaryFindNearest(arr, 1000));
|
|
||||||
assertEquals(0, ol.array.binaryFindNearest(arr, 900));
|
|
||||||
|
|
||||||
assertEquals(1, ol.array.binaryFindNearest(arr, 750));
|
|
||||||
|
|
||||||
assertEquals(1, ol.array.binaryFindNearest(arr, 550));
|
|
||||||
assertEquals(1, ol.array.binaryFindNearest(arr, 500));
|
|
||||||
assertEquals(1, ol.array.binaryFindNearest(arr, 450));
|
|
||||||
|
|
||||||
assertEquals(2, ol.array.binaryFindNearest(arr, 300));
|
|
||||||
|
|
||||||
assertEquals(2, ol.array.binaryFindNearest(arr, 200));
|
|
||||||
assertEquals(2, ol.array.binaryFindNearest(arr, 100));
|
|
||||||
assertEquals(2, ol.array.binaryFindNearest(arr, 50));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testLinearFindNearest() {
|
|
||||||
var arr = [1000, 500, 100];
|
|
||||||
|
|
||||||
assertEquals(0, ol.array.linearFindNearest(arr, 10000));
|
|
||||||
assertEquals(0, ol.array.linearFindNearest(arr, 1000));
|
|
||||||
assertEquals(0, ol.array.linearFindNearest(arr, 900));
|
|
||||||
|
|
||||||
assertEquals(1, ol.array.linearFindNearest(arr, 750));
|
|
||||||
|
|
||||||
assertEquals(1, ol.array.linearFindNearest(arr, 550));
|
|
||||||
assertEquals(1, ol.array.linearFindNearest(arr, 500));
|
|
||||||
assertEquals(1, ol.array.linearFindNearest(arr, 450));
|
|
||||||
|
|
||||||
assertEquals(2, ol.array.linearFindNearest(arr, 300));
|
|
||||||
|
|
||||||
assertEquals(2, ol.array.linearFindNearest(arr, 200));
|
|
||||||
assertEquals(2, ol.array.linearFindNearest(arr, 100));
|
|
||||||
assertEquals(2, ol.array.linearFindNearest(arr, 50));
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
goog.provide('ol.Attribution');
|
|
||||||
|
|
||||||
goog.require('ol.CoverageArea');
|
|
||||||
goog.require('ol.Projection');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {string} html HTML.
|
|
||||||
* @param {Array.<ol.CoverageArea>=} opt_coverageAreas Coverage areas.
|
|
||||||
* @param {ol.Projection=} opt_projection Projection.
|
|
||||||
*/
|
|
||||||
ol.Attribution = function(html, opt_coverageAreas, opt_projection) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.html_ = html;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Array.<ol.CoverageArea>}
|
|
||||||
*/
|
|
||||||
this.coverageAreas_ = opt_coverageAreas || null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Projection}
|
|
||||||
*/
|
|
||||||
this.projection_ = opt_projection || null;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array.<ol.CoverageArea>} Coverage areas.
|
|
||||||
*/
|
|
||||||
ol.Attribution.prototype.getCoverageAreas = function() {
|
|
||||||
return this.coverageAreas_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string} HTML.
|
|
||||||
*/
|
|
||||||
ol.Attribution.prototype.getHtml = function() {
|
|
||||||
return this.html_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Projection} Projection.
|
|
||||||
*/
|
|
||||||
ol.Attribution.prototype.getProjection = function() {
|
|
||||||
return this.projection_;
|
|
||||||
};
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
goog.provide('ol.Coordinate');
|
|
||||||
|
|
||||||
goog.require('goog.math.Vec2');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {goog.math.Vec2}
|
|
||||||
* @param {number} x X.
|
|
||||||
* @param {number} y Y.
|
|
||||||
*/
|
|
||||||
ol.Coordinate = function(x, y) {
|
|
||||||
goog.base(this, x, y);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.Coordinate, goog.math.Vec2);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {ol.Coordinate}
|
|
||||||
*/
|
|
||||||
ol.Coordinate.ZERO = new ol.Coordinate(0, 0);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Coordinate} Clone.
|
|
||||||
*/
|
|
||||||
ol.Coordinate.prototype.clone = function() {
|
|
||||||
return new ol.Coordinate(this.x, this.y);
|
|
||||||
};
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
goog.provide('ol.CoverageArea');
|
|
||||||
|
|
||||||
goog.require('ol.Extent');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
*/
|
|
||||||
ol.CoverageArea = function(extent) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
this.extent = extent;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @return {boolean} Intersects.
|
|
||||||
*/
|
|
||||||
ol.CoverageArea.prototype.intersectsExtent = function(extent) {
|
|
||||||
return this.extent.intersects(extent);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @param {number} resolution Resolution.
|
|
||||||
* @return {boolean} Intersects.
|
|
||||||
*/
|
|
||||||
ol.CoverageArea.prototype.intersectsExtentAndResolution = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TransformFunction} transformFn Transform.
|
|
||||||
* @return {ol.CoverageArea} Transformed coverage area.
|
|
||||||
*/
|
|
||||||
ol.CoverageArea.prototype.transform = function(transformFn) {
|
|
||||||
var extent = this.extent.transform(transformFn);
|
|
||||||
return new ol.CoverageArea(extent);
|
|
||||||
};
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
goog.provide('ol.RendererHint');
|
|
||||||
goog.provide('ol.createMap');
|
|
||||||
|
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('ol.Collection');
|
|
||||||
goog.require('ol.Map');
|
|
||||||
goog.require('ol.MapProperty');
|
|
||||||
goog.require('ol.Projection');
|
|
||||||
goog.require('ol.dom');
|
|
||||||
goog.require('ol.dom.MapRenderer');
|
|
||||||
goog.require('ol.interaction.AltDragRotate');
|
|
||||||
goog.require('ol.interaction.CenterConstraint');
|
|
||||||
goog.require('ol.interaction.Constraints');
|
|
||||||
goog.require('ol.interaction.DblClickZoom');
|
|
||||||
goog.require('ol.interaction.DragPan');
|
|
||||||
goog.require('ol.interaction.KeyboardPan');
|
|
||||||
goog.require('ol.interaction.KeyboardZoom');
|
|
||||||
goog.require('ol.interaction.MouseWheelZoom');
|
|
||||||
goog.require('ol.interaction.ResolutionConstraint');
|
|
||||||
goog.require('ol.interaction.RotationConstraint');
|
|
||||||
goog.require('ol.interaction.ShiftDragZoom');
|
|
||||||
goog.require('ol.webgl');
|
|
||||||
goog.require('ol.webgl.MapRenderer');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {string} Default projection code.
|
|
||||||
*/
|
|
||||||
ol.DEFAULT_PROJECTION_CODE = 'EPSG:3857';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {string} Default user projection code.
|
|
||||||
*/
|
|
||||||
ol.DEFAULT_USER_PROJECTION_CODE = 'EPSG:4326';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {boolean} Whether to enable DOM.
|
|
||||||
*/
|
|
||||||
ol.ENABLE_DOM = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {boolean} Whether to enable WebGL.
|
|
||||||
*/
|
|
||||||
ol.ENABLE_WEBGL = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.RendererHint = {
|
|
||||||
DOM: 'dom',
|
|
||||||
WEBGL: 'webgl'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array.<ol.RendererHint>}
|
|
||||||
*/
|
|
||||||
ol.DEFAULT_RENDERER_HINT = [
|
|
||||||
ol.RendererHint.WEBGL,
|
|
||||||
ol.RendererHint.DOM
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Element} target Target.
|
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
|
||||||
* @param {ol.RendererHint|Array.<ol.RendererHint>=} opt_rendererHints
|
|
||||||
* Renderer hints.
|
|
||||||
* @return {ol.Map} Map.
|
|
||||||
*/
|
|
||||||
ol.createMap = function(target, opt_values, opt_rendererHints) {
|
|
||||||
|
|
||||||
var values = {};
|
|
||||||
if (goog.isDef(opt_values)) {
|
|
||||||
goog.object.extend(values, opt_values);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME this should be a configuration option
|
|
||||||
var centerConstraint = ol.interaction.CenterConstraint.snapToPixel;
|
|
||||||
var resolutionConstraint =
|
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(
|
|
||||||
Math.exp(Math.log(2) / 8), ol.Projection.EPSG_3857_HALF_SIZE / 128);
|
|
||||||
var rotationConstraint = ol.interaction.RotationConstraint.none;
|
|
||||||
var constraints = new ol.interaction.Constraints(
|
|
||||||
centerConstraint, resolutionConstraint, rotationConstraint);
|
|
||||||
|
|
||||||
if (!goog.object.containsKey(values, ol.MapProperty.INTERACTIONS)) {
|
|
||||||
var interactions = new ol.Collection();
|
|
||||||
interactions.push(new ol.interaction.AltDragRotate(constraints));
|
|
||||||
interactions.push(new ol.interaction.DblClickZoom(constraints));
|
|
||||||
interactions.push(new ol.interaction.DragPan(constraints));
|
|
||||||
interactions.push(new ol.interaction.KeyboardPan(constraints, 16));
|
|
||||||
interactions.push(new ol.interaction.KeyboardZoom(constraints));
|
|
||||||
interactions.push(new ol.interaction.MouseWheelZoom(constraints));
|
|
||||||
interactions.push(new ol.interaction.ShiftDragZoom(constraints));
|
|
||||||
values[ol.MapProperty.INTERACTIONS] = interactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!goog.object.containsKey(values, ol.MapProperty.LAYERS)) {
|
|
||||||
values[ol.MapProperty.LAYERS] = new ol.Collection();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!goog.object.containsKey(values, ol.MapProperty.PROJECTION)) {
|
|
||||||
values[ol.MapProperty.PROJECTION] =
|
|
||||||
ol.Projection.getFromCode(ol.DEFAULT_PROJECTION_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!goog.object.containsKey(values, ol.MapProperty.USER_PROJECTION)) {
|
|
||||||
values[ol.MapProperty.USER_PROJECTION] =
|
|
||||||
ol.Projection.getFromCode(ol.DEFAULT_USER_PROJECTION_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array.<ol.RendererHint>}
|
|
||||||
*/
|
|
||||||
var rendererHints;
|
|
||||||
if (goog.isDef(opt_rendererHints)) {
|
|
||||||
if (goog.isArray(opt_rendererHints)) {
|
|
||||||
rendererHints = opt_rendererHints;
|
|
||||||
} else {
|
|
||||||
rendererHints = [opt_rendererHints];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rendererHints = ol.DEFAULT_RENDERER_HINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
var i, rendererHint, rendererConstructor;
|
|
||||||
for (i = 0; i < rendererHints.length; ++i) {
|
|
||||||
rendererHint = rendererHints[i];
|
|
||||||
if (rendererHint == ol.RendererHint.DOM) {
|
|
||||||
if (ol.ENABLE_DOM && ol.dom.isSupported()) {
|
|
||||||
rendererConstructor = ol.dom.MapRenderer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (rendererHint == ol.RendererHint.WEBGL) {
|
|
||||||
if (ol.ENABLE_WEBGL && ol.webgl.isSupported()) {
|
|
||||||
rendererConstructor = ol.webgl.MapRenderer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (goog.isDef(rendererConstructor)) {
|
|
||||||
return new ol.Map(target, rendererConstructor, values);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
goog.provide('ol.Extent');
|
|
||||||
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Rectangle');
|
|
||||||
goog.require('ol.TransformFunction');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Rectangle}
|
|
||||||
* @param {number} minX Minimum X.
|
|
||||||
* @param {number} minY Minimum Y.
|
|
||||||
* @param {number} maxX Maximum X.
|
|
||||||
* @param {number} maxY Maximum Y.
|
|
||||||
*/
|
|
||||||
ol.Extent = function(minX, minY, maxX, maxY) {
|
|
||||||
goog.base(this, minX, minY, maxX, maxY);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.Extent, ol.Rectangle);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {...ol.Coordinate} var_args Coordinates.
|
|
||||||
* @return {!ol.Extent} Bounding extent.
|
|
||||||
*/
|
|
||||||
ol.Extent.boundingExtent = function(var_args) {
|
|
||||||
var coordinate0 = arguments[0];
|
|
||||||
var extent = new ol.Extent(coordinate0.x, coordinate0.y,
|
|
||||||
coordinate0.x, coordinate0.y);
|
|
||||||
var i;
|
|
||||||
for (i = 1; i < arguments.length; ++i) {
|
|
||||||
var coordinate = arguments[i];
|
|
||||||
extent.minX = Math.min(extent.minX, coordinate.x);
|
|
||||||
extent.minY = Math.min(extent.minY, coordinate.y);
|
|
||||||
extent.maxX = Math.max(extent.maxX, coordinate.x);
|
|
||||||
extent.maxY = Math.max(extent.maxY, coordinate.y);
|
|
||||||
}
|
|
||||||
return extent;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Extent} Extent.
|
|
||||||
*/
|
|
||||||
ol.Extent.prototype.clone = function() {
|
|
||||||
return new ol.Extent(this.minX, this.minY, this.maxX, this.maxY);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TransformFunction} transformFn Transform function.
|
|
||||||
* @return {ol.Extent} Extent.
|
|
||||||
*/
|
|
||||||
ol.Extent.prototype.transform = function(transformFn) {
|
|
||||||
var min = transformFn(new ol.Coordinate(this.minX, this.minY));
|
|
||||||
var max = transformFn(new ol.Coordinate(this.maxX, this.maxY));
|
|
||||||
return new ol.Extent(min.x, min.y, max.x, max.y);
|
|
||||||
};
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
goog.provide('ol.Layer');
|
|
||||||
goog.provide('ol.LayerProperty');
|
|
||||||
|
|
||||||
goog.require('goog.math');
|
|
||||||
goog.require('ol.Object');
|
|
||||||
goog.require('ol.Store');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.LayerProperty = {
|
|
||||||
BRIGHTNESS: 'brightness',
|
|
||||||
CONTRAST: 'contrast',
|
|
||||||
HUE: 'hue',
|
|
||||||
OPACITY: 'opacity',
|
|
||||||
SATURATION: 'saturation',
|
|
||||||
VISIBLE: 'visible'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Object}
|
|
||||||
* @param {ol.Store} store Store.
|
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
|
||||||
*/
|
|
||||||
ol.Layer = function(store, opt_values) {
|
|
||||||
|
|
||||||
goog.base(this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Store}
|
|
||||||
*/
|
|
||||||
this.store_ = store;
|
|
||||||
|
|
||||||
this.setBrightness(0);
|
|
||||||
this.setContrast(0);
|
|
||||||
this.setHue(0);
|
|
||||||
this.setOpacity(1);
|
|
||||||
this.setSaturation(0);
|
|
||||||
this.setVisible(true);
|
|
||||||
|
|
||||||
if (goog.isDef(opt_values)) {
|
|
||||||
this.setValues(opt_values);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.Layer, ol.Object);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Brightness.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getBrightness = function() {
|
|
||||||
return /** @type {number} */ this.get(ol.LayerProperty.BRIGHTNESS);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getBrightness',
|
|
||||||
ol.Layer.prototype.getBrightness);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Contrast.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getContrast = function() {
|
|
||||||
return /** @type {number} */ this.get(ol.LayerProperty.CONTRAST);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getContrast',
|
|
||||||
ol.Layer.prototype.getContrast);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Hue.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getHue = function() {
|
|
||||||
return /** @type {number} */ this.get(ol.LayerProperty.HUE);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getHue',
|
|
||||||
ol.Layer.prototype.getHue);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Opacity.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getOpacity = function() {
|
|
||||||
return /** @type {number} */ this.get(ol.LayerProperty.OPACITY);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getOpacity',
|
|
||||||
ol.Layer.prototype.getOpacity);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Saturation.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getSaturation = function() {
|
|
||||||
return /** @type {number} */ this.get(ol.LayerProperty.SATURATION);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getSaturation',
|
|
||||||
ol.Layer.prototype.getSaturation);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Store} Store.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getStore = function() {
|
|
||||||
return this.store_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} Visible.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.getVisible = function() {
|
|
||||||
return /** @type {boolean} */ this.get(ol.LayerProperty.VISIBLE);
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'getVisible',
|
|
||||||
ol.Layer.prototype.getVisible);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} Is ready.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.isReady = function() {
|
|
||||||
return this.getStore().isReady();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} brightness Brightness.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setBrightness = function(brightness) {
|
|
||||||
brightness = goog.math.clamp(brightness, -1, 1);
|
|
||||||
if (brightness != this.getBrightness()) {
|
|
||||||
this.set(ol.LayerProperty.BRIGHTNESS, brightness);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setBrightness',
|
|
||||||
ol.Layer.prototype.setBrightness);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} contrast Contrast.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setContrast = function(contrast) {
|
|
||||||
contrast = goog.math.clamp(contrast, -1, 1);
|
|
||||||
if (contrast != this.getContrast()) {
|
|
||||||
this.set(ol.LayerProperty.CONTRAST, contrast);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setContrast',
|
|
||||||
ol.Layer.prototype.setContrast);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} hue Hue.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setHue = function(hue) {
|
|
||||||
if (hue != this.getHue()) {
|
|
||||||
this.set(ol.LayerProperty.HUE, hue);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setHue',
|
|
||||||
ol.Layer.prototype.setHue);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} opacity Opacity.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setOpacity = function(opacity) {
|
|
||||||
opacity = goog.math.clamp(opacity, 0, 1);
|
|
||||||
if (opacity != this.getOpacity()) {
|
|
||||||
this.set(ol.LayerProperty.OPACITY, opacity);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setOpacity',
|
|
||||||
ol.Layer.prototype.setOpacity);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} saturation Saturation.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setSaturation = function(saturation) {
|
|
||||||
saturation = goog.math.clamp(saturation, -1, 1);
|
|
||||||
if (saturation != this.getSaturation()) {
|
|
||||||
this.set(ol.LayerProperty.SATURATION, saturation);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setSaturation',
|
|
||||||
ol.Layer.prototype.setSaturation);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} visible Visible.
|
|
||||||
*/
|
|
||||||
ol.Layer.prototype.setVisible = function(visible) {
|
|
||||||
visible = !!visible;
|
|
||||||
if (visible != this.getVisible()) {
|
|
||||||
this.set(ol.LayerProperty.VISIBLE, visible);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
goog.exportProperty(
|
|
||||||
ol.Layer.prototype,
|
|
||||||
'setVisible',
|
|
||||||
ol.Layer.prototype.setVisible);
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
goog.provide('ol.LayerRenderer');
|
|
||||||
|
|
||||||
goog.require('goog.events');
|
|
||||||
goog.require('goog.events.EventType');
|
|
||||||
goog.require('ol.Layer');
|
|
||||||
goog.require('ol.LayerProperty');
|
|
||||||
goog.require('ol.Object');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Object}
|
|
||||||
* @param {ol.MapRenderer} mapRenderer Map renderer.
|
|
||||||
* @param {ol.Layer} layer Layer.
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer = function(mapRenderer, layer) {
|
|
||||||
|
|
||||||
goog.base(this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.MapRenderer}
|
|
||||||
*/
|
|
||||||
this.mapRenderer_ = mapRenderer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Layer}
|
|
||||||
*/
|
|
||||||
this.layer_ = layer;
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.BRIGHTNESS),
|
|
||||||
this.handleLayerBrightnessChange, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.CONTRAST),
|
|
||||||
this.handleLayerContrastChange, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.HUE),
|
|
||||||
this.handleLayerHueChange, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_, goog.events.EventType.LOAD,
|
|
||||||
this.handleLayerLoad, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.OPACITY),
|
|
||||||
this.handleLayerOpacityChange, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.SATURATION),
|
|
||||||
this.handleLayerSaturationChange, false, this);
|
|
||||||
|
|
||||||
goog.events.listen(this.layer_,
|
|
||||||
ol.Object.getChangedEventType(ol.LayerProperty.VISIBLE),
|
|
||||||
this.handleLayerVisibleChange, false, this);
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.LayerRenderer, ol.Object);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Layer} Layer.
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.getLayer = function() {
|
|
||||||
return this.layer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Map} Map.
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.getMap = function() {
|
|
||||||
return this.mapRenderer_.getMap();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.MapRenderer} Map renderer.
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.getMapRenderer = function() {
|
|
||||||
return this.mapRenderer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerBrightnessChange = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerContrastChange = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerHueChange = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerLoad = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerOpacityChange = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerSaturationChange = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.LayerRenderer.prototype.handleLayerVisibleChange = goog.nullFunction;
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
goog.provide('ol.Pixel');
|
|
||||||
|
|
||||||
goog.require('goog.math.Coordinate');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {goog.math.Coordinate}
|
|
||||||
* @param {number} x X.
|
|
||||||
* @param {number} y Y.
|
|
||||||
*/
|
|
||||||
ol.Pixel = function(x, y) {
|
|
||||||
goog.base(this, x, y);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.Pixel, goog.math.Coordinate);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Pixel} Clone.
|
|
||||||
*/
|
|
||||||
ol.Pixel.prototype.clone = function() {
|
|
||||||
return new ol.Pixel(this.x, this.y);
|
|
||||||
};
|
|
||||||
@@ -1,500 +0,0 @@
|
|||||||
goog.provide('ol.Projection');
|
|
||||||
|
|
||||||
goog.require('goog.array');
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.TransformFunction');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {boolean} Enable Proj4js.
|
|
||||||
*/
|
|
||||||
ol.ENABLE_PROJ4JS = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.ProjectionUnits = {
|
|
||||||
DEGREES: 'degrees',
|
|
||||||
METERS: 'm'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {string} code Code.
|
|
||||||
* @param {ol.ProjectionUnits} units Units.
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
*/
|
|
||||||
ol.Projection = function(code, units, extent) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.code_ = code;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.ProjectionUnits}
|
|
||||||
*/
|
|
||||||
this.units_ = units;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
this.extent_ = extent;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string} Code.
|
|
||||||
*/
|
|
||||||
ol.Projection.prototype.getCode = function() {
|
|
||||||
return this.code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Extent} Extent.
|
|
||||||
*/
|
|
||||||
ol.Projection.prototype.getExtent = function() {
|
|
||||||
return this.extent_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.ProjectionUnits} Units.
|
|
||||||
*/
|
|
||||||
ol.Projection.prototype.getUnits = function() {
|
|
||||||
return this.units_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Projection}
|
|
||||||
* @param {string} code Code.
|
|
||||||
* @param {Proj4js.Proj} proj4jsProj Proj4js projection.
|
|
||||||
*/
|
|
||||||
ol.Proj4jsProjection = function(code, proj4jsProj) {
|
|
||||||
|
|
||||||
var units = /** @type {ol.ProjectionUnits} */ proj4jsProj.units;
|
|
||||||
|
|
||||||
goog.base(this, code, units, null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Proj4js.Proj}
|
|
||||||
*/
|
|
||||||
this.proj4jsProj_ = proj4jsProj;
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.Proj4jsProjection, ol.Projection);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Proj4js.Proj} Proj4js projection.
|
|
||||||
*/
|
|
||||||
ol.Proj4jsProjection.prototype.getProj4jsProj = function() {
|
|
||||||
return this.proj4jsProj_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Object.<string, ol.Proj4jsProjection>}
|
|
||||||
*/
|
|
||||||
ol.Projection.proj4jsProjections_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Object.<string, ol.Projection>}
|
|
||||||
*/
|
|
||||||
ol.Projection.projections_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Object.<string, Object.<string, ol.TransformFunction>>}
|
|
||||||
*/
|
|
||||||
ol.Projection.transforms_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Projection>} projections Projections.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.Projection.addEquivalentProjections_ = function(projections) {
|
|
||||||
ol.Projection.addProjections(projections);
|
|
||||||
goog.array.forEach(projections, function(source) {
|
|
||||||
goog.array.forEach(projections, function(destination) {
|
|
||||||
ol.Projection.addTransform(
|
|
||||||
source, destination, ol.Projection.cloneTransform);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Projection>} projections1 Projections.
|
|
||||||
* @param {Array.<ol.Projection>} projections2 Projections.
|
|
||||||
* @param {ol.TransformFunction} forwardTransform Forward transform.
|
|
||||||
* @param {ol.TransformFunction} inverseTransform Inverse transform.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.Projection.addEquivalentTransforms_ =
|
|
||||||
function(projections1, projections2, forwardTransform, inverseTransform) {
|
|
||||||
goog.array.forEach(projections1, function(projection1) {
|
|
||||||
goog.array.forEach(projections2, function(projection2) {
|
|
||||||
ol.Projection.addTransform(projection1, projection2, forwardTransform);
|
|
||||||
ol.Projection.addTransform(projection2, projection1, inverseTransform);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Proj4jsProjection} proj4jsProjection Proj4js projection.
|
|
||||||
*/
|
|
||||||
ol.Projection.addProj4jsProjection = function(proj4jsProjection) {
|
|
||||||
var proj4jsProjections = ol.Projection.proj4jsProjections_;
|
|
||||||
var code = proj4jsProjection.getCode();
|
|
||||||
goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code));
|
|
||||||
proj4jsProjections[code] = proj4jsProjection;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Projection} projection Projection.
|
|
||||||
*/
|
|
||||||
ol.Projection.addProjection = function(projection) {
|
|
||||||
var projections = ol.Projection.projections_;
|
|
||||||
var code = projection.getCode();
|
|
||||||
goog.asserts.assert(!goog.object.containsKey(projections, code));
|
|
||||||
projections[code] = projection;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Projection>} projections Projections.
|
|
||||||
*/
|
|
||||||
ol.Projection.addProjections = function(projections) {
|
|
||||||
goog.array.forEach(projections, function(projection) {
|
|
||||||
ol.Projection.addProjection(projection);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Projection} source Source.
|
|
||||||
* @param {ol.Projection} destination Destination.
|
|
||||||
* @param {ol.TransformFunction} transformFn Transform.
|
|
||||||
*/
|
|
||||||
ol.Projection.addTransform = function(source, destination, transformFn) {
|
|
||||||
var projections = ol.Projection.projections_;
|
|
||||||
var sourceCode = source.getCode();
|
|
||||||
var destinationCode = destination.getCode();
|
|
||||||
var transforms = ol.Projection.transforms_;
|
|
||||||
if (!goog.object.containsKey(transforms, sourceCode)) {
|
|
||||||
transforms[sourceCode] = {};
|
|
||||||
}
|
|
||||||
goog.asserts.assert(
|
|
||||||
!goog.object.containsKey(transforms[sourceCode], destinationCode));
|
|
||||||
transforms[sourceCode][destinationCode] = transformFn;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} code Code.
|
|
||||||
* @return {ol.Projection} Projection.
|
|
||||||
*/
|
|
||||||
ol.Projection.getFromCode = function(code) {
|
|
||||||
var projection = ol.Projection.projections_[code];
|
|
||||||
if (ol.Projection.isProj4jsSupported() && !goog.isDef(projection)) {
|
|
||||||
projection = ol.Projection.getProj4jsProjectionFromCode_(code);
|
|
||||||
}
|
|
||||||
if (!goog.isDef(projection)) {
|
|
||||||
goog.asserts.assert(goog.isDef(projection));
|
|
||||||
projection = null;
|
|
||||||
}
|
|
||||||
return projection;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} code Code.
|
|
||||||
* @private
|
|
||||||
* @return {ol.Proj4jsProjection} Proj4js projection.
|
|
||||||
*/
|
|
||||||
ol.Projection.getProj4jsProjectionFromCode_ = function(code) {
|
|
||||||
var proj4jsProjections = ol.Projection.proj4jsProjections_;
|
|
||||||
var proj4jsProjection = proj4jsProjections[code];
|
|
||||||
if (!goog.isDef(proj4jsProjection)) {
|
|
||||||
var proj4jsProj = new Proj4js.Proj(code);
|
|
||||||
proj4jsProjection = new ol.Proj4jsProjection(code, proj4jsProj);
|
|
||||||
proj4jsProjections[code] = proj4jsProjection;
|
|
||||||
}
|
|
||||||
return proj4jsProjection;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Projection} projection1 Projection 1.
|
|
||||||
* @param {ol.Projection} projection2 Projection 2.
|
|
||||||
* @return {boolean} Equivalent.
|
|
||||||
*/
|
|
||||||
ol.Projection.equivalent = function(projection1, projection2) {
|
|
||||||
if (projection1 === projection2) {
|
|
||||||
return true;
|
|
||||||
} else if (projection1.getUnits() != projection2.getUnits()) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
var transformFn = ol.Projection.getTransform(projection1, projection2);
|
|
||||||
return transformFn === ol.Projection.cloneTransform;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Projection} source Source.
|
|
||||||
* @param {ol.Projection} destination Destination.
|
|
||||||
* @return {ol.TransformFunction} Transform.
|
|
||||||
*/
|
|
||||||
ol.Projection.getTransform = function(source, destination) {
|
|
||||||
var transforms = ol.Projection.transforms_;
|
|
||||||
var sourceCode = source.getCode();
|
|
||||||
var destinationCode = destination.getCode();
|
|
||||||
var transform;
|
|
||||||
if (goog.object.containsKey(transforms, sourceCode) &&
|
|
||||||
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
|
||||||
transform = transforms[sourceCode][destinationCode];
|
|
||||||
}
|
|
||||||
if (ol.Projection.isProj4jsSupported() && !goog.isDef(transform)) {
|
|
||||||
var proj4jsSource;
|
|
||||||
if (source instanceof ol.Proj4jsProjection) {
|
|
||||||
proj4jsSource = source;
|
|
||||||
} else {
|
|
||||||
proj4jsSource =
|
|
||||||
ol.Projection.getProj4jsProjectionFromCode_(source.getCode());
|
|
||||||
}
|
|
||||||
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
|
|
||||||
var proj4jsDestination;
|
|
||||||
if (destination instanceof ol.Proj4jsProjection) {
|
|
||||||
proj4jsDestination = destination;
|
|
||||||
} else {
|
|
||||||
proj4jsDestination =
|
|
||||||
ol.Projection.getProj4jsProjectionFromCode_(source.getCode());
|
|
||||||
}
|
|
||||||
var destinationProj4jsProj = proj4jsDestination.getProj4jsProj();
|
|
||||||
transform =
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
|
||||||
* @return {ol.Coordinate} Coordinate.
|
|
||||||
*/
|
|
||||||
function(coordinate) {
|
|
||||||
var proj4jsPoint = new Proj4js.Point(coordinate.x, coordinate.y);
|
|
||||||
proj4jsPoint = Proj4js.transform(
|
|
||||||
sourceProj4jsProj, destinationProj4jsProj, proj4jsPoint);
|
|
||||||
return new ol.Coordinate(proj4jsPoint.x, proj4jsPoint.y);
|
|
||||||
};
|
|
||||||
ol.Projection.addTransform(source, destination, transform);
|
|
||||||
}
|
|
||||||
if (!goog.isDef(transform)) {
|
|
||||||
goog.asserts.assert(goog.isDef(transform));
|
|
||||||
transform = ol.Projection.identityTransform;
|
|
||||||
}
|
|
||||||
return transform;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sourceCode Source code.
|
|
||||||
* @param {string} destinationCode Destination code.
|
|
||||||
* @return {ol.TransformFunction} Transform.
|
|
||||||
*/
|
|
||||||
ol.Projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
|
||||||
var source = ol.Projection.getFromCode(sourceCode);
|
|
||||||
var destination = ol.Projection.getFromCode(destinationCode);
|
|
||||||
return ol.Projection.getTransform(source, destination);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} Has Proj4js.
|
|
||||||
*/
|
|
||||||
ol.Projection.isProj4jsSupported = function() {
|
|
||||||
return ol.ENABLE_PROJ4JS && 'Proj4js' in goog.global;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.identityTransform = function(point) {
|
|
||||||
return point;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.cloneTransform = function(point) {
|
|
||||||
return point.clone();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @param {ol.Projection} source Source.
|
|
||||||
* @param {ol.Projection} destination Destination.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.transform = function(point, source, destination) {
|
|
||||||
var transformFn = ol.Projection.getTransform(source, destination);
|
|
||||||
return transformFn(point);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @param {string} sourceCode Source code.
|
|
||||||
* @param {string} destinationCode Destination code.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.transformWithCodes =
|
|
||||||
function(point, sourceCode, destinationCode) {
|
|
||||||
var transformFn = ol.Projection.getTransformFromCodes(
|
|
||||||
sourceCode, destinationCode);
|
|
||||||
return transformFn(point);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_3857_RADIUS = 6378137;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.forwardSphericalMercator = function(point) {
|
|
||||||
var x = ol.Projection.EPSG_3857_RADIUS * Math.PI * point.x / 180;
|
|
||||||
var y = ol.Projection.EPSG_3857_RADIUS *
|
|
||||||
Math.log(Math.tan(Math.PI * (point.y + 90) / 360));
|
|
||||||
return new ol.Coordinate(x, y);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate} point Point.
|
|
||||||
* @return {ol.Coordinate} Point.
|
|
||||||
*/
|
|
||||||
ol.Projection.inverseSphericalMercator = function(point) {
|
|
||||||
var x = 180 * point.x / (ol.Projection.EPSG_3857_RADIUS * Math.PI);
|
|
||||||
var y = 360 * Math.atan(
|
|
||||||
Math.exp(point.y / ol.Projection.EPSG_3857_RADIUS)) / Math.PI - 90;
|
|
||||||
return new ol.Coordinate(x, y);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_3857_HALF_SIZE = Math.PI * ol.Projection.EPSG_3857_RADIUS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_3857_EXTENT = new ol.Extent(
|
|
||||||
-ol.Projection.EPSG_3857_HALF_SIZE,
|
|
||||||
-ol.Projection.EPSG_3857_HALF_SIZE,
|
|
||||||
ol.Projection.EPSG_3857_HALF_SIZE,
|
|
||||||
ol.Projection.EPSG_3857_HALF_SIZE);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Array.<string>}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_3857_LIKE_CODES_ = [
|
|
||||||
'EPSG:3857',
|
|
||||||
'EPSG:102100',
|
|
||||||
'EPSG:102113',
|
|
||||||
'EPSG:900913'
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @private
|
|
||||||
* @type {Array.<ol.Projection>}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_3857_LIKE_PROJECTIONS_ = goog.array.map(
|
|
||||||
ol.Projection.EPSG_3857_LIKE_CODES_,
|
|
||||||
function(code) {
|
|
||||||
return new ol.Projection(
|
|
||||||
code,
|
|
||||||
ol.ProjectionUnits.METERS,
|
|
||||||
ol.Projection.EPSG_3857_EXTENT);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @private
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_4326_EXTENT_ = new ol.Extent(-180, -90, 180, 90);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Array.<string>}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_4326_LIKE_CODES_ = [
|
|
||||||
'CRS:84',
|
|
||||||
'EPSG:4326',
|
|
||||||
'urn:ogc:def:crs:EPSG:6.6:4326'
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {Array.<ol.Projection>}
|
|
||||||
*/
|
|
||||||
ol.Projection.EPSG_4326_LIKE_PROJECTIONS = goog.array.map(
|
|
||||||
ol.Projection.EPSG_4326_LIKE_CODES_,
|
|
||||||
function(code) {
|
|
||||||
return new ol.Projection(
|
|
||||||
code,
|
|
||||||
ol.ProjectionUnits.DEGREES,
|
|
||||||
ol.Projection.EPSG_4326_EXTENT_);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ol.Projection.addEquivalentProjections_(
|
|
||||||
ol.Projection.EPSG_3857_LIKE_PROJECTIONS_);
|
|
||||||
ol.Projection.addEquivalentProjections_(
|
|
||||||
ol.Projection.EPSG_4326_LIKE_PROJECTIONS);
|
|
||||||
ol.Projection.addEquivalentTransforms_(
|
|
||||||
ol.Projection.EPSG_4326_LIKE_PROJECTIONS,
|
|
||||||
ol.Projection.EPSG_3857_LIKE_PROJECTIONS_,
|
|
||||||
ol.Projection.forwardSphericalMercator,
|
|
||||||
ol.Projection.inverseSphericalMercator);
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Rectangle');
|
|
||||||
|
|
||||||
|
|
||||||
function testCenter() {
|
|
||||||
var rectangle = new ol.Rectangle(1, 2, 3, 4);
|
|
||||||
var center = rectangle.getCenter();
|
|
||||||
assertEquals(2, center.x);
|
|
||||||
assertEquals(3, center.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testClone() {
|
|
||||||
var rectangle = new ol.Rectangle(1, 2, 3, 4);
|
|
||||||
var clonedRectangle = rectangle.clone();
|
|
||||||
assertTrue(clonedRectangle instanceof ol.Rectangle);
|
|
||||||
assertFalse(clonedRectangle === rectangle);
|
|
||||||
assertEquals(rectangle.minX, clonedRectangle.minX);
|
|
||||||
assertEquals(rectangle.minY, clonedRectangle.minY);
|
|
||||||
assertEquals(rectangle.maxX, clonedRectangle.maxX);
|
|
||||||
assertEquals(rectangle.maxY, clonedRectangle.maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testContainsPositive() {
|
|
||||||
var rectangle = new ol.Rectangle(1, 2, 3, 4);
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(1, 2)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(1, 3)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(1, 4)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(2, 2)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(2, 3)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(2, 4)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(3, 2)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(3, 3)));
|
|
||||||
assertTrue(rectangle.contains(new ol.Coordinate(3, 4)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testContainsNegative() {
|
|
||||||
var rectangle = new ol.Rectangle(1, 2, 3, 4);
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(0, 1)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(0, 2)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(0, 3)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(0, 4)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(0, 5)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(1, 1)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(1, 5)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(2, 1)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(2, 5)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(3, 1)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(3, 5)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(4, 1)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(4, 2)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(4, 3)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(4, 4)));
|
|
||||||
assertFalse(rectangle.contains(new ol.Coordinate(4, 5)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testIntersects() {
|
|
||||||
|
|
||||||
var rectangle1 = new ol.Rectangle(50, 50, 100, 100);
|
|
||||||
|
|
||||||
function assertIntersects(rectangle2) {
|
|
||||||
assertTrue(rectangle1 + ' expected to intersect ' + rectangle2,
|
|
||||||
rectangle1.intersects(rectangle2));
|
|
||||||
}
|
|
||||||
function assertNotIntersects(rectangle2) {
|
|
||||||
assertFalse(rectangle1 + ' expected to not intersect ' + rectangle2,
|
|
||||||
rectangle1.intersects(rectangle2));
|
|
||||||
}
|
|
||||||
|
|
||||||
assertIntersects(rectangle1);
|
|
||||||
assertIntersects(new ol.Rectangle(20, 20, 80, 80));
|
|
||||||
assertIntersects(new ol.Rectangle(20, 50, 80, 100));
|
|
||||||
assertIntersects(new ol.Rectangle(20, 80, 80, 120));
|
|
||||||
assertIntersects(new ol.Rectangle(50, 20, 100, 80));
|
|
||||||
assertIntersects(new ol.Rectangle(50, 80, 100, 120));
|
|
||||||
assertIntersects(new ol.Rectangle(80, 20, 120, 80));
|
|
||||||
assertIntersects(new ol.Rectangle(80, 50, 120, 100));
|
|
||||||
assertIntersects(new ol.Rectangle(80, 80, 120, 120));
|
|
||||||
assertIntersects(new ol.Rectangle(20, 20, 120, 120));
|
|
||||||
assertIntersects(new ol.Rectangle(70, 70, 80, 80));
|
|
||||||
assertNotIntersects(new ol.Rectangle(10, 10, 30, 30));
|
|
||||||
assertNotIntersects(new ol.Rectangle(30, 10, 70, 30));
|
|
||||||
assertNotIntersects(new ol.Rectangle(50, 10, 100, 30));
|
|
||||||
assertNotIntersects(new ol.Rectangle(80, 10, 120, 30));
|
|
||||||
assertNotIntersects(new ol.Rectangle(120, 10, 140, 30));
|
|
||||||
assertNotIntersects(new ol.Rectangle(10, 30, 30, 70));
|
|
||||||
assertNotIntersects(new ol.Rectangle(120, 30, 140, 70));
|
|
||||||
assertNotIntersects(new ol.Rectangle(10, 50, 30, 100));
|
|
||||||
assertNotIntersects(new ol.Rectangle(120, 50, 140, 100));
|
|
||||||
assertNotIntersects(new ol.Rectangle(10, 80, 30, 120));
|
|
||||||
assertNotIntersects(new ol.Rectangle(120, 80, 140, 120));
|
|
||||||
assertNotIntersects(new ol.Rectangle(10, 120, 30, 140));
|
|
||||||
assertNotIntersects(new ol.Rectangle(30, 120, 70, 140));
|
|
||||||
assertNotIntersects(new ol.Rectangle(50, 120, 100, 140));
|
|
||||||
assertNotIntersects(new ol.Rectangle(80, 120, 120, 140));
|
|
||||||
assertNotIntersects(new ol.Rectangle(120, 120, 140, 140));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testSize() {
|
|
||||||
var rectangle = new ol.Rectangle(0, 1, 2, 4);
|
|
||||||
var size = rectangle.getSize();
|
|
||||||
assertEquals(2, size.width);
|
|
||||||
assertEquals(3, size.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testNormalize() {
|
|
||||||
var rectangle = new ol.Rectangle(0, 1, 2, 3);
|
|
||||||
var coordinate;
|
|
||||||
|
|
||||||
coordinate = rectangle.normalize(new ol.Coordinate(1, 2));
|
|
||||||
assertEquals(0.5, coordinate.x);
|
|
||||||
assertEquals(0.5, coordinate.y);
|
|
||||||
|
|
||||||
coordinate = rectangle.normalize(new ol.Coordinate(0, 3));
|
|
||||||
assertEquals(0, coordinate.x);
|
|
||||||
assertEquals(1, coordinate.y);
|
|
||||||
|
|
||||||
coordinate = rectangle.normalize(new ol.Coordinate(2, 1));
|
|
||||||
assertEquals(1, coordinate.x);
|
|
||||||
assertEquals(0, coordinate.y);
|
|
||||||
|
|
||||||
coordinate = rectangle.normalize(new ol.Coordinate(0, 0));
|
|
||||||
assertEquals(0, coordinate.x);
|
|
||||||
assertEquals(-0.5, coordinate.y);
|
|
||||||
|
|
||||||
coordinate = rectangle.normalize(new ol.Coordinate(-1, 1));
|
|
||||||
assertEquals(-0.5, coordinate.x);
|
|
||||||
assertEquals(0, coordinate.y);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testToString() {
|
|
||||||
var rectangle = new ol.Rectangle(0, 1, 2, 3);
|
|
||||||
assertEquals('(0, 1, 2, 3)', rectangle.toString());
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
goog.provide('ol.Store');
|
|
||||||
|
|
||||||
goog.require('goog.functions');
|
|
||||||
goog.require('ol.Attribution');
|
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.Projection');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.Projection} projection Projection.
|
|
||||||
* @param {ol.Extent=} opt_extent Extent.
|
|
||||||
* @param {Array.<ol.Attribution>=} opt_attributions Attributions.
|
|
||||||
*/
|
|
||||||
ol.Store = function(projection, opt_extent, opt_attributions) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Projection}
|
|
||||||
*/
|
|
||||||
this.projection_ = projection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Extent}
|
|
||||||
*/
|
|
||||||
this.extent_ = opt_extent || projection.getExtent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {Array.<ol.Attribution>}
|
|
||||||
*/
|
|
||||||
this.attributions_ = opt_attributions || null;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array.<ol.Attribution>} Attributions.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.getAttributions = function() {
|
|
||||||
return this.attributions_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Extent} Extent.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.getExtent = function() {
|
|
||||||
return this.extent_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Projection} Projection.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.getProjection = function() {
|
|
||||||
return this.projection_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array.<number>|undefined} Resolutions.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.getResolutions = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} Is ready.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.isReady = goog.functions.TRUE;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Attribution>} attributions Attributions.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.setAttributions = function(attributions) {
|
|
||||||
this.attributions_ = attributions;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.setExtent = function(extent) {
|
|
||||||
this.extent_ = extent;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Projection} projection Projetion.
|
|
||||||
*/
|
|
||||||
ol.Store.prototype.setProjection = function(projection) {
|
|
||||||
this.projection_ = projection;
|
|
||||||
};
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
goog.provide('ol.TransformFunction');
|
|
||||||
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {function(ol.Coordinate): ol.Coordinate}
|
|
||||||
*/
|
|
||||||
ol.TransformFunction;
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol');
|
||||||
goog.require('ol3');
|
goog.require('ol3.Collection');
|
||||||
|
|
||||||
|
|
||||||
function testCreateFromArray() {
|
function testCreateFromArray() {
|
||||||
var array = [0, 1, 2];
|
var array = [0, 1, 2];
|
||||||
var collection = ol3.collection(array);
|
var collection = ol.collection(array);
|
||||||
assertTrue(collection instanceof ol.Collection);
|
assertTrue(collection instanceof ol3.Collection);
|
||||||
assertEquals(3, collection.getLength());
|
assertEquals(3, collection.getLength());
|
||||||
assertEquals(0, collection.getAt(0));
|
assertEquals(0, collection.getAt(0));
|
||||||
assertEquals(1, collection.getAt(1));
|
assertEquals(1, collection.getAt(1));
|
||||||
@@ -15,8 +15,8 @@ function testCreateFromArray() {
|
|||||||
|
|
||||||
|
|
||||||
function testCreateFromCollection() {
|
function testCreateFromCollection() {
|
||||||
var collection1 = new ol.Collection();
|
var collection1 = new ol3.Collection();
|
||||||
var collection2 = ol3.collection(collection1);
|
var collection2 = ol.collection(collection1);
|
||||||
assertTrue(collection1 === collection2);
|
assertTrue(collection1 === collection2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
goog.provide('ol.Control');
|
|
||||||
|
|
||||||
goog.require('ol.Map');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.Map} map Map.
|
|
||||||
*/
|
|
||||||
ol.Control = function(map) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.Map}
|
|
||||||
*/
|
|
||||||
this.map_ = map;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Element} Element.
|
|
||||||
*/
|
|
||||||
ol.Control.prototype.getElement = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.Map} Map.
|
|
||||||
*/
|
|
||||||
ol.Control.prototype.getMap = function() {
|
|
||||||
return this.map_;
|
|
||||||
};
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
goog.provide('ol.dom.LayerRenderer');
|
|
||||||
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.LayerRenderer');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.LayerRenderer}
|
|
||||||
* @param {ol.MapRenderer} mapRenderer Map renderer.
|
|
||||||
* @param {ol.Layer} layer Layer.
|
|
||||||
* @param {!Element} target Target.
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer = function(mapRenderer, layer, target) {
|
|
||||||
goog.base(this, mapRenderer, layer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {!Element}
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
this.target = target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Top left corner of the target in map coords.
|
|
||||||
*
|
|
||||||
* @type {ol.Coordinate}
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
this.origin = null;
|
|
||||||
|
|
||||||
this.handleLayerOpacityChange();
|
|
||||||
this.handleLayerVisibleChange();
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.dom.LayerRenderer, ol.LayerRenderer);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
* @return {ol.MapRenderer} Map renderer.
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.getMapRenderer = function() {
|
|
||||||
return /** @type {ol.dom.MapRenderer} */ goog.base(this, 'getMapRenderer');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.handleLayerLoad = function() {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.handleLayerOpacityChange = function() {
|
|
||||||
goog.style.setOpacity(this.target, this.getLayer().getOpacity());
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.handleLayerVisibleChange = function() {
|
|
||||||
goog.style.showElement(this.target, this.getLayer().getVisible());
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.render = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the location of the top left corner of the target.
|
|
||||||
*
|
|
||||||
* @param {ol.Coordinate} origin Origin.
|
|
||||||
*/
|
|
||||||
ol.dom.LayerRenderer.prototype.setOrigin = function(origin) {
|
|
||||||
this.origin = origin;
|
|
||||||
};
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
goog.provide('ol.interaction.CenterConstraint');
|
|
||||||
goog.provide('ol.interaction.CenterConstraintType');
|
|
||||||
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {function((ol.Coordinate|undefined),
|
|
||||||
* (number|undefined),
|
|
||||||
* ol.Coordinate): (ol.Coordinate|undefined)}
|
|
||||||
*/
|
|
||||||
ol.interaction.CenterConstraintType;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate|undefined} center Center.
|
|
||||||
* @param {number|undefined} resolution Resolution.
|
|
||||||
* @param {ol.Coordinate} delta Delta.
|
|
||||||
* @return {ol.Coordinate|undefined} Center.
|
|
||||||
*/
|
|
||||||
ol.interaction.CenterConstraint.none = function(center, resolution, delta) {
|
|
||||||
if (goog.isDefAndNotNull(center) && goog.isDef(resolution)) {
|
|
||||||
var x = center.x + delta.x;
|
|
||||||
var y = center.y + delta.y;
|
|
||||||
return new ol.Coordinate(x, y);
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate|undefined} center Center.
|
|
||||||
* @param {number|undefined} resolution Resolution.
|
|
||||||
* @param {ol.Coordinate} delta Delta.
|
|
||||||
* @return {ol.Coordinate|undefined} Center.
|
|
||||||
*/
|
|
||||||
ol.interaction.CenterConstraint.snapToPixel =
|
|
||||||
function(center, resolution, delta) {
|
|
||||||
if (goog.isDefAndNotNull(center) && goog.isDef(resolution)) {
|
|
||||||
var x = Math.floor((center.x + delta.x) / resolution + 0.5) * resolution;
|
|
||||||
var y = Math.floor((center.y + delta.y) / resolution + 0.5) * resolution;
|
|
||||||
return new ol.Coordinate(x, y);
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
goog.provide('ol.interaction.Constraints');
|
|
||||||
|
|
||||||
goog.require('ol.interaction.CenterConstraintType');
|
|
||||||
goog.require('ol.interaction.ResolutionConstraintType');
|
|
||||||
goog.require('ol.interaction.RotationConstraintType');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.interaction.CenterConstraintType} centerConstraint
|
|
||||||
* Center constraint.
|
|
||||||
* @param {ol.interaction.ResolutionConstraintType} resolutionConstraint
|
|
||||||
* Resolution constraint.
|
|
||||||
* @param {ol.interaction.RotationConstraintType} rotationConstraint
|
|
||||||
* Rotation constraint.
|
|
||||||
*/
|
|
||||||
ol.interaction.Constraints =
|
|
||||||
function(centerConstraint, resolutionConstraint, rotationConstraint) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.interaction.CenterConstraintType}
|
|
||||||
*/
|
|
||||||
this.center = centerConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.interaction.ResolutionConstraintType}
|
|
||||||
*/
|
|
||||||
this.resolution = resolutionConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.interaction.RotationConstraintType}
|
|
||||||
*/
|
|
||||||
this.rotation = rotationConstraint;
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
goog.provide('ol.interaction.DragPan');
|
|
||||||
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
|
||||||
goog.require('ol.interaction.Constraints');
|
|
||||||
goog.require('ol.interaction.Drag');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.interaction.Drag}
|
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
|
||||||
*/
|
|
||||||
ol.interaction.DragPan = function(constraints) {
|
|
||||||
goog.base(this, constraints);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.interaction.DragPan, ol.interaction.Drag);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
|
||||||
var map = mapBrowserEvent.map;
|
|
||||||
var resolution = map.getResolution();
|
|
||||||
var rotation = map.getRotation();
|
|
||||||
var delta =
|
|
||||||
new ol.Coordinate(-resolution * this.deltaX, resolution * this.deltaY);
|
|
||||||
if (map.canRotate() && goog.isDef(rotation)) {
|
|
||||||
delta.rotate(rotation);
|
|
||||||
}
|
|
||||||
this.pan(map, delta, this.startCenter);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
|
||||||
if (!browserEvent.shiftKey) {
|
|
||||||
browserEvent.preventDefault();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
// FIXME draw drag box
|
|
||||||
|
|
||||||
goog.provide('ol.interaction.ShiftDragZoom');
|
|
||||||
|
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
|
||||||
goog.require('ol.interaction.Constraints');
|
|
||||||
goog.require('ol.interaction.Drag');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {number} Hysterisis pixels.
|
|
||||||
*/
|
|
||||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS = 8;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const {number}
|
|
||||||
*/
|
|
||||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED =
|
|
||||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS * ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.interaction.Drag}
|
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
|
||||||
*/
|
|
||||||
ol.interaction.ShiftDragZoom = function(constraints) {
|
|
||||||
goog.base(this, constraints);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.interaction.ShiftDragZoom, ol.interaction.Drag);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
|
||||||
function(mapBrowserEvent) {
|
|
||||||
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
|
||||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
|
||||||
var map = mapBrowserEvent.map;
|
|
||||||
var extent = ol.Extent.boundingExtent(
|
|
||||||
this.startCoordinate,
|
|
||||||
mapBrowserEvent.getCoordinate());
|
|
||||||
this.fitExtent(map, extent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.interaction.ShiftDragZoom.prototype.handleDragStart =
|
|
||||||
function(mapBrowserEvent) {
|
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
|
||||||
if (browserEvent.isMouseActionButton() && browserEvent.shiftKey) {
|
|
||||||
browserEvent.preventDefault();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Object');
|
goog.require('ol');
|
||||||
goog.require('ol3');
|
goog.require('ol3.Object');
|
||||||
|
|
||||||
|
|
||||||
function testObject1() {
|
function testObject1() {
|
||||||
var obj = {k: 1};
|
var obj = {k: 1};
|
||||||
obj = ol3.object(obj);
|
obj = ol.object(obj);
|
||||||
assertTrue(obj instanceof ol.Object);
|
assertTrue(obj instanceof ol3.Object);
|
||||||
assertEquals(1, obj.get('k'));
|
assertEquals(1, obj.get('k'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testObject2() {
|
function testObject2() {
|
||||||
var obj1 = new ol.Object();
|
var obj1 = new ol3.Object();
|
||||||
var obj2 = ol3.object(obj1);
|
var obj2 = ol.object(obj1);
|
||||||
assertTrue(obj2 === obj1);
|
assertTrue(obj2 === obj1);
|
||||||
}
|
}
|
||||||
|
|
||||||
168
src/ol/ol.js
Normal file
168
src/ol/ol.js
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
goog.provide('ol');
|
||||||
|
goog.provide('ol.layer');
|
||||||
|
|
||||||
|
goog.require('goog.dom');
|
||||||
|
goog.require('ol3.Collection');
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.Layer');
|
||||||
|
goog.require('ol3.Map');
|
||||||
|
goog.require('ol3.Object');
|
||||||
|
goog.require('ol3.Projection');
|
||||||
|
goog.require('ol3.createMap');
|
||||||
|
goog.require('ol3.layer.OpenStreetMap');
|
||||||
|
|
||||||
|
|
||||||
|
goog.exportSymbol('ol', ol);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Array|ol3.Collection}
|
||||||
|
*/
|
||||||
|
ol.Collection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Array.<number>|ol3.Coordinate|{x: number, y: number}}
|
||||||
|
*/
|
||||||
|
ol.Coordinate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{center: (ol.Coordinate|undefined),
|
||||||
|
* layers: (ol.Collection|undefined),
|
||||||
|
* renderTo: (Element|string|undefined),
|
||||||
|
* resolution: (number|undefined),
|
||||||
|
* zoom: (number|undefined)}}
|
||||||
|
*/
|
||||||
|
ol.MapOptions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object|ol3.Object}
|
||||||
|
*/
|
||||||
|
ol.Object;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {ol3.Projection|string}
|
||||||
|
*/
|
||||||
|
ol.Projection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Collection} collection Collection.
|
||||||
|
* @return {ol3.Collection} Collection.
|
||||||
|
*/
|
||||||
|
ol.collection = function(collection) {
|
||||||
|
if (collection instanceof ol3.Collection) {
|
||||||
|
return collection;
|
||||||
|
} else if (goog.isArray(collection)) {
|
||||||
|
var array = /** @type {Array} */ collection;
|
||||||
|
return new ol3.Collection(collection);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol, 'collection', ol.collection);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
|
* @return {ol3.Coordinate} Coordinate.
|
||||||
|
*/
|
||||||
|
ol.coordinate = function(coordinate) {
|
||||||
|
if (coordinate instanceof ol3.Coordinate) {
|
||||||
|
return coordinate;
|
||||||
|
} else if (goog.isArray(coordinate)) {
|
||||||
|
var array = /** @type {Array.<number>} */ coordinate;
|
||||||
|
return new ol3.Coordinate(array[1], array[0]);
|
||||||
|
} else if (goog.isObject(coordinate)) {
|
||||||
|
var object = /** @type {{x: number, y: number}} */ coordinate;
|
||||||
|
return new ol3.Coordinate(object.x, object.y);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol, 'coordinate', ol.coordinate);
|
||||||
|
|
||||||
|
|
||||||
|
goog.exportProperty(ol, 'layer', ol.layer);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Layer} Layer.
|
||||||
|
*/
|
||||||
|
ol.layer.osm = function() {
|
||||||
|
return new ol3.layer.OpenStreetMap();
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol.layer, 'osm', ol.layer.osm);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.MapOptions=} opt_mapOptions Options.
|
||||||
|
* @return {ol3.Map} Map.
|
||||||
|
*/
|
||||||
|
ol.map = function(opt_mapOptions) {
|
||||||
|
var options = opt_mapOptions || {};
|
||||||
|
var center = ol.coordinate(/** @type {ol.Coordinate} */
|
||||||
|
(goog.object.get(options, 'center', null)));
|
||||||
|
var layers = ol.collection(/** @type {ol.Collection} */
|
||||||
|
(goog.object.get(options, 'layers', null)));
|
||||||
|
var projection = ol.projection(/** @type {ol.Projection} */
|
||||||
|
(goog.object.get(options, 'projection', 'EPSG:3857')));
|
||||||
|
var resolution = /** @type {number|undefined} */
|
||||||
|
goog.object.get(options, 'resolution');
|
||||||
|
if (!goog.isDef(resolution) && goog.object.containsKey(options, 'zoom')) {
|
||||||
|
var zoom = /** @type {number} */ goog.object.get(options, 'zoom');
|
||||||
|
resolution = ol3.Projection.EPSG_3857_HALF_SIZE / (128 << zoom);
|
||||||
|
}
|
||||||
|
var target = goog.dom.getElement(/** @type {Element|string} */
|
||||||
|
(goog.object.get(options, 'renderTo', 'map')));
|
||||||
|
var userProjection = ol.projection(/** @type {ol.Projection} */
|
||||||
|
(goog.object.get(options, 'userProjection', 'EPSG:4326')));
|
||||||
|
var map = ol3.createMap(target, {
|
||||||
|
'layers': layers,
|
||||||
|
'projection': projection,
|
||||||
|
'resolution': resolution,
|
||||||
|
'userProjection': userProjection
|
||||||
|
});
|
||||||
|
if (!goog.isNull(center)) {
|
||||||
|
map.setUserCenter(center);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol, 'map', ol.map);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Object} object Object.
|
||||||
|
* @return {ol3.Object} Object.
|
||||||
|
*/
|
||||||
|
ol.object = function(object) {
|
||||||
|
if (object instanceof ol3.Object) {
|
||||||
|
return object;
|
||||||
|
} else if (goog.isObject(object)) {
|
||||||
|
var values = /** @type {Object} */ object;
|
||||||
|
return new ol3.Object(values);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol, 'object', ol.object);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {ol3.Projection} Projection.
|
||||||
|
*/
|
||||||
|
ol.projection = function(projection) {
|
||||||
|
if (projection instanceof ol3.Projection) {
|
||||||
|
return projection;
|
||||||
|
} else if (goog.isString(projection)) {
|
||||||
|
var code = /** @type {string} */ projection;
|
||||||
|
return ol3.Projection.getFromCode(code);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(ol, 'projection', ol.projection);
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
goog.provide('ol.layer.OpenStreetMap');
|
|
||||||
goog.provide('ol.store.OpenStreetMap');
|
|
||||||
|
|
||||||
goog.require('ol.TileLayer');
|
|
||||||
goog.require('ol.TileUrlFunction');
|
|
||||||
goog.require('ol.tilestore.XYZ');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.TileLayer}
|
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
|
||||||
*/
|
|
||||||
ol.layer.OpenStreetMap = function(opt_values) {
|
|
||||||
var tileStore = new ol.store.OpenStreetMap();
|
|
||||||
goog.base(this, tileStore, opt_values);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.layer.OpenStreetMap, ol.TileLayer);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.tilestore.XYZ}
|
|
||||||
*/
|
|
||||||
ol.store.OpenStreetMap = function() {
|
|
||||||
|
|
||||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(
|
|
||||||
'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png');
|
|
||||||
|
|
||||||
var attribution = new ol.Attribution(
|
|
||||||
'© <a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
|
||||||
'contributors, ' +
|
|
||||||
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>');
|
|
||||||
|
|
||||||
goog.base(this, 18, tileUrlFunction, [attribution]);
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.store.OpenStreetMap, ol.tilestore.XYZ);
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
|
||||||
goog.require('ol.TileBounds');
|
|
||||||
|
|
||||||
|
|
||||||
function testClone() {
|
|
||||||
var tileBounds = new ol.TileBounds(1, 2, 3, 4);
|
|
||||||
var clonedTileBounds = tileBounds.clone();
|
|
||||||
assertTrue(clonedTileBounds instanceof ol.TileBounds);
|
|
||||||
assertFalse(clonedTileBounds === tileBounds);
|
|
||||||
assertEquals(tileBounds.minX, clonedTileBounds.minX);
|
|
||||||
assertEquals(tileBounds.minY, clonedTileBounds.minY);
|
|
||||||
assertEquals(tileBounds.maxX, clonedTileBounds.maxX);
|
|
||||||
assertEquals(tileBounds.maxY, clonedTileBounds.maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testContains() {
|
|
||||||
var tileBounds = new ol.TileBounds(1, 1, 3, 3);
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 0)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 1)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 2)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 1, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 1, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 2, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 2, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 3, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 3, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 0)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 1)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 2)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 4)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testBoundingTileBounds() {
|
|
||||||
var tileBounds = new ol.TileBounds.boundingTileBounds(
|
|
||||||
new ol.TileCoord(3, 1, 3),
|
|
||||||
new ol.TileCoord(3, 2, 0));
|
|
||||||
assertEquals(1, tileBounds.minX);
|
|
||||||
assertEquals(0, tileBounds.minY);
|
|
||||||
assertEquals(2, tileBounds.maxX);
|
|
||||||
assertEquals(3, tileBounds.maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testBoundingTileBoundsMixedZ() {
|
|
||||||
assertThrows(function() {
|
|
||||||
var tileBounds = new ol.TileBounds.boundingTileBounds(
|
|
||||||
new ol.TileCoord(3, 1, 3),
|
|
||||||
new ol.TileCoord(4, 2, 0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testForEachTileCoord() {
|
|
||||||
|
|
||||||
var tileBounds = new ol.TileBounds(0, 2, 1, 3);
|
|
||||||
|
|
||||||
var tileCoords = [];
|
|
||||||
tileBounds.forEachTileCoord(5, function(tileCoord) {
|
|
||||||
tileCoords.push(tileCoord.clone());
|
|
||||||
});
|
|
||||||
|
|
||||||
assertEquals(4, tileCoords.length);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[0].z);
|
|
||||||
assertEquals(0, tileCoords[0].x);
|
|
||||||
assertEquals(2, tileCoords[0].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[1].z);
|
|
||||||
assertEquals(0, tileCoords[1].x);
|
|
||||||
assertEquals(3, tileCoords[1].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[2].z);
|
|
||||||
assertEquals(1, tileCoords[2].x);
|
|
||||||
assertEquals(2, tileCoords[2].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[3].z);
|
|
||||||
assertEquals(1, tileCoords[3].x);
|
|
||||||
assertEquals(3, tileCoords[3].y);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testSize() {
|
|
||||||
var tileBounds = new ol.TileBounds(0, 1, 2, 4);
|
|
||||||
var size = tileBounds.getSize();
|
|
||||||
assertEquals(3, size.width);
|
|
||||||
assertEquals(4, size.height);
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
goog.provide('ol.TileCoverageArea');
|
|
||||||
|
|
||||||
goog.require('ol.CoverageArea');
|
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.TileGrid');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.CoverageArea}
|
|
||||||
* @param {ol.TileGrid} tileGrid Tile grid.
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @param {number} minZ Minimum Z.
|
|
||||||
* @param {number} maxZ Maximum Z.
|
|
||||||
*/
|
|
||||||
ol.TileCoverageArea = function(tileGrid, extent, minZ, maxZ) {
|
|
||||||
|
|
||||||
goog.base(this, extent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.TileGrid}
|
|
||||||
*/
|
|
||||||
this.tileGrid_ = tileGrid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.minZ_ = minZ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.maxZ_ = maxZ;
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.TileCoverageArea, ol.CoverageArea);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.TileCoverageArea.prototype.intersectsExtentAndResolution =
|
|
||||||
function(extent, resolution) {
|
|
||||||
var z = this.tileGrid_.getZForResolution(resolution);
|
|
||||||
return this.intersectsExtentAndZ(extent, z);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @param {number} z Z.
|
|
||||||
* @return {boolean} Intersects.
|
|
||||||
*/
|
|
||||||
ol.TileCoverageArea.prototype.intersectsExtentAndZ = function(extent, z) {
|
|
||||||
return this.minZ_ <= z && z <= this.maxZ_ && this.intersectsExtent(extent);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TransformFunction} transformFn Transform.
|
|
||||||
* @return {ol.TileCoverageArea} Transformed tile coverage area.
|
|
||||||
*/
|
|
||||||
ol.TileCoverageArea.prototype.transform = function(transformFn) {
|
|
||||||
var extent = this.extent.transform(transformFn);
|
|
||||||
return new ol.TileCoverageArea(
|
|
||||||
this.tileGrid_, extent, this.minZ_, this.maxZ_);
|
|
||||||
};
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
goog.provide('ol.TileLayer');
|
|
||||||
|
|
||||||
goog.require('ol.Layer');
|
|
||||||
goog.require('ol.TileStore');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Layer}
|
|
||||||
* @param {ol.TileStore} tileStore Tile store.
|
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
|
||||||
*/
|
|
||||||
ol.TileLayer = function(tileStore, opt_values) {
|
|
||||||
goog.base(this, tileStore, opt_values);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.TileLayer, ol.Layer);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
* @return {ol.TileStore} Store.
|
|
||||||
*/
|
|
||||||
ol.TileLayer.prototype.getStore = function() {
|
|
||||||
return /** @type {ol.TileStore} */ goog.base(this, 'getStore');
|
|
||||||
};
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
|
||||||
goog.require('ol.TileCoord');
|
|
||||||
goog.require('ol.TileUrlFunction');
|
|
||||||
|
|
||||||
|
|
||||||
function testCreateFromTemplate() {
|
|
||||||
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}');
|
|
||||||
assertEquals('3/2/1', tileUrl(new ol.TileCoord(3, 2, 1)));
|
|
||||||
assertUndefined(tileUrl(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testWithTileCoordTransform() {
|
|
||||||
var tileUrl = ol.TileUrlFunction.withTileCoordTransform(
|
|
||||||
function(tileCoord) {
|
|
||||||
return new ol.TileCoord(tileCoord.z, tileCoord.x, -tileCoord.y);
|
|
||||||
},
|
|
||||||
ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}'));
|
|
||||||
assertEquals('3/2/1', tileUrl(new ol.TileCoord(3, 2, -1)));
|
|
||||||
assertUndefined(tileUrl(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testCreateFromTileUrlFunctions() {
|
|
||||||
var tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([
|
|
||||||
ol.TileUrlFunction.createFromTemplate('a'),
|
|
||||||
ol.TileUrlFunction.createFromTemplate('b')
|
|
||||||
]);
|
|
||||||
var tileUrl1 = tileUrl(new ol.TileCoord(1, 0, 0));
|
|
||||||
var tileUrl2 = tileUrl(new ol.TileCoord(1, 0, 1));
|
|
||||||
assertTrue(tileUrl1 != tileUrl2);
|
|
||||||
assertUndefined(tileUrl(null));
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
goog.provide('ol.layer.XYZ');
|
|
||||||
goog.provide('ol.tilegrid.XYZ');
|
|
||||||
goog.provide('ol.tilestore.XYZ');
|
|
||||||
|
|
||||||
goog.require('goog.math');
|
|
||||||
goog.require('ol.Attribution');
|
|
||||||
goog.require('ol.Coordinate');
|
|
||||||
goog.require('ol.Layer');
|
|
||||||
goog.require('ol.Projection');
|
|
||||||
goog.require('ol.Size');
|
|
||||||
goog.require('ol.TileCoord');
|
|
||||||
goog.require('ol.TileGrid');
|
|
||||||
goog.require('ol.TileLayer');
|
|
||||||
goog.require('ol.TileStore');
|
|
||||||
goog.require('ol.TileUrlFunction');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.TileGrid}
|
|
||||||
* @param {number} maxZoom Maximum zoom.
|
|
||||||
* @param {ol.Size=} opt_tileSize Tile size.
|
|
||||||
*/
|
|
||||||
ol.tilegrid.XYZ = function(maxZoom, opt_tileSize) {
|
|
||||||
|
|
||||||
var resolutions = new Array(maxZoom + 1);
|
|
||||||
var z;
|
|
||||||
for (z = 0; z <= maxZoom; ++z) {
|
|
||||||
resolutions[z] = ol.Projection.EPSG_3857_HALF_SIZE / (128 << z);
|
|
||||||
}
|
|
||||||
|
|
||||||
var extent = ol.Projection.EPSG_3857_EXTENT;
|
|
||||||
var origin = new ol.Coordinate(
|
|
||||||
-ol.Projection.EPSG_3857_HALF_SIZE, ol.Projection.EPSG_3857_HALF_SIZE);
|
|
||||||
|
|
||||||
goog.base(this, resolutions, extent, origin, opt_tileSize);
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.tilegrid.XYZ, ol.TileGrid);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileBounds =
|
|
||||||
function(tileCoord, callback, opt_obj) {
|
|
||||||
var x = tileCoord.x;
|
|
||||||
var y = tileCoord.y;
|
|
||||||
var z = tileCoord.z;
|
|
||||||
var tileBounds;
|
|
||||||
while (true) {
|
|
||||||
z -= 1;
|
|
||||||
if (z < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
x = Math.floor(x / 2);
|
|
||||||
y = Math.floor(y / 2);
|
|
||||||
tileBounds = new ol.TileBounds(x, y, x, y);
|
|
||||||
if (callback.call(opt_obj, z, tileBounds)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.TileLayer}
|
|
||||||
* @param {number} maxZoom Maximum zoom.
|
|
||||||
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function.
|
|
||||||
* @param {Array.<ol.Attribution>=} opt_attributions Attributions.
|
|
||||||
* @param {string=} opt_crossOrigin Cross origin.
|
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
|
||||||
*/
|
|
||||||
ol.layer.XYZ = function(
|
|
||||||
maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin, opt_values) {
|
|
||||||
var tileStore = new ol.tilestore.XYZ(
|
|
||||||
maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin);
|
|
||||||
goog.base(this, tileStore, opt_values);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.layer.XYZ, ol.TileLayer);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.TileStore}
|
|
||||||
* @param {number} maxZoom Maximum zoom.
|
|
||||||
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function.
|
|
||||||
* @param {Array.<ol.Attribution>=} opt_attributions Attributions.
|
|
||||||
* @param {string=} opt_crossOrigin Cross origin.
|
|
||||||
*/
|
|
||||||
ol.tilestore.XYZ =
|
|
||||||
function(maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin) {
|
|
||||||
|
|
||||||
var projection = ol.Projection.getFromCode('EPSG:3857');
|
|
||||||
var tileGrid = new ol.tilegrid.XYZ(maxZoom);
|
|
||||||
var tileUrlFunction2 = ol.TileUrlFunction.withTileCoordTransform(
|
|
||||||
function(tileCoord) {
|
|
||||||
var n = 1 << tileCoord.z;
|
|
||||||
var y = -tileCoord.y - 1;
|
|
||||||
if (y < 0 || n <= y) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
var x = goog.math.modulo(tileCoord.x, n);
|
|
||||||
return new ol.TileCoord(tileCoord.z, x, y);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tileUrlFunction);
|
|
||||||
var extent = projection.getExtent();
|
|
||||||
|
|
||||||
goog.base(this, projection, tileGrid, tileUrlFunction2, extent,
|
|
||||||
opt_attributions, opt_crossOrigin);
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.tilestore.XYZ, ol.TileStore);
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
goog.provide('ol.webgl.LayerRenderer');
|
|
||||||
|
|
||||||
goog.require('goog.vec.Mat4');
|
|
||||||
goog.require('ol.Layer');
|
|
||||||
goog.require('ol.LayerRenderer');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.LayerRenderer}
|
|
||||||
* @param {ol.MapRenderer} mapRenderer Map renderer.
|
|
||||||
* @param {ol.Layer} layer Layer.
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer = function(mapRenderer, layer) {
|
|
||||||
goog.base(this, mapRenderer, layer);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.webgl.LayerRenderer, ol.LayerRenderer);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.dispatchChangeEvent = function() {
|
|
||||||
this.dispatchEvent(goog.events.EventType.CHANGE);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
* @return {ol.MapRenderer} MapRenderer.
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.getMapRenderer = function() {
|
|
||||||
return /** @type {ol.webgl.MapRenderer} */ goog.base(this, 'getMapRenderer');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {goog.vec.Mat4.AnyType} Matrix.
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.getMatrix = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {WebGLTexture} Texture.
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.getTexture = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerBrightnessChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerContrastChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerHueChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerLoad = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerOpacityChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerSaturationChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleLayerVisibleChange = function() {
|
|
||||||
this.dispatchChangeEvent();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.handleWebGLContextLost = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
ol.webgl.LayerRenderer.prototype.render = goog.abstractMethod;
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
goog.provide('ol.webgl.shader.Fragment');
|
|
||||||
goog.provide('ol.webgl.shader.Vertex');
|
|
||||||
|
|
||||||
goog.require('goog.functions');
|
|
||||||
goog.require('goog.webgl');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {string} source Source.
|
|
||||||
*/
|
|
||||||
ol.webgl.Shader = function(source) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.source_ = source;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {number} Type.
|
|
||||||
*/
|
|
||||||
ol.webgl.Shader.prototype.getType = goog.abstractMethod;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string} Source.
|
|
||||||
*/
|
|
||||||
ol.webgl.Shader.prototype.getSource = function() {
|
|
||||||
return this.source_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean} Is animated?
|
|
||||||
*/
|
|
||||||
ol.webgl.Shader.prototype.isAnimated = goog.functions.FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.webgl.Shader}
|
|
||||||
* @param {string} source Source.
|
|
||||||
*/
|
|
||||||
ol.webgl.shader.Fragment = function(source) {
|
|
||||||
goog.base(this, source);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.webgl.shader.Fragment, ol.webgl.Shader);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.shader.Fragment.prototype.getType = function() {
|
|
||||||
return goog.webgl.FRAGMENT_SHADER;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.webgl.Shader}
|
|
||||||
* @param {string} source Source.
|
|
||||||
*/
|
|
||||||
ol.webgl.shader.Vertex = function(source) {
|
|
||||||
goog.base(this, source);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.webgl.shader.Vertex, ol.webgl.Shader);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.webgl.shader.Vertex.prototype.getType = function() {
|
|
||||||
return goog.webgl.VERTEX_SHADER;
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.array');
|
goog.provide('ol3.array');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ goog.require('goog.array');
|
|||||||
* @param {number} target Target.
|
* @param {number} target Target.
|
||||||
* @return {number} Index.
|
* @return {number} Index.
|
||||||
*/
|
*/
|
||||||
ol.array.binaryFindNearest = function(arr, target) {
|
ol3.array.binaryFindNearest = function(arr, target) {
|
||||||
var index = goog.array.binarySearch(arr, target, function(a, b) {
|
var index = goog.array.binarySearch(arr, target, function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
@@ -35,7 +35,7 @@ ol.array.binaryFindNearest = function(arr, target) {
|
|||||||
* @param {number} target Target.
|
* @param {number} target Target.
|
||||||
* @return {number} Index.
|
* @return {number} Index.
|
||||||
*/
|
*/
|
||||||
ol.array.linearFindNearest = function(arr, target) {
|
ol3.array.linearFindNearest = function(arr, target) {
|
||||||
var n = arr.length;
|
var n = arr.length;
|
||||||
if (arr[0] <= target) {
|
if (arr[0] <= target) {
|
||||||
return 0;
|
return 0;
|
||||||
46
src/ol3/base/array_test.js
Normal file
46
src/ol3/base/array_test.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
goog.require('goog.testing.jsunit');
|
||||||
|
goog.require('ol3.array');
|
||||||
|
|
||||||
|
|
||||||
|
function testBinaryFindNearest() {
|
||||||
|
var arr = [1000, 500, 100];
|
||||||
|
|
||||||
|
assertEquals(0, ol3.array.binaryFindNearest(arr, 10000));
|
||||||
|
assertEquals(0, ol3.array.binaryFindNearest(arr, 1000));
|
||||||
|
assertEquals(0, ol3.array.binaryFindNearest(arr, 900));
|
||||||
|
|
||||||
|
assertEquals(1, ol3.array.binaryFindNearest(arr, 750));
|
||||||
|
|
||||||
|
assertEquals(1, ol3.array.binaryFindNearest(arr, 550));
|
||||||
|
assertEquals(1, ol3.array.binaryFindNearest(arr, 500));
|
||||||
|
assertEquals(1, ol3.array.binaryFindNearest(arr, 450));
|
||||||
|
|
||||||
|
assertEquals(2, ol3.array.binaryFindNearest(arr, 300));
|
||||||
|
|
||||||
|
assertEquals(2, ol3.array.binaryFindNearest(arr, 200));
|
||||||
|
assertEquals(2, ol3.array.binaryFindNearest(arr, 100));
|
||||||
|
assertEquals(2, ol3.array.binaryFindNearest(arr, 50));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testLinearFindNearest() {
|
||||||
|
var arr = [1000, 500, 100];
|
||||||
|
|
||||||
|
assertEquals(0, ol3.array.linearFindNearest(arr, 10000));
|
||||||
|
assertEquals(0, ol3.array.linearFindNearest(arr, 1000));
|
||||||
|
assertEquals(0, ol3.array.linearFindNearest(arr, 900));
|
||||||
|
|
||||||
|
assertEquals(1, ol3.array.linearFindNearest(arr, 750));
|
||||||
|
|
||||||
|
assertEquals(1, ol3.array.linearFindNearest(arr, 550));
|
||||||
|
assertEquals(1, ol3.array.linearFindNearest(arr, 500));
|
||||||
|
assertEquals(1, ol3.array.linearFindNearest(arr, 450));
|
||||||
|
|
||||||
|
assertEquals(2, ol3.array.linearFindNearest(arr, 300));
|
||||||
|
|
||||||
|
assertEquals(2, ol3.array.linearFindNearest(arr, 200));
|
||||||
|
assertEquals(2, ol3.array.linearFindNearest(arr, 100));
|
||||||
|
assertEquals(2, ol3.array.linearFindNearest(arr, 50));
|
||||||
|
|
||||||
|
}
|
||||||
58
src/ol3/base/attribution.js
Normal file
58
src/ol3/base/attribution.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
goog.provide('ol3.Attribution');
|
||||||
|
|
||||||
|
goog.require('ol3.CoverageArea');
|
||||||
|
goog.require('ol3.Projection');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {string} html HTML.
|
||||||
|
* @param {Array.<ol3.CoverageArea>=} opt_coverageAreas Coverage areas.
|
||||||
|
* @param {ol3.Projection=} opt_projection Projection.
|
||||||
|
*/
|
||||||
|
ol3.Attribution = function(html, opt_coverageAreas, opt_projection) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.html_ = html;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Array.<ol3.CoverageArea>}
|
||||||
|
*/
|
||||||
|
this.coverageAreas_ = opt_coverageAreas || null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Projection}
|
||||||
|
*/
|
||||||
|
this.projection_ = opt_projection || null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array.<ol3.CoverageArea>} Coverage areas.
|
||||||
|
*/
|
||||||
|
ol3.Attribution.prototype.getCoverageAreas = function() {
|
||||||
|
return this.coverageAreas_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string} HTML.
|
||||||
|
*/
|
||||||
|
ol3.Attribution.prototype.getHtml = function() {
|
||||||
|
return this.html_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Projection} Projection.
|
||||||
|
*/
|
||||||
|
ol3.Attribution.prototype.getProjection = function() {
|
||||||
|
return this.projection_;
|
||||||
|
};
|
||||||
@@ -4,20 +4,20 @@
|
|||||||
* @see https://developers.google.com/maps/documentation/javascript/reference
|
* @see https://developers.google.com/maps/documentation/javascript/reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
goog.provide('ol.Collection');
|
goog.provide('ol3.Collection');
|
||||||
goog.provide('ol.CollectionEvent');
|
goog.provide('ol3.CollectionEvent');
|
||||||
goog.provide('ol.CollectionEventType');
|
goog.provide('ol3.CollectionEventType');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.events.Event');
|
goog.require('goog.events.Event');
|
||||||
goog.require('ol.Object');
|
goog.require('ol3.Object');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.CollectionEventType = {
|
ol3.CollectionEventType = {
|
||||||
ADD: 'add',
|
ADD: 'add',
|
||||||
INSERT_AT: 'insert_at',
|
INSERT_AT: 'insert_at',
|
||||||
REMOVE: 'remove',
|
REMOVE: 'remove',
|
||||||
@@ -30,13 +30,13 @@ ol.CollectionEventType = {
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {goog.events.Event}
|
* @extends {goog.events.Event}
|
||||||
* @param {ol.CollectionEventType} type Type.
|
* @param {ol3.CollectionEventType} type Type.
|
||||||
* @param {*=} opt_elem Element.
|
* @param {*=} opt_elem Element.
|
||||||
* @param {number=} opt_index Index.
|
* @param {number=} opt_index Index.
|
||||||
* @param {*=} opt_prev Value.
|
* @param {*=} opt_prev Value.
|
||||||
* @param {Object=} opt_target Target.
|
* @param {Object=} opt_target Target.
|
||||||
*/
|
*/
|
||||||
ol.CollectionEvent =
|
ol3.CollectionEvent =
|
||||||
function(type, opt_elem, opt_index, opt_prev, opt_target) {
|
function(type, opt_elem, opt_index, opt_prev, opt_target) {
|
||||||
|
|
||||||
goog.base(this, type, opt_target);
|
goog.base(this, type, opt_target);
|
||||||
@@ -57,13 +57,13 @@ ol.CollectionEvent =
|
|||||||
this.prev = opt_prev;
|
this.prev = opt_prev;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.CollectionEvent, goog.events.Event);
|
goog.inherits(ol3.CollectionEvent, goog.events.Event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.CollectionProperty = {
|
ol3.CollectionProperty = {
|
||||||
LENGTH: 'length'
|
LENGTH: 'length'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@ ol.CollectionProperty = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Object}
|
* @extends {ol3.Object}
|
||||||
* @param {Array=} opt_array Array.
|
* @param {Array=} opt_array Array.
|
||||||
*/
|
*/
|
||||||
ol.Collection = function(opt_array) {
|
ol3.Collection = function(opt_array) {
|
||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
@@ -87,13 +87,13 @@ ol.Collection = function(opt_array) {
|
|||||||
this.updateLength_();
|
this.updateLength_();
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Collection, ol.Object);
|
goog.inherits(ol3.Collection, ol3.Object);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.clear = function() {
|
ol3.Collection.prototype.clear = function() {
|
||||||
while (this[ol.CollectionProperty.LENGTH]) {
|
while (this[ol3.CollectionProperty.LENGTH]) {
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -103,7 +103,7 @@ ol.Collection.prototype.clear = function() {
|
|||||||
* @param {Function} f Function.
|
* @param {Function} f Function.
|
||||||
* @param {Object=} opt_obj Object.
|
* @param {Object=} opt_obj Object.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.forEach = function(f, opt_obj) {
|
ol3.Collection.prototype.forEach = function(f, opt_obj) {
|
||||||
goog.array.forEach(this.array_, f, opt_obj);
|
goog.array.forEach(this.array_, f, opt_obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ ol.Collection.prototype.forEach = function(f, opt_obj) {
|
|||||||
/**
|
/**
|
||||||
* @return {Array} Array.
|
* @return {Array} Array.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.getArray = function() {
|
ol3.Collection.prototype.getArray = function() {
|
||||||
return this.array_;
|
return this.array_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ ol.Collection.prototype.getArray = function() {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @return {*} Element.
|
* @return {*} Element.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.getAt = function(index) {
|
ol3.Collection.prototype.getAt = function(index) {
|
||||||
return this.array_[index];
|
return this.array_[index];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ ol.Collection.prototype.getAt = function(index) {
|
|||||||
/**
|
/**
|
||||||
* @return {number} Length.
|
* @return {number} Length.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.getLength = function() {
|
ol3.Collection.prototype.getLength = function() {
|
||||||
return /** @type {number} */ this.get(ol.CollectionProperty.LENGTH);
|
return /** @type {number} */ this.get(ol3.CollectionProperty.LENGTH);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -137,20 +137,20 @@ ol.Collection.prototype.getLength = function() {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @param {*} elem Element.
|
* @param {*} elem Element.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.insertAt = function(index, elem) {
|
ol3.Collection.prototype.insertAt = function(index, elem) {
|
||||||
goog.array.insertAt(this.array_, elem, index);
|
goog.array.insertAt(this.array_, elem, index);
|
||||||
this.updateLength_();
|
this.updateLength_();
|
||||||
this.dispatchEvent(new ol.CollectionEvent(
|
this.dispatchEvent(new ol3.CollectionEvent(
|
||||||
ol.CollectionEventType.ADD, elem, undefined, undefined, this));
|
ol3.CollectionEventType.ADD, elem, undefined, undefined, this));
|
||||||
this.dispatchEvent(new ol.CollectionEvent(
|
this.dispatchEvent(new ol3.CollectionEvent(
|
||||||
ol.CollectionEventType.INSERT_AT, elem, index, undefined, this));
|
ol3.CollectionEventType.INSERT_AT, elem, index, undefined, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {*} Element.
|
* @return {*} Element.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.pop = function() {
|
ol3.Collection.prototype.pop = function() {
|
||||||
return this.removeAt(this.getLength() - 1);
|
return this.removeAt(this.getLength() - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ ol.Collection.prototype.pop = function() {
|
|||||||
* @param {*} elem Element.
|
* @param {*} elem Element.
|
||||||
* @return {number} Length.
|
* @return {number} Length.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.push = function(elem) {
|
ol3.Collection.prototype.push = function(elem) {
|
||||||
var n = this.array_.length;
|
var n = this.array_.length;
|
||||||
this.insertAt(n, elem);
|
this.insertAt(n, elem);
|
||||||
return n;
|
return n;
|
||||||
@@ -170,13 +170,13 @@ ol.Collection.prototype.push = function(elem) {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @return {*} Value.
|
* @return {*} Value.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.removeAt = function(index) {
|
ol3.Collection.prototype.removeAt = function(index) {
|
||||||
var prev = this.array_[index];
|
var prev = this.array_[index];
|
||||||
goog.array.removeAt(this.array_, index);
|
goog.array.removeAt(this.array_, index);
|
||||||
this.updateLength_();
|
this.updateLength_();
|
||||||
this.dispatchEvent(new ol.CollectionEvent(
|
this.dispatchEvent(new ol3.CollectionEvent(
|
||||||
ol.CollectionEventType.REMOVE, prev, undefined, undefined, this));
|
ol3.CollectionEventType.REMOVE, prev, undefined, undefined, this));
|
||||||
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.REMOVE_AT,
|
this.dispatchEvent(new ol3.CollectionEvent(ol3.CollectionEventType.REMOVE_AT,
|
||||||
undefined, index, prev, this));
|
undefined, index, prev, this));
|
||||||
return prev;
|
return prev;
|
||||||
};
|
};
|
||||||
@@ -186,16 +186,16 @@ ol.Collection.prototype.removeAt = function(index) {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @param {*} elem Element.
|
* @param {*} elem Element.
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.setAt = function(index, elem) {
|
ol3.Collection.prototype.setAt = function(index, elem) {
|
||||||
var n = this[ol.CollectionProperty.LENGTH];
|
var n = this[ol3.CollectionProperty.LENGTH];
|
||||||
if (index < n) {
|
if (index < n) {
|
||||||
var prev = this.array_[index];
|
var prev = this.array_[index];
|
||||||
this.array_[index] = elem;
|
this.array_[index] = elem;
|
||||||
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.SET_AT,
|
this.dispatchEvent(new ol3.CollectionEvent(ol3.CollectionEventType.SET_AT,
|
||||||
elem, index, prev, this));
|
elem, index, prev, this));
|
||||||
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.REMOVE,
|
this.dispatchEvent(new ol3.CollectionEvent(ol3.CollectionEventType.REMOVE,
|
||||||
prev, undefined, undefined, this));
|
prev, undefined, undefined, this));
|
||||||
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.ADD,
|
this.dispatchEvent(new ol3.CollectionEvent(ol3.CollectionEventType.ADD,
|
||||||
elem, undefined, undefined, this));
|
elem, undefined, undefined, this));
|
||||||
} else {
|
} else {
|
||||||
var j;
|
var j;
|
||||||
@@ -210,6 +210,6 @@ ol.Collection.prototype.setAt = function(index, elem) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Collection.prototype.updateLength_ = function() {
|
ol3.Collection.prototype.updateLength_ = function() {
|
||||||
this.set(ol.CollectionProperty.LENGTH, this.array_.length);
|
this.set(ol3.CollectionProperty.LENGTH, this.array_.length);
|
||||||
};
|
};
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol3.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol3.CollectionEventType');
|
||||||
|
|
||||||
|
|
||||||
function testEmpty() {
|
function testEmpty() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
assertEquals(0, collection.getLength());
|
assertEquals(0, collection.getLength());
|
||||||
assertTrue(goog.array.equals(collection.getArray(), []));
|
assertTrue(goog.array.equals(collection.getArray(), []));
|
||||||
assertUndefined(collection.getAt(0));
|
assertUndefined(collection.getAt(0));
|
||||||
@@ -14,7 +14,7 @@ function testEmpty() {
|
|||||||
|
|
||||||
function testConstruct() {
|
function testConstruct() {
|
||||||
var array = [0, 1, 2];
|
var array = [0, 1, 2];
|
||||||
var collection = new ol.Collection(array);
|
var collection = new ol3.Collection(array);
|
||||||
assertEquals(0, collection.getAt(0));
|
assertEquals(0, collection.getAt(0));
|
||||||
assertEquals(1, collection.getAt(1));
|
assertEquals(1, collection.getAt(1));
|
||||||
assertEquals(2, collection.getAt(2));
|
assertEquals(2, collection.getAt(2));
|
||||||
@@ -22,7 +22,7 @@ function testConstruct() {
|
|||||||
|
|
||||||
|
|
||||||
function testPush() {
|
function testPush() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
collection.push(1);
|
collection.push(1);
|
||||||
assertEquals(1, collection.getLength());
|
assertEquals(1, collection.getLength());
|
||||||
assertTrue(goog.array.equals(collection.getArray(), [1]));
|
assertTrue(goog.array.equals(collection.getArray(), [1]));
|
||||||
@@ -31,7 +31,7 @@ function testPush() {
|
|||||||
|
|
||||||
|
|
||||||
function testPushPop() {
|
function testPushPop() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
collection.push(1);
|
collection.push(1);
|
||||||
collection.pop();
|
collection.pop();
|
||||||
assertEquals(0, collection.getLength());
|
assertEquals(0, collection.getLength());
|
||||||
@@ -41,7 +41,7 @@ function testPushPop() {
|
|||||||
|
|
||||||
|
|
||||||
function testInsertAt() {
|
function testInsertAt() {
|
||||||
var collection = new ol.Collection([0, 2]);
|
var collection = new ol3.Collection([0, 2]);
|
||||||
collection.insertAt(1, 1);
|
collection.insertAt(1, 1);
|
||||||
assertEquals(0, collection.getAt(0));
|
assertEquals(0, collection.getAt(0));
|
||||||
assertEquals(1, collection.getAt(1));
|
assertEquals(1, collection.getAt(1));
|
||||||
@@ -50,7 +50,7 @@ function testInsertAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetAt() {
|
function testSetAt() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
collection.setAt(1, 1);
|
collection.setAt(1, 1);
|
||||||
assertEquals(2, collection.getLength());
|
assertEquals(2, collection.getLength());
|
||||||
assertUndefined(collection.getAt(0));
|
assertUndefined(collection.getAt(0));
|
||||||
@@ -59,7 +59,7 @@ function testSetAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testRemoveAt() {
|
function testRemoveAt() {
|
||||||
var collection = new ol.Collection([0, 1, 2]);
|
var collection = new ol3.Collection([0, 1, 2]);
|
||||||
collection.removeAt(1);
|
collection.removeAt(1);
|
||||||
assertEquals(0, collection.getAt(0));
|
assertEquals(0, collection.getAt(0));
|
||||||
assertEquals(2, collection.getAt(1));
|
assertEquals(2, collection.getAt(1));
|
||||||
@@ -67,7 +67,7 @@ function testRemoveAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testForEachEmpty() {
|
function testForEachEmpty() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
var forEachCalled = false;
|
var forEachCalled = false;
|
||||||
collection.forEach(function() {
|
collection.forEach(function() {
|
||||||
forEachCalled = true;
|
forEachCalled = true;
|
||||||
@@ -77,7 +77,7 @@ function testForEachEmpty() {
|
|||||||
|
|
||||||
|
|
||||||
function testForEachPopulated() {
|
function testForEachPopulated() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
collection.push(1);
|
collection.push(1);
|
||||||
collection.push(2);
|
collection.push(2);
|
||||||
var forEachCount = 0;
|
var forEachCount = 0;
|
||||||
@@ -89,9 +89,9 @@ function testForEachPopulated() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetAtEvent() {
|
function testSetAtEvent() {
|
||||||
var collection = new ol.Collection(['a', 'b']);
|
var collection = new ol3.Collection(['a', 'b']);
|
||||||
var index, prev;
|
var index, prev;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.SET_AT, function(e) {
|
goog.events.listen(collection, ol3.CollectionEventType.SET_AT, function(e) {
|
||||||
index = e.index;
|
index = e.index;
|
||||||
prev = e.prev;
|
prev = e.prev;
|
||||||
});
|
});
|
||||||
@@ -102,12 +102,13 @@ function testSetAtEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testRemoveAtEvent() {
|
function testRemoveAtEvent() {
|
||||||
var collection = new ol.Collection(['a']);
|
var collection = new ol3.Collection(['a']);
|
||||||
var index, prev;
|
var index, prev;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.REMOVE_AT, function(e) {
|
goog.events.listen(
|
||||||
index = e.index;
|
collection, ol3.CollectionEventType.REMOVE_AT, function(e) {
|
||||||
prev = e.prev;
|
index = e.index;
|
||||||
});
|
prev = e.prev;
|
||||||
|
});
|
||||||
collection.pop();
|
collection.pop();
|
||||||
assertEquals(0, index);
|
assertEquals(0, index);
|
||||||
assertEquals('a', prev);
|
assertEquals('a', prev);
|
||||||
@@ -115,22 +116,24 @@ function testRemoveAtEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testInsertAtEvent() {
|
function testInsertAtEvent() {
|
||||||
var collection = new ol.Collection([0, 2]);
|
var collection = new ol3.Collection([0, 2]);
|
||||||
var index;
|
var index;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.INSERT_AT, function(e) {
|
goog.events.listen(
|
||||||
index = e.index;
|
collection, ol3.CollectionEventType.INSERT_AT, function(e) {
|
||||||
});
|
index = e.index;
|
||||||
|
});
|
||||||
collection.insertAt(1, 1);
|
collection.insertAt(1, 1);
|
||||||
assertEquals(1, index);
|
assertEquals(1, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testSetAtBeyondEnd() {
|
function testSetAtBeyondEnd() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
var inserts = [];
|
var inserts = [];
|
||||||
goog.events.listen(collection, ol.CollectionEventType.INSERT_AT, function(e) {
|
goog.events.listen(
|
||||||
inserts.push(e.index);
|
collection, ol3.CollectionEventType.INSERT_AT, function(e) {
|
||||||
});
|
inserts.push(e.index);
|
||||||
|
});
|
||||||
collection.setAt(2, 0);
|
collection.setAt(2, 0);
|
||||||
assertEquals(3, collection.getLength());
|
assertEquals(3, collection.getLength());
|
||||||
assertUndefined(collection.getAt(0));
|
assertUndefined(collection.getAt(0));
|
||||||
@@ -144,7 +147,7 @@ function testSetAtBeyondEnd() {
|
|||||||
|
|
||||||
|
|
||||||
function testLengthChangeInsertAt() {
|
function testLengthChangeInsertAt() {
|
||||||
var collection = new ol.Collection([0, 1, 2]);
|
var collection = new ol3.Collection([0, 1, 2]);
|
||||||
var lengthEventDispatched;
|
var lengthEventDispatched;
|
||||||
goog.events.listen(collection, 'length_changed', function() {
|
goog.events.listen(collection, 'length_changed', function() {
|
||||||
lengthEventDispatched = true;
|
lengthEventDispatched = true;
|
||||||
@@ -155,7 +158,7 @@ function testLengthChangeInsertAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testLengthChangeRemoveAt() {
|
function testLengthChangeRemoveAt() {
|
||||||
var collection = new ol.Collection([0, 1, 2]);
|
var collection = new ol3.Collection([0, 1, 2]);
|
||||||
var lengthEventDispatched;
|
var lengthEventDispatched;
|
||||||
goog.events.listen(collection, 'length_changed', function() {
|
goog.events.listen(collection, 'length_changed', function() {
|
||||||
lengthEventDispatched = true;
|
lengthEventDispatched = true;
|
||||||
@@ -166,7 +169,7 @@ function testLengthChangeRemoveAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testLengthChangeSetAt() {
|
function testLengthChangeSetAt() {
|
||||||
var collection = new ol.Collection([0, 1, 2]);
|
var collection = new ol3.Collection([0, 1, 2]);
|
||||||
var lengthEventDispatched;
|
var lengthEventDispatched;
|
||||||
goog.events.listen(collection, 'length_changed', function() {
|
goog.events.listen(collection, 'length_changed', function() {
|
||||||
lengthEventDispatched = true;
|
lengthEventDispatched = true;
|
||||||
@@ -177,7 +180,7 @@ function testLengthChangeSetAt() {
|
|||||||
|
|
||||||
|
|
||||||
function testForEach() {
|
function testForEach() {
|
||||||
var collection = new ol.Collection([1, 2, 4]);
|
var collection = new ol3.Collection([1, 2, 4]);
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
collection.forEach(function(elem) {
|
collection.forEach(function(elem) {
|
||||||
sum += elem;
|
sum += elem;
|
||||||
@@ -187,7 +190,7 @@ function testForEach() {
|
|||||||
|
|
||||||
|
|
||||||
function testForEachScope() {
|
function testForEachScope() {
|
||||||
var collection = new ol.Collection([0]);
|
var collection = new ol3.Collection([0]);
|
||||||
var that;
|
var that;
|
||||||
var uniqueObj = {};
|
var uniqueObj = {};
|
||||||
collection.forEach(function(elem) {
|
collection.forEach(function(elem) {
|
||||||
@@ -198,9 +201,9 @@ function testForEachScope() {
|
|||||||
|
|
||||||
|
|
||||||
function testAddEvent() {
|
function testAddEvent() {
|
||||||
var collection = new ol.Collection();
|
var collection = new ol3.Collection();
|
||||||
var elem;
|
var elem;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
goog.events.listen(collection, ol3.CollectionEventType.ADD, function(e) {
|
||||||
elem = e.elem;
|
elem = e.elem;
|
||||||
});
|
});
|
||||||
collection.push(1);
|
collection.push(1);
|
||||||
@@ -209,13 +212,13 @@ function testAddEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testAddRemoveEvent() {
|
function testAddRemoveEvent() {
|
||||||
var collection = new ol.Collection([1]);
|
var collection = new ol3.Collection([1]);
|
||||||
var addedElem;
|
var addedElem;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
|
goog.events.listen(collection, ol3.CollectionEventType.ADD, function(e) {
|
||||||
addedElem = e.elem;
|
addedElem = e.elem;
|
||||||
});
|
});
|
||||||
var removedElem;
|
var removedElem;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.REMOVE, function(e) {
|
goog.events.listen(collection, ol3.CollectionEventType.REMOVE, function(e) {
|
||||||
removedElem = e.elem;
|
removedElem = e.elem;
|
||||||
});
|
});
|
||||||
collection.setAt(0, 2);
|
collection.setAt(0, 2);
|
||||||
@@ -225,9 +228,9 @@ function testAddRemoveEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testRemove() {
|
function testRemove() {
|
||||||
var collection = new ol.Collection([1]);
|
var collection = new ol3.Collection([1]);
|
||||||
var elem;
|
var elem;
|
||||||
goog.events.listen(collection, ol.CollectionEventType.REMOVE, function(e) {
|
goog.events.listen(collection, ol3.CollectionEventType.REMOVE, function(e) {
|
||||||
elem = e.elem;
|
elem = e.elem;
|
||||||
});
|
});
|
||||||
collection.pop();
|
collection.pop();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.Color');
|
goog.provide('ol3.Color');
|
||||||
|
|
||||||
goog.require('goog.color');
|
goog.require('goog.color');
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ goog.require('goog.color');
|
|||||||
* @param {number} b Blue.
|
* @param {number} b Blue.
|
||||||
* @param {number} a Alpha.
|
* @param {number} a Alpha.
|
||||||
*/
|
*/
|
||||||
ol.Color = function(r, g, b, a) {
|
ol3.Color = function(r, g, b, a) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@@ -39,18 +39,18 @@ ol.Color = function(r, g, b, a) {
|
|||||||
/**
|
/**
|
||||||
* @param {string} str String.
|
* @param {string} str String.
|
||||||
* @param {number=} opt_a Alpha.
|
* @param {number=} opt_a Alpha.
|
||||||
* @return {ol.Color} Color.
|
* @return {ol3.Color} Color.
|
||||||
*/
|
*/
|
||||||
ol.Color.createFromString = function(str, opt_a) {
|
ol3.Color.createFromString = function(str, opt_a) {
|
||||||
var rgb = goog.color.hexToRgb(goog.color.parse(str).hex);
|
var rgb = goog.color.hexToRgb(goog.color.parse(str).hex);
|
||||||
var a = opt_a || 255;
|
var a = opt_a || 255;
|
||||||
return new ol.Color(rgb[0], rgb[1], rgb[2], a);
|
return new ol3.Color(rgb[0], rgb[1], rgb[2], a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Color} Clone.
|
* @return {ol3.Color} Clone.
|
||||||
*/
|
*/
|
||||||
ol.Color.prototype.clone = function() {
|
ol3.Color.prototype.clone = function() {
|
||||||
return new ol.Color(this.r, this.g, this.b, this.a);
|
return new ol3.Color(this.r, this.g, this.b, this.a);
|
||||||
};
|
};
|
||||||
31
src/ol3/base/coordinate.js
Normal file
31
src/ol3/base/coordinate.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
goog.provide('ol3.Coordinate');
|
||||||
|
|
||||||
|
goog.require('goog.math.Vec2');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {goog.math.Vec2}
|
||||||
|
* @param {number} x X.
|
||||||
|
* @param {number} y Y.
|
||||||
|
*/
|
||||||
|
ol3.Coordinate = function(x, y) {
|
||||||
|
goog.base(this, x, y);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.Coordinate, goog.math.Vec2);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {ol3.Coordinate}
|
||||||
|
*/
|
||||||
|
ol3.Coordinate.ZERO = new ol3.Coordinate(0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Coordinate} Clone.
|
||||||
|
*/
|
||||||
|
ol3.Coordinate.prototype.clone = function() {
|
||||||
|
return new ol3.Coordinate(this.x, this.y);
|
||||||
|
};
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
goog.provide('ol.CoordinateFormat');
|
goog.provide('ol3.CoordinateFormat');
|
||||||
goog.provide('ol.CoordinateFormatType');
|
goog.provide('ol3.CoordinateFormatType');
|
||||||
|
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function((ol.Coordinate|undefined)): string}
|
* @typedef {function((ol3.Coordinate|undefined)): string}
|
||||||
*/
|
*/
|
||||||
ol.CoordinateFormatType;
|
ol3.CoordinateFormatType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} precision Precision.
|
* @param {number} precision Precision.
|
||||||
* @return {ol.CoordinateFormatType} Coordinate format.
|
* @return {ol3.CoordinateFormatType} Coordinate format.
|
||||||
*/
|
*/
|
||||||
ol.CoordinateFormat.createXY = function(precision) {
|
ol3.CoordinateFormat.createXY = function(precision) {
|
||||||
return function(coordinate) {
|
return function(coordinate) {
|
||||||
if (goog.isDef(coordinate)) {
|
if (goog.isDef(coordinate)) {
|
||||||
return coordinate.x.toFixed(precision) + ', ' +
|
return coordinate.x.toFixed(precision) + ', ' +
|
||||||
@@ -33,7 +33,7 @@ ol.CoordinateFormat.createXY = function(precision) {
|
|||||||
* @param {string} hemispheres Hemispheres.
|
* @param {string} hemispheres Hemispheres.
|
||||||
* @return {string} String.
|
* @return {string} String.
|
||||||
*/
|
*/
|
||||||
ol.CoordinateFormat.degreesToHDMS_ = function(degrees, hemispheres) {
|
ol3.CoordinateFormat.degreesToHDMS_ = function(degrees, hemispheres) {
|
||||||
var normalizedDegrees = goog.math.modulo(degrees + 180, 360) - 180;
|
var normalizedDegrees = goog.math.modulo(degrees + 180, 360) - 180;
|
||||||
var x = Math.abs(Math.round(3600 * normalizedDegrees));
|
var x = Math.abs(Math.round(3600 * normalizedDegrees));
|
||||||
return Math.floor(x / 3600) + '\u00b0 ' +
|
return Math.floor(x / 3600) + '\u00b0 ' +
|
||||||
@@ -44,13 +44,13 @@ ol.CoordinateFormat.degreesToHDMS_ = function(degrees, hemispheres) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|undefined} coordinate Coordinate.
|
* @param {ol3.Coordinate|undefined} coordinate Coordinate.
|
||||||
* @return {string} Coordinate format.
|
* @return {string} Coordinate format.
|
||||||
*/
|
*/
|
||||||
ol.CoordinateFormat.hdms = function(coordinate) {
|
ol3.CoordinateFormat.hdms = function(coordinate) {
|
||||||
if (goog.isDef(coordinate)) {
|
if (goog.isDef(coordinate)) {
|
||||||
return ol.CoordinateFormat.degreesToHDMS_(coordinate.y, 'NS') + ' ' +
|
return ol3.CoordinateFormat.degreesToHDMS_(coordinate.y, 'NS') + ' ' +
|
||||||
ol.CoordinateFormat.degreesToHDMS_(coordinate.x, 'EW');
|
ol3.CoordinateFormat.degreesToHDMS_(coordinate.x, 'EW');
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
45
src/ol3/base/coveragearea.js
Normal file
45
src/ol3/base/coveragearea.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
goog.provide('ol3.CoverageArea');
|
||||||
|
|
||||||
|
goog.require('ol3.Extent');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {ol3.Extent} extent Extent.
|
||||||
|
*/
|
||||||
|
ol3.CoverageArea = function(extent) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol3.Extent}
|
||||||
|
*/
|
||||||
|
this.extent = extent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Extent} extent Extent.
|
||||||
|
* @return {boolean} Intersects.
|
||||||
|
*/
|
||||||
|
ol3.CoverageArea.prototype.intersectsExtent = function(extent) {
|
||||||
|
return this.extent.intersects(extent);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Extent} extent Extent.
|
||||||
|
* @param {number} resolution Resolution.
|
||||||
|
* @return {boolean} Intersects.
|
||||||
|
*/
|
||||||
|
ol3.CoverageArea.prototype.intersectsExtentAndResolution = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.TransformFunction} transformFn Transform.
|
||||||
|
* @return {ol3.CoverageArea} Transformed coverage area.
|
||||||
|
*/
|
||||||
|
ol3.CoverageArea.prototype.transform = function(transformFn) {
|
||||||
|
var extent = this.extent.transform(transformFn);
|
||||||
|
return new ol3.CoverageArea(extent);
|
||||||
|
};
|
||||||
153
src/ol3/base/createmap.js
Normal file
153
src/ol3/base/createmap.js
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
goog.provide('ol3.RendererHint');
|
||||||
|
goog.provide('ol3.createMap');
|
||||||
|
|
||||||
|
goog.require('goog.object');
|
||||||
|
goog.require('ol3.Collection');
|
||||||
|
goog.require('ol3.Map');
|
||||||
|
goog.require('ol3.MapProperty');
|
||||||
|
goog.require('ol3.Projection');
|
||||||
|
goog.require('ol3.dom');
|
||||||
|
goog.require('ol3.dom.MapRenderer');
|
||||||
|
goog.require('ol3.interaction.AltDragRotate');
|
||||||
|
goog.require('ol3.interaction.CenterConstraint');
|
||||||
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
goog.require('ol3.interaction.DblClickZoom');
|
||||||
|
goog.require('ol3.interaction.DragPan');
|
||||||
|
goog.require('ol3.interaction.KeyboardPan');
|
||||||
|
goog.require('ol3.interaction.KeyboardZoom');
|
||||||
|
goog.require('ol3.interaction.MouseWheelZoom');
|
||||||
|
goog.require('ol3.interaction.ResolutionConstraint');
|
||||||
|
goog.require('ol3.interaction.RotationConstraint');
|
||||||
|
goog.require('ol3.interaction.ShiftDragZoom');
|
||||||
|
goog.require('ol3.webgl');
|
||||||
|
goog.require('ol3.webgl.MapRenderer');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {string} Default projection code.
|
||||||
|
*/
|
||||||
|
ol3.DEFAULT_PROJECTION_CODE = 'EPSG:3857';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {string} Default user projection code.
|
||||||
|
*/
|
||||||
|
ol3.DEFAULT_USER_PROJECTION_CODE = 'EPSG:4326';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean} Whether to enable DOM.
|
||||||
|
*/
|
||||||
|
ol3.ENABLE_DOM = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean} Whether to enable WebGL.
|
||||||
|
*/
|
||||||
|
ol3.ENABLE_WEBGL = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol3.RendererHint = {
|
||||||
|
DOM: 'dom',
|
||||||
|
WEBGL: 'webgl'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<ol3.RendererHint>}
|
||||||
|
*/
|
||||||
|
ol3.DEFAULT_RENDERER_HINT = [
|
||||||
|
ol3.RendererHint.WEBGL,
|
||||||
|
ol3.RendererHint.DOM
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Element} target Target.
|
||||||
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
|
* @param {ol3.RendererHint|Array.<ol3.RendererHint>=} opt_rendererHints
|
||||||
|
* Renderer hints.
|
||||||
|
* @return {ol3.Map} Map.
|
||||||
|
*/
|
||||||
|
ol3.createMap = function(target, opt_values, opt_rendererHints) {
|
||||||
|
|
||||||
|
var values = {};
|
||||||
|
if (goog.isDef(opt_values)) {
|
||||||
|
goog.object.extend(values, opt_values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME this should be a configuration option
|
||||||
|
var centerConstraint = ol3.interaction.CenterConstraint.snapToPixel;
|
||||||
|
var resolutionConstraint =
|
||||||
|
ol3.interaction.ResolutionConstraint.createSnapToPower(
|
||||||
|
Math.exp(Math.log(2) / 8), ol3.Projection.EPSG_3857_HALF_SIZE / 128);
|
||||||
|
var rotationConstraint = ol3.interaction.RotationConstraint.none;
|
||||||
|
var constraints = new ol3.interaction.Constraints(
|
||||||
|
centerConstraint, resolutionConstraint, rotationConstraint);
|
||||||
|
|
||||||
|
if (!goog.object.containsKey(values, ol3.MapProperty.INTERACTIONS)) {
|
||||||
|
var interactions = new ol3.Collection();
|
||||||
|
interactions.push(new ol3.interaction.AltDragRotate(constraints));
|
||||||
|
interactions.push(new ol3.interaction.DblClickZoom(constraints));
|
||||||
|
interactions.push(new ol3.interaction.DragPan(constraints));
|
||||||
|
interactions.push(new ol3.interaction.KeyboardPan(constraints, 16));
|
||||||
|
interactions.push(new ol3.interaction.KeyboardZoom(constraints));
|
||||||
|
interactions.push(new ol3.interaction.MouseWheelZoom(constraints));
|
||||||
|
interactions.push(new ol3.interaction.ShiftDragZoom(constraints));
|
||||||
|
values[ol3.MapProperty.INTERACTIONS] = interactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!goog.object.containsKey(values, ol3.MapProperty.LAYERS)) {
|
||||||
|
values[ol3.MapProperty.LAYERS] = new ol3.Collection();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!goog.object.containsKey(values, ol3.MapProperty.PROJECTION)) {
|
||||||
|
values[ol3.MapProperty.PROJECTION] =
|
||||||
|
ol3.Projection.getFromCode(ol3.DEFAULT_PROJECTION_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!goog.object.containsKey(values, ol3.MapProperty.USER_PROJECTION)) {
|
||||||
|
values[ol3.MapProperty.USER_PROJECTION] =
|
||||||
|
ol3.Projection.getFromCode(ol3.DEFAULT_USER_PROJECTION_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<ol3.RendererHint>}
|
||||||
|
*/
|
||||||
|
var rendererHints;
|
||||||
|
if (goog.isDef(opt_rendererHints)) {
|
||||||
|
if (goog.isArray(opt_rendererHints)) {
|
||||||
|
rendererHints = opt_rendererHints;
|
||||||
|
} else {
|
||||||
|
rendererHints = [opt_rendererHints];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rendererHints = ol3.DEFAULT_RENDERER_HINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
var i, rendererHint, rendererConstructor;
|
||||||
|
for (i = 0; i < rendererHints.length; ++i) {
|
||||||
|
rendererHint = rendererHints[i];
|
||||||
|
if (rendererHint == ol3.RendererHint.DOM) {
|
||||||
|
if (ol3.ENABLE_DOM && ol3.dom.isSupported()) {
|
||||||
|
rendererConstructor = ol3.dom.MapRenderer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (rendererHint == ol3.RendererHint.WEBGL) {
|
||||||
|
if (ol3.ENABLE_WEBGL && ol3.webgl.isSupported()) {
|
||||||
|
rendererConstructor = ol3.webgl.MapRenderer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goog.isDef(rendererConstructor)) {
|
||||||
|
return new ol3.Map(target, rendererConstructor, values);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
59
src/ol3/base/extent.js
Normal file
59
src/ol3/base/extent.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
goog.provide('ol3.Extent');
|
||||||
|
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.Rectangle');
|
||||||
|
goog.require('ol3.TransformFunction');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.Rectangle}
|
||||||
|
* @param {number} minX Minimum X.
|
||||||
|
* @param {number} minY Minimum Y.
|
||||||
|
* @param {number} maxX Maximum X.
|
||||||
|
* @param {number} maxY Maximum Y.
|
||||||
|
*/
|
||||||
|
ol3.Extent = function(minX, minY, maxX, maxY) {
|
||||||
|
goog.base(this, minX, minY, maxX, maxY);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.Extent, ol3.Rectangle);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {...ol3.Coordinate} var_args Coordinates.
|
||||||
|
* @return {!ol3.Extent} Bounding extent.
|
||||||
|
*/
|
||||||
|
ol3.Extent.boundingExtent = function(var_args) {
|
||||||
|
var coordinate0 = arguments[0];
|
||||||
|
var extent = new ol3.Extent(coordinate0.x, coordinate0.y,
|
||||||
|
coordinate0.x, coordinate0.y);
|
||||||
|
var i;
|
||||||
|
for (i = 1; i < arguments.length; ++i) {
|
||||||
|
var coordinate = arguments[i];
|
||||||
|
extent.minX = Math.min(extent.minX, coordinate.x);
|
||||||
|
extent.minY = Math.min(extent.minY, coordinate.y);
|
||||||
|
extent.maxX = Math.max(extent.maxX, coordinate.x);
|
||||||
|
extent.maxY = Math.max(extent.maxY, coordinate.y);
|
||||||
|
}
|
||||||
|
return extent;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Extent} Extent.
|
||||||
|
*/
|
||||||
|
ol3.Extent.prototype.clone = function() {
|
||||||
|
return new ol3.Extent(this.minX, this.minY, this.maxX, this.maxY);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.TransformFunction} transformFn Transform function.
|
||||||
|
* @return {ol3.Extent} Extent.
|
||||||
|
*/
|
||||||
|
ol3.Extent.prototype.transform = function(transformFn) {
|
||||||
|
var min = transformFn(new ol3.Coordinate(this.minX, this.minY));
|
||||||
|
var max = transformFn(new ol3.Coordinate(this.maxX, this.maxY));
|
||||||
|
return new ol3.Extent(min.x, min.y, max.x, max.y);
|
||||||
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol3.Extent');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol3.Projection');
|
||||||
|
|
||||||
|
|
||||||
function testClone() {
|
function testClone() {
|
||||||
var extent = new ol.Extent(1, 2, 3, 4);
|
var extent = new ol3.Extent(1, 2, 3, 4);
|
||||||
var clonedExtent = extent.clone();
|
var clonedExtent = extent.clone();
|
||||||
assertTrue(clonedExtent instanceof ol.Extent);
|
assertTrue(clonedExtent instanceof ol3.Extent);
|
||||||
assertFalse(clonedExtent === extent);
|
assertFalse(clonedExtent === extent);
|
||||||
assertEquals(extent.minX, clonedExtent.minX);
|
assertEquals(extent.minX, clonedExtent.minX);
|
||||||
assertEquals(extent.minY, clonedExtent.minY);
|
assertEquals(extent.minY, clonedExtent.minY);
|
||||||
@@ -17,8 +17,8 @@ function testClone() {
|
|||||||
|
|
||||||
function testTransform() {
|
function testTransform() {
|
||||||
var transformFn =
|
var transformFn =
|
||||||
ol.Projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
|
ol3.Projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
|
||||||
var sourceExtent = new ol.Extent(-15, -30, 45, 60);
|
var sourceExtent = new ol3.Extent(-15, -30, 45, 60);
|
||||||
var destinationExtent = sourceExtent.transform(transformFn);
|
var destinationExtent = sourceExtent.transform(transformFn);
|
||||||
assertNotNullNorUndefined(destinationExtent);
|
assertNotNullNorUndefined(destinationExtent);
|
||||||
// FIXME check values with third-party tool
|
// FIXME check values with third-party tool
|
||||||
228
src/ol3/base/layer.js
Normal file
228
src/ol3/base/layer.js
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
goog.provide('ol3.Layer');
|
||||||
|
goog.provide('ol3.LayerProperty');
|
||||||
|
|
||||||
|
goog.require('goog.math');
|
||||||
|
goog.require('ol3.Object');
|
||||||
|
goog.require('ol3.Store');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol3.LayerProperty = {
|
||||||
|
BRIGHTNESS: 'brightness',
|
||||||
|
CONTRAST: 'contrast',
|
||||||
|
HUE: 'hue',
|
||||||
|
OPACITY: 'opacity',
|
||||||
|
SATURATION: 'saturation',
|
||||||
|
VISIBLE: 'visible'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.Object}
|
||||||
|
* @param {ol3.Store} store Store.
|
||||||
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
|
*/
|
||||||
|
ol3.Layer = function(store, opt_values) {
|
||||||
|
|
||||||
|
goog.base(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Store}
|
||||||
|
*/
|
||||||
|
this.store_ = store;
|
||||||
|
|
||||||
|
this.setBrightness(0);
|
||||||
|
this.setContrast(0);
|
||||||
|
this.setHue(0);
|
||||||
|
this.setOpacity(1);
|
||||||
|
this.setSaturation(0);
|
||||||
|
this.setVisible(true);
|
||||||
|
|
||||||
|
if (goog.isDef(opt_values)) {
|
||||||
|
this.setValues(opt_values);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.Layer, ol3.Object);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Brightness.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getBrightness = function() {
|
||||||
|
return /** @type {number} */ this.get(ol3.LayerProperty.BRIGHTNESS);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getBrightness',
|
||||||
|
ol3.Layer.prototype.getBrightness);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Contrast.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getContrast = function() {
|
||||||
|
return /** @type {number} */ this.get(ol3.LayerProperty.CONTRAST);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getContrast',
|
||||||
|
ol3.Layer.prototype.getContrast);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Hue.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getHue = function() {
|
||||||
|
return /** @type {number} */ this.get(ol3.LayerProperty.HUE);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getHue',
|
||||||
|
ol3.Layer.prototype.getHue);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Opacity.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getOpacity = function() {
|
||||||
|
return /** @type {number} */ this.get(ol3.LayerProperty.OPACITY);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getOpacity',
|
||||||
|
ol3.Layer.prototype.getOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Saturation.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getSaturation = function() {
|
||||||
|
return /** @type {number} */ this.get(ol3.LayerProperty.SATURATION);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getSaturation',
|
||||||
|
ol3.Layer.prototype.getSaturation);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Store} Store.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getStore = function() {
|
||||||
|
return this.store_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} Visible.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.getVisible = function() {
|
||||||
|
return /** @type {boolean} */ this.get(ol3.LayerProperty.VISIBLE);
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'getVisible',
|
||||||
|
ol3.Layer.prototype.getVisible);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} Is ready.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.isReady = function() {
|
||||||
|
return this.getStore().isReady();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} brightness Brightness.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setBrightness = function(brightness) {
|
||||||
|
brightness = goog.math.clamp(brightness, -1, 1);
|
||||||
|
if (brightness != this.getBrightness()) {
|
||||||
|
this.set(ol3.LayerProperty.BRIGHTNESS, brightness);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setBrightness',
|
||||||
|
ol3.Layer.prototype.setBrightness);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} contrast Contrast.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setContrast = function(contrast) {
|
||||||
|
contrast = goog.math.clamp(contrast, -1, 1);
|
||||||
|
if (contrast != this.getContrast()) {
|
||||||
|
this.set(ol3.LayerProperty.CONTRAST, contrast);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setContrast',
|
||||||
|
ol3.Layer.prototype.setContrast);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} hue Hue.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setHue = function(hue) {
|
||||||
|
if (hue != this.getHue()) {
|
||||||
|
this.set(ol3.LayerProperty.HUE, hue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setHue',
|
||||||
|
ol3.Layer.prototype.setHue);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} opacity Opacity.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setOpacity = function(opacity) {
|
||||||
|
opacity = goog.math.clamp(opacity, 0, 1);
|
||||||
|
if (opacity != this.getOpacity()) {
|
||||||
|
this.set(ol3.LayerProperty.OPACITY, opacity);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setOpacity',
|
||||||
|
ol3.Layer.prototype.setOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} saturation Saturation.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setSaturation = function(saturation) {
|
||||||
|
saturation = goog.math.clamp(saturation, -1, 1);
|
||||||
|
if (saturation != this.getSaturation()) {
|
||||||
|
this.set(ol3.LayerProperty.SATURATION, saturation);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setSaturation',
|
||||||
|
ol3.Layer.prototype.setSaturation);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} visible Visible.
|
||||||
|
*/
|
||||||
|
ol3.Layer.prototype.setVisible = function(visible) {
|
||||||
|
visible = !!visible;
|
||||||
|
if (visible != this.getVisible()) {
|
||||||
|
this.set(ol3.LayerProperty.VISIBLE, visible);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
goog.exportProperty(
|
||||||
|
ol3.Layer.prototype,
|
||||||
|
'setVisible',
|
||||||
|
ol3.Layer.prototype.setVisible);
|
||||||
127
src/ol3/base/layerrenderer.js
Normal file
127
src/ol3/base/layerrenderer.js
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
goog.provide('ol3.LayerRenderer');
|
||||||
|
|
||||||
|
goog.require('goog.events');
|
||||||
|
goog.require('goog.events.EventType');
|
||||||
|
goog.require('ol3.Layer');
|
||||||
|
goog.require('ol3.LayerProperty');
|
||||||
|
goog.require('ol3.Object');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.Object}
|
||||||
|
* @param {ol3.MapRenderer} mapRenderer Map renderer.
|
||||||
|
* @param {ol3.Layer} layer Layer.
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer = function(mapRenderer, layer) {
|
||||||
|
|
||||||
|
goog.base(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.MapRenderer}
|
||||||
|
*/
|
||||||
|
this.mapRenderer_ = mapRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Layer}
|
||||||
|
*/
|
||||||
|
this.layer_ = layer;
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.BRIGHTNESS),
|
||||||
|
this.handleLayerBrightnessChange, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.CONTRAST),
|
||||||
|
this.handleLayerContrastChange, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.HUE),
|
||||||
|
this.handleLayerHueChange, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_, goog.events.EventType.LOAD,
|
||||||
|
this.handleLayerLoad, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.OPACITY),
|
||||||
|
this.handleLayerOpacityChange, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.SATURATION),
|
||||||
|
this.handleLayerSaturationChange, false, this);
|
||||||
|
|
||||||
|
goog.events.listen(this.layer_,
|
||||||
|
ol3.Object.getChangedEventType(ol3.LayerProperty.VISIBLE),
|
||||||
|
this.handleLayerVisibleChange, false, this);
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.LayerRenderer, ol3.Object);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Layer} Layer.
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.getLayer = function() {
|
||||||
|
return this.layer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Map} Map.
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.getMap = function() {
|
||||||
|
return this.mapRenderer_.getMap();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.MapRenderer} Map renderer.
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.getMapRenderer = function() {
|
||||||
|
return this.mapRenderer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerBrightnessChange = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerContrastChange = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerHueChange = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerLoad = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerOpacityChange = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerSaturationChange = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol3.LayerRenderer.prototype.handleLayerVisibleChange = goog.nullFunction;
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
// FIXME layer renderers should skip when they can't reproject
|
// FIXME layer renderers should skip when they can't reproject
|
||||||
// FIXME add tilt and height?
|
// FIXME add tilt and height?
|
||||||
|
|
||||||
goog.provide('ol.Map');
|
goog.provide('ol3.Map');
|
||||||
goog.provide('ol.MapEventType');
|
goog.provide('ol3.MapEventType');
|
||||||
goog.provide('ol.MapProperty');
|
goog.provide('ol3.MapProperty');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.debug.Logger');
|
goog.require('goog.debug.Logger');
|
||||||
@@ -27,24 +27,24 @@ goog.require('goog.fx.Dragger');
|
|||||||
goog.require('goog.fx.anim');
|
goog.require('goog.fx.anim');
|
||||||
goog.require('goog.fx.anim.Animated');
|
goog.require('goog.fx.anim.Animated');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol3.Collection');
|
||||||
goog.require('ol.Color');
|
goog.require('ol3.Color');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol3.Extent');
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
goog.require('ol.LayerRenderer');
|
goog.require('ol3.LayerRenderer');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.Object');
|
goog.require('ol3.Object');
|
||||||
goog.require('ol.Pixel');
|
goog.require('ol3.Pixel');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol3.Projection');
|
||||||
goog.require('ol.Size');
|
goog.require('ol3.Size');
|
||||||
goog.require('ol.TransformFunction');
|
goog.require('ol3.TransformFunction');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.MapEventType = {
|
ol3.MapEventType = {
|
||||||
POST_RENDER: 'postrender'
|
POST_RENDER: 'postrender'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ ol.MapEventType = {
|
|||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.MapProperty = {
|
ol3.MapProperty = {
|
||||||
BACKGROUND_COLOR: 'backgroundColor',
|
BACKGROUND_COLOR: 'backgroundColor',
|
||||||
CENTER: 'center',
|
CENTER: 'center',
|
||||||
INTERACTIONS: 'interactions',
|
INTERACTIONS: 'interactions',
|
||||||
@@ -68,7 +68,7 @@ ol.MapProperty = {
|
|||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
ol.MapPaneZIndex = {
|
ol3.MapPaneZIndex = {
|
||||||
VIEWPORT: 1000
|
VIEWPORT: 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,16 +76,16 @@ ol.MapPaneZIndex = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Object}
|
* @extends {ol3.Object}
|
||||||
* @implements {goog.fx.anim.Animated}
|
* @implements {goog.fx.anim.Animated}
|
||||||
* @param {Element} container Container.
|
* @param {Element} container Container.
|
||||||
* @param {function(new: ol.MapRenderer, Element, ol.Map)} rendererConstructor
|
* @param {function(new: ol3.MapRenderer, Element, ol3.Map)} rendererConstructor
|
||||||
* Renderer constructor.
|
* Renderer constructor.
|
||||||
* @param {Object=} opt_values Values.
|
* @param {Object=} opt_values Values.
|
||||||
* @param {goog.dom.ViewportSizeMonitor=} opt_viewportSizeMonitor
|
* @param {goog.dom.ViewportSizeMonitor=} opt_viewportSizeMonitor
|
||||||
* Viewport size monitor.
|
* Viewport size monitor.
|
||||||
*/
|
*/
|
||||||
ol.Map = function(
|
ol3.Map = function(
|
||||||
container, rendererConstructor, opt_values, opt_viewportSizeMonitor) {
|
container, rendererConstructor, opt_values, opt_viewportSizeMonitor) {
|
||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
@@ -95,20 +95,20 @@ ol.Map = function(
|
|||||||
* @protected
|
* @protected
|
||||||
* @type {goog.debug.Logger}
|
* @type {goog.debug.Logger}
|
||||||
*/
|
*/
|
||||||
this.logger = goog.debug.Logger.getLogger('ol.map.' + goog.getUid(this));
|
this.logger = goog.debug.Logger.getLogger('ol3.map.' + goog.getUid(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.TransformFunction}
|
* @type {ol3.TransformFunction}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.userToMapTransform_ = ol.Projection.identityTransform;
|
this.userToMapTransform_ = ol3.Projection.identityTransform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.TransformFunction}
|
* @type {ol3.TransformFunction}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.mapToUserTransform_ = ol.Projection.cloneTransform;
|
this.mapToUserTransform_ = ol3.Projection.cloneTransform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -150,7 +150,7 @@ ol.Map = function(
|
|||||||
this.viewport_.style.overflow = 'hidden';
|
this.viewport_.style.overflow = 'hidden';
|
||||||
this.viewport_.style.width = '100%';
|
this.viewport_.style.width = '100%';
|
||||||
this.viewport_.style.height = '100%';
|
this.viewport_.style.height = '100%';
|
||||||
this.viewport_.style.zIndex = ol.MapPaneZIndex.VIEWPORT;
|
this.viewport_.style.zIndex = ol3.MapPaneZIndex.VIEWPORT;
|
||||||
goog.dom.appendChild(container, this.viewport_);
|
goog.dom.appendChild(container, this.viewport_);
|
||||||
|
|
||||||
goog.events.listen(this.viewport_, [
|
goog.events.listen(this.viewport_, [
|
||||||
@@ -179,7 +179,7 @@ ol.Map = function(
|
|||||||
this.registerDisposable(dragger);
|
this.registerDisposable(dragger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.MapRenderer}
|
* @type {ol3.MapRenderer}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.renderer_ = new rendererConstructor(this.viewport_, this);
|
this.renderer_ = new rendererConstructor(this.viewport_, this);
|
||||||
@@ -196,11 +196,11 @@ ol.Map = function(
|
|||||||
this.handleBrowserWindowResize, false, this);
|
this.handleBrowserWindowResize, false, this);
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
this, ol.Object.getChangedEventType(ol.MapProperty.PROJECTION),
|
this, ol3.Object.getChangedEventType(ol3.MapProperty.PROJECTION),
|
||||||
this.handleProjectionChanged, false, this);
|
this.handleProjectionChanged, false, this);
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
this, ol.Object.getChangedEventType(ol.MapProperty.USER_PROJECTION),
|
this, ol3.Object.getChangedEventType(ol3.MapProperty.USER_PROJECTION),
|
||||||
this.handleUserProjectionChanged, false, this);
|
this.handleUserProjectionChanged, false, this);
|
||||||
|
|
||||||
if (goog.isDef(opt_values)) {
|
if (goog.isDef(opt_values)) {
|
||||||
@@ -210,21 +210,21 @@ ol.Map = function(
|
|||||||
this.handleBrowserWindowResize();
|
this.handleBrowserWindowResize();
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Map, ol.Object);
|
goog.inherits(ol3.Map, ol3.Object);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} Can rotate.
|
* @return {boolean} Can rotate.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.canRotate = function() {
|
ol3.Map.prototype.canRotate = function() {
|
||||||
return this.renderer_.canRotate();
|
return this.renderer_.canRotate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol3.Extent} extent Extent.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.fitExtent = function(extent) {
|
ol3.Map.prototype.fitExtent = function(extent) {
|
||||||
this.withFrozenRendering(function() {
|
this.withFrozenRendering(function() {
|
||||||
this.setCenter(extent.getCenter());
|
this.setCenter(extent.getCenter());
|
||||||
this.setResolution(this.getResolutionForExtent(extent));
|
this.setResolution(this.getResolutionForExtent(extent));
|
||||||
@@ -236,58 +236,58 @@ ol.Map.prototype.fitExtent = function(extent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent} userExtent Extent in user projection.
|
* @param {ol3.Extent} userExtent Extent in user projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.fitUserExtent = function(userExtent) {
|
ol3.Map.prototype.fitUserExtent = function(userExtent) {
|
||||||
this.fitExtent(userExtent.transform(this.userToMapTransform_));
|
this.fitExtent(userExtent.transform(this.userToMapTransform_));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.freezeRendering = function() {
|
ol3.Map.prototype.freezeRendering = function() {
|
||||||
++this.freezeRenderingCount_;
|
++this.freezeRenderingCount_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Color|undefined} Background color.
|
* @return {ol3.Color|undefined} Background color.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getBackgroundColor = function() {
|
ol3.Map.prototype.getBackgroundColor = function() {
|
||||||
return /** @type {ol.Color|undefined} */ (
|
return /** @type {ol3.Color|undefined} */ (
|
||||||
this.get(ol.MapProperty.BACKGROUND_COLOR));
|
this.get(ol3.MapProperty.BACKGROUND_COLOR));
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getBackgroundColor',
|
'getBackgroundColor',
|
||||||
ol.Map.prototype.getBackgroundColor);
|
ol3.Map.prototype.getBackgroundColor);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Coordinate|undefined} Center.
|
* @return {ol3.Coordinate|undefined} Center.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCenter = function() {
|
ol3.Map.prototype.getCenter = function() {
|
||||||
return /** @type {ol.Coordinate} */ this.get(ol.MapProperty.CENTER);
|
return /** @type {ol3.Coordinate} */ this.get(ol3.MapProperty.CENTER);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getCenter',
|
'getCenter',
|
||||||
ol.Map.prototype.getCenter);
|
ol3.Map.prototype.getCenter);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Element} Container.
|
* @return {Element} Container.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getContainer = function() {
|
ol3.Map.prototype.getContainer = function() {
|
||||||
return this.container_;
|
return this.container_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Pixel} pixel Pixel.
|
* @param {ol3.Pixel} pixel Pixel.
|
||||||
* @return {ol.Coordinate|undefined} Coordinate.
|
* @return {ol3.Coordinate|undefined} Coordinate.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
ol3.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
||||||
if (this.isDef()) {
|
if (this.isDef()) {
|
||||||
return this.renderer_.getCoordinateFromPixel(pixel);
|
return this.renderer_.getCoordinateFromPixel(pixel);
|
||||||
} else {
|
} else {
|
||||||
@@ -297,9 +297,9 @@ ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Extent|undefined} Extent.
|
* @return {ol3.Extent|undefined} Extent.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getExtent = function() {
|
ol3.Map.prototype.getExtent = function() {
|
||||||
if (this.isDef()) {
|
if (this.isDef()) {
|
||||||
var center = this.getCenter();
|
var center = this.getCenter();
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
@@ -308,7 +308,7 @@ ol.Map.prototype.getExtent = function() {
|
|||||||
var minY = center.y - resolution * size.height / 2;
|
var minY = center.y - resolution * size.height / 2;
|
||||||
var maxX = center.x + resolution * size.width / 2;
|
var maxX = center.x + resolution * size.width / 2;
|
||||||
var maxY = center.y + resolution * size.height / 2;
|
var maxY = center.y + resolution * size.height / 2;
|
||||||
return new ol.Extent(minX, minY, maxX, maxY);
|
return new ol3.Extent(minX, minY, maxX, maxY);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -316,30 +316,30 @@ ol.Map.prototype.getExtent = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Collection} Interactions.
|
* @return {ol3.Collection} Interactions.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getInteractions = function() {
|
ol3.Map.prototype.getInteractions = function() {
|
||||||
return /** @type {ol.Collection} */ this.get(ol.MapProperty.INTERACTIONS);
|
return /** @type {ol3.Collection} */ this.get(ol3.MapProperty.INTERACTIONS);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getInteractions',
|
'getInteractions',
|
||||||
ol.Map.prototype.getInteractions);
|
ol3.Map.prototype.getInteractions);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Collection} Layers.
|
* @return {ol3.Collection} Layers.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getLayers = function() {
|
ol3.Map.prototype.getLayers = function() {
|
||||||
return /** @type {ol.Collection} */ (this.get(ol.MapProperty.LAYERS));
|
return /** @type {ol3.Collection} */ (this.get(ol3.MapProperty.LAYERS));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol3.Coordinate} coordinate Coordinate.
|
||||||
* @return {ol.Pixel|undefined} Pixel.
|
* @return {ol3.Pixel|undefined} Pixel.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
|
ol3.Map.prototype.getPixelFromCoordinate = function(coordinate) {
|
||||||
if (this.isDef()) {
|
if (this.isDef()) {
|
||||||
return this.renderer_.getPixelFromCoordinate(coordinate);
|
return this.renderer_.getPixelFromCoordinate(coordinate);
|
||||||
} else {
|
} else {
|
||||||
@@ -349,34 +349,34 @@ ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Projection|undefined} Projection.
|
* @return {ol3.Projection|undefined} Projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getProjection = function() {
|
ol3.Map.prototype.getProjection = function() {
|
||||||
return /** @type {ol.Projection} */ this.get(ol.MapProperty.PROJECTION);
|
return /** @type {ol3.Projection} */ this.get(ol3.MapProperty.PROJECTION);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getProjection',
|
'getProjection',
|
||||||
ol.Map.prototype.getProjection);
|
ol3.Map.prototype.getProjection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number|undefined} Resolution.
|
* @return {number|undefined} Resolution.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getResolution = function() {
|
ol3.Map.prototype.getResolution = function() {
|
||||||
return /** @type {number} */ this.get(ol.MapProperty.RESOLUTION);
|
return /** @type {number} */ this.get(ol3.MapProperty.RESOLUTION);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getResolution',
|
'getResolution',
|
||||||
ol.Map.prototype.getResolution);
|
ol3.Map.prototype.getResolution);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol3.Extent} extent Extent.
|
||||||
* @return {number|undefined} Resolution.
|
* @return {number|undefined} Resolution.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getResolutionForExtent = function(extent) {
|
ol3.Map.prototype.getResolutionForExtent = function(extent) {
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
if (goog.isDef(size)) {
|
if (goog.isDef(size)) {
|
||||||
var xResolution = (extent.maxX - extent.minX) / size.width;
|
var xResolution = (extent.maxX - extent.minX) / size.width;
|
||||||
@@ -389,58 +389,58 @@ ol.Map.prototype.getResolutionForExtent = function(extent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Extent} Rotated extent.
|
* @return {ol3.Extent} Rotated extent.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getRotatedExtent = function() {
|
ol3.Map.prototype.getRotatedExtent = function() {
|
||||||
goog.asserts.assert(this.isDef());
|
goog.asserts.assert(this.isDef());
|
||||||
var center = /** @type {!ol.Coordinate} */ this.getCenter();
|
var center = /** @type {!ol3.Coordinate} */ this.getCenter();
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var rotation = this.getRotation() || 0;
|
var rotation = this.getRotation() || 0;
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
var xScale = resolution * size.width / 2;
|
var xScale = resolution * size.width / 2;
|
||||||
var yScale = resolution * size.height / 2;
|
var yScale = resolution * size.height / 2;
|
||||||
var corners = [
|
var corners = [
|
||||||
new ol.Coordinate(-xScale, -yScale),
|
new ol3.Coordinate(-xScale, -yScale),
|
||||||
new ol.Coordinate(-xScale, yScale),
|
new ol3.Coordinate(-xScale, yScale),
|
||||||
new ol.Coordinate(xScale, -yScale),
|
new ol3.Coordinate(xScale, -yScale),
|
||||||
new ol.Coordinate(xScale, yScale)
|
new ol3.Coordinate(xScale, yScale)
|
||||||
];
|
];
|
||||||
goog.array.forEach(corners, function(corner) {
|
goog.array.forEach(corners, function(corner) {
|
||||||
corner.rotate(rotation);
|
corner.rotate(rotation);
|
||||||
corner.add(center);
|
corner.add(center);
|
||||||
});
|
});
|
||||||
return ol.Extent.boundingExtent.apply(null, corners);
|
return ol3.Extent.boundingExtent.apply(null, corners);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number|undefined} Rotation.
|
* @return {number|undefined} Rotation.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getRotation = function() {
|
ol3.Map.prototype.getRotation = function() {
|
||||||
return /** @type {number|undefined} */ this.get(ol.MapProperty.ROTATION);
|
return /** @type {number|undefined} */ this.get(ol3.MapProperty.ROTATION);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getRotation',
|
'getRotation',
|
||||||
ol.Map.prototype.getRotation);
|
ol3.Map.prototype.getRotation);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Size|undefined} Size.
|
* @return {ol3.Size|undefined} Size.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getSize = function() {
|
ol3.Map.prototype.getSize = function() {
|
||||||
return /** @type {ol.Size|undefined} */ this.get(ol.MapProperty.SIZE);
|
return /** @type {ol3.Size|undefined} */ this.get(ol3.MapProperty.SIZE);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getSize',
|
'getSize',
|
||||||
ol.Map.prototype.getSize);
|
ol3.Map.prototype.getSize);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Coordinate|undefined} Center in user projection.
|
* @return {ol3.Coordinate|undefined} Center in user projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getUserCenter = function() {
|
ol3.Map.prototype.getUserCenter = function() {
|
||||||
var center = this.getCenter();
|
var center = this.getCenter();
|
||||||
if (goog.isDef(center)) {
|
if (goog.isDef(center)) {
|
||||||
return this.mapToUserTransform_(center);
|
return this.mapToUserTransform_(center);
|
||||||
@@ -451,9 +451,9 @@ ol.Map.prototype.getUserCenter = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Extent|undefined} Extent in user projection.
|
* @return {ol3.Extent|undefined} Extent in user projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getUserExtent = function() {
|
ol3.Map.prototype.getUserExtent = function() {
|
||||||
var extent = this.getExtent();
|
var extent = this.getExtent();
|
||||||
if (goog.isDef(extent)) {
|
if (goog.isDef(extent)) {
|
||||||
return extent.transform(this.mapToUserTransform_);
|
return extent.transform(this.mapToUserTransform_);
|
||||||
@@ -465,21 +465,22 @@ ol.Map.prototype.getUserExtent = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @return {ol.Projection|undefined} Projection.
|
* @return {ol3.Projection|undefined} Projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getUserProjection = function() {
|
ol3.Map.prototype.getUserProjection = function() {
|
||||||
return /** @type {ol.Projection} */ this.get(ol.MapProperty.USER_PROJECTION);
|
return /** @type {ol3.Projection} */ this.get(
|
||||||
|
ol3.MapProperty.USER_PROJECTION);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'getUserProjection',
|
'getUserProjection',
|
||||||
ol.Map.prototype.getUserProjection);
|
ol3.Map.prototype.getUserProjection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Element} Viewport.
|
* @return {Element} Viewport.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getViewport = function() {
|
ol3.Map.prototype.getViewport = function() {
|
||||||
return this.viewport_;
|
return this.viewport_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -488,11 +489,11 @@ ol.Map.prototype.getViewport = function() {
|
|||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @param {string=} opt_type Type.
|
* @param {string=} opt_type Type.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
ol3.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
||||||
var type = opt_type || browserEvent.type;
|
var type = opt_type || browserEvent.type;
|
||||||
var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent);
|
var mapBrowserEvent = new ol3.MapBrowserEvent(type, this, browserEvent);
|
||||||
var interactions = this.getInteractions();
|
var interactions = this.getInteractions();
|
||||||
var interactionsArray = /** @type {Array.<ol.Interaction>} */
|
var interactionsArray = /** @type {Array.<ol3.Interaction>} */
|
||||||
interactions.getArray();
|
interactions.getArray();
|
||||||
goog.array.every(interactionsArray, function(interaction) {
|
goog.array.every(interactionsArray, function(interaction) {
|
||||||
interaction.handleMapBrowserEvent(mapBrowserEvent);
|
interaction.handleMapBrowserEvent(mapBrowserEvent);
|
||||||
@@ -504,7 +505,7 @@ ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
|||||||
/**
|
/**
|
||||||
* @param {goog.fx.DragEvent} dragEvent Drag event.
|
* @param {goog.fx.DragEvent} dragEvent Drag event.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleDraggerEvent = function(dragEvent) {
|
ol3.Map.prototype.handleDraggerEvent = function(dragEvent) {
|
||||||
var browserEvent = dragEvent.browserEvent;
|
var browserEvent = dragEvent.browserEvent;
|
||||||
this.handleBrowserEvent(browserEvent, dragEvent.type);
|
this.handleBrowserEvent(browserEvent, dragEvent.type);
|
||||||
};
|
};
|
||||||
@@ -513,7 +514,7 @@ ol.Map.prototype.handleDraggerEvent = function(dragEvent) {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleProjectionChanged = function() {
|
ol3.Map.prototype.handleProjectionChanged = function() {
|
||||||
this.recalculateTransforms_();
|
this.recalculateTransforms_();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -521,7 +522,7 @@ ol.Map.prototype.handleProjectionChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleUserProjectionChanged = function() {
|
ol3.Map.prototype.handleUserProjectionChanged = function() {
|
||||||
this.recalculateTransforms_();
|
this.recalculateTransforms_();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -529,8 +530,8 @@ ol.Map.prototype.handleUserProjectionChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.handleBrowserWindowResize = function() {
|
ol3.Map.prototype.handleBrowserWindowResize = function() {
|
||||||
var size = new ol.Size(this.container_.clientWidth,
|
var size = new ol3.Size(this.container_.clientWidth,
|
||||||
this.container_.clientHeight);
|
this.container_.clientHeight);
|
||||||
this.setSize(size);
|
this.setSize(size);
|
||||||
};
|
};
|
||||||
@@ -539,7 +540,7 @@ ol.Map.prototype.handleBrowserWindowResize = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Is animating.
|
* @return {boolean} Is animating.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.isAnimating = function() {
|
ol3.Map.prototype.isAnimating = function() {
|
||||||
return this.animatingCount_ > 0;
|
return this.animatingCount_ > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -547,7 +548,7 @@ ol.Map.prototype.isAnimating = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Is defined.
|
* @return {boolean} Is defined.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.isDef = function() {
|
ol3.Map.prototype.isDef = function() {
|
||||||
return goog.isDefAndNotNull(this.getCenter()) &&
|
return goog.isDefAndNotNull(this.getCenter()) &&
|
||||||
goog.isDef(this.getResolution()) &&
|
goog.isDef(this.getResolution()) &&
|
||||||
goog.isDefAndNotNull(this.getSize());
|
goog.isDefAndNotNull(this.getSize());
|
||||||
@@ -557,7 +558,7 @@ ol.Map.prototype.isDef = function() {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.onAnimationFrame = function() {
|
ol3.Map.prototype.onAnimationFrame = function() {
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
this.logger.info('onAnimationFrame');
|
this.logger.info('onAnimationFrame');
|
||||||
}
|
}
|
||||||
@@ -568,25 +569,25 @@ ol.Map.prototype.onAnimationFrame = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.recalculateTransforms_ = function() {
|
ol3.Map.prototype.recalculateTransforms_ = function() {
|
||||||
var projection = this.getProjection();
|
var projection = this.getProjection();
|
||||||
var userProjection = this.getUserProjection();
|
var userProjection = this.getUserProjection();
|
||||||
if (goog.isDefAndNotNull(projection) &&
|
if (goog.isDefAndNotNull(projection) &&
|
||||||
goog.isDefAndNotNull(userProjection)) {
|
goog.isDefAndNotNull(userProjection)) {
|
||||||
this.mapToUserTransform_ = ol.Projection.getTransform(
|
this.mapToUserTransform_ = ol3.Projection.getTransform(
|
||||||
projection, userProjection);
|
projection, userProjection);
|
||||||
this.userToMapTransform_ = ol.Projection.getTransform(
|
this.userToMapTransform_ = ol3.Projection.getTransform(
|
||||||
userProjection, projection);
|
userProjection, projection);
|
||||||
} else {
|
} else {
|
||||||
this.mapToUserTransform_ = ol.Projection.cloneTransform;
|
this.mapToUserTransform_ = ol3.Projection.cloneTransform;
|
||||||
this.userToMapTransform_ = ol.Projection.identityTransform;
|
this.userToMapTransform_ = ol3.Projection.identityTransform;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.render = function() {
|
ol3.Map.prototype.render = function() {
|
||||||
if (this.animatingCount_ < 1) {
|
if (this.animatingCount_ < 1) {
|
||||||
if (this.freezeRenderingCount_ === 0) {
|
if (this.freezeRenderingCount_ === 0) {
|
||||||
this.renderFrame_();
|
this.renderFrame_();
|
||||||
@@ -600,7 +601,7 @@ ol.Map.prototype.render = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.renderFrame_ = function() {
|
ol3.Map.prototype.renderFrame_ = function() {
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
this.logger.info('renderFrame_');
|
this.logger.info('renderFrame_');
|
||||||
}
|
}
|
||||||
@@ -617,142 +618,142 @@ ol.Map.prototype.renderFrame_ = function() {
|
|||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
this.logger.info('postrender');
|
this.logger.info('postrender');
|
||||||
}
|
}
|
||||||
this.dispatchEvent(ol.MapEventType.POST_RENDER);
|
this.dispatchEvent(ol3.MapEventType.POST_RENDER);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Color} backgroundColor Background color.
|
* @param {ol3.Color} backgroundColor Background color.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setBackgroundColor = function(backgroundColor) {
|
ol3.Map.prototype.setBackgroundColor = function(backgroundColor) {
|
||||||
this.set(ol.MapProperty.BACKGROUND_COLOR, backgroundColor);
|
this.set(ol3.MapProperty.BACKGROUND_COLOR, backgroundColor);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setBackgroundColor',
|
'setBackgroundColor',
|
||||||
ol.Map.prototype.setBackgroundColor);
|
ol3.Map.prototype.setBackgroundColor);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|undefined} center Center.
|
* @param {ol3.Coordinate|undefined} center Center.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setCenter = function(center) {
|
ol3.Map.prototype.setCenter = function(center) {
|
||||||
this.set(ol.MapProperty.CENTER, center);
|
this.set(ol3.MapProperty.CENTER, center);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setCenter',
|
'setCenter',
|
||||||
ol.Map.prototype.setCenter);
|
ol3.Map.prototype.setCenter);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Collection} interactions Interactions.
|
* @param {ol3.Collection} interactions Interactions.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setInteractions = function(interactions) {
|
ol3.Map.prototype.setInteractions = function(interactions) {
|
||||||
this.set(ol.MapProperty.INTERACTIONS, interactions);
|
this.set(ol3.MapProperty.INTERACTIONS, interactions);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setInteractions',
|
'setInteractions',
|
||||||
ol.Map.prototype.setInteractions);
|
ol3.Map.prototype.setInteractions);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {ol.Collection} layers Layers.
|
* @param {ol3.Collection} layers Layers.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setLayers = function(layers) {
|
ol3.Map.prototype.setLayers = function(layers) {
|
||||||
this.set(ol.MapProperty.LAYERS, layers);
|
this.set(ol3.MapProperty.LAYERS, layers);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setLayers',
|
'setLayers',
|
||||||
ol.Map.prototype.setLayers);
|
ol3.Map.prototype.setLayers);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {ol.Projection} projection Projection.
|
* @param {ol3.Projection} projection Projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setProjection = function(projection) {
|
ol3.Map.prototype.setProjection = function(projection) {
|
||||||
this.set(ol.MapProperty.PROJECTION, projection);
|
this.set(ol3.MapProperty.PROJECTION, projection);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setProjection',
|
'setProjection',
|
||||||
ol.Map.prototype.setProjection);
|
ol3.Map.prototype.setProjection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {number|undefined} resolution Resolution.
|
* @param {number|undefined} resolution Resolution.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setResolution = function(resolution) {
|
ol3.Map.prototype.setResolution = function(resolution) {
|
||||||
this.set(ol.MapProperty.RESOLUTION, resolution);
|
this.set(ol3.MapProperty.RESOLUTION, resolution);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setResolution',
|
'setResolution',
|
||||||
ol.Map.prototype.setResolution);
|
ol3.Map.prototype.setResolution);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {number|undefined} rotation Rotation.
|
* @param {number|undefined} rotation Rotation.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setRotation = function(rotation) {
|
ol3.Map.prototype.setRotation = function(rotation) {
|
||||||
this.set(ol.MapProperty.ROTATION, rotation);
|
this.set(ol3.MapProperty.ROTATION, rotation);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setRotation',
|
'setRotation',
|
||||||
ol.Map.prototype.setRotation);
|
ol3.Map.prototype.setRotation);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol3.Size} size Size.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setSize = function(size) {
|
ol3.Map.prototype.setSize = function(size) {
|
||||||
var currentSize = this.getSize();
|
var currentSize = this.getSize();
|
||||||
if (!goog.isDef(currentSize) || !currentSize.equals(size)) {
|
if (!goog.isDef(currentSize) || !currentSize.equals(size)) {
|
||||||
this.set(ol.MapProperty.SIZE, size);
|
this.set(ol3.MapProperty.SIZE, size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setSize',
|
'setSize',
|
||||||
ol.Map.prototype.setSize);
|
ol3.Map.prototype.setSize);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {ol.Coordinate} userCenter Center in user projection.
|
* @param {ol3.Coordinate} userCenter Center in user projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setUserCenter = function(userCenter) {
|
ol3.Map.prototype.setUserCenter = function(userCenter) {
|
||||||
this.setCenter(this.userToMapTransform_(userCenter));
|
this.setCenter(this.userToMapTransform_(userCenter));
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setUserCenter',
|
'setUserCenter',
|
||||||
ol.Map.prototype.setUserCenter);
|
ol3.Map.prototype.setUserCenter);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {ol.Projection} userProjection User projection.
|
* @param {ol3.Projection} userProjection User projection.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setUserProjection = function(userProjection) {
|
ol3.Map.prototype.setUserProjection = function(userProjection) {
|
||||||
this.set(ol.MapProperty.USER_PROJECTION, userProjection);
|
this.set(ol3.MapProperty.USER_PROJECTION, userProjection);
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.Map.prototype,
|
ol3.Map.prototype,
|
||||||
'setUserProjection',
|
'setUserProjection',
|
||||||
ol.Map.prototype.setUserProjection);
|
ol3.Map.prototype.setUserProjection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.startAnimating = function() {
|
ol3.Map.prototype.startAnimating = function() {
|
||||||
if (++this.animatingCount_ == 1) {
|
if (++this.animatingCount_ == 1) {
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
this.logger.info('startAnimating');
|
this.logger.info('startAnimating');
|
||||||
@@ -764,7 +765,7 @@ ol.Map.prototype.startAnimating = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.stopAnimating = function() {
|
ol3.Map.prototype.stopAnimating = function() {
|
||||||
goog.asserts.assert(this.animatingCount_ > 0);
|
goog.asserts.assert(this.animatingCount_ > 0);
|
||||||
if (--this.animatingCount_ === 0) {
|
if (--this.animatingCount_ === 0) {
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
@@ -777,7 +778,7 @@ ol.Map.prototype.stopAnimating = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.unfreezeRendering = function() {
|
ol3.Map.prototype.unfreezeRendering = function() {
|
||||||
goog.asserts.assert(this.freezeRenderingCount_ > 0);
|
goog.asserts.assert(this.freezeRenderingCount_ > 0);
|
||||||
if (--this.freezeRenderingCount_ === 0 &&
|
if (--this.freezeRenderingCount_ === 0 &&
|
||||||
this.animatingCount_ < 1 &&
|
this.animatingCount_ < 1 &&
|
||||||
@@ -792,7 +793,7 @@ ol.Map.prototype.unfreezeRendering = function() {
|
|||||||
* @param {T=} opt_obj Object.
|
* @param {T=} opt_obj Object.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.withFrozenRendering = function(f, opt_obj) {
|
ol3.Map.prototype.withFrozenRendering = function(f, opt_obj) {
|
||||||
this.freezeRendering();
|
this.freezeRendering();
|
||||||
try {
|
try {
|
||||||
f.call(opt_obj);
|
f.call(opt_obj);
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
goog.provide('ol.MapBrowserEvent');
|
goog.provide('ol3.MapBrowserEvent');
|
||||||
|
|
||||||
goog.require('goog.events.BrowserEvent');
|
goog.require('goog.events.BrowserEvent');
|
||||||
goog.require('goog.style');
|
goog.require('goog.style');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.MapEvent');
|
goog.require('ol3.MapEvent');
|
||||||
goog.require('ol.Pixel');
|
goog.require('ol3.Pixel');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.MapEvent}
|
* @extends {ol3.MapEvent}
|
||||||
* @param {string} type Event type.
|
* @param {string} type Event type.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEvent = function(type, map, browserEvent) {
|
ol3.MapBrowserEvent = function(type, map, browserEvent) {
|
||||||
|
|
||||||
goog.base(this, type, map);
|
goog.base(this, type, map);
|
||||||
|
|
||||||
@@ -26,18 +26,18 @@ ol.MapBrowserEvent = function(type, map, browserEvent) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Coordinate|undefined}
|
* @type {ol3.Coordinate|undefined}
|
||||||
*/
|
*/
|
||||||
this.coordinate_ = undefined;
|
this.coordinate_ = undefined;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
|
goog.inherits(ol3.MapBrowserEvent, ol3.MapEvent);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Coordinate|undefined} Coordinate.
|
* @return {ol3.Coordinate|undefined} Coordinate.
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEvent.prototype.getCoordinate = function() {
|
ol3.MapBrowserEvent.prototype.getCoordinate = function() {
|
||||||
if (goog.isDef(this.coordinate_)) {
|
if (goog.isDef(this.coordinate_)) {
|
||||||
return this.coordinate_;
|
return this.coordinate_;
|
||||||
} else {
|
} else {
|
||||||
@@ -45,7 +45,7 @@ ol.MapBrowserEvent.prototype.getCoordinate = function() {
|
|||||||
var browserEvent = this.browserEvent;
|
var browserEvent = this.browserEvent;
|
||||||
var eventPosition = goog.style.getRelativePosition(
|
var eventPosition = goog.style.getRelativePosition(
|
||||||
browserEvent, map.getViewport());
|
browserEvent, map.getViewport());
|
||||||
var pixel = new ol.Pixel(eventPosition.x, eventPosition.y);
|
var pixel = new ol3.Pixel(eventPosition.x, eventPosition.y);
|
||||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||||
this.coordinate_ = coordinate;
|
this.coordinate_ = coordinate;
|
||||||
return coordinate;
|
return coordinate;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.MapEvent');
|
goog.provide('ol3.MapEvent');
|
||||||
|
|
||||||
goog.require('goog.events.Event');
|
goog.require('goog.events.Event');
|
||||||
|
|
||||||
@@ -8,14 +8,14 @@ goog.require('goog.events.Event');
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @extends {goog.events.Event}
|
* @extends {goog.events.Event}
|
||||||
* @param {string} type Event type.
|
* @param {string} type Event type.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
*/
|
*/
|
||||||
ol.MapEvent = function(type, map) {
|
ol3.MapEvent = function(type, map) {
|
||||||
|
|
||||||
goog.base(this, type);
|
goog.base(this, type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Map}
|
* @type {ol3.Map}
|
||||||
*/
|
*/
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
@@ -25,12 +25,12 @@ ol.MapEvent = function(type, map) {
|
|||||||
this.defaultPrevented = false;
|
this.defaultPrevented = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.MapEvent, goog.events.Event);
|
goog.inherits(ol3.MapEvent, goog.events.Event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.MapEvent.prototype.preventDefault = function() {
|
ol3.MapEvent.prototype.preventDefault = function() {
|
||||||
goog.base(this, 'preventDefault');
|
goog.base(this, 'preventDefault');
|
||||||
this.defaultPrevented = true;
|
this.defaultPrevented = true;
|
||||||
};
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
goog.provide('ol.MapRenderer');
|
goog.provide('ol3.MapRenderer');
|
||||||
|
|
||||||
goog.require('goog.Disposable');
|
goog.require('goog.Disposable');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.fx.anim');
|
goog.require('goog.fx.anim');
|
||||||
goog.require('goog.fx.anim.Animated');
|
goog.require('goog.fx.anim.Animated');
|
||||||
goog.require('goog.vec.Mat4');
|
goog.require('goog.vec.Mat4');
|
||||||
goog.require('ol.Map');
|
goog.require('ol3.Map');
|
||||||
goog.require('ol.MapProperty');
|
goog.require('ol3.MapProperty');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ goog.require('ol.MapProperty');
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @extends {goog.Disposable}
|
* @extends {goog.Disposable}
|
||||||
* @param {Element} container Container.
|
* @param {Element} container Container.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer = function(container, map) {
|
ol3.MapRenderer = function(container, map) {
|
||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ ol.MapRenderer = function(container, map) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {ol.Map}
|
* @type {ol3.Map}
|
||||||
*/
|
*/
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {Object.<number, ol.LayerRenderer>}
|
* @type {Object.<number, ol3.LayerRenderer>}
|
||||||
*/
|
*/
|
||||||
this.layerRenderers = {};
|
this.layerRenderers = {};
|
||||||
|
|
||||||
@@ -68,39 +68,39 @@ ol.MapRenderer = function(container, map) {
|
|||||||
*/
|
*/
|
||||||
this.mapListenerKeys_ = [
|
this.mapListenerKeys_ = [
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.BACKGROUND_COLOR),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.BACKGROUND_COLOR),
|
||||||
this.handleBackgroundColorChanged, false, this),
|
this.handleBackgroundColorChanged, false, this),
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.CENTER),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.CENTER),
|
||||||
this.handleCenterChanged, false, this),
|
this.handleCenterChanged, false, this),
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.LAYERS),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.LAYERS),
|
||||||
this.handleLayersChanged, false, this),
|
this.handleLayersChanged, false, this),
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.RESOLUTION),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.RESOLUTION),
|
||||||
this.handleResolutionChanged, false, this),
|
this.handleResolutionChanged, false, this),
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.ROTATION),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.ROTATION),
|
||||||
this.handleRotationChanged, false, this),
|
this.handleRotationChanged, false, this),
|
||||||
|
|
||||||
goog.events.listen(
|
goog.events.listen(
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.SIZE),
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.SIZE),
|
||||||
this.handleSizeChanged, false, this)
|
this.handleSizeChanged, false, this)
|
||||||
];
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.MapRenderer, goog.Disposable);
|
goog.inherits(ol3.MapRenderer, goog.Disposable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.addLayer = function(layer) {
|
ol3.MapRenderer.prototype.addLayer = function(layer) {
|
||||||
var layerRenderer = this.createLayerRenderer(layer);
|
var layerRenderer = this.createLayerRenderer(layer);
|
||||||
this.setLayerRenderer(layer, layerRenderer);
|
this.setLayerRenderer(layer, layerRenderer);
|
||||||
};
|
};
|
||||||
@@ -109,21 +109,21 @@ ol.MapRenderer.prototype.addLayer = function(layer) {
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Can rotate.
|
* @return {boolean} Can rotate.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.canRotate = goog.functions.FALSE;
|
ol3.MapRenderer.prototype.canRotate = goog.functions.FALSE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
* @return {ol.LayerRenderer} layerRenderer Layer renderer.
|
* @return {ol3.LayerRenderer} layerRenderer Layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.createLayerRenderer = goog.abstractMethod;
|
ol3.MapRenderer.prototype.createLayerRenderer = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.disposeInternal = function() {
|
ol3.MapRenderer.prototype.disposeInternal = function() {
|
||||||
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
||||||
goog.dispose(layerRenderer);
|
goog.dispose(layerRenderer);
|
||||||
});
|
});
|
||||||
@@ -136,11 +136,11 @@ ol.MapRenderer.prototype.disposeInternal = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {function(this: T, ol.Layer, ol.LayerRenderer, number)} f Function.
|
* @param {function(this: T, ol3.Layer, ol3.LayerRenderer, number)} f Function.
|
||||||
* @param {T=} opt_obj Object.
|
* @param {T=} opt_obj Object.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.forEachReadyVisibleLayer = function(f, opt_obj) {
|
ol3.MapRenderer.prototype.forEachReadyVisibleLayer = function(f, opt_obj) {
|
||||||
var layers = this.map.getLayers();
|
var layers = this.map.getLayers();
|
||||||
layers.forEach(function(layer, index) {
|
layers.forEach(function(layer, index) {
|
||||||
if (layer.isReady() && layer.getVisible()) {
|
if (layer.isReady() && layer.getVisible()) {
|
||||||
@@ -152,23 +152,23 @@ ol.MapRenderer.prototype.forEachReadyVisibleLayer = function(f, opt_obj) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Pixel} pixel Pixel.
|
* @param {ol3.Pixel} pixel Pixel.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol3.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.getCoordinateFromPixel = function(pixel) {
|
ol3.MapRenderer.prototype.getCoordinateFromPixel = function(pixel) {
|
||||||
this.updateMatrices_();
|
this.updateMatrices_();
|
||||||
var vec3 = [pixel.x, pixel.y, 0];
|
var vec3 = [pixel.x, pixel.y, 0];
|
||||||
goog.vec.Mat4.multVec3(this.pixelToCoordinateMatrix_, vec3, vec3);
|
goog.vec.Mat4.multVec3(this.pixelToCoordinateMatrix_, vec3, vec3);
|
||||||
return new ol.Coordinate(vec3[0], vec3[1]);
|
return new ol3.Coordinate(vec3[0], vec3[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
* @return {ol.LayerRenderer} Layer renderer.
|
* @return {ol3.LayerRenderer} Layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.getLayerRenderer = function(layer) {
|
ol3.MapRenderer.prototype.getLayerRenderer = function(layer) {
|
||||||
var key = goog.getUid(layer);
|
var key = goog.getUid(layer);
|
||||||
var layerRenderer = this.layerRenderers[key];
|
var layerRenderer = this.layerRenderers[key];
|
||||||
goog.asserts.assert(goog.isDef(layerRenderer));
|
goog.asserts.assert(goog.isDef(layerRenderer));
|
||||||
@@ -177,44 +177,44 @@ ol.MapRenderer.prototype.getLayerRenderer = function(layer) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Map} Map.
|
* @return {ol3.Map} Map.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.getMap = function() {
|
ol3.MapRenderer.prototype.getMap = function() {
|
||||||
return this.map;
|
return this.map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol3.Coordinate} coordinate Coordinate.
|
||||||
* @return {ol.Pixel} Pixel.
|
* @return {ol3.Pixel} Pixel.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.getPixelFromCoordinate = function(coordinate) {
|
ol3.MapRenderer.prototype.getPixelFromCoordinate = function(coordinate) {
|
||||||
this.updateMatrices_();
|
this.updateMatrices_();
|
||||||
var vec3 = [coordinate.x, coordinate.y, 0];
|
var vec3 = [coordinate.x, coordinate.y, 0];
|
||||||
goog.vec.Mat4.multVec3(this.coordinateToPixelMatrix_, vec3, vec3);
|
goog.vec.Mat4.multVec3(this.coordinateToPixelMatrix_, vec3, vec3);
|
||||||
return new ol.Pixel(vec3[0], vec3[1]);
|
return new ol3.Pixel(vec3[0], vec3[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleBackgroundColorChanged = goog.nullFunction;
|
ol3.MapRenderer.prototype.handleBackgroundColorChanged = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleCenterChanged = function() {
|
ol3.MapRenderer.prototype.handleCenterChanged = function() {
|
||||||
this.matricesDirty_ = true;
|
this.matricesDirty_ = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol3.CollectionEvent} collectionEvent Collection event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleLayersAdd = function(collectionEvent) {
|
ol3.MapRenderer.prototype.handleLayersAdd = function(collectionEvent) {
|
||||||
var layer = /** @type {ol.Layer} */ collectionEvent.elem;
|
var layer = /** @type {ol3.Layer} */ collectionEvent.elem;
|
||||||
this.addLayer(layer);
|
this.addLayer(layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ ol.MapRenderer.prototype.handleLayersAdd = function(collectionEvent) {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleLayersChanged = function() {
|
ol3.MapRenderer.prototype.handleLayersChanged = function() {
|
||||||
var layerRenderers = goog.object.getValues(this.layerRenderers);
|
var layerRenderers = goog.object.getValues(this.layerRenderers);
|
||||||
goog.array.forEach(layerRenderers, function(layerRenderer) {
|
goog.array.forEach(layerRenderers, function(layerRenderer) {
|
||||||
this.removeLayerRenderer(layerRenderer);
|
this.removeLayerRenderer(layerRenderer);
|
||||||
@@ -236,9 +236,9 @@ ol.MapRenderer.prototype.handleLayersChanged = function() {
|
|||||||
if (goog.isDefAndNotNull(layers)) {
|
if (goog.isDefAndNotNull(layers)) {
|
||||||
layers.forEach(this.addLayer, this);
|
layers.forEach(this.addLayer, this);
|
||||||
this.layersListenerKeys_ = [
|
this.layersListenerKeys_ = [
|
||||||
goog.events.listen(layers, ol.CollectionEventType.ADD,
|
goog.events.listen(layers, ol3.CollectionEventType.ADD,
|
||||||
this.handleLayersAdd, false, this),
|
this.handleLayersAdd, false, this),
|
||||||
goog.events.listen(layers, ol.CollectionEventType.REMOVE,
|
goog.events.listen(layers, ol3.CollectionEventType.REMOVE,
|
||||||
this.handleLayersRemove, false, this)
|
this.handleLayersRemove, false, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -246,11 +246,11 @@ ol.MapRenderer.prototype.handleLayersChanged = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol3.CollectionEvent} collectionEvent Collection event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleLayersRemove = function(collectionEvent) {
|
ol3.MapRenderer.prototype.handleLayersRemove = function(collectionEvent) {
|
||||||
var layer = /** @type {ol.Layer} */ collectionEvent.elem;
|
var layer = /** @type {ol3.Layer} */ collectionEvent.elem;
|
||||||
this.removeLayer(layer);
|
this.removeLayer(layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ ol.MapRenderer.prototype.handleLayersRemove = function(collectionEvent) {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleResolutionChanged = function() {
|
ol3.MapRenderer.prototype.handleResolutionChanged = function() {
|
||||||
this.matricesDirty_ = true;
|
this.matricesDirty_ = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ ol.MapRenderer.prototype.handleResolutionChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleRotationChanged = function() {
|
ol3.MapRenderer.prototype.handleRotationChanged = function() {
|
||||||
this.matricesDirty_ = true;
|
this.matricesDirty_ = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -274,26 +274,26 @@ ol.MapRenderer.prototype.handleRotationChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.handleSizeChanged = function() {
|
ol3.MapRenderer.prototype.handleSizeChanged = function() {
|
||||||
this.matricesDirty_ = true;
|
this.matricesDirty_ = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.removeLayer = function(layer) {
|
ol3.MapRenderer.prototype.removeLayer = function(layer) {
|
||||||
goog.dispose(this.removeLayerRenderer(layer));
|
goog.dispose(this.removeLayerRenderer(layer));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @return {ol.LayerRenderer} Layer renderer.
|
* @return {ol3.LayerRenderer} Layer renderer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.removeLayerRenderer = function(layer) {
|
ol3.MapRenderer.prototype.removeLayerRenderer = function(layer) {
|
||||||
var key = goog.getUid(layer);
|
var key = goog.getUid(layer);
|
||||||
if (key in this.layerRenderers) {
|
if (key in this.layerRenderers) {
|
||||||
var layerRenderer = this.layerRenderers[key];
|
var layerRenderer = this.layerRenderers[key];
|
||||||
@@ -308,7 +308,7 @@ ol.MapRenderer.prototype.removeLayerRenderer = function(layer) {
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Animating.
|
* @return {boolean} Animating.
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.render = function() {
|
ol3.MapRenderer.prototype.render = function() {
|
||||||
var animate = false;
|
var animate = false;
|
||||||
this.forEachReadyVisibleLayer(function(layer, layerRenderer) {
|
this.forEachReadyVisibleLayer(function(layer, layerRenderer) {
|
||||||
if (layerRenderer.render()) {
|
if (layerRenderer.render()) {
|
||||||
@@ -320,11 +320,11 @@ ol.MapRenderer.prototype.render = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @param {ol.LayerRenderer} layerRenderer Layer renderer.
|
* @param {ol3.LayerRenderer} layerRenderer Layer renderer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.setLayerRenderer = function(layer, layerRenderer) {
|
ol3.MapRenderer.prototype.setLayerRenderer = function(layer, layerRenderer) {
|
||||||
var key = goog.getUid(layer);
|
var key = goog.getUid(layer);
|
||||||
goog.asserts.assert(!(key in this.layerRenderers));
|
goog.asserts.assert(!(key in this.layerRenderers));
|
||||||
this.layerRenderers[key] = layerRenderer;
|
this.layerRenderers[key] = layerRenderer;
|
||||||
@@ -334,15 +334,15 @@ ol.MapRenderer.prototype.setLayerRenderer = function(layer, layerRenderer) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapRenderer.prototype.updateMatrices_ = function() {
|
ol3.MapRenderer.prototype.updateMatrices_ = function() {
|
||||||
|
|
||||||
if (this.matricesDirty_) {
|
if (this.matricesDirty_) {
|
||||||
|
|
||||||
var map = this.map;
|
var map = this.map;
|
||||||
var center = /** @type {!ol.Coordinate} */ map.getCenter();
|
var center = /** @type {!ol3.Coordinate} */ map.getCenter();
|
||||||
var resolution = /** @type {number} */ map.getResolution();
|
var resolution = /** @type {number} */ map.getResolution();
|
||||||
var rotation = map.getRotation();
|
var rotation = map.getRotation();
|
||||||
var size = /** @type {!ol.Size} */ map.getSize();
|
var size = /** @type {!ol3.Size} */ map.getSize();
|
||||||
|
|
||||||
goog.vec.Mat4.makeIdentity(this.coordinateToPixelMatrix_);
|
goog.vec.Mat4.makeIdentity(this.coordinateToPixelMatrix_);
|
||||||
goog.vec.Mat4.translate(this.coordinateToPixelMatrix_,
|
goog.vec.Mat4.translate(this.coordinateToPixelMatrix_,
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* @see https://developers.google.com/maps/documentation/javascript/reference
|
* @see https://developers.google.com/maps/documentation/javascript/reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
goog.provide('ol.Object');
|
goog.provide('ol3.Object');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
@@ -16,7 +16,7 @@ goog.require('goog.object');
|
|||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.ObjectProperty = {
|
ol3.ObjectProperty = {
|
||||||
ACCESSORS: 'ol_accessors_',
|
ACCESSORS: 'ol_accessors_',
|
||||||
BINDINGS: 'ol_bindings_'
|
BINDINGS: 'ol_bindings_'
|
||||||
};
|
};
|
||||||
@@ -28,52 +28,52 @@ ol.ObjectProperty = {
|
|||||||
* @extends {goog.events.EventTarget}
|
* @extends {goog.events.EventTarget}
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
*/
|
*/
|
||||||
ol.Object = function(opt_values) {
|
ol3.Object = function(opt_values) {
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
if (goog.isDef(opt_values)) {
|
if (goog.isDef(opt_values)) {
|
||||||
this.setValues(opt_values);
|
this.setValues(opt_values);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Object, goog.events.EventTarget);
|
goog.inherits(ol3.Object, goog.events.EventTarget);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string, string>}
|
* @type {Object.<string, string>}
|
||||||
*/
|
*/
|
||||||
ol.Object.changedEventTypeCache_ = {};
|
ol3.Object.changedEventTypeCache_ = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string, string>}
|
* @type {Object.<string, string>}
|
||||||
*/
|
*/
|
||||||
ol.Object.getterNameCache_ = {};
|
ol3.Object.getterNameCache_ = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string, string>}
|
* @type {Object.<string, string>}
|
||||||
*/
|
*/
|
||||||
ol.Object.setterNameCache_ = {};
|
ol3.Object.setterNameCache_ = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} str String.
|
* @param {string} str String.
|
||||||
* @return {string} Capitalized string.
|
* @return {string} Capitalized string.
|
||||||
*/
|
*/
|
||||||
ol.Object.capitalize = function(str) {
|
ol3.Object.capitalize = function(str) {
|
||||||
return str.substr(0, 1).toUpperCase() + str.substr(1);
|
return str.substr(0, 1).toUpperCase() + str.substr(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Object} obj Object.
|
* @param {ol3.Object} obj Object.
|
||||||
* @return {Object.<string, {target: ol.Object, key: string}>} Accessors.
|
* @return {Object.<string, {target: ol3.Object, key: string}>} Accessors.
|
||||||
*/
|
*/
|
||||||
ol.Object.getAccessors = function(obj) {
|
ol3.Object.getAccessors = function(obj) {
|
||||||
return obj[ol.ObjectProperty.ACCESSORS] ||
|
return obj[ol3.ObjectProperty.ACCESSORS] ||
|
||||||
(obj[ol.ObjectProperty.ACCESSORS] = {});
|
(obj[ol3.ObjectProperty.ACCESSORS] = {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ ol.Object.getAccessors = function(obj) {
|
|||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @return {string} Changed name.
|
* @return {string} Changed name.
|
||||||
*/
|
*/
|
||||||
ol.Object.getChangedEventType = function(key) {
|
ol3.Object.getChangedEventType = function(key) {
|
||||||
return ol.Object.changedEventTypeCache_[key] ||
|
return ol3.Object.changedEventTypeCache_[key] ||
|
||||||
(ol.Object.changedEventTypeCache_[key] = key.toLowerCase() + '_changed');
|
(ol3.Object.changedEventTypeCache_[key] = key.toLowerCase() + '_changed');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -91,19 +91,19 @@ ol.Object.getChangedEventType = function(key) {
|
|||||||
* @param {string} key String.
|
* @param {string} key String.
|
||||||
* @return {string} Getter name.
|
* @return {string} Getter name.
|
||||||
*/
|
*/
|
||||||
ol.Object.getGetterName = function(key) {
|
ol3.Object.getGetterName = function(key) {
|
||||||
return ol.Object.getterNameCache_[key] ||
|
return ol3.Object.getterNameCache_[key] ||
|
||||||
(ol.Object.getterNameCache_[key] = 'get' + ol.Object.capitalize(key));
|
(ol3.Object.getterNameCache_[key] = 'get' + ol3.Object.capitalize(key));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Object} obj Object.
|
* @param {ol3.Object} obj Object.
|
||||||
* @return {Object.<string, ?number>} Listeners.
|
* @return {Object.<string, ?number>} Listeners.
|
||||||
*/
|
*/
|
||||||
ol.Object.getListeners = function(obj) {
|
ol3.Object.getListeners = function(obj) {
|
||||||
return obj[ol.ObjectProperty.BINDINGS] ||
|
return obj[ol3.ObjectProperty.BINDINGS] ||
|
||||||
(obj[ol.ObjectProperty.BINDINGS] = {});
|
(obj[ol3.ObjectProperty.BINDINGS] = {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -111,28 +111,28 @@ ol.Object.getListeners = function(obj) {
|
|||||||
* @param {string} key String.
|
* @param {string} key String.
|
||||||
* @return {string} Setter name.
|
* @return {string} Setter name.
|
||||||
*/
|
*/
|
||||||
ol.Object.getSetterName = function(key) {
|
ol3.Object.getSetterName = function(key) {
|
||||||
return ol.Object.setterNameCache_[key] ||
|
return ol3.Object.setterNameCache_[key] ||
|
||||||
(ol.Object.setterNameCache_[key] = 'set' + ol.Object.capitalize(key));
|
(ol3.Object.setterNameCache_[key] = 'set' + ol3.Object.capitalize(key));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @param {ol.Object} target Target.
|
* @param {ol3.Object} target Target.
|
||||||
* @param {string=} opt_targetKey Target key.
|
* @param {string=} opt_targetKey Target key.
|
||||||
* @param {boolean=} opt_noNotify No notify.
|
* @param {boolean=} opt_noNotify No notify.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.bindTo =
|
ol3.Object.prototype.bindTo =
|
||||||
function(key, target, opt_targetKey, opt_noNotify) {
|
function(key, target, opt_targetKey, opt_noNotify) {
|
||||||
var targetKey = opt_targetKey || key;
|
var targetKey = opt_targetKey || key;
|
||||||
this.unbind(key);
|
this.unbind(key);
|
||||||
var eventType = ol.Object.getChangedEventType(targetKey);
|
var eventType = ol3.Object.getChangedEventType(targetKey);
|
||||||
var listeners = ol.Object.getListeners(this);
|
var listeners = ol3.Object.getListeners(this);
|
||||||
listeners[key] = goog.events.listen(target, eventType, function() {
|
listeners[key] = goog.events.listen(target, eventType, function() {
|
||||||
this.notifyInternal_(key);
|
this.notifyInternal_(key);
|
||||||
}, undefined, this);
|
}, undefined, this);
|
||||||
var accessors = ol.Object.getAccessors(this);
|
var accessors = ol3.Object.getAccessors(this);
|
||||||
accessors[key] = {target: target, key: targetKey};
|
accessors[key] = {target: target, key: targetKey};
|
||||||
var noNotify = opt_noNotify || false;
|
var noNotify = opt_noNotify || false;
|
||||||
if (!noNotify) {
|
if (!noNotify) {
|
||||||
@@ -144,20 +144,20 @@ ol.Object.prototype.bindTo =
|
|||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.changed = goog.nullFunction;
|
ol3.Object.prototype.changed = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @return {*} Value.
|
* @return {*} Value.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.get = function(key) {
|
ol3.Object.prototype.get = function(key) {
|
||||||
var accessors = ol.Object.getAccessors(this);
|
var accessors = ol3.Object.getAccessors(this);
|
||||||
if (goog.object.containsKey(accessors, key)) {
|
if (goog.object.containsKey(accessors, key)) {
|
||||||
var accessor = accessors[key];
|
var accessor = accessors[key];
|
||||||
var target = accessor.target;
|
var target = accessor.target;
|
||||||
var targetKey = accessor.key;
|
var targetKey = accessor.key;
|
||||||
var getterName = ol.Object.getGetterName(targetKey);
|
var getterName = ol3.Object.getGetterName(targetKey);
|
||||||
if (target[getterName]) {
|
if (target[getterName]) {
|
||||||
return target[getterName]();
|
return target[getterName]();
|
||||||
} else {
|
} else {
|
||||||
@@ -172,8 +172,8 @@ ol.Object.prototype.get = function(key) {
|
|||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.notify = function(key) {
|
ol3.Object.prototype.notify = function(key) {
|
||||||
var accessors = ol.Object.getAccessors(this);
|
var accessors = ol3.Object.getAccessors(this);
|
||||||
if (goog.object.containsKey(accessors, key)) {
|
if (goog.object.containsKey(accessors, key)) {
|
||||||
var accessor = accessors[key];
|
var accessor = accessors[key];
|
||||||
var target = accessor.target;
|
var target = accessor.target;
|
||||||
@@ -189,8 +189,8 @@ ol.Object.prototype.notify = function(key) {
|
|||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.notifyInternal_ = function(key) {
|
ol3.Object.prototype.notifyInternal_ = function(key) {
|
||||||
var eventType = ol.Object.getChangedEventType(key);
|
var eventType = ol3.Object.getChangedEventType(key);
|
||||||
this.dispatchEvent(eventType);
|
this.dispatchEvent(eventType);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -199,13 +199,13 @@ ol.Object.prototype.notifyInternal_ = function(key) {
|
|||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @param {*} value Value.
|
* @param {*} value Value.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.set = function(key, value) {
|
ol3.Object.prototype.set = function(key, value) {
|
||||||
var accessors = ol.Object.getAccessors(this);
|
var accessors = ol3.Object.getAccessors(this);
|
||||||
if (goog.object.containsKey(accessors, key)) {
|
if (goog.object.containsKey(accessors, key)) {
|
||||||
var accessor = accessors[key];
|
var accessor = accessors[key];
|
||||||
var target = accessor.target;
|
var target = accessor.target;
|
||||||
var targetKey = accessor.key;
|
var targetKey = accessor.key;
|
||||||
var setterName = ol.Object.getSetterName(targetKey);
|
var setterName = ol3.Object.getSetterName(targetKey);
|
||||||
if (target[setterName]) {
|
if (target[setterName]) {
|
||||||
target[setterName](value);
|
target[setterName](value);
|
||||||
} else {
|
} else {
|
||||||
@@ -221,9 +221,9 @@ ol.Object.prototype.set = function(key, value) {
|
|||||||
/**
|
/**
|
||||||
* @param {Object.<string, *>} options Options.
|
* @param {Object.<string, *>} options Options.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.setOptions = function(options) {
|
ol3.Object.prototype.setOptions = function(options) {
|
||||||
goog.object.forEach(options, function(value, key) {
|
goog.object.forEach(options, function(value, key) {
|
||||||
var setterName = ol.Object.getSetterName(key);
|
var setterName = ol3.Object.getSetterName(key);
|
||||||
if (this[setterName]) {
|
if (this[setterName]) {
|
||||||
this[setterName](value);
|
this[setterName](value);
|
||||||
} else {
|
} else {
|
||||||
@@ -236,20 +236,20 @@ ol.Object.prototype.setOptions = function(options) {
|
|||||||
/**
|
/**
|
||||||
* @param {Object.<string, *>} values Values.
|
* @param {Object.<string, *>} values Values.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.setValues = ol.Object.prototype.setOptions;
|
ol3.Object.prototype.setValues = ol3.Object.prototype.setOptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.unbind = function(key) {
|
ol3.Object.prototype.unbind = function(key) {
|
||||||
var listeners = ol.Object.getListeners(this);
|
var listeners = ol3.Object.getListeners(this);
|
||||||
var listener = listeners[key];
|
var listener = listeners[key];
|
||||||
if (listener) {
|
if (listener) {
|
||||||
delete listeners[key];
|
delete listeners[key];
|
||||||
goog.events.unlistenByKey(listener);
|
goog.events.unlistenByKey(listener);
|
||||||
var value = this.get(key);
|
var value = this.get(key);
|
||||||
var accessors = ol.Object.getAccessors(this);
|
var accessors = ol3.Object.getAccessors(this);
|
||||||
delete accessors[key];
|
delete accessors[key];
|
||||||
this[key] = value;
|
this[key] = value;
|
||||||
}
|
}
|
||||||
@@ -258,8 +258,8 @@ ol.Object.prototype.unbind = function(key) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Object.prototype.unbindAll = function() {
|
ol3.Object.prototype.unbindAll = function() {
|
||||||
var listeners = ol.Object.getListeners(this);
|
var listeners = ol3.Object.getListeners(this);
|
||||||
var keys = goog.object.getKeys(listeners);
|
var keys = goog.object.getKeys(listeners);
|
||||||
goog.array.forEach(keys, function(key) {
|
goog.array.forEach(keys, function(key) {
|
||||||
this.unbind(key);
|
this.unbind(key);
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Object');
|
goog.require('ol3.Object');
|
||||||
|
|
||||||
|
|
||||||
function testModel() {
|
function testModel() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
assertNotNullNorUndefined(m);
|
assertNotNullNorUndefined(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testGetUndefined() {
|
function testGetUndefined() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
assertUndefined(m.get('k'));
|
assertUndefined(m.get('k'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testGetSetGet() {
|
function testGetSetGet() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
assertUndefined(m.get('k'));
|
assertUndefined(m.get('k'));
|
||||||
m.set('k', 1);
|
m.set('k', 1);
|
||||||
assertEquals(1, m.get('k'));
|
assertEquals(1, m.get('k'));
|
||||||
@@ -23,7 +23,7 @@ function testGetSetGet() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetValues() {
|
function testSetValues() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
m.setValues({
|
m.setValues({
|
||||||
k1: 1,
|
k1: 1,
|
||||||
k2: 2
|
k2: 2
|
||||||
@@ -34,7 +34,7 @@ function testSetValues() {
|
|||||||
|
|
||||||
|
|
||||||
function testNotifyKeyEvent() {
|
function testNotifyKeyEvent() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var eventDispatched = false;
|
var eventDispatched = false;
|
||||||
goog.events.listen(m, 'k_changed', function() {
|
goog.events.listen(m, 'k_changed', function() {
|
||||||
eventDispatched = true;
|
eventDispatched = true;
|
||||||
@@ -45,8 +45,8 @@ function testNotifyKeyEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindSetNotifyKeyEvent() {
|
function testBindSetNotifyKeyEvent() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
var callbackCalled = false;
|
var callbackCalled = false;
|
||||||
goog.events.listen(n, 'k_changed', function() {
|
goog.events.listen(n, 'k_changed', function() {
|
||||||
eventDispatched = true;
|
eventDispatched = true;
|
||||||
@@ -58,7 +58,7 @@ function testBindSetNotifyKeyEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetNotifyKeyEvent() {
|
function testSetNotifyKeyEvent() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var eventDispatched = false;
|
var eventDispatched = false;
|
||||||
goog.events.listen(m, 'k_changed', function() {
|
goog.events.listen(m, 'k_changed', function() {
|
||||||
eventDispatched = true;
|
eventDispatched = true;
|
||||||
@@ -69,8 +69,8 @@ function testSetNotifyKeyEvent() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetBind() {
|
function testSetBind() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
m.set('k', 1);
|
m.set('k', 1);
|
||||||
assertEquals(1, m.get('k'));
|
assertEquals(1, m.get('k'));
|
||||||
assertUndefined(n.get('k'));
|
assertUndefined(n.get('k'));
|
||||||
@@ -81,8 +81,8 @@ function testSetBind() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindSet() {
|
function testBindSet() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
m.set('k', 1);
|
m.set('k', 1);
|
||||||
assertEquals(1, m.get('k'));
|
assertEquals(1, m.get('k'));
|
||||||
@@ -91,8 +91,8 @@ function testBindSet() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindSetBackwards() {
|
function testBindSetBackwards() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
n.set('k', 1);
|
n.set('k', 1);
|
||||||
assertEquals(1, m.get('k'));
|
assertEquals(1, m.get('k'));
|
||||||
@@ -101,8 +101,8 @@ function testBindSetBackwards() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetBindBackwards() {
|
function testSetBindBackwards() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.set('k', 1);
|
n.set('k', 1);
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
assertUndefined(m.get('k'));
|
assertUndefined(m.get('k'));
|
||||||
@@ -111,8 +111,8 @@ function testSetBindBackwards() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindSetUnbind() {
|
function testBindSetUnbind() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
n.set('k', 1);
|
n.set('k', 1);
|
||||||
assertEquals(1, m.get('k'));
|
assertEquals(1, m.get('k'));
|
||||||
@@ -127,8 +127,8 @@ function testBindSetUnbind() {
|
|||||||
|
|
||||||
|
|
||||||
function testUnbindAll() {
|
function testUnbindAll() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
n.set('k', 1);
|
n.set('k', 1);
|
||||||
assertEquals(m.get('k'), 1);
|
assertEquals(m.get('k'), 1);
|
||||||
@@ -143,8 +143,8 @@ function testUnbindAll() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindNotify() {
|
function testBindNotify() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
m.bindTo('k', n);
|
m.bindTo('k', n);
|
||||||
mEventDispatched = false;
|
mEventDispatched = false;
|
||||||
goog.events.listen(m, 'k_changed', function() {
|
goog.events.listen(m, 'k_changed', function() {
|
||||||
@@ -161,8 +161,8 @@ function testBindNotify() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindBackwardsNotify() {
|
function testBindBackwardsNotify() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('k', m);
|
n.bindTo('k', m);
|
||||||
mEventDispatched = false;
|
mEventDispatched = false;
|
||||||
goog.events.listen(m, 'k_changed', function() {
|
goog.events.listen(m, 'k_changed', function() {
|
||||||
@@ -179,8 +179,8 @@ function testBindBackwardsNotify() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindRename() {
|
function testBindRename() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
n.bindTo('kn', m, 'km');
|
n.bindTo('kn', m, 'km');
|
||||||
m.set('km', 1);
|
m.set('km', 1);
|
||||||
assertEquals(m.get('km'), 1);
|
assertEquals(m.get('km'), 1);
|
||||||
@@ -189,8 +189,8 @@ function testBindRename() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindRenameEvents() {
|
function testBindRenameEvents() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
kmEventDispatched = false;
|
kmEventDispatched = false;
|
||||||
goog.events.listen(m, 'km_changed', function() {
|
goog.events.listen(m, 'km_changed', function() {
|
||||||
kmEventDispatched = true;
|
kmEventDispatched = true;
|
||||||
@@ -209,9 +209,9 @@ function testBindRenameEvents() {
|
|||||||
|
|
||||||
|
|
||||||
function testTransitiveBindForwards() {
|
function testTransitiveBindForwards() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
var o = new ol.Object();
|
var o = new ol3.Object();
|
||||||
n.bindTo('kn', m, 'km');
|
n.bindTo('kn', m, 'km');
|
||||||
o.bindTo('ko', n, 'kn');
|
o.bindTo('ko', n, 'kn');
|
||||||
m.set('km', 1);
|
m.set('km', 1);
|
||||||
@@ -222,9 +222,9 @@ function testTransitiveBindForwards() {
|
|||||||
|
|
||||||
|
|
||||||
function testTransitiveBindBackwards() {
|
function testTransitiveBindBackwards() {
|
||||||
var m = new ol.Object();
|
var m = new ol3.Object();
|
||||||
var n = new ol.Object();
|
var n = new ol3.Object();
|
||||||
var o = new ol.Object();
|
var o = new ol3.Object();
|
||||||
n.bindTo('kn', m, 'km');
|
n.bindTo('kn', m, 'km');
|
||||||
o.bindTo('ko', n, 'kn');
|
o.bindTo('ko', n, 'kn');
|
||||||
o.set('ko', 1);
|
o.set('ko', 1);
|
||||||
@@ -236,10 +236,10 @@ function testTransitiveBindBackwards() {
|
|||||||
|
|
||||||
function testMrideyAccessors() {
|
function testMrideyAccessors() {
|
||||||
// http://blog.mridey.com/2010/03/maps-javascript-api-v3-more-about.html
|
// http://blog.mridey.com/2010/03/maps-javascript-api-v3-more-about.html
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
a.set('level', 2);
|
a.set('level', 2);
|
||||||
assertEquals(2, a.get('level'));
|
assertEquals(2, a.get('level'));
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
b.setValues({
|
b.setValues({
|
||||||
level: 2,
|
level: 2,
|
||||||
index: 3,
|
index: 3,
|
||||||
@@ -251,16 +251,16 @@ function testMrideyAccessors() {
|
|||||||
|
|
||||||
function testMrideyBinding() {
|
function testMrideyBinding() {
|
||||||
// http://blog.mridey.com/2010/03/maps-javascript-api-v3-more-about.html
|
// http://blog.mridey.com/2010/03/maps-javascript-api-v3-more-about.html
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
a.set('level', 2);
|
a.set('level', 2);
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
b.bindTo('index', a, 'level');
|
b.bindTo('index', a, 'level');
|
||||||
assertEquals(2, b.get('index'));
|
assertEquals(2, b.get('index'));
|
||||||
a.set('level', 3);
|
a.set('level', 3);
|
||||||
assertEquals(3, b.get('index'));
|
assertEquals(3, b.get('index'));
|
||||||
b.set('index', 4);
|
b.set('index', 4);
|
||||||
assertEquals(4, a.get('level'));
|
assertEquals(4, a.get('level'));
|
||||||
var c = new ol.Object();
|
var c = new ol3.Object();
|
||||||
c.bindTo('zoom', a, 'level');
|
c.bindTo('zoom', a, 'level');
|
||||||
assertEquals(4, c.get('zoom'));
|
assertEquals(4, c.get('zoom'));
|
||||||
b.unbind('index');
|
b.unbind('index');
|
||||||
@@ -272,8 +272,8 @@ function testMrideyBinding() {
|
|||||||
|
|
||||||
|
|
||||||
function testCircularBind() {
|
function testCircularBind() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
a.bindTo('k', b);
|
a.bindTo('k', b);
|
||||||
assertThrows(function() {
|
assertThrows(function() {
|
||||||
b.bindTo('k', a);
|
b.bindTo('k', a);
|
||||||
@@ -282,8 +282,8 @@ function testCircularBind() {
|
|||||||
|
|
||||||
|
|
||||||
function testPriority() {
|
function testPriority() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
a.set('k', 1);
|
a.set('k', 1);
|
||||||
b.set('k', 2);
|
b.set('k', 2);
|
||||||
a.bindTo('k', b);
|
a.bindTo('k', b);
|
||||||
@@ -293,8 +293,8 @@ function testPriority() {
|
|||||||
|
|
||||||
|
|
||||||
function testPriorityUndefined() {
|
function testPriorityUndefined() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
a.set('k', 1);
|
a.set('k', 1);
|
||||||
a.bindTo('k', b);
|
a.bindTo('k', b);
|
||||||
assertUndefined(a.get('k'));
|
assertUndefined(a.get('k'));
|
||||||
@@ -303,7 +303,7 @@ function testPriorityUndefined() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetter() {
|
function testSetter() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var x;
|
var x;
|
||||||
var setterCalled;
|
var setterCalled;
|
||||||
a.setX = function(value) {
|
a.setX = function(value) {
|
||||||
@@ -317,14 +317,14 @@ function testSetter() {
|
|||||||
|
|
||||||
|
|
||||||
function testSetterBind() {
|
function testSetterBind() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var x;
|
var x;
|
||||||
var setterCalled;
|
var setterCalled;
|
||||||
a.setX = function(value) {
|
a.setX = function(value) {
|
||||||
this.x = value;
|
this.x = value;
|
||||||
setterCalled = true;
|
setterCalled = true;
|
||||||
};
|
};
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
b.bindTo('x', a);
|
b.bindTo('x', a);
|
||||||
b.set('x', 1);
|
b.set('x', 1);
|
||||||
assertEquals(1, a.get('x'));
|
assertEquals(1, a.get('x'));
|
||||||
@@ -334,7 +334,7 @@ function testSetterBind() {
|
|||||||
|
|
||||||
|
|
||||||
function testGetter() {
|
function testGetter() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var getterCalled;
|
var getterCalled;
|
||||||
a.getX = function() {
|
a.getX = function() {
|
||||||
getterCalled = true;
|
getterCalled = true;
|
||||||
@@ -346,13 +346,13 @@ function testGetter() {
|
|||||||
|
|
||||||
|
|
||||||
function testGetterBind() {
|
function testGetterBind() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
var getterCalled;
|
var getterCalled;
|
||||||
a.getX = function() {
|
a.getX = function() {
|
||||||
getterCalled = true;
|
getterCalled = true;
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
var b = new ol.Object();
|
var b = new ol3.Object();
|
||||||
b.bindTo('x', a);
|
b.bindTo('x', a);
|
||||||
assertEquals(1, b.get('x'));
|
assertEquals(1, b.get('x'));
|
||||||
assertTrue(getterCalled);
|
assertTrue(getterCalled);
|
||||||
@@ -360,7 +360,7 @@ function testGetterBind() {
|
|||||||
|
|
||||||
|
|
||||||
function testBindSelf() {
|
function testBindSelf() {
|
||||||
var a = new ol.Object();
|
var a = new ol3.Object();
|
||||||
assertThrows(function() {
|
assertThrows(function() {
|
||||||
a.bindTo('k', a);
|
a.bindTo('k', a);
|
||||||
});
|
});
|
||||||
@@ -368,13 +368,13 @@ function testBindSelf() {
|
|||||||
|
|
||||||
|
|
||||||
function testCreateWithOptions() {
|
function testCreateWithOptions() {
|
||||||
var obj = new ol.Object({k: 1});
|
var obj = new ol3.Object({k: 1});
|
||||||
assertEquals(1, obj.get('k'));
|
assertEquals(1, obj.get('k'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testEventTypeCaseSensitivity() {
|
function testEventTypeCaseSensitivity() {
|
||||||
var obj = new ol.Object();
|
var obj = new ol3.Object();
|
||||||
var lowercaseEventDispatched = false;
|
var lowercaseEventDispatched = false;
|
||||||
goog.events.listen(obj, 'k_changed', function() {
|
goog.events.listen(obj, 'k_changed', function() {
|
||||||
lowercaseEventDispatched = true;
|
lowercaseEventDispatched = true;
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
goog.provide('ol');
|
goog.provide('ol3');
|
||||||
|
|
||||||
goog.require('goog.debug.Logger');
|
goog.require('goog.debug.Logger');
|
||||||
|
|
||||||
|
|
||||||
if (goog.DEBUG) {
|
if (goog.DEBUG) {
|
||||||
var logger = goog.debug.Logger.getLogger('ol');
|
var logger = goog.debug.Logger.getLogger('ol3');
|
||||||
logger.setLevel(goog.debug.Logger.Level.FINEST);
|
logger.setLevel(goog.debug.Logger.Level.FINEST);
|
||||||
}
|
}
|
||||||
24
src/ol3/base/pixel.js
Normal file
24
src/ol3/base/pixel.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
goog.provide('ol3.Pixel');
|
||||||
|
|
||||||
|
goog.require('goog.math.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {goog.math.Coordinate}
|
||||||
|
* @param {number} x X.
|
||||||
|
* @param {number} y Y.
|
||||||
|
*/
|
||||||
|
ol3.Pixel = function(x, y) {
|
||||||
|
goog.base(this, x, y);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.Pixel, goog.math.Coordinate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Pixel} Clone.
|
||||||
|
*/
|
||||||
|
ol3.Pixel.prototype.clone = function() {
|
||||||
|
return new ol3.Pixel(this.x, this.y);
|
||||||
|
};
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
goog.provide('ol.PixelBounds');
|
goog.provide('ol3.PixelBounds');
|
||||||
|
|
||||||
goog.require('ol.Rectangle');
|
goog.require('ol3.Rectangle');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Rectangle}
|
* @extends {ol3.Rectangle}
|
||||||
* @param {number} minX Minimum X.
|
* @param {number} minX Minimum X.
|
||||||
* @param {number} minY Minimum Y.
|
* @param {number} minY Minimum Y.
|
||||||
* @param {number} maxX Maximum X.
|
* @param {number} maxX Maximum X.
|
||||||
* @param {number} maxY Maximum Y.
|
* @param {number} maxY Maximum Y.
|
||||||
*/
|
*/
|
||||||
ol.PixelBounds = function(minX, minY, maxX, maxY) {
|
ol3.PixelBounds = function(minX, minY, maxX, maxY) {
|
||||||
goog.base(this, minX, minY, maxX, maxY);
|
goog.base(this, minX, minY, maxX, maxY);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.PixelBounds, ol.Rectangle);
|
goog.inherits(ol3.PixelBounds, ol3.Rectangle);
|
||||||
500
src/ol3/base/projection.js
Normal file
500
src/ol3/base/projection.js
Normal file
@@ -0,0 +1,500 @@
|
|||||||
|
goog.provide('ol3.Projection');
|
||||||
|
|
||||||
|
goog.require('goog.array');
|
||||||
|
goog.require('goog.asserts');
|
||||||
|
goog.require('goog.object');
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.Extent');
|
||||||
|
goog.require('ol3.TransformFunction');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean} Enable Proj4js.
|
||||||
|
*/
|
||||||
|
ol3.ENABLE_PROJ4JS = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol3.ProjectionUnits = {
|
||||||
|
DEGREES: 'degrees',
|
||||||
|
METERS: 'm'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {string} code Code.
|
||||||
|
* @param {ol3.ProjectionUnits} units Units.
|
||||||
|
* @param {ol3.Extent} extent Extent.
|
||||||
|
*/
|
||||||
|
ol3.Projection = function(code, units, extent) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.code_ = code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.ProjectionUnits}
|
||||||
|
*/
|
||||||
|
this.units_ = units;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Extent}
|
||||||
|
*/
|
||||||
|
this.extent_ = extent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string} Code.
|
||||||
|
*/
|
||||||
|
ol3.Projection.prototype.getCode = function() {
|
||||||
|
return this.code_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Extent} Extent.
|
||||||
|
*/
|
||||||
|
ol3.Projection.prototype.getExtent = function() {
|
||||||
|
return this.extent_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.ProjectionUnits} Units.
|
||||||
|
*/
|
||||||
|
ol3.Projection.prototype.getUnits = function() {
|
||||||
|
return this.units_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.Projection}
|
||||||
|
* @param {string} code Code.
|
||||||
|
* @param {Proj4js.Proj} proj4jsProj Proj4js projection.
|
||||||
|
*/
|
||||||
|
ol3.Proj4jsProjection = function(code, proj4jsProj) {
|
||||||
|
|
||||||
|
var units = /** @type {ol3.ProjectionUnits} */ proj4jsProj.units;
|
||||||
|
|
||||||
|
goog.base(this, code, units, null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Proj4js.Proj}
|
||||||
|
*/
|
||||||
|
this.proj4jsProj_ = proj4jsProj;
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.Proj4jsProjection, ol3.Projection);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Proj4js.Proj} Proj4js projection.
|
||||||
|
*/
|
||||||
|
ol3.Proj4jsProjection.prototype.getProj4jsProj = function() {
|
||||||
|
return this.proj4jsProj_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, ol3.Proj4jsProjection>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.proj4jsProjections_ = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, ol3.Projection>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.projections_ = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, Object.<string, ol3.TransformFunction>>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.transforms_ = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol3.Projection>} projections Projections.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol3.Projection.addEquivalentProjections_ = function(projections) {
|
||||||
|
ol3.Projection.addProjections(projections);
|
||||||
|
goog.array.forEach(projections, function(source) {
|
||||||
|
goog.array.forEach(projections, function(destination) {
|
||||||
|
ol3.Projection.addTransform(
|
||||||
|
source, destination, ol3.Projection.cloneTransform);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol3.Projection>} projections1 Projections.
|
||||||
|
* @param {Array.<ol3.Projection>} projections2 Projections.
|
||||||
|
* @param {ol3.TransformFunction} forwardTransform Forward transform.
|
||||||
|
* @param {ol3.TransformFunction} inverseTransform Inverse transform.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol3.Projection.addEquivalentTransforms_ =
|
||||||
|
function(projections1, projections2, forwardTransform, inverseTransform) {
|
||||||
|
goog.array.forEach(projections1, function(projection1) {
|
||||||
|
goog.array.forEach(projections2, function(projection2) {
|
||||||
|
ol3.Projection.addTransform(projection1, projection2, forwardTransform);
|
||||||
|
ol3.Projection.addTransform(projection2, projection1, inverseTransform);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Proj4jsProjection} proj4jsProjection Proj4js projection.
|
||||||
|
*/
|
||||||
|
ol3.Projection.addProj4jsProjection = function(proj4jsProjection) {
|
||||||
|
var proj4jsProjections = ol3.Projection.proj4jsProjections_;
|
||||||
|
var code = proj4jsProjection.getCode();
|
||||||
|
goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code));
|
||||||
|
proj4jsProjections[code] = proj4jsProjection;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Projection} projection Projection.
|
||||||
|
*/
|
||||||
|
ol3.Projection.addProjection = function(projection) {
|
||||||
|
var projections = ol3.Projection.projections_;
|
||||||
|
var code = projection.getCode();
|
||||||
|
goog.asserts.assert(!goog.object.containsKey(projections, code));
|
||||||
|
projections[code] = projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol3.Projection>} projections Projections.
|
||||||
|
*/
|
||||||
|
ol3.Projection.addProjections = function(projections) {
|
||||||
|
goog.array.forEach(projections, function(projection) {
|
||||||
|
ol3.Projection.addProjection(projection);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Projection} source Source.
|
||||||
|
* @param {ol3.Projection} destination Destination.
|
||||||
|
* @param {ol3.TransformFunction} transformFn Transform.
|
||||||
|
*/
|
||||||
|
ol3.Projection.addTransform = function(source, destination, transformFn) {
|
||||||
|
var projections = ol3.Projection.projections_;
|
||||||
|
var sourceCode = source.getCode();
|
||||||
|
var destinationCode = destination.getCode();
|
||||||
|
var transforms = ol3.Projection.transforms_;
|
||||||
|
if (!goog.object.containsKey(transforms, sourceCode)) {
|
||||||
|
transforms[sourceCode] = {};
|
||||||
|
}
|
||||||
|
goog.asserts.assert(
|
||||||
|
!goog.object.containsKey(transforms[sourceCode], destinationCode));
|
||||||
|
transforms[sourceCode][destinationCode] = transformFn;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} code Code.
|
||||||
|
* @return {ol3.Projection} Projection.
|
||||||
|
*/
|
||||||
|
ol3.Projection.getFromCode = function(code) {
|
||||||
|
var projection = ol3.Projection.projections_[code];
|
||||||
|
if (ol3.Projection.isProj4jsSupported() && !goog.isDef(projection)) {
|
||||||
|
projection = ol3.Projection.getProj4jsProjectionFromCode_(code);
|
||||||
|
}
|
||||||
|
if (!goog.isDef(projection)) {
|
||||||
|
goog.asserts.assert(goog.isDef(projection));
|
||||||
|
projection = null;
|
||||||
|
}
|
||||||
|
return projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} code Code.
|
||||||
|
* @private
|
||||||
|
* @return {ol3.Proj4jsProjection} Proj4js projection.
|
||||||
|
*/
|
||||||
|
ol3.Projection.getProj4jsProjectionFromCode_ = function(code) {
|
||||||
|
var proj4jsProjections = ol3.Projection.proj4jsProjections_;
|
||||||
|
var proj4jsProjection = proj4jsProjections[code];
|
||||||
|
if (!goog.isDef(proj4jsProjection)) {
|
||||||
|
var proj4jsProj = new Proj4js.Proj(code);
|
||||||
|
proj4jsProjection = new ol3.Proj4jsProjection(code, proj4jsProj);
|
||||||
|
proj4jsProjections[code] = proj4jsProjection;
|
||||||
|
}
|
||||||
|
return proj4jsProjection;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Projection} projection1 Projection 1.
|
||||||
|
* @param {ol3.Projection} projection2 Projection 2.
|
||||||
|
* @return {boolean} Equivalent.
|
||||||
|
*/
|
||||||
|
ol3.Projection.equivalent = function(projection1, projection2) {
|
||||||
|
if (projection1 === projection2) {
|
||||||
|
return true;
|
||||||
|
} else if (projection1.getUnits() != projection2.getUnits()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
var transformFn = ol3.Projection.getTransform(projection1, projection2);
|
||||||
|
return transformFn === ol3.Projection.cloneTransform;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Projection} source Source.
|
||||||
|
* @param {ol3.Projection} destination Destination.
|
||||||
|
* @return {ol3.TransformFunction} Transform.
|
||||||
|
*/
|
||||||
|
ol3.Projection.getTransform = function(source, destination) {
|
||||||
|
var transforms = ol3.Projection.transforms_;
|
||||||
|
var sourceCode = source.getCode();
|
||||||
|
var destinationCode = destination.getCode();
|
||||||
|
var transform;
|
||||||
|
if (goog.object.containsKey(transforms, sourceCode) &&
|
||||||
|
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
||||||
|
transform = transforms[sourceCode][destinationCode];
|
||||||
|
}
|
||||||
|
if (ol3.Projection.isProj4jsSupported() && !goog.isDef(transform)) {
|
||||||
|
var proj4jsSource;
|
||||||
|
if (source instanceof ol3.Proj4jsProjection) {
|
||||||
|
proj4jsSource = source;
|
||||||
|
} else {
|
||||||
|
proj4jsSource =
|
||||||
|
ol3.Projection.getProj4jsProjectionFromCode_(source.getCode());
|
||||||
|
}
|
||||||
|
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
|
||||||
|
var proj4jsDestination;
|
||||||
|
if (destination instanceof ol3.Proj4jsProjection) {
|
||||||
|
proj4jsDestination = destination;
|
||||||
|
} else {
|
||||||
|
proj4jsDestination =
|
||||||
|
ol3.Projection.getProj4jsProjectionFromCode_(source.getCode());
|
||||||
|
}
|
||||||
|
var destinationProj4jsProj = proj4jsDestination.getProj4jsProj();
|
||||||
|
transform =
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} coordinate Coordinate.
|
||||||
|
* @return {ol3.Coordinate} Coordinate.
|
||||||
|
*/
|
||||||
|
function(coordinate) {
|
||||||
|
var proj4jsPoint = new Proj4js.Point(coordinate.x, coordinate.y);
|
||||||
|
proj4jsPoint = Proj4js.transform(
|
||||||
|
sourceProj4jsProj, destinationProj4jsProj, proj4jsPoint);
|
||||||
|
return new ol3.Coordinate(proj4jsPoint.x, proj4jsPoint.y);
|
||||||
|
};
|
||||||
|
ol3.Projection.addTransform(source, destination, transform);
|
||||||
|
}
|
||||||
|
if (!goog.isDef(transform)) {
|
||||||
|
goog.asserts.assert(goog.isDef(transform));
|
||||||
|
transform = ol3.Projection.identityTransform;
|
||||||
|
}
|
||||||
|
return transform;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sourceCode Source code.
|
||||||
|
* @param {string} destinationCode Destination code.
|
||||||
|
* @return {ol3.TransformFunction} Transform.
|
||||||
|
*/
|
||||||
|
ol3.Projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
||||||
|
var source = ol3.Projection.getFromCode(sourceCode);
|
||||||
|
var destination = ol3.Projection.getFromCode(destinationCode);
|
||||||
|
return ol3.Projection.getTransform(source, destination);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} Has Proj4js.
|
||||||
|
*/
|
||||||
|
ol3.Projection.isProj4jsSupported = function() {
|
||||||
|
return ol3.ENABLE_PROJ4JS && 'Proj4js' in goog.global;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.identityTransform = function(point) {
|
||||||
|
return point;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.cloneTransform = function(point) {
|
||||||
|
return point.clone();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @param {ol3.Projection} source Source.
|
||||||
|
* @param {ol3.Projection} destination Destination.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.transform = function(point, source, destination) {
|
||||||
|
var transformFn = ol3.Projection.getTransform(source, destination);
|
||||||
|
return transformFn(point);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @param {string} sourceCode Source code.
|
||||||
|
* @param {string} destinationCode Destination code.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.transformWithCodes =
|
||||||
|
function(point, sourceCode, destinationCode) {
|
||||||
|
var transformFn = ol3.Projection.getTransformFromCodes(
|
||||||
|
sourceCode, destinationCode);
|
||||||
|
return transformFn(point);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_3857_RADIUS = 6378137;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.forwardSphericalMercator = function(point) {
|
||||||
|
var x = ol3.Projection.EPSG_3857_RADIUS * Math.PI * point.x / 180;
|
||||||
|
var y = ol3.Projection.EPSG_3857_RADIUS *
|
||||||
|
Math.log(Math.tan(Math.PI * (point.y + 90) / 360));
|
||||||
|
return new ol3.Coordinate(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate} point Point.
|
||||||
|
* @return {ol3.Coordinate} Point.
|
||||||
|
*/
|
||||||
|
ol3.Projection.inverseSphericalMercator = function(point) {
|
||||||
|
var x = 180 * point.x / (ol3.Projection.EPSG_3857_RADIUS * Math.PI);
|
||||||
|
var y = 360 * Math.atan(
|
||||||
|
Math.exp(point.y / ol3.Projection.EPSG_3857_RADIUS)) / Math.PI - 90;
|
||||||
|
return new ol3.Coordinate(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_3857_HALF_SIZE = Math.PI * ol3.Projection.EPSG_3857_RADIUS;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {ol3.Extent}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_3857_EXTENT = new ol3.Extent(
|
||||||
|
-ol3.Projection.EPSG_3857_HALF_SIZE,
|
||||||
|
-ol3.Projection.EPSG_3857_HALF_SIZE,
|
||||||
|
ol3.Projection.EPSG_3857_HALF_SIZE,
|
||||||
|
ol3.Projection.EPSG_3857_HALF_SIZE);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Array.<string>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_3857_LIKE_CODES_ = [
|
||||||
|
'EPSG:3857',
|
||||||
|
'EPSG:102100',
|
||||||
|
'EPSG:102113',
|
||||||
|
'EPSG:900913'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @private
|
||||||
|
* @type {Array.<ol3.Projection>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_3857_LIKE_PROJECTIONS_ = goog.array.map(
|
||||||
|
ol3.Projection.EPSG_3857_LIKE_CODES_,
|
||||||
|
function(code) {
|
||||||
|
return new ol3.Projection(
|
||||||
|
code,
|
||||||
|
ol3.ProjectionUnits.METERS,
|
||||||
|
ol3.Projection.EPSG_3857_EXTENT);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Extent}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_4326_EXTENT_ = new ol3.Extent(-180, -90, 180, 90);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Array.<string>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_4326_LIKE_CODES_ = [
|
||||||
|
'CRS:84',
|
||||||
|
'EPSG:4326',
|
||||||
|
'urn:ogc:def:crs:EPSG:6.6:4326'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {Array.<ol3.Projection>}
|
||||||
|
*/
|
||||||
|
ol3.Projection.EPSG_4326_LIKE_PROJECTIONS = goog.array.map(
|
||||||
|
ol3.Projection.EPSG_4326_LIKE_CODES_,
|
||||||
|
function(code) {
|
||||||
|
return new ol3.Projection(
|
||||||
|
code,
|
||||||
|
ol3.ProjectionUnits.DEGREES,
|
||||||
|
ol3.Projection.EPSG_4326_EXTENT_);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ol3.Projection.addEquivalentProjections_(
|
||||||
|
ol3.Projection.EPSG_3857_LIKE_PROJECTIONS_);
|
||||||
|
ol3.Projection.addEquivalentProjections_(
|
||||||
|
ol3.Projection.EPSG_4326_LIKE_PROJECTIONS);
|
||||||
|
ol3.Projection.addEquivalentTransforms_(
|
||||||
|
ol3.Projection.EPSG_4326_LIKE_PROJECTIONS,
|
||||||
|
ol3.Projection.EPSG_3857_LIKE_PROJECTIONS_,
|
||||||
|
ol3.Projection.forwardSphericalMercator,
|
||||||
|
ol3.Projection.inverseSphericalMercator);
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol3.Projection');
|
||||||
|
|
||||||
|
|
||||||
function _testAllEquivalent(codes) {
|
function _testAllEquivalent(codes) {
|
||||||
var projections = goog.array.map(codes, ol.Projection.getFromCode);
|
var projections = goog.array.map(codes, ol3.Projection.getFromCode);
|
||||||
goog.array.forEach(projections, function(source) {
|
goog.array.forEach(projections, function(source) {
|
||||||
goog.array.forEach(projections, function(destination) {
|
goog.array.forEach(projections, function(destination) {
|
||||||
assertTrue(ol.Projection.equivalent(source, destination));
|
assertTrue(ol3.Projection.equivalent(source, destination));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -34,10 +34,10 @@ function testEpsg4326Equivalence() {
|
|||||||
|
|
||||||
|
|
||||||
function testIdentityTransform() {
|
function testIdentityTransform() {
|
||||||
var epsg4326 = ol.Projection.getFromCode('EPSG:4326');
|
var epsg4326 = ol3.Projection.getFromCode('EPSG:4326');
|
||||||
var uniqueObject = {};
|
var uniqueObject = {};
|
||||||
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
|
var sourcePoint = new ol3.Coordinate(uniqueObject, uniqueObject);
|
||||||
var destinationPoint = ol.Projection.transform(
|
var destinationPoint = ol3.Projection.transform(
|
||||||
sourcePoint, epsg4326, epsg4326);
|
sourcePoint, epsg4326, epsg4326);
|
||||||
assertFalse(sourcePoint === destinationPoint);
|
assertFalse(sourcePoint === destinationPoint);
|
||||||
assertTrue(destinationPoint.x === sourcePoint.x);
|
assertTrue(destinationPoint.x === sourcePoint.x);
|
||||||
@@ -46,8 +46,8 @@ function testIdentityTransform() {
|
|||||||
|
|
||||||
|
|
||||||
function testForwardSphericalMercatorOrigin() {
|
function testForwardSphericalMercatorOrigin() {
|
||||||
var point = ol.Projection.transformWithCodes(
|
var point = ol3.Projection.transformWithCodes(
|
||||||
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
|
new ol3.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
|
||||||
assertNotNullNorUndefined(point);
|
assertNotNullNorUndefined(point);
|
||||||
assertEquals(0, point.x);
|
assertEquals(0, point.x);
|
||||||
assertRoughlyEquals(0, point.y, 1e-9);
|
assertRoughlyEquals(0, point.y, 1e-9);
|
||||||
@@ -55,8 +55,8 @@ function testForwardSphericalMercatorOrigin() {
|
|||||||
|
|
||||||
|
|
||||||
function testInverseSphericalMercatorOrigin() {
|
function testInverseSphericalMercatorOrigin() {
|
||||||
var point = ol.Projection.transformWithCodes(
|
var point = ol3.Projection.transformWithCodes(
|
||||||
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
|
new ol3.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
|
||||||
assertNotNullNorUndefined(point);
|
assertNotNullNorUndefined(point);
|
||||||
assertEquals(0, point.x);
|
assertEquals(0, point.x);
|
||||||
assertEquals(0, point.y);
|
assertEquals(0, point.y);
|
||||||
@@ -65,8 +65,8 @@ function testInverseSphericalMercatorOrigin() {
|
|||||||
|
|
||||||
function testForwardSphericalMercatorAlastaira() {
|
function testForwardSphericalMercatorAlastaira() {
|
||||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||||
var point = ol.Projection.transformWithCodes(
|
var point = ol3.Projection.transformWithCodes(
|
||||||
new ol.Coordinate(-5.625, 52.4827802220782),
|
new ol3.Coordinate(-5.625, 52.4827802220782),
|
||||||
'EPSG:4326',
|
'EPSG:4326',
|
||||||
'EPSG:900913');
|
'EPSG:900913');
|
||||||
assertNotNullNorUndefined(point);
|
assertNotNullNorUndefined(point);
|
||||||
@@ -77,8 +77,8 @@ function testForwardSphericalMercatorAlastaira() {
|
|||||||
|
|
||||||
function testInverseSphericalMercatorAlastaira() {
|
function testInverseSphericalMercatorAlastaira() {
|
||||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||||
var point = ol.Projection.transformWithCodes(
|
var point = ol3.Projection.transformWithCodes(
|
||||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
new ol3.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||||
'EPSG:900913',
|
'EPSG:900913',
|
||||||
'EPSG:4326');
|
'EPSG:4326');
|
||||||
assertNotNullNorUndefined(point);
|
assertNotNullNorUndefined(point);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.Rectangle');
|
goog.provide('ol3.Rectangle');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Size');
|
goog.require('ol3.Size');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ goog.require('ol.Size');
|
|||||||
* @param {number} maxX Maximum X.
|
* @param {number} maxX Maximum X.
|
||||||
* @param {number} maxY Maximum Y.
|
* @param {number} maxY Maximum Y.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle = function(minX, minY, maxX, maxY) {
|
ol3.Rectangle = function(minX, minY, maxX, maxY) {
|
||||||
|
|
||||||
goog.asserts.assert(minX <= maxX);
|
goog.asserts.assert(minX <= maxX);
|
||||||
goog.asserts.assert(minY <= maxY);
|
goog.asserts.assert(minY <= maxY);
|
||||||
@@ -42,28 +42,28 @@ ol.Rectangle = function(minX, minY, maxX, maxY) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Rectangle} Clone.
|
* @return {ol3.Rectangle} Clone.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.clone = function() {
|
ol3.Rectangle.prototype.clone = function() {
|
||||||
return new ol.Rectangle(this.minX, this.minY, this.maxX, this.maxY);
|
return new ol3.Rectangle(this.minX, this.minY, this.maxX, this.maxY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol3.Coordinate} coordinate Coordinate.
|
||||||
* @return {boolean} Contains.
|
* @return {boolean} Contains.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.contains = function(coordinate) {
|
ol3.Rectangle.prototype.contains = function(coordinate) {
|
||||||
return this.minX <= coordinate.x && coordinate.x <= this.maxX &&
|
return this.minX <= coordinate.x && coordinate.x <= this.maxX &&
|
||||||
this.minY <= coordinate.y && coordinate.y <= this.maxY;
|
this.minY <= coordinate.y && coordinate.y <= this.maxY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Coordinate} Center.
|
* @return {ol3.Coordinate} Center.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.getCenter = function() {
|
ol3.Rectangle.prototype.getCenter = function() {
|
||||||
return new ol.Coordinate(
|
return new ol3.Coordinate(
|
||||||
(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
|
(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,32 +71,32 @@ ol.Rectangle.prototype.getCenter = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {number} Height.
|
* @return {number} Height.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.getHeight = function() {
|
ol3.Rectangle.prototype.getHeight = function() {
|
||||||
return this.maxY - this.minY;
|
return this.maxY - this.minY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Size} Size.
|
* @return {ol3.Size} Size.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.getSize = function() {
|
ol3.Rectangle.prototype.getSize = function() {
|
||||||
return new ol.Size(this.getWidth(), this.getHeight());
|
return new ol3.Size(this.getWidth(), this.getHeight());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} Width.
|
* @return {number} Width.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.getWidth = function() {
|
ol3.Rectangle.prototype.getWidth = function() {
|
||||||
return this.maxX - this.minX;
|
return this.maxX - this.minX;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Rectangle} rectangle Rectangle.
|
* @param {ol3.Rectangle} rectangle Rectangle.
|
||||||
* @return {boolean} Intersects.
|
* @return {boolean} Intersects.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.intersects = function(rectangle) {
|
ol3.Rectangle.prototype.intersects = function(rectangle) {
|
||||||
return this.minX <= rectangle.maxX &&
|
return this.minX <= rectangle.maxX &&
|
||||||
this.maxX >= rectangle.minX &&
|
this.maxX >= rectangle.minX &&
|
||||||
this.minY <= rectangle.maxY &&
|
this.minY <= rectangle.maxY &&
|
||||||
@@ -105,11 +105,11 @@ ol.Rectangle.prototype.intersects = function(rectangle) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol3.Coordinate} coordinate Coordinate.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol3.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.normalize = function(coordinate) {
|
ol3.Rectangle.prototype.normalize = function(coordinate) {
|
||||||
return new ol.Coordinate(
|
return new ol3.Coordinate(
|
||||||
(coordinate.x - this.minX) / this.getWidth(),
|
(coordinate.x - this.minX) / this.getWidth(),
|
||||||
(coordinate.y - this.minY) / this.getHeight());
|
(coordinate.y - this.minY) / this.getHeight());
|
||||||
};
|
};
|
||||||
@@ -118,6 +118,6 @@ ol.Rectangle.prototype.normalize = function(coordinate) {
|
|||||||
/**
|
/**
|
||||||
* @return {string} String.
|
* @return {string} String.
|
||||||
*/
|
*/
|
||||||
ol.Rectangle.prototype.toString = function() {
|
ol3.Rectangle.prototype.toString = function() {
|
||||||
return '(' + [this.minX, this.minY, this.maxX, this.maxY].join(', ') + ')';
|
return '(' + [this.minX, this.minY, this.maxX, this.maxY].join(', ') + ')';
|
||||||
};
|
};
|
||||||
142
src/ol3/base/rectangle_test.js
Normal file
142
src/ol3/base/rectangle_test.js
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
goog.require('goog.testing.jsunit');
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.Rectangle');
|
||||||
|
|
||||||
|
|
||||||
|
function testCenter() {
|
||||||
|
var rectangle = new ol3.Rectangle(1, 2, 3, 4);
|
||||||
|
var center = rectangle.getCenter();
|
||||||
|
assertEquals(2, center.x);
|
||||||
|
assertEquals(3, center.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testClone() {
|
||||||
|
var rectangle = new ol3.Rectangle(1, 2, 3, 4);
|
||||||
|
var clonedRectangle = rectangle.clone();
|
||||||
|
assertTrue(clonedRectangle instanceof ol3.Rectangle);
|
||||||
|
assertFalse(clonedRectangle === rectangle);
|
||||||
|
assertEquals(rectangle.minX, clonedRectangle.minX);
|
||||||
|
assertEquals(rectangle.minY, clonedRectangle.minY);
|
||||||
|
assertEquals(rectangle.maxX, clonedRectangle.maxX);
|
||||||
|
assertEquals(rectangle.maxY, clonedRectangle.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testContainsPositive() {
|
||||||
|
var rectangle = new ol3.Rectangle(1, 2, 3, 4);
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(1, 2)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(1, 3)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(1, 4)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(2, 2)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(2, 3)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(2, 4)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(3, 2)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(3, 3)));
|
||||||
|
assertTrue(rectangle.contains(new ol3.Coordinate(3, 4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testContainsNegative() {
|
||||||
|
var rectangle = new ol3.Rectangle(1, 2, 3, 4);
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(0, 1)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(0, 2)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(0, 3)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(0, 4)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(0, 5)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(1, 1)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(1, 5)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(2, 1)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(2, 5)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(3, 1)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(3, 5)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(4, 1)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(4, 2)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(4, 3)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(4, 4)));
|
||||||
|
assertFalse(rectangle.contains(new ol3.Coordinate(4, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testIntersects() {
|
||||||
|
|
||||||
|
var rectangle1 = new ol3.Rectangle(50, 50, 100, 100);
|
||||||
|
|
||||||
|
function assertIntersects(rectangle2) {
|
||||||
|
assertTrue(rectangle1 + ' expected to intersect ' + rectangle2,
|
||||||
|
rectangle1.intersects(rectangle2));
|
||||||
|
}
|
||||||
|
function assertNotIntersects(rectangle2) {
|
||||||
|
assertFalse(rectangle1 + ' expected to not intersect ' + rectangle2,
|
||||||
|
rectangle1.intersects(rectangle2));
|
||||||
|
}
|
||||||
|
|
||||||
|
assertIntersects(rectangle1);
|
||||||
|
assertIntersects(new ol3.Rectangle(20, 20, 80, 80));
|
||||||
|
assertIntersects(new ol3.Rectangle(20, 50, 80, 100));
|
||||||
|
assertIntersects(new ol3.Rectangle(20, 80, 80, 120));
|
||||||
|
assertIntersects(new ol3.Rectangle(50, 20, 100, 80));
|
||||||
|
assertIntersects(new ol3.Rectangle(50, 80, 100, 120));
|
||||||
|
assertIntersects(new ol3.Rectangle(80, 20, 120, 80));
|
||||||
|
assertIntersects(new ol3.Rectangle(80, 50, 120, 100));
|
||||||
|
assertIntersects(new ol3.Rectangle(80, 80, 120, 120));
|
||||||
|
assertIntersects(new ol3.Rectangle(20, 20, 120, 120));
|
||||||
|
assertIntersects(new ol3.Rectangle(70, 70, 80, 80));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(10, 10, 30, 30));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(30, 10, 70, 30));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(50, 10, 100, 30));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(80, 10, 120, 30));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(120, 10, 140, 30));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(10, 30, 30, 70));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(120, 30, 140, 70));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(10, 50, 30, 100));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(120, 50, 140, 100));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(10, 80, 30, 120));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(120, 80, 140, 120));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(10, 120, 30, 140));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(30, 120, 70, 140));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(50, 120, 100, 140));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(80, 120, 120, 140));
|
||||||
|
assertNotIntersects(new ol3.Rectangle(120, 120, 140, 140));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testSize() {
|
||||||
|
var rectangle = new ol3.Rectangle(0, 1, 2, 4);
|
||||||
|
var size = rectangle.getSize();
|
||||||
|
assertEquals(2, size.width);
|
||||||
|
assertEquals(3, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testNormalize() {
|
||||||
|
var rectangle = new ol3.Rectangle(0, 1, 2, 3);
|
||||||
|
var coordinate;
|
||||||
|
|
||||||
|
coordinate = rectangle.normalize(new ol3.Coordinate(1, 2));
|
||||||
|
assertEquals(0.5, coordinate.x);
|
||||||
|
assertEquals(0.5, coordinate.y);
|
||||||
|
|
||||||
|
coordinate = rectangle.normalize(new ol3.Coordinate(0, 3));
|
||||||
|
assertEquals(0, coordinate.x);
|
||||||
|
assertEquals(1, coordinate.y);
|
||||||
|
|
||||||
|
coordinate = rectangle.normalize(new ol3.Coordinate(2, 1));
|
||||||
|
assertEquals(1, coordinate.x);
|
||||||
|
assertEquals(0, coordinate.y);
|
||||||
|
|
||||||
|
coordinate = rectangle.normalize(new ol3.Coordinate(0, 0));
|
||||||
|
assertEquals(0, coordinate.x);
|
||||||
|
assertEquals(-0.5, coordinate.y);
|
||||||
|
|
||||||
|
coordinate = rectangle.normalize(new ol3.Coordinate(-1, 1));
|
||||||
|
assertEquals(-0.5, coordinate.x);
|
||||||
|
assertEquals(0, coordinate.y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testToString() {
|
||||||
|
var rectangle = new ol3.Rectangle(0, 1, 2, 3);
|
||||||
|
assertEquals('(0, 1, 2, 3)', rectangle.toString());
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.Size');
|
goog.provide('ol3.Size');
|
||||||
|
|
||||||
goog.require('goog.math.Size');
|
goog.require('goog.math.Size');
|
||||||
|
|
||||||
@@ -10,16 +10,16 @@ goog.require('goog.math.Size');
|
|||||||
* @param {number} width Width.
|
* @param {number} width Width.
|
||||||
* @param {number} height Height.
|
* @param {number} height Height.
|
||||||
*/
|
*/
|
||||||
ol.Size = function(width, height) {
|
ol3.Size = function(width, height) {
|
||||||
goog.base(this, width, height);
|
goog.base(this, width, height);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Size, goog.math.Size);
|
goog.inherits(ol3.Size, goog.math.Size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol3.Size} size Size.
|
||||||
* @return {boolean} Equals.
|
* @return {boolean} Equals.
|
||||||
*/
|
*/
|
||||||
ol.Size.prototype.equals = function(size) {
|
ol3.Size.prototype.equals = function(size) {
|
||||||
return this.width == size.width && this.height == size.height;
|
return this.width == size.width && this.height == size.height;
|
||||||
};
|
};
|
||||||
96
src/ol3/base/store.js
Normal file
96
src/ol3/base/store.js
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
goog.provide('ol3.Store');
|
||||||
|
|
||||||
|
goog.require('goog.functions');
|
||||||
|
goog.require('ol3.Attribution');
|
||||||
|
goog.require('ol3.Extent');
|
||||||
|
goog.require('ol3.Projection');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {ol3.Projection} projection Projection.
|
||||||
|
* @param {ol3.Extent=} opt_extent Extent.
|
||||||
|
* @param {Array.<ol3.Attribution>=} opt_attributions Attributions.
|
||||||
|
*/
|
||||||
|
ol3.Store = function(projection, opt_extent, opt_attributions) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Projection}
|
||||||
|
*/
|
||||||
|
this.projection_ = projection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Extent}
|
||||||
|
*/
|
||||||
|
this.extent_ = opt_extent || projection.getExtent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Array.<ol3.Attribution>}
|
||||||
|
*/
|
||||||
|
this.attributions_ = opt_attributions || null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array.<ol3.Attribution>} Attributions.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.getAttributions = function() {
|
||||||
|
return this.attributions_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Extent} Extent.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.getExtent = function() {
|
||||||
|
return this.extent_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Projection} Projection.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.getProjection = function() {
|
||||||
|
return this.projection_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array.<number>|undefined} Resolutions.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.getResolutions = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} Is ready.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.isReady = goog.functions.TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol3.Attribution>} attributions Attributions.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.setAttributions = function(attributions) {
|
||||||
|
this.attributions_ = attributions;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Extent} extent Extent.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.setExtent = function(extent) {
|
||||||
|
this.extent_ = extent;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Projection} projection Projetion.
|
||||||
|
*/
|
||||||
|
ol3.Store.prototype.setProjection = function(projection) {
|
||||||
|
this.projection_ = projection;
|
||||||
|
};
|
||||||
9
src/ol3/base/transformfunction.js
Normal file
9
src/ol3/base/transformfunction.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
goog.provide('ol3.TransformFunction');
|
||||||
|
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {function(ol3.Coordinate): ol3.Coordinate}
|
||||||
|
*/
|
||||||
|
ol3.TransformFunction;
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// FIXME handle layer order
|
// FIXME handle layer order
|
||||||
// FIXME check clean-up code
|
// FIXME check clean-up code
|
||||||
|
|
||||||
goog.provide('ol.control.Attribution');
|
goog.provide('ol3.control.Attribution');
|
||||||
|
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('goog.dom.TagName');
|
goog.require('goog.dom.TagName');
|
||||||
@@ -11,21 +11,21 @@ goog.require('goog.events');
|
|||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('goog.style');
|
goog.require('goog.style');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol3.Collection');
|
||||||
goog.require('ol.Control');
|
goog.require('ol3.Control');
|
||||||
goog.require('ol.CoverageArea');
|
goog.require('ol3.CoverageArea');
|
||||||
goog.require('ol.Layer');
|
goog.require('ol3.Layer');
|
||||||
goog.require('ol.MapProperty');
|
goog.require('ol3.MapProperty');
|
||||||
goog.require('ol.TileCoverageArea');
|
goog.require('ol3.TileCoverageArea');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Control}
|
* @extends {ol3.Control}
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution = function(map) {
|
ol3.control.Attribution = function(map) {
|
||||||
|
|
||||||
goog.base(this, map);
|
goog.base(this, map);
|
||||||
|
|
||||||
@@ -55,39 +55,41 @@ ol.control.Attribution = function(map) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<number, Array.<ol.CoverageArea>>}
|
* @type {Object.<number, Array.<ol3.CoverageArea>>}
|
||||||
*/
|
*/
|
||||||
this.coverageAreass_ = {};
|
this.coverageAreass_ = {};
|
||||||
|
|
||||||
goog.events.listen(map, ol.Object.getChangedEventType(ol.MapProperty.CENTER),
|
goog.events.listen(
|
||||||
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.CENTER),
|
||||||
this.handleMapChanged, false, this);
|
this.handleMapChanged, false, this);
|
||||||
|
|
||||||
goog.events.listen(map, ol.Object.getChangedEventType(ol.MapProperty.LAYERS),
|
goog.events.listen(
|
||||||
|
map, ol3.Object.getChangedEventType(ol3.MapProperty.LAYERS),
|
||||||
this.handleMapLayersChanged, false, this);
|
this.handleMapLayersChanged, false, this);
|
||||||
|
|
||||||
goog.events.listen(map,
|
goog.events.listen(map,
|
||||||
ol.Object.getChangedEventType(ol.MapProperty.RESOLUTION),
|
ol3.Object.getChangedEventType(ol3.MapProperty.RESOLUTION),
|
||||||
this.handleMapChanged, false, this);
|
this.handleMapChanged, false, this);
|
||||||
|
|
||||||
goog.events.listen(map, ol.Object.getChangedEventType(ol.MapProperty.SIZE),
|
goog.events.listen(map, ol3.Object.getChangedEventType(ol3.MapProperty.SIZE),
|
||||||
this.handleMapChanged, false, this);
|
this.handleMapChanged, false, this);
|
||||||
|
|
||||||
this.handleMapLayersChanged();
|
this.handleMapLayersChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.Attribution, ol.Control);
|
goog.inherits(ol3.control.Attribution, ol3.Control);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.addLayer = function(layer) {
|
ol3.control.Attribution.prototype.addLayer = function(layer) {
|
||||||
|
|
||||||
var layerKey = goog.getUid(layer);
|
var layerKey = goog.getUid(layer);
|
||||||
|
|
||||||
this.layerVisibleChangeListenerKeys_[layerKey] = goog.events.listen(
|
this.layerVisibleChangeListenerKeys_[layerKey] = goog.events.listen(
|
||||||
layer, ol.Object.getChangedEventType(ol.LayerProperty.VISIBLE),
|
layer, ol3.Object.getChangedEventType(ol3.LayerProperty.VISIBLE),
|
||||||
this.handleLayerVisibleChanged, false, this);
|
this.handleLayerVisibleChanged, false, this);
|
||||||
|
|
||||||
if (layer.getStore().isReady()) {
|
if (layer.getStore().isReady()) {
|
||||||
@@ -101,10 +103,10 @@ ol.control.Attribution.prototype.addLayer = function(layer) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.createAttributionElementsForLayer_ =
|
ol3.control.Attribution.prototype.createAttributionElementsForLayer_ =
|
||||||
function(layer) {
|
function(layer) {
|
||||||
|
|
||||||
var store = layer.getStore();
|
var store = layer.getStore();
|
||||||
@@ -115,8 +117,8 @@ ol.control.Attribution.prototype.createAttributionElementsForLayer_ =
|
|||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var mapIsDef = map.isDef();
|
var mapIsDef = map.isDef();
|
||||||
var mapExtent = /** @type {ol.Extent} */ map.getExtent();
|
var mapExtent = /** @type {ol3.Extent} */ map.getExtent();
|
||||||
var mapProjection = /** @type {ol.Projection} */ map.getProjection();
|
var mapProjection = /** @type {ol3.Projection} */ map.getProjection();
|
||||||
var mapResolution = /** @type {number} */ map.getResolution();
|
var mapResolution = /** @type {number} */ map.getResolution();
|
||||||
|
|
||||||
var layerVisible = layer.getVisible();
|
var layerVisible = layer.getVisible();
|
||||||
@@ -155,20 +157,20 @@ ol.control.Attribution.prototype.createAttributionElementsForLayer_ =
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.getElement = function() {
|
ol3.control.Attribution.prototype.getElement = function() {
|
||||||
return this.ulElement_;
|
return this.ulElement_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @param {ol.Extent} mapExtent Map extent.
|
* @param {ol3.Extent} mapExtent Map extent.
|
||||||
* @param {number} mapResolution Map resolution.
|
* @param {number} mapResolution Map resolution.
|
||||||
* @param {ol.Projection} mapProjection Map projection.
|
* @param {ol3.Projection} mapProjection Map projection.
|
||||||
* @return {Object.<number, boolean>} Attribution visibilities.
|
* @return {Object.<number, boolean>} Attribution visibilities.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
ol3.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
||||||
function(layer, mapExtent, mapResolution, mapProjection) {
|
function(layer, mapExtent, mapResolution, mapProjection) {
|
||||||
|
|
||||||
var store = layer.getStore();
|
var store = layer.getStore();
|
||||||
@@ -179,8 +181,8 @@ ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mapZ;
|
var mapZ;
|
||||||
if (store instanceof ol.TileStore) {
|
if (store instanceof ol3.TileStore) {
|
||||||
var tileStore = /** @type {ol.TileStore} */ store;
|
var tileStore = /** @type {ol3.TileStore} */ store;
|
||||||
var tileGrid = tileStore.getTileGrid();
|
var tileGrid = tileStore.getTileGrid();
|
||||||
mapZ = tileGrid.getZForResolution(mapResolution);
|
mapZ = tileGrid.getZForResolution(mapResolution);
|
||||||
}
|
}
|
||||||
@@ -199,10 +201,10 @@ ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
|||||||
var attributionProjection = attribution.getProjection();
|
var attributionProjection = attribution.getProjection();
|
||||||
coverageAreas = attribution.getCoverageAreas();
|
coverageAreas = attribution.getCoverageAreas();
|
||||||
if (!goog.isNull(coverageAreas) &&
|
if (!goog.isNull(coverageAreas) &&
|
||||||
!ol.Projection.equivalent(attributionProjection, mapProjection)) {
|
!ol3.Projection.equivalent(attributionProjection, mapProjection)) {
|
||||||
var transformFn = ol.Projection.getTransform(
|
var transformFn = ol3.Projection.getTransform(
|
||||||
attributionProjection, mapProjection);
|
attributionProjection, mapProjection);
|
||||||
if (transformFn !== ol.Projection.cloneTransform) {
|
if (transformFn !== ol3.Projection.cloneTransform) {
|
||||||
coverageAreas = goog.array.map(coverageAreas, function(coverageArea) {
|
coverageAreas = goog.array.map(coverageAreas, function(coverageArea) {
|
||||||
return coverageArea.transform(transformFn);
|
return coverageArea.transform(transformFn);
|
||||||
});
|
});
|
||||||
@@ -212,15 +214,16 @@ ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!goog.isNull(coverageAreas)) {
|
if (!goog.isNull(coverageAreas)) {
|
||||||
if (store instanceof ol.TileStore) {
|
if (store instanceof ol3.TileStore) {
|
||||||
attributionVisible = goog.array.some(
|
attributionVisible = goog.array.some(
|
||||||
coverageAreas,
|
coverageAreas,
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileCoverageArea} tileCoverageArea Tile coverage area.
|
* @param {ol3.TileCoverageArea} tileCoverageArea
|
||||||
|
* Tile coverage area.
|
||||||
*/
|
*/
|
||||||
function(tileCoverageArea) {
|
function(tileCoverageArea) {
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
tileCoverageArea instanceof ol.TileCoverageArea);
|
tileCoverageArea instanceof ol3.TileCoverageArea);
|
||||||
return tileCoverageArea.intersectsExtentAndZ(mapExtent, mapZ);
|
return tileCoverageArea.intersectsExtentAndZ(mapExtent, mapZ);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -245,8 +248,8 @@ ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
|
|||||||
/**
|
/**
|
||||||
* @param {goog.events.Event} event Event.
|
* @param {goog.events.Event} event Event.
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleLayerLoad = function(event) {
|
ol3.control.Attribution.prototype.handleLayerLoad = function(event) {
|
||||||
var layer = /** @type {ol.Layer} */ event.target;
|
var layer = /** @type {ol3.Layer} */ event.target;
|
||||||
this.createAttributionElementsForLayer_(layer);
|
this.createAttributionElementsForLayer_(layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -255,15 +258,15 @@ ol.control.Attribution.prototype.handleLayerLoad = function(event) {
|
|||||||
* @param {goog.events.Event} event Event.
|
* @param {goog.events.Event} event Event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleLayerVisibleChanged = function(event) {
|
ol3.control.Attribution.prototype.handleLayerVisibleChanged = function(event) {
|
||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var mapIsDef = map.isDef();
|
var mapIsDef = map.isDef();
|
||||||
var mapExtent = /** @type {ol.Extent} */ map.getExtent();
|
var mapExtent = /** @type {ol3.Extent} */ map.getExtent();
|
||||||
var mapProjection = /** @type {ol.Projection} */ map.getProjection();
|
var mapProjection = /** @type {ol3.Projection} */ map.getProjection();
|
||||||
var mapResolution = /** @type {number} */ map.getResolution();
|
var mapResolution = /** @type {number} */ map.getResolution();
|
||||||
|
|
||||||
var layer = /** @type {ol.Layer} */ event.target;
|
var layer = /** @type {ol3.Layer} */ event.target;
|
||||||
|
|
||||||
this.updateLayerAttributionsVisibility_(
|
this.updateLayerAttributionsVisibility_(
|
||||||
layer, mapIsDef, mapExtent, mapResolution, mapProjection);
|
layer, mapIsDef, mapExtent, mapResolution, mapProjection);
|
||||||
@@ -272,22 +275,22 @@ ol.control.Attribution.prototype.handleLayerVisibleChanged = function(event) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol3.CollectionEvent} collectionEvent Collection event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleLayersAdd = function(collectionEvent) {
|
ol3.control.Attribution.prototype.handleLayersAdd = function(collectionEvent) {
|
||||||
var layer = /** @type {ol.Layer} */ collectionEvent.elem;
|
var layer = /** @type {ol3.Layer} */ collectionEvent.elem;
|
||||||
this.addLayer(layer);
|
this.addLayer(layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol3.CollectionEvent} collectionEvent Collection event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleLayersRemove =
|
ol3.control.Attribution.prototype.handleLayersRemove =
|
||||||
function(collectionEvent) {
|
function(collectionEvent) {
|
||||||
var layer = /** @type {ol.Layer} */ collectionEvent.elem;
|
var layer = /** @type {ol3.Layer} */ collectionEvent.elem;
|
||||||
this.removeLayer(layer);
|
this.removeLayer(layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -295,12 +298,12 @@ ol.control.Attribution.prototype.handleLayersRemove =
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleMapChanged = function() {
|
ol3.control.Attribution.prototype.handleMapChanged = function() {
|
||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var mapIsDef = map.isDef();
|
var mapIsDef = map.isDef();
|
||||||
var mapExtent = /** @type {ol.Extent} */ map.getExtent();
|
var mapExtent = /** @type {ol3.Extent} */ map.getExtent();
|
||||||
var mapProjection = /** @type {ol.Projection} */ map.getProjection();
|
var mapProjection = /** @type {ol3.Projection} */ map.getProjection();
|
||||||
var mapResolution = map.getResolution();
|
var mapResolution = map.getResolution();
|
||||||
|
|
||||||
var layers = map.getLayers();
|
var layers = map.getLayers();
|
||||||
@@ -315,7 +318,7 @@ ol.control.Attribution.prototype.handleMapChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleMapLayersChanged = function() {
|
ol3.control.Attribution.prototype.handleMapLayersChanged = function() {
|
||||||
if (!goog.isNull(this.layersListenerKeys_)) {
|
if (!goog.isNull(this.layersListenerKeys_)) {
|
||||||
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
|
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
|
||||||
this.layersListenerKeys_ = null;
|
this.layersListenerKeys_ = null;
|
||||||
@@ -330,9 +333,9 @@ ol.control.Attribution.prototype.handleMapLayersChanged = function() {
|
|||||||
if (goog.isDefAndNotNull(layers)) {
|
if (goog.isDefAndNotNull(layers)) {
|
||||||
layers.forEach(this.addLayer, this);
|
layers.forEach(this.addLayer, this);
|
||||||
this.layersListenerKeys_ = [
|
this.layersListenerKeys_ = [
|
||||||
goog.events.listen(layers, ol.CollectionEventType.ADD,
|
goog.events.listen(layers, ol3.CollectionEventType.ADD,
|
||||||
this.handleLayersAdd, false, this),
|
this.handleLayersAdd, false, this),
|
||||||
goog.events.listen(layers, ol.CollectionEventType.REMOVE,
|
goog.events.listen(layers, ol3.CollectionEventType.REMOVE,
|
||||||
this.handleLayersRemove, false, this)
|
this.handleLayersRemove, false, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -340,10 +343,10 @@ ol.control.Attribution.prototype.handleMapLayersChanged = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.removeLayer = function(layer) {
|
ol3.control.Attribution.prototype.removeLayer = function(layer) {
|
||||||
|
|
||||||
var layerKey = goog.getUid(layer);
|
var layerKey = goog.getUid(layer);
|
||||||
|
|
||||||
@@ -362,14 +365,14 @@ ol.control.Attribution.prototype.removeLayer = function(layer) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Layer} layer Layer.
|
* @param {ol3.Layer} layer Layer.
|
||||||
* @param {boolean} mapIsDef Map is defined.
|
* @param {boolean} mapIsDef Map is defined.
|
||||||
* @param {ol.Extent} mapExtent Map extent.
|
* @param {ol3.Extent} mapExtent Map extent.
|
||||||
* @param {number} mapResolution Map resolution.
|
* @param {number} mapResolution Map resolution.
|
||||||
* @param {ol.Projection} mapProjection Map projection.
|
* @param {ol3.Projection} mapProjection Map projection.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.updateLayerAttributionsVisibility_ =
|
ol3.control.Attribution.prototype.updateLayerAttributionsVisibility_ =
|
||||||
function(layer, mapIsDef, mapExtent, mapResolution, mapProjection) {
|
function(layer, mapIsDef, mapExtent, mapResolution, mapProjection) {
|
||||||
if (mapIsDef && layer.getVisible()) {
|
if (mapIsDef && layer.getVisible()) {
|
||||||
var attributionVisibilities = this.getLayerAttributionVisiblities_(
|
var attributionVisibilities = this.getLayerAttributionVisiblities_(
|
||||||
33
src/ol3/control/control.js
Normal file
33
src/ol3/control/control.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
goog.provide('ol3.Control');
|
||||||
|
|
||||||
|
goog.require('ol3.Map');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {ol3.Map} map Map.
|
||||||
|
*/
|
||||||
|
ol3.Control = function(map) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol3.Map}
|
||||||
|
*/
|
||||||
|
this.map_ = map;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Element} Element.
|
||||||
|
*/
|
||||||
|
ol3.Control.prototype.getElement = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol3.Map} Map.
|
||||||
|
*/
|
||||||
|
ol3.Control.prototype.getMap = function() {
|
||||||
|
return this.map_;
|
||||||
|
};
|
||||||
@@ -1,26 +1,26 @@
|
|||||||
// FIXME should listen on appropriate pane, once it is defined
|
// FIXME should listen on appropriate pane, once it is defined
|
||||||
|
|
||||||
goog.provide('ol.control.MousePosition');
|
goog.provide('ol3.control.MousePosition');
|
||||||
|
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Control');
|
goog.require('ol3.Control');
|
||||||
goog.require('ol.MapProperty');
|
goog.require('ol3.MapProperty');
|
||||||
goog.require('ol.Object');
|
goog.require('ol3.Object');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol3.Projection');
|
||||||
goog.require('ol.TransformFunction');
|
goog.require('ol3.TransformFunction');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Control}
|
* @extends {ol3.Control}
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {ol.Projection=} opt_projection Projection.
|
* @param {ol3.Projection=} opt_projection Projection.
|
||||||
* @param {ol.CoordinateFormatType=} opt_coordinateFormat Coordinate format.
|
* @param {ol3.CoordinateFormatType=} opt_coordinateFormat Coordinate format.
|
||||||
* @param {string=} opt_undefinedHTML Undefined HTML.
|
* @param {string=} opt_undefinedHTML Undefined HTML.
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition =
|
ol3.control.MousePosition =
|
||||||
function(map, opt_projection, opt_coordinateFormat, opt_undefinedHTML) {
|
function(map, opt_projection, opt_coordinateFormat, opt_undefinedHTML) {
|
||||||
|
|
||||||
goog.base(this, map);
|
goog.base(this, map);
|
||||||
@@ -33,13 +33,13 @@ ol.control.MousePosition =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Projection}
|
* @type {ol3.Projection}
|
||||||
*/
|
*/
|
||||||
this.projection_ = opt_projection || null;
|
this.projection_ = opt_projection || null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.CoordinateFormatType|undefined}
|
* @type {ol3.CoordinateFormatType|undefined}
|
||||||
*/
|
*/
|
||||||
this.coordinateFormat_ = opt_coordinateFormat;
|
this.coordinateFormat_ = opt_coordinateFormat;
|
||||||
|
|
||||||
@@ -51,12 +51,12 @@ ol.control.MousePosition =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.TransformFunction}
|
* @type {ol3.TransformFunction}
|
||||||
*/
|
*/
|
||||||
this.transform_ = ol.Projection.identityTransform;
|
this.transform_ = ol3.Projection.identityTransform;
|
||||||
|
|
||||||
goog.events.listen(map,
|
goog.events.listen(map,
|
||||||
ol.Object.getChangedEventType(ol.MapProperty.PROJECTION),
|
ol3.Object.getChangedEventType(ol3.MapProperty.PROJECTION),
|
||||||
this.handleMapProjectionChanged, false, this);
|
this.handleMapProjectionChanged, false, this);
|
||||||
|
|
||||||
goog.events.listen(map.getViewport(), goog.events.EventType.MOUSEMOVE,
|
goog.events.listen(map.getViewport(), goog.events.EventType.MOUSEMOVE,
|
||||||
@@ -68,13 +68,13 @@ ol.control.MousePosition =
|
|||||||
this.handleMapProjectionChanged();
|
this.handleMapProjectionChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.MousePosition, ol.Control);
|
goog.inherits(ol3.control.MousePosition, ol3.Control);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.getElement = function() {
|
ol3.control.MousePosition.prototype.getElement = function() {
|
||||||
return this.divElement_;
|
return this.divElement_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,14 +82,14 @@ ol.control.MousePosition.prototype.getElement = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.handleMapProjectionChanged = function() {
|
ol3.control.MousePosition.prototype.handleMapProjectionChanged = function() {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var mapProjection = map.getProjection();
|
var mapProjection = map.getProjection();
|
||||||
if (!goog.isDef(mapProjection) || goog.isNull(this.projection_)) {
|
if (!goog.isDef(mapProjection) || goog.isNull(this.projection_)) {
|
||||||
this.transform_ = ol.Projection.identityTransform;
|
this.transform_ = ol3.Projection.identityTransform;
|
||||||
} else {
|
} else {
|
||||||
this.transform_ =
|
this.transform_ =
|
||||||
ol.Projection.getTransform(mapProjection, this.projection_);
|
ol3.Projection.getTransform(mapProjection, this.projection_);
|
||||||
}
|
}
|
||||||
// FIXME should we instead re-calculate using the last known mouse position?
|
// FIXME should we instead re-calculate using the last known mouse position?
|
||||||
this.divElement_.innerHTML = this.undefinedHTML_;
|
this.divElement_.innerHTML = this.undefinedHTML_;
|
||||||
@@ -100,9 +100,9 @@ ol.control.MousePosition.prototype.handleMapProjectionChanged = function() {
|
|||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.handleMouseMove = function(browserEvent) {
|
ol3.control.MousePosition.prototype.handleMouseMove = function(browserEvent) {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var pixel = new ol.Pixel(browserEvent.offsetX, browserEvent.offsetY);
|
var pixel = new ol3.Pixel(browserEvent.offsetX, browserEvent.offsetY);
|
||||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||||
var html;
|
var html;
|
||||||
if (goog.isDef(coordinate)) {
|
if (goog.isDef(coordinate)) {
|
||||||
@@ -123,6 +123,6 @@ ol.control.MousePosition.prototype.handleMouseMove = function(browserEvent) {
|
|||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.handleMouseOut = function(browserEvent) {
|
ol3.control.MousePosition.prototype.handleMouseOut = function(browserEvent) {
|
||||||
this.divElement_.innerHTML = this.undefinedHTML_;
|
this.divElement_.innerHTML = this.undefinedHTML_;
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.dom');
|
goog.provide('ol3.dom');
|
||||||
|
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
|
|
||||||
@@ -6,4 +6,4 @@ goog.require('goog.functions');
|
|||||||
/**
|
/**
|
||||||
* @return {boolean} Is supported.
|
* @return {boolean} Is supported.
|
||||||
*/
|
*/
|
||||||
ol.dom.isSupported = goog.functions.TRUE;
|
ol3.dom.isSupported = goog.functions.TRUE;
|
||||||
84
src/ol3/dom/layerrenderer.js
Normal file
84
src/ol3/dom/layerrenderer.js
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
goog.provide('ol3.dom.LayerRenderer');
|
||||||
|
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.LayerRenderer');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.LayerRenderer}
|
||||||
|
* @param {ol3.MapRenderer} mapRenderer Map renderer.
|
||||||
|
* @param {ol3.Layer} layer Layer.
|
||||||
|
* @param {!Element} target Target.
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer = function(mapRenderer, layer, target) {
|
||||||
|
goog.base(this, mapRenderer, layer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {!Element}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.target = target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Top left corner of the target in map coords.
|
||||||
|
*
|
||||||
|
* @type {ol3.Coordinate}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.origin = null;
|
||||||
|
|
||||||
|
this.handleLayerOpacityChange();
|
||||||
|
this.handleLayerVisibleChange();
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.dom.LayerRenderer, ol3.LayerRenderer);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
* @return {ol3.MapRenderer} Map renderer.
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.getMapRenderer = function() {
|
||||||
|
return /** @type {ol3.dom.MapRenderer} */ goog.base(this, 'getMapRenderer');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.handleLayerLoad = function() {
|
||||||
|
this.getMap().render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.handleLayerOpacityChange = function() {
|
||||||
|
goog.style.setOpacity(this.target, this.getLayer().getOpacity());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.handleLayerVisibleChange = function() {
|
||||||
|
goog.style.showElement(this.target, this.getLayer().getVisible());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.render = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the location of the top left corner of the target.
|
||||||
|
*
|
||||||
|
* @param {ol3.Coordinate} origin Origin.
|
||||||
|
*/
|
||||||
|
ol3.dom.LayerRenderer.prototype.setOrigin = function(origin) {
|
||||||
|
this.origin = origin;
|
||||||
|
};
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
goog.provide('ol.dom.MapRenderer');
|
goog.provide('ol3.dom.MapRenderer');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('goog.dom.TagName');
|
goog.require('goog.dom.TagName');
|
||||||
goog.require('goog.style');
|
goog.require('goog.style');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Map');
|
goog.require('ol3.Map');
|
||||||
goog.require('ol.MapRenderer');
|
goog.require('ol3.MapRenderer');
|
||||||
goog.require('ol.TileLayer');
|
goog.require('ol3.TileLayer');
|
||||||
goog.require('ol.dom.TileLayerRenderer');
|
goog.require('ol3.dom.TileLayerRenderer');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.MapRenderer}
|
* @extends {ol3.MapRenderer}
|
||||||
* @param {Element} container Container.
|
* @param {Element} container Container.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer = function(container, map) {
|
ol3.dom.MapRenderer = function(container, map) {
|
||||||
|
|
||||||
goog.base(this, container, map);
|
goog.base(this, container, map);
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ ol.dom.MapRenderer = function(container, map) {
|
|||||||
this.layerPanes_ = {};
|
this.layerPanes_ = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Coordinate|undefined}
|
* @type {ol3.Coordinate|undefined}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.renderedCenter_ = undefined;
|
this.renderedCenter_ = undefined;
|
||||||
@@ -46,27 +46,27 @@ ol.dom.MapRenderer = function(container, map) {
|
|||||||
/**
|
/**
|
||||||
* The pixel offset of the layers pane with respect to its container.
|
* The pixel offset of the layers pane with respect to its container.
|
||||||
*
|
*
|
||||||
* @type {ol.Coordinate}
|
* @type {ol3.Coordinate}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.layersPaneOffset_ = null;
|
this.layersPaneOffset_ = null;
|
||||||
};
|
};
|
||||||
goog.inherits(ol.dom.MapRenderer, ol.MapRenderer);
|
goog.inherits(ol3.dom.MapRenderer, ol3.MapRenderer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.createLayerRenderer = function(layer) {
|
ol3.dom.MapRenderer.prototype.createLayerRenderer = function(layer) {
|
||||||
|
|
||||||
if (layer instanceof ol.TileLayer) {
|
if (layer instanceof ol3.TileLayer) {
|
||||||
|
|
||||||
var layerPane = goog.dom.createElement(goog.dom.TagName.DIV);
|
var layerPane = goog.dom.createElement(goog.dom.TagName.DIV);
|
||||||
layerPane.className = 'ol-layer';
|
layerPane.className = 'ol-layer';
|
||||||
layerPane.style.position = 'absolute';
|
layerPane.style.position = 'absolute';
|
||||||
goog.dom.appendChild(this.layersPane_, layerPane);
|
goog.dom.appendChild(this.layersPane_, layerPane);
|
||||||
|
|
||||||
var layerRenderer = new ol.dom.TileLayerRenderer(this, layer, layerPane);
|
var layerRenderer = new ol3.dom.TileLayerRenderer(this, layer, layerPane);
|
||||||
|
|
||||||
this.layerPanes_[goog.getUid(layerRenderer)] = layerPane;
|
this.layerPanes_[goog.getUid(layerRenderer)] = layerPane;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ ol.dom.MapRenderer.prototype.createLayerRenderer = function(layer) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.handleCenterChanged = function() {
|
ol3.dom.MapRenderer.prototype.handleCenterChanged = function() {
|
||||||
goog.base(this, 'handleCenterChanged');
|
goog.base(this, 'handleCenterChanged');
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (!map.isDef()) {
|
if (!map.isDef()) {
|
||||||
@@ -102,7 +102,7 @@ ol.dom.MapRenderer.prototype.handleCenterChanged = function() {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.handleResolutionChanged = function() {
|
ol3.dom.MapRenderer.prototype.handleResolutionChanged = function() {
|
||||||
goog.base(this, 'handleResolutionChanged');
|
goog.base(this, 'handleResolutionChanged');
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (!map.isDef()) {
|
if (!map.isDef()) {
|
||||||
@@ -119,8 +119,8 @@ ol.dom.MapRenderer.prototype.handleResolutionChanged = function() {
|
|||||||
* Reset the layers pane to its initial position.
|
* Reset the layers pane to its initial position.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.resetLayersPane_ = function() {
|
ol3.dom.MapRenderer.prototype.resetLayersPane_ = function() {
|
||||||
var offset = new ol.Coordinate(0, 0);
|
var offset = new ol3.Coordinate(0, 0);
|
||||||
goog.style.setPosition(this.layersPane_, offset);
|
goog.style.setPosition(this.layersPane_, offset);
|
||||||
|
|
||||||
this.layersPaneOffset_ = offset;
|
this.layersPaneOffset_ = offset;
|
||||||
@@ -134,13 +134,13 @@ ol.dom.MapRenderer.prototype.resetLayersPane_ = function() {
|
|||||||
* Set the origin for each layer renderer.
|
* Set the origin for each layer renderer.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.setOrigin_ = function() {
|
ol3.dom.MapRenderer.prototype.setOrigin_ = function() {
|
||||||
var center = this.map.getCenter();
|
var center = this.map.getCenter();
|
||||||
var resolution = this.map.getResolution();
|
var resolution = this.map.getResolution();
|
||||||
var targetSize = this.map.getSize();
|
var targetSize = this.map.getSize();
|
||||||
var targetWidth = targetSize.width;
|
var targetWidth = targetSize.width;
|
||||||
var targetHeight = targetSize.height;
|
var targetHeight = targetSize.height;
|
||||||
var origin = new ol.Coordinate(
|
var origin = new ol3.Coordinate(
|
||||||
center.x - resolution * targetWidth / 2,
|
center.x - resolution * targetWidth / 2,
|
||||||
center.y + resolution * targetHeight / 2);
|
center.y + resolution * targetHeight / 2);
|
||||||
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
||||||
@@ -153,7 +153,7 @@ ol.dom.MapRenderer.prototype.setOrigin_ = function() {
|
|||||||
* Move the layers pane.
|
* Move the layers pane.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.dom.MapRenderer.prototype.shiftLayersPane_ = function() {
|
ol3.dom.MapRenderer.prototype.shiftLayersPane_ = function() {
|
||||||
var center = this.map.getCenter();
|
var center = this.map.getCenter();
|
||||||
var oldCenter = this.renderedCenter_;
|
var oldCenter = this.renderedCenter_;
|
||||||
var resolution = this.map.getResolution();
|
var resolution = this.map.getResolution();
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
goog.provide('ol.dom.TileLayerRenderer');
|
goog.provide('ol3.dom.TileLayerRenderer');
|
||||||
|
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol3.Extent');
|
||||||
goog.require('ol.dom.LayerRenderer');
|
goog.require('ol3.dom.LayerRenderer');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.dom.LayerRenderer}
|
* @extends {ol3.dom.LayerRenderer}
|
||||||
* @param {ol.MapRenderer} mapRenderer Map renderer.
|
* @param {ol3.MapRenderer} mapRenderer Map renderer.
|
||||||
* @param {ol.TileLayer} tileLayer Tile layer.
|
* @param {ol3.TileLayer} tileLayer Tile layer.
|
||||||
* @param {!Element} target Target.
|
* @param {!Element} target Target.
|
||||||
*/
|
*/
|
||||||
ol.dom.TileLayerRenderer = function(mapRenderer, tileLayer, target) {
|
ol3.dom.TileLayerRenderer = function(mapRenderer, tileLayer, target) {
|
||||||
goog.base(this, mapRenderer, tileLayer, target);
|
goog.base(this, mapRenderer, tileLayer, target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,15 +29,15 @@ ol.dom.TileLayerRenderer = function(mapRenderer, tileLayer, target) {
|
|||||||
*/
|
*/
|
||||||
this.renderedMapResolution_ = undefined;
|
this.renderedMapResolution_ = undefined;
|
||||||
};
|
};
|
||||||
goog.inherits(ol.dom.TileLayerRenderer, ol.dom.LayerRenderer);
|
goog.inherits(ol3.dom.TileLayerRenderer, ol3.dom.LayerRenderer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
* @return {ol.TileLayer} Layer.
|
* @return {ol3.TileLayer} Layer.
|
||||||
*/
|
*/
|
||||||
ol.dom.TileLayerRenderer.prototype.getLayer = function() {
|
ol3.dom.TileLayerRenderer.prototype.getLayer = function() {
|
||||||
return /** @type {ol.TileLayer} */ goog.base(this, 'getLayer');
|
return /** @type {ol3.TileLayer} */ goog.base(this, 'getLayer');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -46,14 +46,14 @@ ol.dom.TileLayerRenderer.prototype.getLayer = function() {
|
|||||||
* @private
|
* @private
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @return {ol.Coordinate} Offset.
|
* @return {ol3.Coordinate} Offset.
|
||||||
*/
|
*/
|
||||||
ol.dom.TileLayerRenderer.prototype.getTileOffset_ = function(z, resolution) {
|
ol3.dom.TileLayerRenderer.prototype.getTileOffset_ = function(z, resolution) {
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
var tileStore = tileLayer.getStore();
|
var tileStore = tileLayer.getStore();
|
||||||
var tileGrid = tileStore.getTileGrid();
|
var tileGrid = tileStore.getTileGrid();
|
||||||
var tileOrigin = tileGrid.getOrigin(z);
|
var tileOrigin = tileGrid.getOrigin(z);
|
||||||
var offset = new ol.Coordinate(
|
var offset = new ol3.Coordinate(
|
||||||
Math.round((this.origin.x - tileOrigin.x) / resolution),
|
Math.round((this.origin.x - tileOrigin.x) / resolution),
|
||||||
Math.round((tileOrigin.y - this.origin.y) / resolution));
|
Math.round((tileOrigin.y - this.origin.y) / resolution));
|
||||||
return offset;
|
return offset;
|
||||||
@@ -63,14 +63,14 @@ ol.dom.TileLayerRenderer.prototype.getTileOffset_ = function(z, resolution) {
|
|||||||
/**
|
/**
|
||||||
* Get rid of tiles outside the rendered extent.
|
* Get rid of tiles outside the rendered extent.
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
* @param {ol3.TileBounds} tileBounds Tile bounds.
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
*/
|
*/
|
||||||
ol.dom.TileLayerRenderer.prototype.removeInvisibleTiles_ = function(
|
ol3.dom.TileLayerRenderer.prototype.removeInvisibleTiles_ = function(
|
||||||
tileBounds, z) {
|
tileBounds, z) {
|
||||||
var key, tileCoord, prune, tile;
|
var key, tileCoord, prune, tile;
|
||||||
for (key in this.renderedTiles_) {
|
for (key in this.renderedTiles_) {
|
||||||
tileCoord = ol.TileCoord.createFromString(key);
|
tileCoord = ol3.TileCoord.createFromString(key);
|
||||||
prune = z !== tileCoord.z ||
|
prune = z !== tileCoord.z ||
|
||||||
tileCoord.x < tileBounds.minX ||
|
tileCoord.x < tileBounds.minX ||
|
||||||
tileCoord.x > tileBounds.maxX ||
|
tileCoord.x > tileBounds.maxX ||
|
||||||
@@ -88,13 +88,13 @@ ol.dom.TileLayerRenderer.prototype.removeInvisibleTiles_ = function(
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.dom.TileLayerRenderer.prototype.render = function() {
|
ol3.dom.TileLayerRenderer.prototype.render = function() {
|
||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (!map.isDef()) {
|
if (!map.isDef()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var mapExtent = /** @type {!ol.Extent} */ map.getExtent();
|
var mapExtent = /** @type {!ol3.Extent} */ map.getExtent();
|
||||||
var mapResolution = /** @type {number} */ map.getResolution();
|
var mapResolution = /** @type {number} */ map.getResolution();
|
||||||
|
|
||||||
var tileLayer = this.getLayer();
|
var tileLayer = this.getLayer();
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
goog.provide('ol.interaction.AltDragRotate');
|
goog.provide('ol3.interaction.AltDragRotate');
|
||||||
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Drag');
|
goog.require('ol3.interaction.Drag');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.interaction.Drag}
|
* @extends {ol3.interaction.Drag}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.AltDragRotate = function(constraints) {
|
ol3.interaction.AltDragRotate = function(constraints) {
|
||||||
|
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
|
|
||||||
@@ -21,13 +21,13 @@ ol.interaction.AltDragRotate = function(constraints) {
|
|||||||
this.startRotation_ = 0;
|
this.startRotation_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.AltDragRotate, ol.interaction.Drag);
|
goog.inherits(ol3.interaction.AltDragRotate, ol3.interaction.Drag);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
ol3.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
@@ -41,7 +41,7 @@ ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.AltDragRotate.prototype.handleDragStart =
|
ol3.interaction.AltDragRotate.prototype.handleDragStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
47
src/ol3/interaction/centerconstraint.js
Normal file
47
src/ol3/interaction/centerconstraint.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
goog.provide('ol3.interaction.CenterConstraint');
|
||||||
|
goog.provide('ol3.interaction.CenterConstraintType');
|
||||||
|
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {function((ol3.Coordinate|undefined),
|
||||||
|
* (number|undefined),
|
||||||
|
* ol3.Coordinate): (ol3.Coordinate|undefined)}
|
||||||
|
*/
|
||||||
|
ol3.interaction.CenterConstraintType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate|undefined} center Center.
|
||||||
|
* @param {number|undefined} resolution Resolution.
|
||||||
|
* @param {ol3.Coordinate} delta Delta.
|
||||||
|
* @return {ol3.Coordinate|undefined} Center.
|
||||||
|
*/
|
||||||
|
ol3.interaction.CenterConstraint.none = function(center, resolution, delta) {
|
||||||
|
if (goog.isDefAndNotNull(center) && goog.isDef(resolution)) {
|
||||||
|
var x = center.x + delta.x;
|
||||||
|
var y = center.y + delta.y;
|
||||||
|
return new ol3.Coordinate(x, y);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol3.Coordinate|undefined} center Center.
|
||||||
|
* @param {number|undefined} resolution Resolution.
|
||||||
|
* @param {ol3.Coordinate} delta Delta.
|
||||||
|
* @return {ol3.Coordinate|undefined} Center.
|
||||||
|
*/
|
||||||
|
ol3.interaction.CenterConstraint.snapToPixel =
|
||||||
|
function(center, resolution, delta) {
|
||||||
|
if (goog.isDefAndNotNull(center) && goog.isDef(resolution)) {
|
||||||
|
var x = Math.floor((center.x + delta.x) / resolution + 0.5) * resolution;
|
||||||
|
var y = Math.floor((center.y + delta.y) / resolution + 0.5) * resolution;
|
||||||
|
return new ol3.Coordinate(x, y);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
36
src/ol3/interaction/constraints.js
Normal file
36
src/ol3/interaction/constraints.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
goog.provide('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
goog.require('ol3.interaction.CenterConstraintType');
|
||||||
|
goog.require('ol3.interaction.ResolutionConstraintType');
|
||||||
|
goog.require('ol3.interaction.RotationConstraintType');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {ol3.interaction.CenterConstraintType} centerConstraint
|
||||||
|
* Center constraint.
|
||||||
|
* @param {ol3.interaction.ResolutionConstraintType} resolutionConstraint
|
||||||
|
* Resolution constraint.
|
||||||
|
* @param {ol3.interaction.RotationConstraintType} rotationConstraint
|
||||||
|
* Rotation constraint.
|
||||||
|
*/
|
||||||
|
ol3.interaction.Constraints =
|
||||||
|
function(centerConstraint, resolutionConstraint, rotationConstraint) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol3.interaction.CenterConstraintType}
|
||||||
|
*/
|
||||||
|
this.center = centerConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol3.interaction.ResolutionConstraintType}
|
||||||
|
*/
|
||||||
|
this.resolution = resolutionConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol3.interaction.RotationConstraintType}
|
||||||
|
*/
|
||||||
|
this.rotation = rotationConstraint;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
goog.provide('ol.interaction.DblClickZoom');
|
goog.provide('ol3.interaction.DblClickZoom');
|
||||||
|
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.DblClickZoom = function(constraints) {
|
ol3.interaction.DblClickZoom = function(constraints) {
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.DblClickZoom, ol.Interaction);
|
goog.inherits(ol3.interaction.DblClickZoom, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.DblClickZoom.prototype.handleMapBrowserEvent =
|
ol3.interaction.DblClickZoom.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (browserEvent.type == goog.events.EventType.DBLCLICK &&
|
if (browserEvent.type == goog.events.EventType.DBLCLICK &&
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
|
|
||||||
goog.provide('ol.interaction.Drag');
|
goog.provide('ol3.interaction.Drag');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Drag = function(constraints) {
|
ol3.interaction.Drag = function(constraints) {
|
||||||
|
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
|
|
||||||
@@ -47,45 +47,45 @@ ol.interaction.Drag = function(constraints) {
|
|||||||
this.offsetY = 0;
|
this.offsetY = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Coordinate}
|
* @type {ol3.Coordinate}
|
||||||
*/
|
*/
|
||||||
this.startCenter = null;
|
this.startCenter = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Coordinate}
|
* @type {ol3.Coordinate}
|
||||||
*/
|
*/
|
||||||
this.startCoordinate = null;
|
this.startCoordinate = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.Drag, ol.Interaction);
|
goog.inherits(ol3.interaction.Drag, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
|
* @param {ol3.MapBrowserEvent} mapBrowserEvent Event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.interaction.Drag.prototype.handleDrag = goog.nullFunction;
|
ol3.interaction.Drag.prototype.handleDrag = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
|
* @param {ol3.MapBrowserEvent} mapBrowserEvent Event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.interaction.Drag.prototype.handleDragEnd = goog.nullFunction;
|
ol3.interaction.Drag.prototype.handleDragEnd = goog.nullFunction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
|
* @param {ol3.MapBrowserEvent} mapBrowserEvent Event.
|
||||||
* @protected
|
* @protected
|
||||||
* @return {boolean} Capture dragging.
|
* @return {boolean} Capture dragging.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Drag.prototype.handleDragStart = goog.functions.FALSE;
|
ol3.interaction.Drag.prototype.handleDragStart = goog.functions.FALSE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.Drag.prototype.handleMapBrowserEvent =
|
ol3.interaction.Drag.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
if (!map.isDef()) {
|
if (!map.isDef()) {
|
||||||
@@ -111,8 +111,8 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent =
|
|||||||
this.startY = browserEvent.clientY;
|
this.startY = browserEvent.clientY;
|
||||||
this.deltaX = 0;
|
this.deltaX = 0;
|
||||||
this.deltaY = 0;
|
this.deltaY = 0;
|
||||||
this.startCenter = /** @type {!ol.Coordinate} */ map.getCenter();
|
this.startCenter = /** @type {!ol3.Coordinate} */ map.getCenter();
|
||||||
this.startCoordinate = /** @type {ol.Coordinate} */
|
this.startCoordinate = /** @type {ol3.Coordinate} */
|
||||||
mapBrowserEvent.getCoordinate();
|
mapBrowserEvent.getCoordinate();
|
||||||
if (this.handleDragStart(mapBrowserEvent)) {
|
if (this.handleDragStart(mapBrowserEvent)) {
|
||||||
this.dragging_ = true;
|
this.dragging_ = true;
|
||||||
48
src/ol3/interaction/dragpan.js
Normal file
48
src/ol3/interaction/dragpan.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
goog.provide('ol3.interaction.DragPan');
|
||||||
|
|
||||||
|
goog.require('ol3.Coordinate');
|
||||||
|
goog.require('ol3.MapBrowserEvent');
|
||||||
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
goog.require('ol3.interaction.Drag');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.interaction.Drag}
|
||||||
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
|
*/
|
||||||
|
ol3.interaction.DragPan = function(constraints) {
|
||||||
|
goog.base(this, constraints);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.interaction.DragPan, ol3.interaction.Drag);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||||
|
var map = mapBrowserEvent.map;
|
||||||
|
var resolution = map.getResolution();
|
||||||
|
var rotation = map.getRotation();
|
||||||
|
var delta =
|
||||||
|
new ol3.Coordinate(-resolution * this.deltaX, resolution * this.deltaY);
|
||||||
|
if (map.canRotate() && goog.isDef(rotation)) {
|
||||||
|
delta.rotate(rotation);
|
||||||
|
}
|
||||||
|
this.pan(map, delta, this.startCenter);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
|
if (!browserEvent.shiftKey) {
|
||||||
|
browserEvent.preventDefault();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
// FIXME factor out key precondition (shift et. al)
|
// FIXME factor out key precondition (shift et. al)
|
||||||
|
|
||||||
goog.provide('ol.Interaction');
|
goog.provide('ol3.Interaction');
|
||||||
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.Interaction = function(constraints) {
|
ol3.Interaction = function(constraints) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {ol.interaction.Constraints}
|
* @type {ol3.interaction.Constraints}
|
||||||
*/
|
*/
|
||||||
this.constraints = constraints;
|
this.constraints = constraints;
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@ ol.Interaction = function(constraints) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol3.Extent} extent Extent.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.fitExtent = function(map, extent) {
|
ol3.Interaction.prototype.fitExtent = function(map, extent) {
|
||||||
var resolution = map.getResolutionForExtent(extent);
|
var resolution = map.getResolutionForExtent(extent);
|
||||||
resolution = this.constraints.resolution(resolution, 0);
|
resolution = this.constraints.resolution(resolution, 0);
|
||||||
var center = extent.getCenter();
|
var center = extent.getCenter();
|
||||||
center = this.constraints.center(center, resolution, ol.Coordinate.ZERO);
|
center = this.constraints.center(center, resolution, ol3.Coordinate.ZERO);
|
||||||
map.withFrozenRendering(function() {
|
map.withFrozenRendering(function() {
|
||||||
map.setCenter(center);
|
map.setCenter(center);
|
||||||
map.setResolution(resolution);
|
map.setResolution(resolution);
|
||||||
@@ -39,17 +39,17 @@ ol.Interaction.prototype.fitExtent = function(map, extent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
* @param {ol3.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.handleMapBrowserEvent = goog.abstractMethod;
|
ol3.Interaction.prototype.handleMapBrowserEvent = goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {ol.Coordinate} delta Delta.
|
* @param {ol3.Coordinate} delta Delta.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor.
|
* @param {ol3.Coordinate=} opt_anchor Anchor.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.pan = function(map, delta, opt_anchor) {
|
ol3.Interaction.prototype.pan = function(map, delta, opt_anchor) {
|
||||||
var center = opt_anchor ? opt_anchor : map.getCenter();
|
var center = opt_anchor ? opt_anchor : map.getCenter();
|
||||||
var resolution = map.getResolution();
|
var resolution = map.getResolution();
|
||||||
center = this.constraints.center(center, resolution, delta);
|
center = this.constraints.center(center, resolution, delta);
|
||||||
@@ -58,12 +58,12 @@ ol.Interaction.prototype.pan = function(map, delta, opt_anchor) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {number|undefined} rotation Rotation.
|
* @param {number|undefined} rotation Rotation.
|
||||||
* @param {number} delta Delta.
|
* @param {number} delta Delta.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor.
|
* @param {ol3.Coordinate=} opt_anchor Anchor.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.rotate = function(map, rotation, delta, opt_anchor) {
|
ol3.Interaction.prototype.rotate = function(map, rotation, delta, opt_anchor) {
|
||||||
// FIXME handle rotation about anchor
|
// FIXME handle rotation about anchor
|
||||||
rotation = this.constraints.rotation(rotation, delta);
|
rotation = this.constraints.rotation(rotation, delta);
|
||||||
map.setRotation(rotation);
|
map.setRotation(rotation);
|
||||||
@@ -71,31 +71,31 @@ ol.Interaction.prototype.rotate = function(map, rotation, delta, opt_anchor) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {number|undefined} resolution Resolution.
|
* @param {number|undefined} resolution Resolution.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.setResolution = function(map, resolution) {
|
ol3.Interaction.prototype.setResolution = function(map, resolution) {
|
||||||
resolution = this.constraints.resolution(resolution, 0);
|
resolution = this.constraints.resolution(resolution, 0);
|
||||||
map.setResolution(resolution);
|
map.setResolution(resolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol3.Map} map Map.
|
||||||
* @param {number|undefined} resolution Resolution.
|
* @param {number|undefined} resolution Resolution.
|
||||||
* @param {number} delta Delta.
|
* @param {number} delta Delta.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor.
|
* @param {ol3.Coordinate=} opt_anchor Anchor.
|
||||||
*/
|
*/
|
||||||
ol.Interaction.prototype.zoom = function(map, resolution, delta, opt_anchor) {
|
ol3.Interaction.prototype.zoom = function(map, resolution, delta, opt_anchor) {
|
||||||
if (goog.isDefAndNotNull(opt_anchor)) {
|
if (goog.isDefAndNotNull(opt_anchor)) {
|
||||||
var anchor = opt_anchor;
|
var anchor = opt_anchor;
|
||||||
var mapCenter = /** @type {!ol.Coordinate} */ map.getCenter();
|
var mapCenter = /** @type {!ol3.Coordinate} */ map.getCenter();
|
||||||
var mapResolution = map.getResolution();
|
var mapResolution = map.getResolution();
|
||||||
resolution = this.constraints.resolution(resolution, delta);
|
resolution = this.constraints.resolution(resolution, delta);
|
||||||
var x = anchor.x - resolution * (anchor.x - mapCenter.x) / mapResolution;
|
var x = anchor.x - resolution * (anchor.x - mapCenter.x) / mapResolution;
|
||||||
var y = anchor.y - resolution * (anchor.y - mapCenter.y) / mapResolution;
|
var y = anchor.y - resolution * (anchor.y - mapCenter.y) / mapResolution;
|
||||||
var center = new ol.Coordinate(x, y);
|
var center = new ol3.Coordinate(x, y);
|
||||||
center = this.constraints.center(center, resolution, ol.Coordinate.ZERO);
|
center = this.constraints.center(center, resolution, ol3.Coordinate.ZERO);
|
||||||
map.withFrozenRendering(function() {
|
map.withFrozenRendering(function() {
|
||||||
map.setCenter(center);
|
map.setCenter(center);
|
||||||
map.setResolution(resolution);
|
map.setResolution(resolution);
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
// FIXME this class is ugly and should be removed
|
// FIXME this class is ugly and should be removed
|
||||||
|
|
||||||
goog.provide('ol.interaction.Keyboard');
|
goog.provide('ol3.interaction.Keyboard');
|
||||||
|
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
*/
|
*/
|
||||||
ol.interaction.Keyboard = function() {
|
ol3.interaction.Keyboard = function() {
|
||||||
|
|
||||||
goog.base(this, null);
|
goog.base(this, null);
|
||||||
|
|
||||||
@@ -21,14 +21,14 @@ ol.interaction.Keyboard = function() {
|
|||||||
this.charCodeCallbacks_ = {};
|
this.charCodeCallbacks_ = {};
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.Keyboard, ol.Interaction);
|
goog.inherits(ol3.interaction.Keyboard, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} s String.
|
* @param {string} s String.
|
||||||
* @param {Function} callback Callback.
|
* @param {Function} callback Callback.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Keyboard.prototype.addCallback = function(s, callback) {
|
ol3.interaction.Keyboard.prototype.addCallback = function(s, callback) {
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < s.length; ++i) {
|
for (i = 0; i < s.length; ++i) {
|
||||||
this.charCodeCallbacks_[s.charCodeAt(i)] = callback;
|
this.charCodeCallbacks_[s.charCodeAt(i)] = callback;
|
||||||
@@ -39,7 +39,7 @@ ol.interaction.Keyboard.prototype.addCallback = function(s, callback) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.Keyboard.prototype.handleMapBrowserEvent =
|
ol3.interaction.Keyboard.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
||||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
goog.provide('ol.interaction.KeyboardPan');
|
goog.provide('ol3.interaction.KeyboardPan');
|
||||||
|
|
||||||
goog.require('goog.events.KeyCodes');
|
goog.require('goog.events.KeyCodes');
|
||||||
goog.require('goog.events.KeyHandler.EventType');
|
goog.require('goog.events.KeyHandler.EventType');
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
* @param {number} pixelDelta Pixel delta.
|
* @param {number} pixelDelta Pixel delta.
|
||||||
*/
|
*/
|
||||||
ol.interaction.KeyboardPan = function(constraints, pixelDelta) {
|
ol3.interaction.KeyboardPan = function(constraints, pixelDelta) {
|
||||||
|
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
|
|
||||||
@@ -24,13 +24,13 @@ ol.interaction.KeyboardPan = function(constraints, pixelDelta) {
|
|||||||
this.pixelDelta_ = pixelDelta;
|
this.pixelDelta_ = pixelDelta;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.KeyboardPan, ol.Interaction);
|
goog.inherits(ol3.interaction.KeyboardPan, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
ol3.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
||||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||||
@@ -45,14 +45,14 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
var delta;
|
var delta;
|
||||||
var mapUnitsDelta = resolution * this.pixelDelta_;
|
var mapUnitsDelta = resolution * this.pixelDelta_;
|
||||||
if (keyCode == goog.events.KeyCodes.DOWN) {
|
if (keyCode == goog.events.KeyCodes.DOWN) {
|
||||||
delta = new ol.Coordinate(0, -mapUnitsDelta);
|
delta = new ol3.Coordinate(0, -mapUnitsDelta);
|
||||||
} else if (keyCode == goog.events.KeyCodes.LEFT) {
|
} else if (keyCode == goog.events.KeyCodes.LEFT) {
|
||||||
delta = new ol.Coordinate(-mapUnitsDelta, 0);
|
delta = new ol3.Coordinate(-mapUnitsDelta, 0);
|
||||||
} else if (keyCode == goog.events.KeyCodes.RIGHT) {
|
} else if (keyCode == goog.events.KeyCodes.RIGHT) {
|
||||||
delta = new ol.Coordinate(mapUnitsDelta, 0);
|
delta = new ol3.Coordinate(mapUnitsDelta, 0);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(keyCode == goog.events.KeyCodes.UP);
|
goog.asserts.assert(keyCode == goog.events.KeyCodes.UP);
|
||||||
delta = new ol.Coordinate(0, mapUnitsDelta);
|
delta = new ol3.Coordinate(0, mapUnitsDelta);
|
||||||
}
|
}
|
||||||
this.pan(map, delta);
|
this.pan(map, delta);
|
||||||
keyEvent.preventDefault();
|
keyEvent.preventDefault();
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
goog.provide('ol.interaction.KeyboardZoom');
|
goog.provide('ol3.interaction.KeyboardZoom');
|
||||||
|
|
||||||
goog.require('goog.events.KeyCodes');
|
goog.require('goog.events.KeyCodes');
|
||||||
goog.require('goog.events.KeyHandler.EventType');
|
goog.require('goog.events.KeyHandler.EventType');
|
||||||
goog.require('ol.Interaction');
|
goog.require('ol3.Interaction');
|
||||||
goog.require('ol.interaction.ResolutionConstraintType');
|
goog.require('ol3.interaction.ResolutionConstraintType');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.KeyboardZoom = function(constraints) {
|
ol3.interaction.KeyboardZoom = function(constraints) {
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.KeyboardZoom, ol.Interaction);
|
goog.inherits(ol3.interaction.KeyboardZoom, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
ol3.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
||||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
goog.provide('ol.interaction.MouseWheelZoom');
|
goog.provide('ol3.interaction.MouseWheelZoom');
|
||||||
|
|
||||||
goog.require('goog.events.MouseWheelEvent');
|
goog.require('goog.events.MouseWheelEvent');
|
||||||
goog.require('goog.events.MouseWheelHandler.EventType');
|
goog.require('goog.events.MouseWheelHandler.EventType');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Interaction}
|
* @extends {ol3.Interaction}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.MouseWheelZoom = function(constraints) {
|
ol3.interaction.MouseWheelZoom = function(constraints) {
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.MouseWheelZoom, ol.Interaction);
|
goog.inherits(ol3.interaction.MouseWheelZoom, ol3.Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
ol3.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (mapBrowserEvent.type ==
|
if (mapBrowserEvent.type ==
|
||||||
goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) {
|
goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) {
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
goog.provide('ol.interaction.ResolutionConstraint');
|
goog.provide('ol3.interaction.ResolutionConstraint');
|
||||||
goog.provide('ol.interaction.ResolutionConstraintType');
|
goog.provide('ol3.interaction.ResolutionConstraintType');
|
||||||
|
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('ol.array');
|
goog.require('ol3.array');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function((number|undefined), number): (number|undefined)}
|
* @typedef {function((number|undefined), number): (number|undefined)}
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraintType;
|
ol3.interaction.ResolutionConstraintType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} power Power.
|
* @param {number} power Power.
|
||||||
* @param {number} maxResolution Maximum resolution.
|
* @param {number} maxResolution Maximum resolution.
|
||||||
* @param {number=} opt_minResolution Minimum resolution.
|
* @param {number=} opt_minResolution Minimum resolution.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol3.interaction.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createContinuous =
|
ol3.interaction.ResolutionConstraint.createContinuous =
|
||||||
function(power, maxResolution, opt_minResolution) {
|
function(power, maxResolution, opt_minResolution) {
|
||||||
var minResolution = opt_minResolution || 0;
|
var minResolution = opt_minResolution || 0;
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
@@ -33,13 +33,13 @@ ol.interaction.ResolutionConstraint.createContinuous =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} resolutions Resolutions.
|
* @param {Array.<number>} resolutions Resolutions.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol3.interaction.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions =
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions =
|
||||||
function(resolutions) {
|
function(resolutions) {
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
var z = ol.array.linearFindNearest(resolutions, resolution);
|
var z = ol3.array.linearFindNearest(resolutions, resolution);
|
||||||
z = goog.math.clamp(z + delta, 0, resolutions.length - 1);
|
z = goog.math.clamp(z + delta, 0, resolutions.length - 1);
|
||||||
return resolutions[z];
|
return resolutions[z];
|
||||||
} else {
|
} else {
|
||||||
@@ -53,9 +53,9 @@ ol.interaction.ResolutionConstraint.createSnapToResolutions =
|
|||||||
* @param {number} power Power.
|
* @param {number} power Power.
|
||||||
* @param {number} maxResolution Maximum resolution.
|
* @param {number} maxResolution Maximum resolution.
|
||||||
* @param {number=} opt_maxLevel Maximum level.
|
* @param {number=} opt_maxLevel Maximum level.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol3.interaction.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower =
|
ol3.interaction.ResolutionConstraint.createSnapToPower =
|
||||||
function(power, maxResolution, opt_maxLevel) {
|
function(power, maxResolution, opt_maxLevel) {
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
goog.require('goog.testing.jsunit');
|
||||||
goog.require('ol.interaction.ResolutionConstraint');
|
goog.require('ol3.interaction.ResolutionConstraint');
|
||||||
|
|
||||||
|
|
||||||
function testSnapToResolutionsZero() {
|
function testSnapToResolutionsZero() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(1000, resolutionConstraint(1000, 0));
|
assertEquals(1000, resolutionConstraint(1000, 0));
|
||||||
assertEquals(500, resolutionConstraint(500, 0));
|
assertEquals(500, resolutionConstraint(500, 0));
|
||||||
@@ -15,7 +15,7 @@ function testSnapToResolutionsZero() {
|
|||||||
|
|
||||||
function testSnapToResolutionsZoomIn() {
|
function testSnapToResolutionsZoomIn() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(500, resolutionConstraint(1000, 1));
|
assertEquals(500, resolutionConstraint(1000, 1));
|
||||||
assertEquals(250, resolutionConstraint(500, 1));
|
assertEquals(250, resolutionConstraint(500, 1));
|
||||||
@@ -26,7 +26,7 @@ function testSnapToResolutionsZoomIn() {
|
|||||||
|
|
||||||
function testSnapToResolutionsZoomOut() {
|
function testSnapToResolutionsZoomOut() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(1000, resolutionConstraint(1000, -1));
|
assertEquals(1000, resolutionConstraint(1000, -1));
|
||||||
assertEquals(1000, resolutionConstraint(500, -1));
|
assertEquals(1000, resolutionConstraint(500, -1));
|
||||||
@@ -37,7 +37,7 @@ function testSnapToResolutionsZoomOut() {
|
|||||||
|
|
||||||
function testSnapToResolutionsNearestZero() {
|
function testSnapToResolutionsNearestZero() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(1000, resolutionConstraint(1050, 0));
|
assertEquals(1000, resolutionConstraint(1050, 0));
|
||||||
assertEquals(1000, resolutionConstraint(950, 0));
|
assertEquals(1000, resolutionConstraint(950, 0));
|
||||||
@@ -52,7 +52,7 @@ function testSnapToResolutionsNearestZero() {
|
|||||||
|
|
||||||
function testSnapToResolutionsNearestZoomIn() {
|
function testSnapToResolutionsNearestZoomIn() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(500, resolutionConstraint(1050, 1));
|
assertEquals(500, resolutionConstraint(1050, 1));
|
||||||
assertEquals(500, resolutionConstraint(950, 1));
|
assertEquals(500, resolutionConstraint(950, 1));
|
||||||
@@ -67,7 +67,7 @@ function testSnapToResolutionsNearestZoomIn() {
|
|||||||
|
|
||||||
function testSnapToResolutionsNearestZoomOut() {
|
function testSnapToResolutionsNearestZoomOut() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol3.interaction.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
assertEquals(1000, resolutionConstraint(1050, -1));
|
assertEquals(1000, resolutionConstraint(1050, -1));
|
||||||
assertEquals(1000, resolutionConstraint(950, -1));
|
assertEquals(1000, resolutionConstraint(950, -1));
|
||||||
@@ -82,7 +82,7 @@ function testSnapToResolutionsNearestZoomOut() {
|
|||||||
|
|
||||||
function testSnapToPowerZero() {
|
function testSnapToPowerZero() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol3.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
assertEquals(1024, resolutionConstraint(1024, 0));
|
assertEquals(1024, resolutionConstraint(1024, 0));
|
||||||
assertEquals(512, resolutionConstraint(512, 0));
|
assertEquals(512, resolutionConstraint(512, 0));
|
||||||
assertEquals(256, resolutionConstraint(256, 0));
|
assertEquals(256, resolutionConstraint(256, 0));
|
||||||
@@ -99,7 +99,7 @@ function testSnapToPowerZero() {
|
|||||||
|
|
||||||
function testSnapToPowerZoomIn() {
|
function testSnapToPowerZoomIn() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol3.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
assertEquals(512, resolutionConstraint(1024, 1));
|
assertEquals(512, resolutionConstraint(1024, 1));
|
||||||
assertEquals(256, resolutionConstraint(512, 1));
|
assertEquals(256, resolutionConstraint(512, 1));
|
||||||
assertEquals(128, resolutionConstraint(256, 1));
|
assertEquals(128, resolutionConstraint(256, 1));
|
||||||
@@ -116,7 +116,7 @@ function testSnapToPowerZoomIn() {
|
|||||||
|
|
||||||
function testSnapToPowerZoomOut() {
|
function testSnapToPowerZoomOut() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol3.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
assertEquals(1024, resolutionConstraint(1024, -1));
|
assertEquals(1024, resolutionConstraint(1024, -1));
|
||||||
assertEquals(1024, resolutionConstraint(512, -1));
|
assertEquals(1024, resolutionConstraint(512, -1));
|
||||||
assertEquals(512, resolutionConstraint(256, -1));
|
assertEquals(512, resolutionConstraint(256, -1));
|
||||||
@@ -133,7 +133,7 @@ function testSnapToPowerZoomOut() {
|
|||||||
|
|
||||||
function testSnapToPowerNearestZero() {
|
function testSnapToPowerNearestZero() {
|
||||||
var resolutionConstraint =
|
var resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol3.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
assertEquals(1024, resolutionConstraint(1050, 0));
|
assertEquals(1024, resolutionConstraint(1050, 0));
|
||||||
assertEquals(1024, resolutionConstraint(9050, 0));
|
assertEquals(1024, resolutionConstraint(9050, 0));
|
||||||
assertEquals(512, resolutionConstraint(550, 0));
|
assertEquals(512, resolutionConstraint(550, 0));
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
goog.provide('ol.interaction.RotationConstraint');
|
goog.provide('ol3.interaction.RotationConstraint');
|
||||||
goog.provide('ol.interaction.RotationConstraintType');
|
goog.provide('ol3.interaction.RotationConstraintType');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function((number|undefined), number): (number|undefined)}
|
* @typedef {function((number|undefined), number): (number|undefined)}
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraintType;
|
ol3.interaction.RotationConstraintType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +13,7 @@ ol.interaction.RotationConstraintType;
|
|||||||
* @param {number} delta Delta.
|
* @param {number} delta Delta.
|
||||||
* @return {number|undefined} Rotation.
|
* @return {number|undefined} Rotation.
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraint.none = function(rotation, delta) {
|
ol3.interaction.RotationConstraint.none = function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
return rotation + delta;
|
return rotation + delta;
|
||||||
} else {
|
} else {
|
||||||
@@ -24,9 +24,9 @@ ol.interaction.RotationConstraint.none = function(rotation, delta) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} n N.
|
* @param {number} n N.
|
||||||
* @return {ol.interaction.RotationConstraintType} Rotation constraint.
|
* @return {ol3.interaction.RotationConstraintType} Rotation constraint.
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraint.createSnapToN = function(n) {
|
ol3.interaction.RotationConstraint.createSnapToN = function(n) {
|
||||||
var theta = 2 * Math.PI / n;
|
var theta = 2 * Math.PI / n;
|
||||||
return function(rotation, delta) {
|
return function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
goog.provide('ol.interaction.ShiftDragRotateAndZoom');
|
goog.provide('ol3.interaction.ShiftDragRotateAndZoom');
|
||||||
|
|
||||||
goog.require('goog.math.Vec2');
|
goog.require('goog.math.Vec2');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol3.MapBrowserEvent');
|
||||||
goog.require('ol.interaction.Constraints');
|
goog.require('ol3.interaction.Constraints');
|
||||||
goog.require('ol.interaction.Drag');
|
goog.require('ol3.interaction.Drag');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.interaction.Drag}
|
* @extends {ol3.interaction.Drag}
|
||||||
* @param {ol.interaction.Constraints} constraints Constraints.
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ShiftDragRotateAndZoom = function(constraints) {
|
ol3.interaction.ShiftDragRotateAndZoom = function(constraints) {
|
||||||
|
|
||||||
goog.base(this, constraints);
|
goog.base(this, constraints);
|
||||||
|
|
||||||
@@ -29,13 +29,13 @@ ol.interaction.ShiftDragRotateAndZoom = function(constraints) {
|
|||||||
this.startRotation_ = 0;
|
this.startRotation_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.ShiftDragRotateAndZoom, ol.interaction.Drag);
|
goog.inherits(ol3.interaction.ShiftDragRotateAndZoom, ol3.interaction.Drag);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
ol3.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
@@ -54,7 +54,7 @@ ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDragStart =
|
ol3.interaction.ShiftDragRotateAndZoom.prototype.handleDragStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
65
src/ol3/interaction/shiftdragzoom.js
Normal file
65
src/ol3/interaction/shiftdragzoom.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
// FIXME draw drag box
|
||||||
|
|
||||||
|
goog.provide('ol3.interaction.ShiftDragZoom');
|
||||||
|
|
||||||
|
goog.require('ol3.Extent');
|
||||||
|
goog.require('ol3.MapBrowserEvent');
|
||||||
|
goog.require('ol3.interaction.Constraints');
|
||||||
|
goog.require('ol3.interaction.Drag');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {number} Hysterisis pixels.
|
||||||
|
*/
|
||||||
|
ol3.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS = 8;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const {number}
|
||||||
|
*/
|
||||||
|
ol3.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED =
|
||||||
|
ol3.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS *
|
||||||
|
ol3.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.interaction.Drag}
|
||||||
|
* @param {ol3.interaction.Constraints} constraints Constraints.
|
||||||
|
*/
|
||||||
|
ol3.interaction.ShiftDragZoom = function(constraints) {
|
||||||
|
goog.base(this, constraints);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.interaction.ShiftDragZoom, ol3.interaction.Drag);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||||
|
function(mapBrowserEvent) {
|
||||||
|
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
||||||
|
ol3.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
||||||
|
var map = mapBrowserEvent.map;
|
||||||
|
var extent = ol3.Extent.boundingExtent(
|
||||||
|
this.startCoordinate,
|
||||||
|
mapBrowserEvent.getCoordinate());
|
||||||
|
this.fitExtent(map, extent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol3.interaction.ShiftDragZoom.prototype.handleDragStart =
|
||||||
|
function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
|
if (browserEvent.isMouseActionButton() && browserEvent.shiftKey) {
|
||||||
|
browserEvent.preventDefault();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
goog.provide('ol.layer.BingMaps');
|
goog.provide('ol3.layer.BingMaps');
|
||||||
goog.provide('ol.tilestore.BingMaps');
|
goog.provide('ol3.tilestore.BingMaps');
|
||||||
|
|
||||||
goog.require('goog.Uri');
|
goog.require('goog.Uri');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.net.Jsonp');
|
goog.require('goog.net.Jsonp');
|
||||||
goog.require('ol.TileCoverageArea');
|
goog.require('ol3.TileCoverageArea');
|
||||||
goog.require('ol.TileLayer');
|
goog.require('ol3.TileLayer');
|
||||||
goog.require('ol.TileStore');
|
goog.require('ol3.TileStore');
|
||||||
goog.require('ol.tilegrid.XYZ');
|
goog.require('ol3.tilegrid.XYZ');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.BingMapsStyle = {
|
ol3.BingMapsStyle = {
|
||||||
AERIAL: 'Aerial',
|
AERIAL: 'Aerial',
|
||||||
AERIAL_WITH_LABELS: 'AerialWithLabels',
|
AERIAL_WITH_LABELS: 'AerialWithLabels',
|
||||||
ROAD: 'Road',
|
ROAD: 'Road',
|
||||||
@@ -26,33 +26,33 @@ ol.BingMapsStyle = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.TileLayer}
|
* @extends {ol3.TileLayer}
|
||||||
* @param {ol.BingMapsStyle} style Bing Maps style.
|
* @param {ol3.BingMapsStyle} style Bing Maps style.
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @param {string=} opt_culture Culture.
|
* @param {string=} opt_culture Culture.
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
*/
|
*/
|
||||||
ol.layer.BingMaps = function(style, key, opt_culture, opt_values) {
|
ol3.layer.BingMaps = function(style, key, opt_culture, opt_values) {
|
||||||
var tileStore = new ol.tilestore.BingMaps(style, key, opt_culture,
|
var tileStore = new ol3.tilestore.BingMaps(style, key, opt_culture,
|
||||||
function(tileStore) {
|
function(tileStore) {
|
||||||
this.dispatchEvent(goog.events.EventType.LOAD);
|
this.dispatchEvent(goog.events.EventType.LOAD);
|
||||||
}, this);
|
}, this);
|
||||||
goog.base(this, tileStore, opt_values);
|
goog.base(this, tileStore, opt_values);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.layer.BingMaps, ol.TileLayer);
|
goog.inherits(ol3.layer.BingMaps, ol3.TileLayer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.TileStore}
|
* @extends {ol3.TileStore}
|
||||||
* @param {ol.BingMapsStyle} style Bing Maps style.
|
* @param {ol3.BingMapsStyle} style Bing Maps style.
|
||||||
* @param {string} key Key.
|
* @param {string} key Key.
|
||||||
* @param {string=} opt_culture Culture.
|
* @param {string=} opt_culture Culture.
|
||||||
* @param {?function(ol.tilestore.BingMaps)=} opt_callback Callback.
|
* @param {?function(ol3.tilestore.BingMaps)=} opt_callback Callback.
|
||||||
* @param {*=} opt_obj Object.
|
* @param {*=} opt_obj Object.
|
||||||
*/
|
*/
|
||||||
ol.tilestore.BingMaps =
|
ol3.tilestore.BingMaps =
|
||||||
function(style, key, opt_culture, opt_callback, opt_obj) {
|
function(style, key, opt_culture, opt_callback, opt_obj) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +69,7 @@ ol.tilestore.BingMaps =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {?function(ol.tilestore.BingMaps)}
|
* @type {?function(ol3.tilestore.BingMaps)}
|
||||||
*/
|
*/
|
||||||
this.callback_ = opt_callback || null;
|
this.callback_ = opt_callback || null;
|
||||||
|
|
||||||
@@ -87,20 +87,20 @@ ol.tilestore.BingMaps =
|
|||||||
'key': key
|
'key': key
|
||||||
}, goog.bind(this.handleImageryMetadataResponse, this));
|
}, goog.bind(this.handleImageryMetadataResponse, this));
|
||||||
|
|
||||||
var projection = ol.Projection.getFromCode('EPSG:3857');
|
var projection = ol3.Projection.getFromCode('EPSG:3857');
|
||||||
var extent = projection.getExtent();
|
var extent = projection.getExtent();
|
||||||
|
|
||||||
goog.base(
|
goog.base(
|
||||||
this, projection, null, ol.TileUrlFunction.nullTileUrlFunction, extent);
|
this, projection, null, ol3.TileUrlFunction.nullTileUrlFunction, extent);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.tilestore.BingMaps, ol.TileStore);
|
goog.inherits(ol3.tilestore.BingMaps, ol3.TileStore);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {BingMapsImageryMetadataResponse} response Response.
|
* @param {BingMapsImageryMetadataResponse} response Response.
|
||||||
*/
|
*/
|
||||||
ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
ol3.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
||||||
function(response) {
|
function(response) {
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
@@ -117,11 +117,11 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
|
|
||||||
var zoomMin = resource.zoomMin;
|
var zoomMin = resource.zoomMin;
|
||||||
var zoomMax = resource.zoomMax;
|
var zoomMax = resource.zoomMax;
|
||||||
var tileSize = new ol.Size(resource.imageWidth, resource.imageHeight);
|
var tileSize = new ol3.Size(resource.imageWidth, resource.imageHeight);
|
||||||
var tileGrid = new ol.tilegrid.XYZ(zoomMax, tileSize);
|
var tileGrid = new ol3.tilegrid.XYZ(zoomMax, tileSize);
|
||||||
this.tileGrid = tileGrid;
|
this.tileGrid = tileGrid;
|
||||||
|
|
||||||
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
this.tileUrlFunction = ol3.TileUrlFunction.withTileCoordTransform(
|
||||||
function(tileCoord) {
|
function(tileCoord) {
|
||||||
if (tileCoord.z < zoomMin || zoomMax < tileCoord.z) {
|
if (tileCoord.z < zoomMin || zoomMax < tileCoord.z) {
|
||||||
return null;
|
return null;
|
||||||
@@ -132,10 +132,10 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
var x = goog.math.modulo(tileCoord.x, n);
|
var x = goog.math.modulo(tileCoord.x, n);
|
||||||
return new ol.TileCoord(tileCoord.z, x, y);
|
return new ol3.TileCoord(tileCoord.z, x, y);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ol.TileUrlFunction.createFromTileUrlFunctions(
|
ol3.TileUrlFunction.createFromTileUrlFunctions(
|
||||||
goog.array.map(
|
goog.array.map(
|
||||||
resource.imageUrlSubdomains,
|
resource.imageUrlSubdomains,
|
||||||
function(subdomain) {
|
function(subdomain) {
|
||||||
@@ -152,7 +152,7 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
};
|
};
|
||||||
})));
|
})));
|
||||||
|
|
||||||
var projection = ol.Projection.getFromCode('EPSG:4326');
|
var projection = ol3.Projection.getFromCode('EPSG:4326');
|
||||||
var attributions = goog.array.map(
|
var attributions = goog.array.map(
|
||||||
resource.imageryProviders,
|
resource.imageryProviders,
|
||||||
function(imageryProvider) {
|
function(imageryProvider) {
|
||||||
@@ -161,12 +161,12 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
imageryProvider.coverageAreas,
|
imageryProvider.coverageAreas,
|
||||||
function(coverageArea) {
|
function(coverageArea) {
|
||||||
var bbox = coverageArea.bbox;
|
var bbox = coverageArea.bbox;
|
||||||
var extent = new ol.Extent(bbox[1], bbox[0], bbox[3], bbox[2]);
|
var extent = new ol3.Extent(bbox[1], bbox[0], bbox[3], bbox[2]);
|
||||||
var minZ = coverageArea.zoomMin;
|
var minZ = coverageArea.zoomMin;
|
||||||
var maxZ = coverageArea.zoomMax;
|
var maxZ = coverageArea.zoomMax;
|
||||||
return new ol.TileCoverageArea(tileGrid, extent, minZ, maxZ);
|
return new ol3.TileCoverageArea(tileGrid, extent, minZ, maxZ);
|
||||||
});
|
});
|
||||||
return new ol.Attribution(html, coverageAreas, projection);
|
return new ol3.Attribution(html, coverageAreas, projection);
|
||||||
});
|
});
|
||||||
this.setAttributions(attributions);
|
this.setAttributions(attributions);
|
||||||
|
|
||||||
@@ -184,6 +184,6 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.tilestore.BingMaps.prototype.isReady = function() {
|
ol3.tilestore.BingMaps.prototype.isReady = function() {
|
||||||
return this.ready_;
|
return this.ready_;
|
||||||
};
|
};
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
goog.provide('ol.layer.MapQuestOSM');
|
goog.provide('ol3.layer.MapQuestOSM');
|
||||||
goog.provide('ol.layer.MapQuestOpenAerial');
|
goog.provide('ol3.layer.MapQuestOpenAerial');
|
||||||
|
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol3.Attribution');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol3.TileUrlFunction');
|
||||||
goog.require('ol.layer.XYZ');
|
goog.require('ol3.layer.XYZ');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.layer.XYZ}
|
* @extends {ol3.layer.XYZ}
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
*/
|
*/
|
||||||
ol.layer.MapQuestOSM = function(opt_values) {
|
ol3.layer.MapQuestOSM = function(opt_values) {
|
||||||
|
|
||||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(
|
var tileUrlFunction = ol3.TileUrlFunction.createFromTemplate(
|
||||||
'http://otile{1-4}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg');
|
'http://otile{1-4}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg');
|
||||||
|
|
||||||
var attributions = [
|
var attributions = [
|
||||||
new ol.Attribution(
|
new ol3.Attribution(
|
||||||
'Tiles Courtesy of ' +
|
'Tiles Courtesy of ' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a> ' +
|
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a> ' +
|
||||||
'<img src="http://developer.mapquest.com/content/osm/mq_logo.png">'),
|
'<img src="http://developer.mapquest.com/content/osm/mq_logo.png">'),
|
||||||
new ol.Attribution(
|
new ol3.Attribution(
|
||||||
'Data © ' +
|
'Data © ' +
|
||||||
'<a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
'<a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
||||||
'contributors, ' +
|
'contributors, ' +
|
||||||
@@ -32,26 +32,26 @@ ol.layer.MapQuestOSM = function(opt_values) {
|
|||||||
goog.base(this, 18, tileUrlFunction, attributions);
|
goog.base(this, 18, tileUrlFunction, attributions);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.layer.MapQuestOSM, ol.layer.XYZ);
|
goog.inherits(ol3.layer.MapQuestOSM, ol3.layer.XYZ);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.layer.XYZ}
|
* @extends {ol3.layer.XYZ}
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
*/
|
*/
|
||||||
ol.layer.MapQuestOpenAerial = function(opt_values) {
|
ol3.layer.MapQuestOpenAerial = function(opt_values) {
|
||||||
|
|
||||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(
|
var tileUrlFunction = ol3.TileUrlFunction.createFromTemplate(
|
||||||
'http://oatile{1-4}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg');
|
'http://oatile{1-4}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg');
|
||||||
|
|
||||||
var attributions = [
|
var attributions = [
|
||||||
new ol.Attribution(
|
new ol3.Attribution(
|
||||||
'Tiles Courtesy of ' +
|
'Tiles Courtesy of ' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a> ' +
|
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a> ' +
|
||||||
'<img src="http://developer.mapquest.com/content/osm/mq_logo.png">'),
|
'<img src="http://developer.mapquest.com/content/osm/mq_logo.png">'),
|
||||||
new ol.Attribution(
|
new ol3.Attribution(
|
||||||
'Portions Courtesy NASA/JPL-Caltech and ' +
|
'Portions Courtesy NASA/JPL-Caltech and ' +
|
||||||
'U.S. Depart. of Agriculture, Farm Service Agency')
|
'U.S. Depart. of Agriculture, Farm Service Agency')
|
||||||
];
|
];
|
||||||
@@ -59,4 +59,4 @@ ol.layer.MapQuestOpenAerial = function(opt_values) {
|
|||||||
goog.base(this, 18, tileUrlFunction, attributions);
|
goog.base(this, 18, tileUrlFunction, attributions);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.layer.MapQuestOpenAerial, ol.layer.XYZ);
|
goog.inherits(ol3.layer.MapQuestOpenAerial, ol3.layer.XYZ);
|
||||||
40
src/ol3/tile/openstreetmap.js
Normal file
40
src/ol3/tile/openstreetmap.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
goog.provide('ol3.layer.OpenStreetMap');
|
||||||
|
goog.provide('ol3.store.OpenStreetMap');
|
||||||
|
|
||||||
|
goog.require('ol3.TileLayer');
|
||||||
|
goog.require('ol3.TileUrlFunction');
|
||||||
|
goog.require('ol3.tilestore.XYZ');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.TileLayer}
|
||||||
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
|
*/
|
||||||
|
ol3.layer.OpenStreetMap = function(opt_values) {
|
||||||
|
var tileStore = new ol3.store.OpenStreetMap();
|
||||||
|
goog.base(this, tileStore, opt_values);
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.layer.OpenStreetMap, ol3.TileLayer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol3.tilestore.XYZ}
|
||||||
|
*/
|
||||||
|
ol3.store.OpenStreetMap = function() {
|
||||||
|
|
||||||
|
var tileUrlFunction = ol3.TileUrlFunction.createFromTemplate(
|
||||||
|
'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png');
|
||||||
|
|
||||||
|
var attribution = new ol3.Attribution(
|
||||||
|
'© <a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
||||||
|
'contributors, ' +
|
||||||
|
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>');
|
||||||
|
|
||||||
|
goog.base(this, 18, tileUrlFunction, [attribution]);
|
||||||
|
|
||||||
|
};
|
||||||
|
goog.inherits(ol3.store.OpenStreetMap, ol3.tilestore.XYZ);
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
// FIXME Configure minZoom when supported by TileGrid
|
// FIXME Configure minZoom when supported by TileGrid
|
||||||
|
|
||||||
goog.provide('ol.layer.Stamen');
|
goog.provide('ol3.layer.Stamen');
|
||||||
goog.provide('ol.store.Stamen');
|
goog.provide('ol3.store.Stamen');
|
||||||
|
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol3.TileUrlFunction');
|
||||||
goog.require('ol.layer.XYZ');
|
goog.require('ol3.layer.XYZ');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.StamenProvider = {
|
ol3.StamenProvider = {
|
||||||
TERRAIN: 'terrain',
|
TERRAIN: 'terrain',
|
||||||
TONER: 'toner',
|
TONER: 'toner',
|
||||||
WATERCOLOR: 'watercolor'
|
WATERCOLOR: 'watercolor'
|
||||||
@@ -20,7 +20,7 @@ ol.StamenProvider = {
|
|||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
ol.StamenFlavor = {
|
ol3.StamenFlavor = {
|
||||||
TERRAIN_BACKGROUND: 'background',
|
TERRAIN_BACKGROUND: 'background',
|
||||||
TERRAIN_LABELS: 'labels',
|
TERRAIN_LABELS: 'labels',
|
||||||
TERRAIN_LINES: 'lines',
|
TERRAIN_LINES: 'lines',
|
||||||
@@ -38,21 +38,21 @@ ol.StamenFlavor = {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<ol.StamenProvider,
|
* @type {Object.<ol3.StamenProvider,
|
||||||
* {type: string, minZoom: number, maxZoom: number}>}
|
* {type: string, minZoom: number, maxZoom: number}>}
|
||||||
*/
|
*/
|
||||||
ol.StamenProviderConfig = {};
|
ol3.StamenProviderConfig = {};
|
||||||
ol.StamenProviderConfig[ol.StamenProvider.TERRAIN] = {
|
ol3.StamenProviderConfig[ol3.StamenProvider.TERRAIN] = {
|
||||||
type: 'jpg',
|
type: 'jpg',
|
||||||
minZoom: 4,
|
minZoom: 4,
|
||||||
maxZoom: 18
|
maxZoom: 18
|
||||||
};
|
};
|
||||||
ol.StamenProviderConfig[ol.StamenProvider.TONER] = {
|
ol3.StamenProviderConfig[ol3.StamenProvider.TONER] = {
|
||||||
type: 'png',
|
type: 'png',
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
maxZoom: 20
|
maxZoom: 20
|
||||||
};
|
};
|
||||||
ol.StamenProviderConfig[ol.StamenProvider.WATERCOLOR] = {
|
ol3.StamenProviderConfig[ol3.StamenProvider.WATERCOLOR] = {
|
||||||
type: 'jpg',
|
type: 'jpg',
|
||||||
minZoom: 3,
|
minZoom: 3,
|
||||||
maxZoom: 16
|
maxZoom: 16
|
||||||
@@ -62,23 +62,23 @@ ol.StamenProviderConfig[ol.StamenProvider.WATERCOLOR] = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.layer.XYZ}
|
* @extends {ol3.layer.XYZ}
|
||||||
* @param {ol.StamenProvider} provider Provider.
|
* @param {ol3.StamenProvider} provider Provider.
|
||||||
* @param {ol.StamenFlavor=} opt_flavor Flavor.
|
* @param {ol3.StamenFlavor=} opt_flavor Flavor.
|
||||||
* @param {Object.<string, *>=} opt_values Values.
|
* @param {Object.<string, *>=} opt_values Values.
|
||||||
*/
|
*/
|
||||||
ol.layer.Stamen = function(provider, opt_flavor, opt_values) {
|
ol3.layer.Stamen = function(provider, opt_flavor, opt_values) {
|
||||||
|
|
||||||
var config = ol.StamenProviderConfig[provider];
|
var config = ol3.StamenProviderConfig[provider];
|
||||||
|
|
||||||
var layer = provider;
|
var layer = provider;
|
||||||
if (goog.isDef(opt_flavor)) {
|
if (goog.isDef(opt_flavor)) {
|
||||||
layer += '-' + opt_flavor;
|
layer += '-' + opt_flavor;
|
||||||
}
|
}
|
||||||
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(
|
var tileUrlFunction = ol3.TileUrlFunction.createFromTemplate(
|
||||||
'http://{a-d}.tile.stamen.com/' + layer + '/{z}/{x}/{y}.' + config.type);
|
'http://{a-d}.tile.stamen.com/' + layer + '/{z}/{x}/{y}.' + config.type);
|
||||||
|
|
||||||
var attribution = new ol.Attribution(
|
var attribution = new ol3.Attribution(
|
||||||
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
|
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
|
||||||
'under ' +
|
'under ' +
|
||||||
'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. ' +
|
'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. ' +
|
||||||
@@ -89,4 +89,4 @@ ol.layer.Stamen = function(provider, opt_flavor, opt_values) {
|
|||||||
goog.base(this, config.maxZoom, tileUrlFunction, [attribution]);
|
goog.base(this, config.maxZoom, tileUrlFunction, [attribution]);
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.layer.Stamen, ol.layer.XYZ);
|
goog.inherits(ol3.layer.Stamen, ol3.layer.XYZ);
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
goog.provide('ol.Tile');
|
goog.provide('ol3.Tile');
|
||||||
goog.provide('ol.TileState');
|
goog.provide('ol3.TileState');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventTarget');
|
goog.require('goog.events.EventTarget');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol3.TileCoord');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
ol.TileState = {
|
ol3.TileState = {
|
||||||
IDLE: 0,
|
IDLE: 0,
|
||||||
LOADING: 1,
|
LOADING: 1,
|
||||||
LOADED: 2,
|
LOADED: 2,
|
||||||
@@ -23,16 +23,16 @@ ol.TileState = {
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {goog.events.EventTarget}
|
* @extends {goog.events.EventTarget}
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol3.TileCoord} tileCoord Tile coordinate.
|
||||||
* @param {string} src Source.
|
* @param {string} src Source.
|
||||||
* @param {?string} crossOrigin Cross origin.
|
* @param {?string} crossOrigin Cross origin.
|
||||||
*/
|
*/
|
||||||
ol.Tile = function(tileCoord, src, crossOrigin) {
|
ol3.Tile = function(tileCoord, src, crossOrigin) {
|
||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.TileCoord}
|
* @type {ol3.TileCoord}
|
||||||
*/
|
*/
|
||||||
this.tileCoord = tileCoord;
|
this.tileCoord = tileCoord;
|
||||||
|
|
||||||
@@ -44,9 +44,9 @@ ol.Tile = function(tileCoord, src, crossOrigin) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.TileState}
|
* @type {ol3.TileState}
|
||||||
*/
|
*/
|
||||||
this.state_ = ol.TileState.IDLE;
|
this.state_ = ol3.TileState.IDLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -70,13 +70,13 @@ ol.Tile = function(tileCoord, src, crossOrigin) {
|
|||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Tile, goog.events.EventTarget);
|
goog.inherits(ol3.Tile, goog.events.EventTarget);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.dispatchChangeEvent = function() {
|
ol3.Tile.prototype.dispatchChangeEvent = function() {
|
||||||
this.dispatchEvent(goog.events.EventType.CHANGE);
|
this.dispatchEvent(goog.events.EventType.CHANGE);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ ol.Tile.prototype.dispatchChangeEvent = function() {
|
|||||||
* @param {Object=} opt_context Object.
|
* @param {Object=} opt_context Object.
|
||||||
* @return {Image} Image.
|
* @return {Image} Image.
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.getImage = function(opt_context) {
|
ol3.Tile.prototype.getImage = function(opt_context) {
|
||||||
if (goog.isDef(opt_context)) {
|
if (goog.isDef(opt_context)) {
|
||||||
var image;
|
var image;
|
||||||
var key = goog.getUid(opt_context);
|
var key = goog.getUid(opt_context);
|
||||||
@@ -105,9 +105,9 @@ ol.Tile.prototype.getImage = function(opt_context) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.TileState} State.
|
* @return {ol3.TileState} State.
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.getState = function() {
|
ol3.Tile.prototype.getState = function() {
|
||||||
return this.state_;
|
return this.state_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,8 +115,8 @@ ol.Tile.prototype.getState = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.handleImageError_ = function() {
|
ol3.Tile.prototype.handleImageError_ = function() {
|
||||||
this.state_ = ol.TileState.ERROR;
|
this.state_ = ol3.TileState.ERROR;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -124,8 +124,8 @@ ol.Tile.prototype.handleImageError_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.handleImageLoad_ = function() {
|
ol3.Tile.prototype.handleImageLoad_ = function() {
|
||||||
this.state_ = ol.TileState.LOADED;
|
this.state_ = ol3.TileState.LOADED;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
this.dispatchChangeEvent();
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
@@ -133,9 +133,9 @@ ol.Tile.prototype.handleImageLoad_ = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.load = function() {
|
ol3.Tile.prototype.load = function() {
|
||||||
if (this.state_ == ol.TileState.IDLE) {
|
if (this.state_ == ol3.TileState.IDLE) {
|
||||||
this.state_ = ol.TileState.LOADING;
|
this.state_ = ol3.TileState.LOADING;
|
||||||
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
||||||
@@ -151,7 +151,7 @@ ol.Tile.prototype.load = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.unlistenImage_ = function() {
|
ol3.Tile.prototype.unlistenImage_ = function() {
|
||||||
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_));
|
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_));
|
||||||
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
goog.array.forEach(this.imageListenerKeys_, goog.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
goog.provide('ol.TileBounds');
|
goog.provide('ol3.TileBounds');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.Rectangle');
|
goog.require('ol3.Rectangle');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol3.TileCoord');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Rectangle}
|
* @extends {ol3.Rectangle}
|
||||||
* @param {number} minX Minimum X.
|
* @param {number} minX Minimum X.
|
||||||
* @param {number} minY Minimum Y.
|
* @param {number} minY Minimum Y.
|
||||||
* @param {number} maxX Maximum X.
|
* @param {number} maxX Maximum X.
|
||||||
* @param {number} maxY Maximum Y.
|
* @param {number} maxY Maximum Y.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds = function(minX, minY, maxX, maxY) {
|
ol3.TileBounds = function(minX, minY, maxX, maxY) {
|
||||||
goog.base(this, minX, minY, maxX, maxY);
|
goog.base(this, minX, minY, maxX, maxY);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.TileBounds, ol.Rectangle);
|
goog.inherits(ol3.TileBounds, ol3.Rectangle);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {...ol.TileCoord} var_args Tile coordinates.
|
* @param {...ol3.TileCoord} var_args Tile coordinates.
|
||||||
* @return {!ol.TileBounds} Bounding tile box.
|
* @return {!ol3.TileBounds} Bounding tile box.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.boundingTileBounds = function(var_args) {
|
ol3.TileBounds.boundingTileBounds = function(var_args) {
|
||||||
var tileCoord0 = arguments[0];
|
var tileCoord0 = arguments[0];
|
||||||
var tileBounds = new ol.TileBounds(tileCoord0.x, tileCoord0.y,
|
var tileBounds = new ol3.TileBounds(tileCoord0.x, tileCoord0.y,
|
||||||
tileCoord0.x, tileCoord0.y);
|
tileCoord0.x, tileCoord0.y);
|
||||||
var i;
|
var i;
|
||||||
for (i = 1; i < arguments.length; ++i) {
|
for (i = 1; i < arguments.length; ++i) {
|
||||||
var tileCoord = arguments[i];
|
var tileCoord = arguments[i];
|
||||||
@@ -42,38 +42,38 @@ ol.TileBounds.boundingTileBounds = function(var_args) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.TileBounds} Clone.
|
* @return {ol3.TileBounds} Clone.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.clone = function() {
|
ol3.TileBounds.prototype.clone = function() {
|
||||||
return new ol.TileBounds(this.minX, this.minY, this.maxX, this.maxY);
|
return new ol3.TileBounds(this.minX, this.minY, this.maxX, this.maxY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol3.TileCoord} tileCoord Tile coordinate.
|
||||||
* @return {boolean} Contains tile coordinate.
|
* @return {boolean} Contains tile coordinate.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.contains = function(tileCoord) {
|
ol3.TileBounds.prototype.contains = function(tileCoord) {
|
||||||
return this.minX <= tileCoord.x && tileCoord.x <= this.maxX &&
|
return this.minX <= tileCoord.x && tileCoord.x <= this.maxX &&
|
||||||
this.minY <= tileCoord.y && tileCoord.y <= this.maxY;
|
this.minY <= tileCoord.y && tileCoord.y <= this.maxY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
* @param {ol3.TileBounds} tileBounds Tile bounds.
|
||||||
* @return {boolean} Contains.
|
* @return {boolean} Contains.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.containsTileBounds = function(tileBounds) {
|
ol3.TileBounds.prototype.containsTileBounds = function(tileBounds) {
|
||||||
return this.minX <= tileBounds.minX && tileBounds.maxX <= this.maxX &&
|
return this.minX <= tileBounds.minX && tileBounds.maxX <= this.maxX &&
|
||||||
this.minY <= tileBounds.minY && tileBounds.minY <= this.maxY;
|
this.minY <= tileBounds.minY && tileBounds.minY <= this.maxY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
* @param {ol3.TileBounds} tileBounds Tile bounds.
|
||||||
* @return {boolean} Equals.
|
* @return {boolean} Equals.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.equals = function(tileBounds) {
|
ol3.TileBounds.prototype.equals = function(tileBounds) {
|
||||||
return this.minX == tileBounds.minX && tileBounds.maxX == this.maxX &&
|
return this.minX == tileBounds.minX && tileBounds.maxX == this.maxX &&
|
||||||
this.minY == tileBounds.minY && tileBounds.minY == this.minY;
|
this.minY == tileBounds.minY && tileBounds.minY == this.minY;
|
||||||
};
|
};
|
||||||
@@ -81,15 +81,15 @@ ol.TileBounds.prototype.equals = function(tileBounds) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
* @param {function(this: T, ol.TileCoord)} f Callback.
|
* @param {function(this: T, ol3.TileCoord)} f Callback.
|
||||||
* @param {T=} opt_obj The object to be used for the value of 'this' within f.
|
* @param {T=} opt_obj The object to be used for the value of 'this' within f.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
ol3.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
||||||
var x, y;
|
var x, y;
|
||||||
for (x = this.minX; x <= this.maxX; ++x) {
|
for (x = this.minX; x <= this.maxX; ++x) {
|
||||||
for (y = this.minY; y <= this.maxY; ++y) {
|
for (y = this.minY; y <= this.maxY; ++y) {
|
||||||
f.call(opt_obj, new ol.TileCoord(z, x, y));
|
f.call(opt_obj, new ol3.TileCoord(z, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -99,7 +99,7 @@ ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
|||||||
* @override
|
* @override
|
||||||
* @return {number} Height.
|
* @return {number} Height.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.getHeight = function() {
|
ol3.TileBounds.prototype.getHeight = function() {
|
||||||
return this.maxY - this.minY + 1;
|
return this.maxY - this.minY + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,6 +108,6 @@ ol.TileBounds.prototype.getHeight = function() {
|
|||||||
* @override
|
* @override
|
||||||
* @return {number} Width.
|
* @return {number} Width.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.getWidth = function() {
|
ol3.TileBounds.prototype.getWidth = function() {
|
||||||
return this.maxX - this.minX + 1;
|
return this.maxX - this.minX + 1;
|
||||||
};
|
};
|
||||||
102
src/ol3/tile/tilebounds_test.js
Normal file
102
src/ol3/tile/tilebounds_test.js
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
goog.require('goog.testing.jsunit');
|
||||||
|
goog.require('ol3.TileBounds');
|
||||||
|
|
||||||
|
|
||||||
|
function testClone() {
|
||||||
|
var tileBounds = new ol3.TileBounds(1, 2, 3, 4);
|
||||||
|
var clonedTileBounds = tileBounds.clone();
|
||||||
|
assertTrue(clonedTileBounds instanceof ol3.TileBounds);
|
||||||
|
assertFalse(clonedTileBounds === tileBounds);
|
||||||
|
assertEquals(tileBounds.minX, clonedTileBounds.minX);
|
||||||
|
assertEquals(tileBounds.minY, clonedTileBounds.minY);
|
||||||
|
assertEquals(tileBounds.maxX, clonedTileBounds.maxX);
|
||||||
|
assertEquals(tileBounds.maxY, clonedTileBounds.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testContains() {
|
||||||
|
var tileBounds = new ol3.TileBounds(1, 1, 3, 3);
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 0, 0)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 0, 1)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 0, 2)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 0, 3)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 0, 4)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 1, 0)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 1, 1)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 1, 2)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 1, 3)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 1, 4)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 2, 0)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 2, 1)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 2, 2)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 2, 3)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 2, 4)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 3, 0)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 3, 1)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 3, 2)));
|
||||||
|
assertTrue(tileBounds.contains(new ol3.TileCoord(0, 3, 3)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 3, 4)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 4, 0)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 4, 1)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 4, 2)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 4, 3)));
|
||||||
|
assertFalse(tileBounds.contains(new ol3.TileCoord(0, 4, 4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBoundingTileBounds() {
|
||||||
|
var tileBounds = new ol3.TileBounds.boundingTileBounds(
|
||||||
|
new ol3.TileCoord(3, 1, 3),
|
||||||
|
new ol3.TileCoord(3, 2, 0));
|
||||||
|
assertEquals(1, tileBounds.minX);
|
||||||
|
assertEquals(0, tileBounds.minY);
|
||||||
|
assertEquals(2, tileBounds.maxX);
|
||||||
|
assertEquals(3, tileBounds.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBoundingTileBoundsMixedZ() {
|
||||||
|
assertThrows(function() {
|
||||||
|
var tileBounds = new ol3.TileBounds.boundingTileBounds(
|
||||||
|
new ol3.TileCoord(3, 1, 3),
|
||||||
|
new ol3.TileCoord(4, 2, 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testForEachTileCoord() {
|
||||||
|
|
||||||
|
var tileBounds = new ol3.TileBounds(0, 2, 1, 3);
|
||||||
|
|
||||||
|
var tileCoords = [];
|
||||||
|
tileBounds.forEachTileCoord(5, function(tileCoord) {
|
||||||
|
tileCoords.push(tileCoord.clone());
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(4, tileCoords.length);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[0].z);
|
||||||
|
assertEquals(0, tileCoords[0].x);
|
||||||
|
assertEquals(2, tileCoords[0].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[1].z);
|
||||||
|
assertEquals(0, tileCoords[1].x);
|
||||||
|
assertEquals(3, tileCoords[1].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[2].z);
|
||||||
|
assertEquals(1, tileCoords[2].x);
|
||||||
|
assertEquals(2, tileCoords[2].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[3].z);
|
||||||
|
assertEquals(1, tileCoords[3].x);
|
||||||
|
assertEquals(3, tileCoords[3].y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testSize() {
|
||||||
|
var tileBounds = new ol3.TileBounds(0, 1, 2, 4);
|
||||||
|
var size = tileBounds.getSize();
|
||||||
|
assertEquals(3, size.width);
|
||||||
|
assertEquals(4, size.height);
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.TileCoord');
|
goog.provide('ol3.TileCoord');
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol3.Coordinate');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
ol.QuadKeyCharCode = {
|
ol3.QuadKeyCharCode = {
|
||||||
ZERO: '0'.charCodeAt(0),
|
ZERO: '0'.charCodeAt(0),
|
||||||
ONE: '1'.charCodeAt(0),
|
ONE: '1'.charCodeAt(0),
|
||||||
TWO: '2'.charCodeAt(0),
|
TWO: '2'.charCodeAt(0),
|
||||||
@@ -18,12 +18,12 @@ ol.QuadKeyCharCode = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Coordinate}
|
* @extends {ol3.Coordinate}
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
* @param {number} x X.
|
* @param {number} x X.
|
||||||
* @param {number} y Y.
|
* @param {number} y Y.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord = function(z, x, y) {
|
ol3.TileCoord = function(z, x, y) {
|
||||||
|
|
||||||
goog.base(this, x, y);
|
goog.base(this, x, y);
|
||||||
|
|
||||||
@@ -33,61 +33,61 @@ ol.TileCoord = function(z, x, y) {
|
|||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.TileCoord, ol.Coordinate);
|
goog.inherits(ol3.TileCoord, ol3.Coordinate);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} quadKey Quad key.
|
* @param {string} quadKey Quad key.
|
||||||
* @return {ol.TileCoord} Tile coordinate.
|
* @return {ol3.TileCoord} Tile coordinate.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.createFromQuadKey = function(quadKey) {
|
ol3.TileCoord.createFromQuadKey = function(quadKey) {
|
||||||
var z = quadKey.length, x = 0, y = 0;
|
var z = quadKey.length, x = 0, y = 0;
|
||||||
var mask = 1 << (z - 1);
|
var mask = 1 << (z - 1);
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < z; ++i) {
|
for (i = 0; i < z; ++i) {
|
||||||
switch (quadKey.charCodeAt(i)) {
|
switch (quadKey.charCodeAt(i)) {
|
||||||
case ol.QuadKeyCharCode.ONE:
|
case ol3.QuadKeyCharCode.ONE:
|
||||||
x += mask;
|
x += mask;
|
||||||
break;
|
break;
|
||||||
case ol.QuadKeyCharCode.TWO:
|
case ol3.QuadKeyCharCode.TWO:
|
||||||
y += mask;
|
y += mask;
|
||||||
break;
|
break;
|
||||||
case ol.QuadKeyCharCode.THREE:
|
case ol3.QuadKeyCharCode.THREE:
|
||||||
x += mask;
|
x += mask;
|
||||||
y += mask;
|
y += mask;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
return new ol.TileCoord(z, x, y);
|
return new ol3.TileCoord(z, x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} str String.
|
* @param {string} str String.
|
||||||
* @return {ol.TileCoord} Tile coord.
|
* @return {ol3.TileCoord} Tile coord.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.createFromString = function(str) {
|
ol3.TileCoord.createFromString = function(str) {
|
||||||
var v = str.split('/');
|
var v = str.split('/');
|
||||||
v = goog.array.map(v, function(e, i, a) {
|
v = goog.array.map(v, function(e, i, a) {
|
||||||
return parseInt(e, 10);
|
return parseInt(e, 10);
|
||||||
});
|
});
|
||||||
return new ol.TileCoord(v[0], v[1], v[2]);
|
return new ol3.TileCoord(v[0], v[1], v[2]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.TileCoord} Clone.
|
* @return {ol3.TileCoord} Clone.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.prototype.clone = function() {
|
ol3.TileCoord.prototype.clone = function() {
|
||||||
return new ol.TileCoord(this.z, this.x, this.y);
|
return new ol3.TileCoord(this.z, this.x, this.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} Hash.
|
* @return {number} Hash.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.prototype.hash = function() {
|
ol3.TileCoord.prototype.hash = function() {
|
||||||
return (this.x << this.z) + this.y;
|
return (this.x << this.z) + this.y;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,12 +95,12 @@ ol.TileCoord.prototype.hash = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {string} Quad key.
|
* @return {string} Quad key.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.prototype.quadKey = function() {
|
ol3.TileCoord.prototype.quadKey = function() {
|
||||||
var digits = new Array(this.z);
|
var digits = new Array(this.z);
|
||||||
var mask = 1 << (this.z - 1);
|
var mask = 1 << (this.z - 1);
|
||||||
var i, charCode;
|
var i, charCode;
|
||||||
for (i = 0; i < this.z; ++i) {
|
for (i = 0; i < this.z; ++i) {
|
||||||
charCode = ol.QuadKeyCharCode.ZERO;
|
charCode = ol3.QuadKeyCharCode.ZERO;
|
||||||
if (this.x & mask) {
|
if (this.x & mask) {
|
||||||
charCode += 1;
|
charCode += 1;
|
||||||
}
|
}
|
||||||
@@ -117,6 +117,6 @@ ol.TileCoord.prototype.quadKey = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {string} String.
|
* @return {string} String.
|
||||||
*/
|
*/
|
||||||
ol.TileCoord.prototype.toString = function() {
|
ol3.TileCoord.prototype.toString = function() {
|
||||||
return [this.z, this.x, this.y].join('/');
|
return [this.z, this.x, this.y].join('/');
|
||||||
};
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user