Compare commits
162 Commits
v3.0.0-gam
...
v3.0.0-gam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8c39bd62c | ||
|
|
b518466968 | ||
|
|
5fb78fb352 | ||
|
|
1a933febcd | ||
|
|
2b4b2dadf7 | ||
|
|
aafa578805 | ||
|
|
e707e918aa | ||
|
|
1c8fc8358a | ||
|
|
f0f9291161 | ||
|
|
4f087f1b84 | ||
|
|
6744713a54 | ||
|
|
d5d5f58809 | ||
|
|
4d150e6b84 | ||
|
|
da74fbf529 | ||
|
|
aeaa172abe | ||
|
|
5a1e92830f | ||
|
|
121d19e0ba | ||
|
|
1d26c1faaf | ||
|
|
512c2032ed | ||
|
|
31fa59c996 | ||
|
|
19757ae3e0 | ||
|
|
7c22d8ffd4 | ||
|
|
ea7c32ff6e | ||
|
|
60c7564268 | ||
|
|
d57a35ffcb | ||
|
|
9dc17230c2 | ||
|
|
a02d21d4b5 | ||
|
|
9640a08c0e | ||
|
|
a737cf0d99 | ||
|
|
7789bff3da | ||
|
|
8e2a12bfc1 | ||
|
|
4541019ff4 | ||
|
|
49b91998f9 | ||
|
|
193adf4401 | ||
|
|
1ae82b054c | ||
|
|
1bb5705b55 | ||
|
|
8f1fdde26e | ||
|
|
4cf8383820 | ||
|
|
fc3ed93080 | ||
|
|
0a01f8ef7e | ||
|
|
90c745006d | ||
|
|
a22d7e4d22 | ||
|
|
20e903f8d9 | ||
|
|
f1bdaed15a | ||
|
|
4bcbda61c6 | ||
|
|
17d059f7bb | ||
|
|
9915bb873c | ||
|
|
befcc4ceea | ||
|
|
88ab1ac61a | ||
|
|
8b2277cdda | ||
|
|
0c62469f50 | ||
|
|
dfe92da58d | ||
|
|
b5bdd0d4bb | ||
|
|
8b89f5b689 | ||
|
|
dc09b0a27f | ||
|
|
971c1137bc | ||
|
|
d215696154 | ||
|
|
38bf0b439a | ||
|
|
82604ff60b | ||
|
|
3a0d0c7290 | ||
|
|
8e555fad5b | ||
|
|
570a0c23a7 | ||
|
|
8d991bd638 | ||
|
|
9b1e9dbc8e | ||
|
|
1933d809e2 | ||
|
|
5fdb380fb6 | ||
|
|
9c6cb9db6d | ||
|
|
26e6260446 | ||
|
|
d0301805c7 | ||
|
|
1f88015db0 | ||
|
|
21878ebad3 | ||
|
|
7e8551a767 | ||
|
|
93716fc7f0 | ||
|
|
d8ca8e7341 | ||
|
|
264a01cfd4 | ||
|
|
8a3f1a8f34 | ||
|
|
70cb7a4a0a | ||
|
|
6f398f93dd | ||
|
|
94ba9aeea9 | ||
|
|
4e0d48386b | ||
|
|
76584c3291 | ||
|
|
b452e04e08 | ||
|
|
f18dbcdb97 | ||
|
|
fa25f2a477 | ||
|
|
043cd0ff41 | ||
|
|
489096e40b | ||
|
|
1951c385a8 | ||
|
|
5a24d022cf | ||
|
|
d99a61545c | ||
|
|
fd659d63e9 | ||
|
|
10f4d0c3d7 | ||
|
|
8b29b52e95 | ||
|
|
4cf5ab4620 | ||
|
|
297503e7c9 | ||
|
|
207e23099a | ||
|
|
0666dee697 | ||
|
|
e0a8bb045a | ||
|
|
c6138edbcb | ||
|
|
52294519bc | ||
|
|
07b02c2a55 | ||
|
|
46149ff6f9 | ||
|
|
a4e923cf4b | ||
|
|
d1820fbce5 | ||
|
|
1626399c08 | ||
|
|
2064d08602 | ||
|
|
1129e0d934 | ||
|
|
234dd91ff2 | ||
|
|
f54398eda3 | ||
|
|
a157ecd788 | ||
|
|
167d13b4f6 | ||
|
|
8c4a55cc65 | ||
|
|
35888d1dc6 | ||
|
|
0ae1cd7cf5 | ||
|
|
152b434f1b | ||
|
|
992e0fa218 | ||
|
|
f89abb53a9 | ||
|
|
4e8c9c5470 | ||
|
|
3ea304f5bf | ||
|
|
04e60a9d37 | ||
|
|
064f95f530 | ||
|
|
18462a2af3 | ||
|
|
76e1ca67a4 | ||
|
|
4fed441eda | ||
|
|
067345a4b0 | ||
|
|
6abba32707 | ||
|
|
d8cc019184 | ||
|
|
b8ab6fd771 | ||
|
|
2e541b43d1 | ||
|
|
abe953e4e5 | ||
|
|
b0a1444da0 | ||
|
|
450d42a4cc | ||
|
|
90f2f96797 | ||
|
|
49aabda1b9 | ||
|
|
f8ba6758a2 | ||
|
|
ef1414c508 | ||
|
|
355ca67b86 | ||
|
|
67c2e46c19 | ||
|
|
a93f7b8190 | ||
|
|
700a0b15b3 | ||
|
|
fdf0525c71 | ||
|
|
17bb8d8ca1 | ||
|
|
927513e1f0 | ||
|
|
fe776b0d1a | ||
|
|
54ea8dc52b | ||
|
|
2e1957c42c | ||
|
|
97e59f0976 | ||
|
|
3e49ea2ba0 | ||
|
|
5adb3a6a8e | ||
|
|
242787da45 | ||
|
|
6b230d3711 | ||
|
|
d3234f1b6a | ||
|
|
4b57f7798f | ||
|
|
203df11c96 | ||
|
|
a3e332c0c2 | ||
|
|
70548b4704 | ||
|
|
00fd5caa92 | ||
|
|
07b41f84d0 | ||
|
|
3bbf9ae720 | ||
|
|
97985934e1 | ||
|
|
60f283d5c0 | ||
|
|
29370a04aa | ||
|
|
c1c98b45b9 |
@@ -3,9 +3,6 @@ before_install:
|
||||
- "npm install -g npm && npm install"
|
||||
|
||||
before_script:
|
||||
- "./build.py plovr"
|
||||
- "./build.py serve-integration-test &"
|
||||
- "rm src/ol/renderer/webgl/*shader.js"
|
||||
- "sleep 3"
|
||||
|
||||
script: "./build.py integration-test"
|
||||
script: "./build.py ci"
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
"source": {
|
||||
"includePattern": ".+\\.js(doc)?$",
|
||||
"excludePattern": "(^|\\/|\\\\)_",
|
||||
"exclude": [
|
||||
"src/googx/dom/fullscreen.js"
|
||||
],
|
||||
"include": [
|
||||
"src",
|
||||
"externs/oli.js",
|
||||
@@ -23,7 +20,6 @@
|
||||
"apidoc/plugins/inheritdoc",
|
||||
"apidoc/plugins/interface",
|
||||
"apidoc/plugins/typedefs",
|
||||
"apidoc/plugins/todo",
|
||||
"apidoc/plugins/events",
|
||||
"apidoc/plugins/observable",
|
||||
"apidoc/plugins/api"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
var util = require('util');
|
||||
exports.defineTags = function(dictionary) {
|
||||
dictionary.defineTag('todo', {
|
||||
mustHaveValue: true,
|
||||
canHaveType: true,
|
||||
canHaveName: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
var parts = tag.text.split(' ');
|
||||
if (parts[0] === 'api') {
|
||||
doclet.stability = parts.slice(1).join(' ') || 'experimental';
|
||||
} else if (parts[0] === 'observable') {
|
||||
doclet.observable = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -11,7 +11,7 @@ In the simplest case, a JSDoc block can look like this:
|
||||
/**
|
||||
* Add the given control to the map.
|
||||
* @param {ol.control.Control} control Control.
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
ol.Map.prototype.addControl = function(control) {
|
||||
// ...
|
||||
@@ -22,7 +22,7 @@ contain Markdown.
|
||||
|
||||
The second line tells the Closure compiler the type of the argument.
|
||||
|
||||
The third line (`@todo api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@todo api stable`. Once the documentation story is fully settled, we will remove the `todo ` and just write `@api` or `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
|
||||
The third line (`@api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
|
||||
|
||||
### Events
|
||||
|
||||
@@ -37,7 +37,7 @@ ol.MapBrowserEvent.EventType = {
|
||||
* A true single click with no dragging and no double click. Note that this
|
||||
* event is delayed by 250 ms to ensure that it is not a double click.
|
||||
* @event ol.MapBrowserEvent#singleclick
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
SINGLECLICK: 'singleclick',
|
||||
// ...
|
||||
@@ -52,7 +52,7 @@ oli.MapBrowserEvent;
|
||||
|
||||
/**
|
||||
* @type {ol.Coordinate}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
oli.MapBrowserEvent.prototype.coordinate;
|
||||
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
"""Generates out a Closure deps.js file given a list of JavaScript sources.
|
||||
|
||||
Paths can be specified as arguments or (more commonly) specifying trees
|
||||
with the flags (call with --help for descriptions).
|
||||
|
||||
Usage: depswriter.py [path/to/js1.js [path/to/js2.js] ...]
|
||||
"""
|
||||
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import posixpath
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
import source
|
||||
import treescan
|
||||
|
||||
|
||||
__author__ = 'nnaze@google.com (Nathan Naze)'
|
||||
|
||||
|
||||
def MakeDepsFile(source_map):
|
||||
"""Make a generated deps file.
|
||||
|
||||
Args:
|
||||
source_map: A dict map of the source path to source.Source object.
|
||||
|
||||
Returns:
|
||||
str, A generated deps file source.
|
||||
"""
|
||||
|
||||
# Write in path alphabetical order
|
||||
paths = sorted(source_map.keys())
|
||||
|
||||
lines = []
|
||||
|
||||
for path in paths:
|
||||
js_source = source_map[path]
|
||||
|
||||
# We don't need to add entries that don't provide anything.
|
||||
if js_source.provides:
|
||||
lines.append(_GetDepsLine(path, js_source))
|
||||
|
||||
return ''.join(lines)
|
||||
|
||||
|
||||
def _GetDepsLine(path, js_source):
|
||||
"""Get a deps.js file string for a source."""
|
||||
|
||||
provides = sorted(js_source.provides)
|
||||
requires = sorted(js_source.requires)
|
||||
|
||||
return 'goog.addDependency(\'%s\', %s, %s);\n' % (path, provides, requires)
|
||||
|
||||
|
||||
def _GetOptionsParser():
|
||||
"""Get the options parser."""
|
||||
|
||||
parser = optparse.OptionParser(__doc__)
|
||||
|
||||
parser.add_option('--output_file',
|
||||
dest='output_file',
|
||||
action='store',
|
||||
help=('If specified, write output to this path instead of '
|
||||
'writing to standard output.'))
|
||||
parser.add_option('--root',
|
||||
dest='roots',
|
||||
default=[],
|
||||
action='append',
|
||||
help='A root directory to scan for JS source files. '
|
||||
'Paths of JS files in generated deps file will be '
|
||||
'relative to this path. This flag may be specified '
|
||||
'multiple times.')
|
||||
parser.add_option('--root_with_prefix',
|
||||
dest='roots_with_prefix',
|
||||
default=[],
|
||||
action='append',
|
||||
help='A root directory to scan for JS source files, plus '
|
||||
'a prefix (if either contains a space, surround with '
|
||||
'quotes). Paths in generated deps file will be relative '
|
||||
'to the root, but preceded by the prefix. This flag '
|
||||
'may be specified multiple times.')
|
||||
parser.add_option('--path_with_depspath',
|
||||
dest='paths_with_depspath',
|
||||
default=[],
|
||||
action='append',
|
||||
help='A path to a source file and an alternate path to '
|
||||
'the file in the generated deps file (if either contains '
|
||||
'a space, surround with whitespace). This flag may be '
|
||||
'specified multiple times.')
|
||||
return parser
|
||||
|
||||
|
||||
def _NormalizePathSeparators(path):
|
||||
"""Replaces OS-specific path separators with POSIX-style slashes.
|
||||
|
||||
Args:
|
||||
path: str, A file path.
|
||||
|
||||
Returns:
|
||||
str, The path with any OS-specific path separators (such as backslash on
|
||||
Windows) replaced with URL-compatible forward slashes. A no-op on systems
|
||||
that use POSIX paths.
|
||||
"""
|
||||
return path.replace(os.sep, posixpath.sep)
|
||||
|
||||
|
||||
def _GetRelativePathToSourceDict(root, prefix=''):
|
||||
"""Scans a top root directory for .js sources.
|
||||
|
||||
Args:
|
||||
root: str, Root directory.
|
||||
prefix: str, Prefix for returned paths.
|
||||
|
||||
Returns:
|
||||
dict, A map of relative paths (with prefix, if given), to source.Source
|
||||
objects.
|
||||
"""
|
||||
# Remember and restore the cwd when we're done. We work from the root so
|
||||
# that paths are relative from the root.
|
||||
start_wd = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
path_to_source = {}
|
||||
for path in treescan.ScanTreeForJsFiles('.'):
|
||||
prefixed_path = _NormalizePathSeparators(os.path.join(prefix, path))
|
||||
path_to_source[prefixed_path] = source.Source(source.GetFileContents(path))
|
||||
|
||||
os.chdir(start_wd)
|
||||
|
||||
return path_to_source
|
||||
|
||||
|
||||
def _GetPair(s):
|
||||
"""Return a string as a shell-parsed tuple. Two values expected."""
|
||||
try:
|
||||
# shlex uses '\' as an escape character, so they must be escaped.
|
||||
s = s.replace('\\', '\\\\')
|
||||
first, second = shlex.split(s)
|
||||
return (first, second)
|
||||
except:
|
||||
raise Exception('Unable to parse input line as a pair: %s' % s)
|
||||
|
||||
|
||||
def main():
|
||||
"""CLI frontend to MakeDepsFile."""
|
||||
logging.basicConfig(format=(sys.argv[0] + ': %(message)s'),
|
||||
level=logging.INFO)
|
||||
options, args = _GetOptionsParser().parse_args()
|
||||
|
||||
path_to_source = {}
|
||||
|
||||
# Roots without prefixes
|
||||
for root in options.roots:
|
||||
path_to_source.update(_GetRelativePathToSourceDict(root))
|
||||
|
||||
# Roots with prefixes
|
||||
for root_and_prefix in options.roots_with_prefix:
|
||||
root, prefix = _GetPair(root_and_prefix)
|
||||
path_to_source.update(_GetRelativePathToSourceDict(root, prefix=prefix))
|
||||
|
||||
# Source paths
|
||||
for path in args:
|
||||
path_to_source[path] = source.Source(source.GetFileContents(path))
|
||||
|
||||
# Source paths with alternate deps paths
|
||||
for path_with_depspath in options.paths_with_depspath:
|
||||
srcpath, depspath = _GetPair(path_with_depspath)
|
||||
path_to_source[depspath] = source.Source(source.GetFileContents(srcpath))
|
||||
|
||||
# Make our output pipe.
|
||||
if options.output_file:
|
||||
out = open(options.output_file, 'w')
|
||||
else:
|
||||
out = sys.stdout
|
||||
|
||||
out.write('// This file was autogenerated by %s.\n' % sys.argv[0])
|
||||
out.write('// Please do not edit.\n')
|
||||
|
||||
out.write(MakeDepsFile(path_to_source))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,114 +0,0 @@
|
||||
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
"""Scans a source JS file for its provided and required namespaces.
|
||||
|
||||
Simple class to scan a JavaScript file and express its dependencies.
|
||||
"""
|
||||
|
||||
__author__ = 'nnaze@google.com'
|
||||
|
||||
|
||||
import re
|
||||
|
||||
_BASE_REGEX_STRING = '^\s*goog\.%s\(\s*[\'"](.+)[\'"]\s*\)'
|
||||
_PROVIDE_REGEX = re.compile(_BASE_REGEX_STRING % 'provide')
|
||||
_REQUIRES_REGEX = re.compile(_BASE_REGEX_STRING % 'require')
|
||||
|
||||
# This line identifies base.js and should match the line in that file.
|
||||
_GOOG_BASE_LINE = (
|
||||
'var goog = goog || {}; // Identifies this file as the Closure base.')
|
||||
|
||||
|
||||
class Source(object):
|
||||
"""Scans a JavaScript source for its provided and required namespaces."""
|
||||
|
||||
# Matches a "/* ... */" comment.
|
||||
# Note: We can't definitively distinguish a "/*" in a string literal without a
|
||||
# state machine tokenizer. We'll assume that a line starting with whitespace
|
||||
# and "/*" is a comment.
|
||||
_COMMENT_REGEX = re.compile(
|
||||
r"""
|
||||
^\s* # Start of a new line and whitespace
|
||||
/\* # Opening "/*"
|
||||
.*? # Non greedy match of any characters (including newlines)
|
||||
\*/ # Closing "*/""",
|
||||
re.MULTILINE | re.DOTALL | re.VERBOSE)
|
||||
|
||||
def __init__(self, source):
|
||||
"""Initialize a source.
|
||||
|
||||
Args:
|
||||
source: str, The JavaScript source.
|
||||
"""
|
||||
|
||||
self.provides = set()
|
||||
self.requires = set()
|
||||
|
||||
self._source = source
|
||||
self._ScanSource()
|
||||
|
||||
def __str__(self):
|
||||
return 'Source %s' % self._path
|
||||
|
||||
def GetSource(self):
|
||||
"""Get the source as a string."""
|
||||
return self._source
|
||||
|
||||
@classmethod
|
||||
def _StripComments(cls, source):
|
||||
return cls._COMMENT_REGEX.sub('', source)
|
||||
|
||||
def _ScanSource(self):
|
||||
"""Fill in provides and requires by scanning the source."""
|
||||
|
||||
source = self._StripComments(self.GetSource())
|
||||
|
||||
source_lines = source.splitlines()
|
||||
for line in source_lines:
|
||||
match = _PROVIDE_REGEX.match(line)
|
||||
if match:
|
||||
self.provides.add(match.group(1))
|
||||
match = _REQUIRES_REGEX.match(line)
|
||||
if match:
|
||||
self.requires.add(match.group(1))
|
||||
|
||||
# Closure's base file implicitly provides 'goog'.
|
||||
for line in source_lines:
|
||||
if line == _GOOG_BASE_LINE:
|
||||
if len(self.provides) or len(self.requires):
|
||||
raise Exception(
|
||||
'Base files should not provide or require namespaces.')
|
||||
self.provides.add('goog')
|
||||
|
||||
|
||||
def GetFileContents(path):
|
||||
"""Get a file's contents as a string.
|
||||
|
||||
Args:
|
||||
path: str, Path to file.
|
||||
|
||||
Returns:
|
||||
str, Contents of file.
|
||||
|
||||
Raises:
|
||||
IOError: An error occurred opening or reading the file.
|
||||
|
||||
"""
|
||||
fileobj = open(path)
|
||||
try:
|
||||
return fileobj.read()
|
||||
finally:
|
||||
fileobj.close()
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2010 The Closure Library Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
"""Shared utility functions for scanning directory trees."""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
__author__ = 'nnaze@google.com (Nathan Naze)'
|
||||
|
||||
|
||||
# Matches a .js file path.
|
||||
_JS_FILE_REGEX = re.compile(r'^.+\.js$')
|
||||
|
||||
|
||||
def ScanTreeForJsFiles(root):
|
||||
"""Scans a directory tree for JavaScript files.
|
||||
|
||||
Args:
|
||||
root: str, Path to a root directory.
|
||||
|
||||
Returns:
|
||||
An iterable of paths to JS files, relative to cwd.
|
||||
"""
|
||||
return ScanTree(root, path_filter=_JS_FILE_REGEX)
|
||||
|
||||
|
||||
def ScanTree(root, path_filter=None, ignore_hidden=True):
|
||||
"""Scans a directory tree for files.
|
||||
|
||||
Args:
|
||||
root: str, Path to a root directory.
|
||||
path_filter: A regular expression filter. If set, only paths matching
|
||||
the path_filter are returned.
|
||||
ignore_hidden: If True, do not follow or return hidden directories or files
|
||||
(those starting with a '.' character).
|
||||
|
||||
Yields:
|
||||
A string path to files, relative to cwd.
|
||||
"""
|
||||
|
||||
def OnError(os_error):
|
||||
raise os_error
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(root, onerror=OnError):
|
||||
# os.walk allows us to modify dirnames to prevent decent into particular
|
||||
# directories. Avoid hidden directories.
|
||||
for dirname in dirnames:
|
||||
if ignore_hidden and dirname.startswith('.'):
|
||||
dirnames.remove(dirname)
|
||||
|
||||
for filename in filenames:
|
||||
|
||||
# nothing that starts with '.'
|
||||
if ignore_hidden and filename.startswith('.'):
|
||||
continue
|
||||
|
||||
fullpath = os.path.join(dirpath, filename)
|
||||
|
||||
if path_filter and not path_filter.match(fullpath):
|
||||
continue
|
||||
|
||||
yield os.path.normpath(fullpath)
|
||||
243
build.py
243
build.py
@@ -100,7 +100,6 @@ EXAMPLES_SRC = [path
|
||||
if not path.startswith('examples/bootstrap')
|
||||
if path != 'examples/Jugl.js'
|
||||
if path != 'examples/jquery.min.js'
|
||||
if path != 'examples/loader.js'
|
||||
if path != 'examples/example-list.js']
|
||||
|
||||
EXAMPLES_JSON = ['build/' + example.replace('.html', '.json')
|
||||
@@ -129,17 +128,6 @@ SRC = [path
|
||||
if path.endswith('.js')
|
||||
if path not in SHADER_SRC]
|
||||
|
||||
LIBTESS_JS_SRC = [path
|
||||
for path in ifind('src/libtess.js')
|
||||
if path.endswith('.js')]
|
||||
|
||||
PLOVR_JAR = 'build/plovr-81ed862.jar'
|
||||
PLOVR_JAR_MD5 = '1c752daaf11ad6220b298e7d2ee2b87d'
|
||||
|
||||
PROJ4JS = 'build/proj4js/lib/proj4js-combined.js'
|
||||
PROJ4JS_ZIP = 'build/proj4js-1.1.0.zip'
|
||||
PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897'
|
||||
|
||||
|
||||
def report_sizes(t):
|
||||
stringio = StringIO()
|
||||
@@ -157,7 +145,7 @@ def report_sizes(t):
|
||||
virtual('default', 'build')
|
||||
|
||||
|
||||
virtual('integration-test', 'lint', 'jshint', 'build', 'build-all',
|
||||
virtual('ci', 'lint', 'jshint', 'build', 'build-all',
|
||||
'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc')
|
||||
|
||||
|
||||
@@ -176,40 +164,30 @@ def build_ol_css(t):
|
||||
t.touch()
|
||||
|
||||
|
||||
@target('build/ol.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
|
||||
'buildcfg/base.json', 'buildcfg/ol.json')
|
||||
def build_ol_js(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'buildcfg/ol.json')
|
||||
@target('build/ol.js', SRC, SHADER_SRC, 'buildcfg/ol.json')
|
||||
def build_ol_new_js(t):
|
||||
t.run('node', 'tasks/build.js', 'buildcfg/ol.json', 'build/ol.js')
|
||||
report_sizes(t)
|
||||
|
||||
|
||||
@target('build/ol-simple.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC,
|
||||
LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
|
||||
'buildcfg/ol-simple.json')
|
||||
@target('build/ol-simple.js', SRC, SHADER_SRC, 'buildcfg/ol-simple.json')
|
||||
def build_ol_simple_js(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'buildcfg/ol-simple.json')
|
||||
t.run('node', 'tasks/build.js', 'buildcfg/ol-simple.json', 'build/ol-simple.js')
|
||||
report_sizes(t)
|
||||
|
||||
|
||||
@target('build/ol-whitespace.js', PLOVR_JAR, SRC, EXPORTS,
|
||||
SHADER_SRC, LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
|
||||
'buildcfg/ol-whitespace.json')
|
||||
@target('build/ol-whitespace.js', SRC, SHADER_SRC, 'buildcfg/ol-whitespace.json')
|
||||
def build_ol_whitespace_js(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'buildcfg/ol-whitespace.json')
|
||||
t.run('node', 'tasks/build.js', 'buildcfg/ol-whitespace.json', 'build/ol-whitespace.js')
|
||||
report_sizes(t)
|
||||
|
||||
|
||||
virtual('build-all', 'build/ol-all.js')
|
||||
|
||||
|
||||
@target('build/ol-all.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
|
||||
'buildcfg/base.json', 'buildcfg/ol-all.json')
|
||||
@target('build/ol-all.js', SRC, SHADER_SRC, 'buildcfg/ol-all.json')
|
||||
def build_ol_all_js(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'buildcfg/ol-all.json')
|
||||
t.run('node', 'tasks/build.js', 'buildcfg/ol-all.json', 'build/ol-all.js')
|
||||
|
||||
|
||||
@target(EXPORTS, SRC)
|
||||
@@ -259,12 +237,11 @@ def examples_examples_list_js(t):
|
||||
t.run('%(PYTHON)s', 'bin/exampleparser.py', 'examples', 'examples')
|
||||
|
||||
|
||||
@target('build/examples/all.combined.js', 'build/examples/all.js', PLOVR_JAR,
|
||||
SRC, SHADER_SRC, LIBTESS_JS_SRC,
|
||||
'buildcfg/base.json', 'build/examples/all.json')
|
||||
@target('build/examples/all.combined.js', 'build/examples/all.js',
|
||||
SRC, SHADER_SRC, 'buildcfg/examples-all.json')
|
||||
def build_examples_all_combined_js(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'buildcfg/examples-all.json')
|
||||
t.run('node', 'tasks/build.js', 'buildcfg/examples-all.json',
|
||||
'build/examples/all.combined.js')
|
||||
report_sizes(t)
|
||||
|
||||
|
||||
@@ -282,77 +259,105 @@ def examples_star_json(name, match):
|
||||
# Note that we use the proper way in buildcfg/examples-all.json, which
|
||||
# is only used to check the examples code using the compiler.
|
||||
content = json.dumps({
|
||||
'id': match.group('id'),
|
||||
'inherits': '../../buildcfg/base.json',
|
||||
'inputs': [
|
||||
'../examples/%(id)s.js' % match.groupdict()
|
||||
"exports": [],
|
||||
"src": ["src/**/*.js", "examples/%(id)s.js" % match.groupdict()],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"externs/bingmaps.js",
|
||||
"externs/bootstrap.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/example.js",
|
||||
"externs/geojson.js",
|
||||
"externs/jquery-1.7.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
'externs': [
|
||||
'//jquery-1.7.js',
|
||||
'../externs/bingmaps.js',
|
||||
'../externs/bootstrap.js',
|
||||
'../externs/closure-compiler.js',
|
||||
'../externs/example.js',
|
||||
'../externs/geojson.js',
|
||||
'../externs/oli.js',
|
||||
'../externs/olx.js',
|
||||
'../externs/proj4js.js',
|
||||
'../externs/tilejson.js',
|
||||
'../externs/topojson.js',
|
||||
'../externs/vbarray.js',
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkDebuggerStatement",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkProvides",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicate",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingProperties",
|
||||
"nonStandardJsDocs",
|
||||
"strictModuleDepCheck",
|
||||
"suspiciousCode",
|
||||
"typeInvalidation",
|
||||
"tweakValidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"violatedModuleDep",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "ADVANCED",
|
||||
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||
"use_types_for_optimization": True,
|
||||
"manage_closure_dependencies": True
|
||||
}
|
||||
})
|
||||
with open(t.name, 'wb') as f:
|
||||
f.write(content)
|
||||
dependencies = [__file__, 'buildcfg/base.json']
|
||||
return Target(name, action=action, dependencies=dependencies)
|
||||
return Target(name, action=action, dependencies=[__file__])
|
||||
|
||||
|
||||
@rule(r'\Abuild/examples/(?P<id>.*).combined.js\Z')
|
||||
def examples_star_combined_js(name, match):
|
||||
def action(t):
|
||||
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
|
||||
PLOVR_JAR, 'build', 'build/examples/%(id)s.json' %
|
||||
match.groupdict())
|
||||
config = 'build/examples/%(id)s.json' % match.groupdict()
|
||||
t.run('node', 'tasks/build.js', config, name)
|
||||
report_sizes(t)
|
||||
dependencies = [PLOVR_JAR, SRC, SHADER_SRC, LIBTESS_JS_SRC,
|
||||
'buildcfg/base.json',
|
||||
dependencies = [SRC, SHADER_SRC,
|
||||
'examples/%(id)s.js' % match.groupdict(),
|
||||
'build/examples/%(id)s.json' % match.groupdict()]
|
||||
return Target(name, action=action, dependencies=dependencies)
|
||||
|
||||
|
||||
@target('serve', PLOVR_JAR, 'test-deps', 'examples')
|
||||
@target('serve', 'examples')
|
||||
def serve(t):
|
||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'buildcfg/ol.json',
|
||||
'buildcfg/ol-all.json', EXAMPLES_JSON, 'buildcfg/test.json')
|
||||
t.run('node', 'tasks/serve.js')
|
||||
|
||||
|
||||
@target('serve-integration-test', PLOVR_JAR)
|
||||
def serve_precommit(t):
|
||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve',
|
||||
'buildcfg/ol-all.json', 'buildcfg/test.json')
|
||||
|
||||
|
||||
virtual('lint', 'build/lint-timestamp', 'build/lint-libtess.js-timestamp',
|
||||
'build/check-requires-timestamp', 'build/check-whitespace-timestamp')
|
||||
virtual('lint', 'build/lint-timestamp', 'build/check-requires-timestamp',
|
||||
'build/check-whitespace-timestamp')
|
||||
|
||||
|
||||
@target('build/lint-timestamp', SRC, EXPORTS, EXAMPLES_SRC, SPEC, precious=True)
|
||||
def build_lint_src_timestamp(t):
|
||||
t.run('%(GJSLINT)s',
|
||||
'--jslint_error=all',
|
||||
'--custom_jsdoc_tags=event,fires,todo,function,classdesc',
|
||||
'--strict',
|
||||
t.newer(t.dependencies))
|
||||
t.touch()
|
||||
|
||||
|
||||
@target('build/lint-libtess.js-timestamp', LIBTESS_JS_SRC, precious=True)
|
||||
def build_lint_libtess_js_timestamp(t):
|
||||
t.run('%(GJSLINT)s',
|
||||
'--jslint_error=all',
|
||||
'--disable=110',
|
||||
'--custom_jsdoc_tags=event,fires,function,classdesc,api,observable',
|
||||
'--strict',
|
||||
t.newer(t.dependencies))
|
||||
t.touch()
|
||||
@@ -390,22 +395,21 @@ def _strip_comments(lines):
|
||||
yield lineno, line
|
||||
|
||||
|
||||
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC,
|
||||
SHADER_SRC, LIBTESS_JS_SRC, SPEC)
|
||||
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC, SPEC)
|
||||
def build_check_requires_timestamp(t):
|
||||
from zipfile import ZipFile
|
||||
unused_count = 0
|
||||
all_provides = set()
|
||||
zf = ZipFile(PLOVR_JAR)
|
||||
for zi in zf.infolist():
|
||||
if zi.filename.endswith('.js'):
|
||||
if not zi.filename.startswith('closure/goog/'):
|
||||
closure_lib_path = output('node', '-e',
|
||||
'process.stdout.write(require("closure-util").getLibraryPath())')
|
||||
for filename in ifind(closure_lib_path):
|
||||
if filename.endswith('.js'):
|
||||
if not re.match(r'.*/closure/goog/', filename):
|
||||
continue
|
||||
# Skip goog.i18n because it contains so many modules that it causes
|
||||
# the generated regular expression to exceed Python's limits
|
||||
if zi.filename.startswith('closure/goog/i18n/'):
|
||||
if re.match(r'.*/closure/goog/i18n/', filename):
|
||||
continue
|
||||
for line in zf.open(zi, 'rU'):
|
||||
for line in open(filename, 'rU'):
|
||||
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
||||
if m:
|
||||
all_provides.add(m.group(1))
|
||||
@@ -532,7 +536,7 @@ def build_check_requires_timestamp(t):
|
||||
|
||||
|
||||
@target('build/check-whitespace-timestamp', SRC, EXPORTS, EXAMPLES_SRC,
|
||||
SPEC, JSDOC_SRC, LIBTESS_JS_SRC, precious=True)
|
||||
SPEC, JSDOC_SRC, precious=True)
|
||||
def build_check_whitespace_timestamp(t):
|
||||
CR_RE = re.compile(r'\r')
|
||||
LEADING_WHITESPACE_RE = re.compile(r'\s+')
|
||||
@@ -564,17 +568,6 @@ def build_check_whitespace_timestamp(t):
|
||||
t.touch()
|
||||
|
||||
|
||||
virtual('plovr', PLOVR_JAR)
|
||||
|
||||
|
||||
@target(PLOVR_JAR, clean=False)
|
||||
def plovr_jar(t):
|
||||
t.info('downloading %r', t.name)
|
||||
t.download('https://plovr.googlecode.com/files/' +
|
||||
os.path.basename(PLOVR_JAR), md5=PLOVR_JAR_MD5)
|
||||
t.info('downloaded %r', t.name)
|
||||
|
||||
|
||||
virtual('apidoc', 'build/jsdoc-%(BRANCH)s-timestamp' % vars(variables))
|
||||
|
||||
|
||||
@@ -631,6 +624,8 @@ def host_examples(t):
|
||||
examples_dir = 'build/hosted/%(BRANCH)s/examples'
|
||||
build_dir = 'build/hosted/%(BRANCH)s/build'
|
||||
css_dir = 'build/hosted/%(BRANCH)s/css'
|
||||
closure_lib_path = output('node', '-e',
|
||||
'process.stdout.write(require("closure-util").getLibraryPath())')
|
||||
t.rm_rf(examples_dir)
|
||||
t.makedirs(examples_dir)
|
||||
t.rm_rf(build_dir)
|
||||
@@ -649,14 +644,11 @@ def host_examples(t):
|
||||
'examples/example-list.xml', 'examples/Jugl.js',
|
||||
'examples/jquery.min.js', examples_dir)
|
||||
t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
|
||||
t.makedirs('build/hosted/%(BRANCH)s/closure-library')
|
||||
with t.chdir('build/hosted/%(BRANCH)s/closure-library'):
|
||||
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'closure')
|
||||
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'third_party')
|
||||
t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
|
||||
t.rm_rf('build/hosted/%(BRANCH)s/ol')
|
||||
t.makedirs('build/hosted/%(BRANCH)s/ol')
|
||||
t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
|
||||
t.run('%(PYTHON)s', 'bin/closure/depswriter.py',
|
||||
t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
|
||||
'--root_with_prefix', 'src ../../../ol',
|
||||
'--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
|
||||
'--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
|
||||
@@ -675,29 +667,9 @@ def check_examples(t):
|
||||
t.run('%(PHANTOMJS)s', 'bin/check-example.js', example)
|
||||
|
||||
|
||||
@target(PROJ4JS, PROJ4JS_ZIP)
|
||||
def proj4js(t):
|
||||
from zipfile import ZipFile
|
||||
zf = ZipFile(PROJ4JS_ZIP)
|
||||
contents = zf.open('proj4js/lib/proj4js-combined.js').read()
|
||||
with open(t.name, 'wb') as f:
|
||||
f.write(contents)
|
||||
|
||||
|
||||
@target(PROJ4JS_ZIP, clean=False)
|
||||
def proj4js_zip(t):
|
||||
t.info('downloading %r', t.name)
|
||||
t.download('http://download.osgeo.org/proj4js/' +
|
||||
os.path.basename(t.name), md5=PROJ4JS_ZIP_MD5)
|
||||
t.info('downloaded %r', t.name)
|
||||
|
||||
|
||||
virtual('test-deps', PROJ4JS, 'build/test/requireall.js')
|
||||
|
||||
|
||||
@target('test', 'test-deps', phony=True)
|
||||
@target('test', phony=True)
|
||||
def test(t):
|
||||
t.run('%(PHANTOMJS)s', 'test/mocha-phantomjs.js', 'test/ol.html')
|
||||
t.run('node', 'tasks/test.js')
|
||||
|
||||
|
||||
@target('fixme', phony=True)
|
||||
@@ -758,7 +730,7 @@ There is one option:
|
||||
-c - Cleans up the repository from previous builds.
|
||||
|
||||
The most common targets are:
|
||||
serve - Serves files through plovr, usually on port 9810.
|
||||
serve - Serves files, on port 3000.
|
||||
lint - Runs gjslint on all sourcefiles to enforce specific syntax.
|
||||
build - Builds singlefile versions of OpenLayers JavaScript and
|
||||
CSS. This is also the default build target which runs when
|
||||
@@ -771,18 +743,17 @@ The most common targets are:
|
||||
|
||||
Other less frequently used targets are:
|
||||
apidoc - Builds the API-Documentation using JSDoc3.
|
||||
integration-test - Builds all examples in various modes and usually takes a
|
||||
ci - Builds all examples in various modes and usually takes a
|
||||
long time to finish. This target calls the following
|
||||
targets: lint, build, build-all, test, build-examples,
|
||||
check-examples and apidoc.
|
||||
check-examples and apidoc. This is the target run on
|
||||
Travis CI.
|
||||
reallyclean - Remove untracked files from the repository.
|
||||
checkdeps - Checks whether all required development software is
|
||||
installed on your machine.
|
||||
fixme - Will print a list of parts of the code that are marked
|
||||
with either TODO or FIXME.
|
||||
todo - This is an alias for the fixme-target (see above).
|
||||
plovr - Fetches the required plovr.jar. Usually called by other
|
||||
targets that depend on plovr.
|
||||
|
||||
If no target is given, the build-target will be executed.
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
{
|
||||
|
||||
"ambiguate-properties": true,
|
||||
|
||||
"checks": {
|
||||
"accessControls": "ERROR",
|
||||
"ambiguousFunctionDecl": "ERROR",
|
||||
"checkDebuggerStatement": "WARNING",
|
||||
"checkEventfulObjectDisposal": "ERROR",
|
||||
"checkProvides": "ERROR",
|
||||
"checkRegExp": "ERROR",
|
||||
"checkStructDictInheritance": "ERROR",
|
||||
"checkTypes": "ERROR",
|
||||
"checkVars": "ERROR",
|
||||
"const": "ERROR",
|
||||
"constantProperty": "ERROR",
|
||||
"deprecated": "ERROR",
|
||||
"duplicate": "ERROR",
|
||||
"duplicateMessage": "ERROR",
|
||||
"es3": "ERROR",
|
||||
"es5Strict": "ERROR",
|
||||
"externsValidation": "ERROR",
|
||||
"fileoverviewTags": "ERROR",
|
||||
"globalThis": "ERROR",
|
||||
"internetExplorerChecks": "ERROR",
|
||||
"invalidCasts": "ERROR",
|
||||
"misplacedTypeAnnotation": "ERROR",
|
||||
"missingProperties": "ERROR",
|
||||
"nonStandardJsDocs": "ERROR",
|
||||
"strictModuleDepCheck": "ERROR",
|
||||
"suspiciousCode": "ERROR",
|
||||
"typeInvalidation": "ERROR",
|
||||
"tweakValidation": "ERROR",
|
||||
"undefinedNames": "ERROR",
|
||||
"undefinedVars": "ERROR",
|
||||
"unknownDefines": "ERROR",
|
||||
"uselessCode": "ERROR",
|
||||
"violatedModuleDep": "ERROR",
|
||||
"visibility": "ERROR"
|
||||
},
|
||||
|
||||
"define": {
|
||||
"goog.dom.ASSUME_STANDARDS_MODE": true,
|
||||
"goog.DEBUG": false
|
||||
},
|
||||
|
||||
"disambiguate-properties": true,
|
||||
|
||||
"externs": [
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/olx.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
|
||||
"level": "VERBOSE",
|
||||
|
||||
"mode": "ADVANCED",
|
||||
|
||||
"name-suffixes-to-strip": [
|
||||
"logger",
|
||||
"logger_"
|
||||
],
|
||||
|
||||
"paths": [
|
||||
"../src"
|
||||
],
|
||||
|
||||
"treat-warnings-as-errors": false,
|
||||
|
||||
"type-prefixes-to-strip": [
|
||||
"goog.asserts",
|
||||
"goog.debug.Console",
|
||||
"goog.debug.DebugWindow",
|
||||
"goog.debug.DevCss",
|
||||
"goog.debug.DivConsole",
|
||||
"goog.debug.EntryPointMonitor",
|
||||
"goog.debug.ErrorHandler",
|
||||
"goog.debug.ErrorReporter",
|
||||
"goog.debug.FancyWindow",
|
||||
"goog.debug.Formatter",
|
||||
"goog.debug.FpsDisplay",
|
||||
"goog.debug.GcDiagnostics",
|
||||
"goog.debug.HtmlFormatter",
|
||||
"goog.debug.LogBuffer",
|
||||
"goog.debug.LogManager",
|
||||
"goog.debug.LogRecord",
|
||||
"goog.debug.Logger",
|
||||
"goog.debug.RelativeTimeProvider",
|
||||
"goog.debug.TextFormatter",
|
||||
"goog.debug.Trace",
|
||||
"goog.debug.catchErrors",
|
||||
"goog.debug.deepExpose",
|
||||
"goog.debug.enhanceError",
|
||||
"goog.debug.entryPointRegistry",
|
||||
"goog.debug.errorHandlerWeakDep",
|
||||
"goog.debug.expose",
|
||||
"goog.debug.exposeArray",
|
||||
"goog.debug.exposeException",
|
||||
"goog.debug.getFunctionName",
|
||||
"goog.debug.getStacktrace",
|
||||
"goog.debug.getStacktraceSimple",
|
||||
"goog.debug.logRecordSerializer",
|
||||
"goog.debug.makeWhitespaceVisible",
|
||||
"goog.debug.normalizeErrorObject",
|
||||
"goog.debug.reflect",
|
||||
"goog.log"
|
||||
]
|
||||
|
||||
}
|
||||
@@ -1,21 +1,70 @@
|
||||
{
|
||||
"exports": [],
|
||||
"src": ["src/**/*.js", "build/examples/all.js"],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"//jquery-1.7.js",
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/bootstrap.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/example.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
"id": "simple",
|
||||
"inherits": "base.json",
|
||||
"inputs": [
|
||||
"../build/examples/all.js",
|
||||
"../externs/olx.js"
|
||||
]
|
||||
"externs/bingmaps.js",
|
||||
"externs/bootstrap.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/example.js",
|
||||
"externs/geojson.js",
|
||||
"externs/jquery-1.7.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingGetCssName",
|
||||
"missingProperties",
|
||||
"missingProvide",
|
||||
"missingRequire",
|
||||
"missingReturn",
|
||||
"newCheckTypes",
|
||||
"nonStandardJsDocs",
|
||||
"suspiciousCode",
|
||||
"strictModuleDepCheck",
|
||||
"typeInvalidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "ADVANCED",
|
||||
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||
"use_types_for_optimization": true,
|
||||
"manage_closure_dependencies": true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
15
buildcfg/jsdoc/info/api-plugin.js
Normal file
15
buildcfg/jsdoc/info/api-plugin.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
/**
|
||||
* Handle the api annotation.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('api', {
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.api = tag.text || 'experimental';
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
@@ -10,7 +10,7 @@
|
||||
"includePattern": "\\.js$"
|
||||
},
|
||||
"plugins": [
|
||||
"buildcfg/jsdoc/info/define-plugin",
|
||||
"buildcfg/jsdoc/info/todo-plugin"
|
||||
"buildcfg/jsdoc/info/api-plugin",
|
||||
"buildcfg/jsdoc/info/define-plugin"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @fileoverview This plugin should go away when we get rid of Plovr and can
|
||||
* use Closure Compiler's extra_annotation_name option. Until then, we hijack
|
||||
* the todo tag to add doclet properties for other tags we eventually want to
|
||||
* support. For example, the "todo api" tag can eventually be replaced with
|
||||
* the "api" tag.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Our hook to define new tags.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('todo', {
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
var parts = tag.text.split(' ');
|
||||
if (parts[0] === 'api') {
|
||||
doclet.api = parts.slice(1).join(' ').trim();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
@@ -1,23 +1,65 @@
|
||||
{
|
||||
|
||||
"id": "ol-all",
|
||||
|
||||
"externs": [
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/olx.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
|
||||
"inherits": "base.json",
|
||||
|
||||
"inputs": [
|
||||
"../build/exports.js"
|
||||
]
|
||||
|
||||
"exports": ["*"],
|
||||
"src": ["src/**/*.js"],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"externs/bingmaps.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/geojson.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingGetCssName",
|
||||
"missingProperties",
|
||||
"missingProvide",
|
||||
"missingRequire",
|
||||
"missingReturn",
|
||||
"newCheckTypes",
|
||||
"nonStandardJsDocs",
|
||||
"suspiciousCode",
|
||||
"strictModuleDepCheck",
|
||||
"typeInvalidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "ADVANCED",
|
||||
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||
"use_types_for_optimization": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,66 @@
|
||||
{
|
||||
|
||||
// If ambiguate-properties and disambiguate-properties are set to true
|
||||
// we get function names like "ol_control_Control_prototype$setMap" in
|
||||
// the compiled code when using the SIMPLE compilation. It looks like
|
||||
// "ambiguate-properties" and "disambiguate-properties" are only
|
||||
// appropriate for ADVANCED compilation.
|
||||
|
||||
"ambiguate-properties": false,
|
||||
|
||||
"disambiguate-properties": false,
|
||||
|
||||
"id": "ol-simple",
|
||||
|
||||
"externs": [
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/olx.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
|
||||
"inherits": "ol.json",
|
||||
|
||||
"inputs": [
|
||||
"../build/exports.js"
|
||||
],
|
||||
|
||||
"mode": "SIMPLE",
|
||||
|
||||
// Note: we can't have a (function(){%output%})() output wrapper with
|
||||
// WHITESPACE and SIMPLE modes. See this link for explanations:
|
||||
// https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
|
||||
"output-wrapper": "%output%"
|
||||
"exports": ["*"],
|
||||
"src": ["src/**/*.js"],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"externs/bingmaps.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/geojson.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingGetCssName",
|
||||
"missingProperties",
|
||||
"missingProvide",
|
||||
"missingRequire",
|
||||
"missingReturn",
|
||||
"newCheckTypes",
|
||||
"nonStandardJsDocs",
|
||||
"suspiciousCode",
|
||||
"strictModuleDepCheck",
|
||||
"typeInvalidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "SIMPLE",
|
||||
"output_wrapper": "%output%",
|
||||
"use_types_for_optimization": false,
|
||||
"manage_closure_dependencies": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,66 @@
|
||||
{
|
||||
|
||||
"id": "ol-whitespace",
|
||||
|
||||
// If ambiguate-properties and disambiguate-properties are set to true
|
||||
// we get function names like "ol_control_Control_prototype$setMap" in
|
||||
// the compiled code when using the SIMPLE compilation. It looks like
|
||||
// "ambiguate-properties" and "disambiguate-properties" are only
|
||||
// appropriate for ADVANCED compilation. To be sure we also don't
|
||||
// set them for WHITESPACE.
|
||||
|
||||
"ambiguate-properties": false,
|
||||
|
||||
"disambiguate-properties": false,
|
||||
|
||||
"externs": [
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/olx.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
|
||||
"inherits": "ol.json",
|
||||
|
||||
"inputs": [
|
||||
"../build/exports.js"
|
||||
],
|
||||
|
||||
"mode": "WHITESPACE",
|
||||
|
||||
"output-wrapper": [
|
||||
"var CLOSURE_NO_DEPS = true;\n",
|
||||
"%output%"
|
||||
],
|
||||
|
||||
"pretty-print": true
|
||||
"exports": ["*"],
|
||||
"src": ["src/**/*.js"],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"externs/bingmaps.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/geojson.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingGetCssName",
|
||||
"missingProperties",
|
||||
"missingProvide",
|
||||
"missingRequire",
|
||||
"missingReturn",
|
||||
"newCheckTypes",
|
||||
"nonStandardJsDocs",
|
||||
"suspiciousCode",
|
||||
"strictModuleDepCheck",
|
||||
"typeInvalidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "WHITESPACE_ONLY",
|
||||
"output_wrapper": "var CLOSURE_DEPS = false;\n%output%",
|
||||
"use_types_for_optimization": false,
|
||||
"manage_closure_dependencies": true
|
||||
}
|
||||
}
|
||||
|
||||
101
buildcfg/ol.json
101
buildcfg/ol.json
@@ -1,39 +1,66 @@
|
||||
{
|
||||
|
||||
"id": "ol",
|
||||
|
||||
"css-allowed-unrecognized-properties": [
|
||||
"user-select"
|
||||
],
|
||||
|
||||
"css-inputs": [
|
||||
"../css/ol.css"
|
||||
],
|
||||
|
||||
"css-output-file": "../build/ol.css",
|
||||
|
||||
"externs": [
|
||||
"../externs/bingmaps.js",
|
||||
"../externs/closure-compiler.js",
|
||||
"../externs/geojson.js",
|
||||
"../externs/oli.js",
|
||||
"../externs/olx.js",
|
||||
"../externs/proj4js.js",
|
||||
"../externs/tilejson.js",
|
||||
"../externs/topojson.js",
|
||||
"../externs/vbarray.js"
|
||||
],
|
||||
|
||||
"inherits": "base.json",
|
||||
|
||||
"inputs": [
|
||||
"../build/exports.js"
|
||||
],
|
||||
|
||||
"output-wrapper": "// OpenLayers 3. see http://ol3js.org/\n(function(){%output%})();",
|
||||
|
||||
"paths": [
|
||||
"../src"
|
||||
]
|
||||
|
||||
"exports": ["*"],
|
||||
"src": ["src/**/*.js"],
|
||||
"compile": {
|
||||
"externs": [
|
||||
"externs/bingmaps.js",
|
||||
"externs/closure-compiler.js",
|
||||
"externs/geojson.js",
|
||||
"externs/oli.js",
|
||||
"externs/olx.js",
|
||||
"externs/proj4js.js",
|
||||
"externs/tilejson.js",
|
||||
"externs/topojson.js",
|
||||
"externs/vbarray.js"
|
||||
],
|
||||
"define": [
|
||||
"goog.dom.ASSUME_STANDARDS_MODE=true",
|
||||
"goog.DEBUG=false"
|
||||
],
|
||||
"jscomp_error": [
|
||||
"accessControls",
|
||||
"ambiguousFunctionDecl",
|
||||
"checkEventfulObjectDisposal",
|
||||
"checkRegExp",
|
||||
"checkStructDictInheritance",
|
||||
"checkTypes",
|
||||
"checkVars",
|
||||
"const",
|
||||
"constantProperty",
|
||||
"deprecated",
|
||||
"duplicateMessage",
|
||||
"es3",
|
||||
"externsValidation",
|
||||
"fileoverviewTags",
|
||||
"globalThis",
|
||||
"internetExplorerChecks",
|
||||
"invalidCasts",
|
||||
"misplacedTypeAnnotation",
|
||||
"missingGetCssName",
|
||||
"missingProperties",
|
||||
"missingProvide",
|
||||
"missingRequire",
|
||||
"missingReturn",
|
||||
"newCheckTypes",
|
||||
"nonStandardJsDocs",
|
||||
"suspiciousCode",
|
||||
"strictModuleDepCheck",
|
||||
"typeInvalidation",
|
||||
"undefinedNames",
|
||||
"undefinedVars",
|
||||
"unknownDefines",
|
||||
"uselessCode",
|
||||
"visibility"
|
||||
],
|
||||
"extra_annotation_name": [
|
||||
"api", "observable"
|
||||
],
|
||||
"jscomp_off": [
|
||||
"es5Strict"
|
||||
],
|
||||
"compilation_level": "ADVANCED",
|
||||
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
||||
"use_types_for_optimization": true,
|
||||
"manage_closure_dependencies": true
|
||||
}
|
||||
}
|
||||
|
||||
12
buildcfg/readme.md
Normal file
12
buildcfg/readme.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Build configs
|
||||
|
||||
This directory includes configuration files (json) for the tasks/build.js
|
||||
build script.
|
||||
|
||||
Notes:
|
||||
|
||||
`use_types_for_optimization` is set to `false` for the SIMPLE and WHITESPACE
|
||||
builds. If it was set to `true` we would get function names like
|
||||
`ol_control_Control_prototype$setMap` in the compiled code when using the
|
||||
SIMPLE compilation. `use_types_for_optimization` is only appropriate for
|
||||
ADVANCED compilation. To be sure we also don't set it for WHITESPACE.
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
|
||||
"id": "test",
|
||||
|
||||
"inherits": "base.json",
|
||||
|
||||
"inputs": [
|
||||
"../build/test/requireall.js"
|
||||
],
|
||||
|
||||
"paths": [
|
||||
"../src",
|
||||
"../test"
|
||||
]
|
||||
|
||||
}
|
||||
3
closure-util.json
Normal file
3
closure-util.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"library_url": "https://github.com/google/closure-library/archive/ab89cf45c216615d73a2f5dea720afb9d3415d1f.zip"
|
||||
}
|
||||
104
css/ol.css
104
css/ol.css
@@ -1,53 +1,3 @@
|
||||
.ol-attribution {
|
||||
position: absolute;
|
||||
text-align: right;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 6px;
|
||||
color: #000000;
|
||||
color: rgba(238,238,238,1);
|
||||
background: rgba(0,60,136,0.3);
|
||||
}
|
||||
.ol-attribution a {
|
||||
text-decoration: none;
|
||||
color: #7b98bc;
|
||||
color: rgba(255,255,255,1);
|
||||
}
|
||||
|
||||
.ol-attribution ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 10px;
|
||||
line-height: 12px;
|
||||
}
|
||||
.ol-attribution li {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
line-height: inherit;
|
||||
}
|
||||
.ol-attribution li:not(:last-child):after {
|
||||
content: "\2003";
|
||||
}
|
||||
.ol-attribution-bing-tos {
|
||||
float:right;
|
||||
padding-top: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ol-logo {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
padding: 2px;
|
||||
position: absolute;
|
||||
}
|
||||
.ol-logo ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.ol-logo ul li {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.ol-mouse-position {
|
||||
top: 8px;
|
||||
@@ -226,11 +176,65 @@ button.ol-full-screen-true:after {
|
||||
}
|
||||
.ol-rotate .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-rotate .ol-has-tooltip:focus [role=tooltip],
|
||||
.ol-attribution .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-attribution .ol-has-tooltip:focus [role=tooltip],
|
||||
.ol-full-screen .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-full-screen .ol-has-tooltip:focus [role=tooltip] {
|
||||
right: 2.2em;
|
||||
left: auto;
|
||||
border-radius: 4px 0 0 4px;
|
||||
border-left-width: 3px;
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
.ol-attribution {
|
||||
text-align: right;
|
||||
bottom: .5em;
|
||||
right: .5em;
|
||||
}
|
||||
|
||||
.ol-attribution ul {
|
||||
margin: 0;
|
||||
padding: 0 .5em;
|
||||
font-size: .7rem;
|
||||
line-height: 1.375em;
|
||||
color: #000;
|
||||
text-shadow: 0 0 2px #fff;
|
||||
}
|
||||
.ol-attribution li {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
line-height: inherit;
|
||||
}
|
||||
.ol-attribution li:not(:last-child):after {
|
||||
content: " ";
|
||||
}
|
||||
.ol-attribution img {
|
||||
max-height: 2em;
|
||||
}
|
||||
.ol-attribution ul, .ol-attribution button {
|
||||
display: inline-block;
|
||||
}
|
||||
.ol-attribution:not(.ol-collapsed) button:hover [role=tooltip],
|
||||
.ol-attribution.ol-collapsed ul {
|
||||
display: none;
|
||||
}
|
||||
.ol-attribution:not(.ol-collapsed) {
|
||||
background: rgba(255,255,255,0.8);
|
||||
}
|
||||
.ol-attribution.ol-uncollapsible {
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
border-radius: 4px 0 0;
|
||||
height: 1.1em;
|
||||
line-height: 1em;
|
||||
}
|
||||
.ol-attribution.ol-uncollapsible img {
|
||||
margin-top: -.2em;
|
||||
max-height: 1.6em;
|
||||
}
|
||||
.ol-attribution.ol-uncollapsible button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ol-zoomslider {
|
||||
|
||||
@@ -5,4 +5,4 @@ layout: doc.hbs
|
||||
|
||||
# Tutorials
|
||||
|
||||
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [basic concepts](concepts.html) tutorial. Stay tuned for more!
|
||||
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [introduction](introduction.html) and [basic concepts](concepts.html) tutorial. Stay tuned for more!
|
||||
|
||||
44
doc/tutorials/introduction.md
Normal file
44
doc/tutorials/introduction.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: Introduction
|
||||
layout: doc.hbs
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
## Objectives
|
||||
OpenLayers 3 (OL3) is a fundamental redesign of the OpenLayers web mapping library. Version 2 is widely used, but dates from the early days of Javascript development, and is increasingly showing its age. OL3 has been rewritten from the ground up to use modern design patterns.
|
||||
|
||||
The initial release aims to support much of the functionality provided by version 2, with support for a wide range of commercial and free tile sources, and the most popular open-source vector data formats. As with version 2, data can be in any projection. The initial release also adds some additional functionality, such as the ability to easily rotate or animate maps.
|
||||
|
||||
It is also designed such that major new features, such as displaying 3D maps, or using WebGL to quickly display large vector data sets, can be added in later releases.
|
||||
|
||||
## Closure Tools
|
||||
OL3 is based on Google's Closure Tools. It makes heavy use of parts of the [__Closure Library__](https://developers.google.com/closure/library/). Using this to handle basics like DOM or event handling means the developers can concentrate on mapping functionality, and be sure that the underlying software is well-tested and cross-browser. Closure Library is specially designed to be optimized by the [__Closure Compiler__](https://developers.google.com/closure/compiler/). The 'advanced' optimizations that this provides offers a level of compression that far exceeds anything else available. OL3 has been designed to make full use of this.
|
||||
|
||||
## Public API
|
||||
Using the advanced optimizations of the Closure Compiler means that properties and methods are renamed – `longMeaningfulName` might become `xB` – and so are effectively unusable in applications using the library. To be usable, they have to be explicitly `exported`. This means the exported names, those not renamed, effectively become the public API of the library. These __exportable__ properties and methods are marked in the source, and documented in the [API docs](../apidoc). This is the officially supported API of the library. A build containing all these exportable names is known as a __full build__. A hosted version of this is available, which can be used by any application.
|
||||
|
||||
Although Closure library functions are widely used within OL3, none of them are exported. You will see references to them (they are all in the `goog` namespace) in the API docs, but these are for information only. You can use the Closure library in your own applications if you like, but this is not required.
|
||||
|
||||
## Custom Builds
|
||||
Unlike in, say, Node, where a module's exports are fixed in the source, with Closure Compiler, exports can be defined at compile time. This makes it easy to create builds that are customized to the needs of a particular site or application: a __custom build__ only exports those properties and methods needed by the site or application. As the full build is large, and will probably become larger as new features are added to the API, it's recommended that sites create a custom build for production software.
|
||||
|
||||
## Renderers and Browser Support
|
||||
The library currently includes three renderers: Canvas, DOM, and WebGL. All three support raster data from tile/image servers, but only the Canvas renderer currently supports vector data. This means that only those browsers that [support Canvas](http://caniuse.com/canvas) can handle vector data. In particular, this excludes Internet Explorer versions before 9, though there is some support for those in the DOM renderer. Clearly, the WebGL renderer can only be used on those devices and browsers supporting WebGL.
|
||||
|
||||
The library is intended for use on both desktop/laptop and mobile devices.
|
||||
|
||||
## Objects and Naming Conventions
|
||||
OL3 uses a similar object hierarchy to the Closure library. There is a top-level `ol` namespace (basically, `var ol = {};`). Subdivisions of this are:
|
||||
|
||||
* further namespaces, such as `ol.layer`; these have a lower-case initial
|
||||
* simple objects containing static properties and methods, such as `ol.animation`; these also have a lower-case initial
|
||||
* types, which have an upper-case initial. These are mainly 'classes', which here means a constructor function with prototypal inheritance, such as `ol.Map` or `ol.layer.Vector` (the Vector class within the layer namespace). There are however other, simpler, types, such as `ol.Extent`, which is an array.
|
||||
|
||||
In the API docs, the index on the left lists the namespaces and simple objects first, followed by the classes.
|
||||
|
||||
Class namespaces, such as `ol.layer` have a base class type with the same name, such as `ol.layer.Layer`. These are mainly abstract classes, from which the other subclasses inherit.
|
||||
|
||||
Source files are similarly organised, with a directory for each class namespace. Names are however all lower-case, and the subclasses repeat the superclass type in their name, for example, `ol/layer/vectorlayer.js`.
|
||||
|
||||
The naming structure means that there are sometimes 2 objects with the same name but different initial, such as `ol.feature`, a simple object with static functions to be used with features, and `ol.Feature`, a class used to instantiate new features. These two objects are however stored in the same file, in this case, `ol/feature.js`
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -12,6 +13,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.OSM');
|
||||
@@ -55,6 +56,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Synthetic data example</title>
|
||||
<title>Attributions example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -31,20 +31,21 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Synthetic data example</h4>
|
||||
<p id="shortdesc">Synthetic data example.</p>
|
||||
<h4 id="title">Attributions example</h4>
|
||||
<p id="shortdesc">Example of a attributions visibily change on map resize, to collapse them on small maps.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="synthetic-data.js" target="_blank">synthetic-data.js source</a> to see how this is done.</p>
|
||||
<p>See the <a href="attributions.js" target="_blank">attributions.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">vector</div>
|
||||
<div id="tags">attributions, openstreetmap</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=synthetic-data" type="text/javascript"></script>
|
||||
<script src="jquery.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=attributions" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
33
examples/attributions.js
Normal file
33
examples/attributions.js
Normal file
@@ -0,0 +1,33 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.Attribution');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
var attribution = new ol.control.Attribution({
|
||||
collapsible: false
|
||||
});
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
})
|
||||
],
|
||||
controls: ol.control.defaults({ attribution: false }).extend([attribution]),
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
function checkSize() {
|
||||
var small = map.getSize()[0] < 600;
|
||||
attribution.setCollapsible(small);
|
||||
attribution.setCollapsed(small);
|
||||
}
|
||||
|
||||
$(window).on('resize', checkSize);
|
||||
checkSize();
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.BrowserFeature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
@@ -29,6 +30,11 @@ var map = new ol.Map({
|
||||
layers: [layer],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.OSM');
|
||||
@@ -23,6 +24,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: ol.proj.transform(
|
||||
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
top: 178px;
|
||||
left: 158px;
|
||||
}
|
||||
div.ol-logo {
|
||||
left: 150px;
|
||||
bottom: 30px;
|
||||
}
|
||||
div.ol-attribution {
|
||||
bottom: 30px;
|
||||
right: 50px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.SimpleGeometry');
|
||||
goog.require('ol.layer.Tile');
|
||||
@@ -50,6 +51,11 @@ var map = new ol.Map({
|
||||
vectorLayer
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,11 @@ ol.inherits(app.RotateNorthControl, ol.control.Control);
|
||||
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
new app.RotateNorthControl()
|
||||
]),
|
||||
layers: [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.DeviceOrientation');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -11,6 +12,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
@@ -144,7 +145,7 @@ var vectorSource = new ol.source.GeoJSON(
|
||||
'type': 'MultiPolygon',
|
||||
'coordinates': [
|
||||
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
|
||||
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6], [0e6, 6e6]]],
|
||||
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]],
|
||||
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
|
||||
]
|
||||
}
|
||||
@@ -156,7 +157,7 @@ var vectorSource = new ol.source.GeoJSON(
|
||||
'geometries': [
|
||||
{
|
||||
'type': 'LineString',
|
||||
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
|
||||
'coordinates': [[-5e6, -5e6], [0, -5e6]]
|
||||
},
|
||||
{
|
||||
'type': 'Point',
|
||||
@@ -188,6 +189,11 @@ var map = new ol.Map({
|
||||
vectorLayer
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.require('ol.Geolocation');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Overlay');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.require('ol.FeatureOverlay');
|
||||
goog.require('ol.Geolocation');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.layer.Tile');
|
||||
@@ -21,6 +22,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: view
|
||||
});
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<style type="text/css">
|
||||
div.ol-logo {
|
||||
left: 65px;
|
||||
}
|
||||
div.fill {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.require('ol.Feature');
|
||||
goog.require('ol.FeatureOverlay');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.layer.Tile');
|
||||
@@ -83,6 +84,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [703365.7089403362, 5714629.865071137],
|
||||
zoom: 9
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.BrowserFeature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -20,6 +21,11 @@ if (!ol.BrowserFeature.HAS_WEBGL) {
|
||||
layers: [osm],
|
||||
renderer: 'webgl',
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -10,6 +11,11 @@ var osm = new ol.layer.Tile({
|
||||
var map = new ol.Map({
|
||||
layers: [osm],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.BingMaps');
|
||||
goog.require('ol.source.OSM');
|
||||
@@ -17,6 +18,11 @@ var bing = new ol.layer.Tile({
|
||||
var map = new ol.Map({
|
||||
layers: [osm, bing],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
|
||||
|
||||
/**
|
||||
* Loader to add the plovr generated script to the document.
|
||||
*
|
||||
* The following default values may be overridden with query string
|
||||
* parameters:
|
||||
*
|
||||
* * hostname - the current hostname (window.location.hostname)
|
||||
* * port - 9810
|
||||
* * mode - RAW
|
||||
* * id - id param in loader.js query string; defaults to 'ol' if not set
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <script src="loader.js?id=myexample"></script>
|
||||
*/
|
||||
(function() {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
var params = {
|
||||
hostname: window.location.hostname,
|
||||
port: '9810',
|
||||
mode: 'RAW',
|
||||
id: 'ol'
|
||||
};
|
||||
if (window.location.protocol === 'file:' && !params.hostname) {
|
||||
params.hostname = 'localhost';
|
||||
}
|
||||
var chunks, search, pair;
|
||||
|
||||
var src, index, id, i;
|
||||
for (i = scripts.length - 1; i >= 0; --i) {
|
||||
src = scripts[i].getAttribute('src');
|
||||
if (~(index = src.indexOf('loader.js?'))) {
|
||||
// script params
|
||||
search = src.substr(index + 10);
|
||||
chunks = search ? search.split('&') : [];
|
||||
for (i = chunks.length - 1; i >= 0; --i) {
|
||||
pair = chunks[i].split('=');
|
||||
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// url params
|
||||
search = window.location.search.substring(1);
|
||||
chunks = search ? search.split('&') : [];
|
||||
for (i = chunks.length - 1; i >= 0; --i) {
|
||||
pair = chunks[i].split('=');
|
||||
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
|
||||
var host = params.hostname + ':' + params.port;
|
||||
delete params.hostname;
|
||||
delete params.port;
|
||||
|
||||
var pairs = [];
|
||||
for (var key in params) {
|
||||
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
|
||||
}
|
||||
|
||||
var url = 'http://' + host + '/compile?' + pairs.join('&');
|
||||
document.write('<script type="text/javascript" src="' + url + '"></script>');
|
||||
}());
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -42,6 +43,11 @@ var map = new ol.Map({
|
||||
openSeaMapLayer
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
maxZoom: 18,
|
||||
center: [-244780.24508882355, 5986452.183179816],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
goog.require('ol.source.TileJSON');
|
||||
@@ -27,6 +28,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [653600, 5723680],
|
||||
zoom: 5
|
||||
|
||||
@@ -127,8 +127,8 @@ var source = new ol.source.GeoJSON(
|
||||
'coordinates': [
|
||||
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
|
||||
[-3e6, 6e6], [-5e6, 6e6]]],
|
||||
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6],
|
||||
[0e6, 6e6], [-2e6, 6e6]]],
|
||||
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
|
||||
[0, 6e6], [-2e6, 6e6]]],
|
||||
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
|
||||
[3e6, 6e6], [1e6, 6e6]]]
|
||||
]
|
||||
@@ -141,7 +141,7 @@ var source = new ol.source.GeoJSON(
|
||||
'geometries': [
|
||||
{
|
||||
'type': 'LineString',
|
||||
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
|
||||
'coordinates': [[-5e6, -5e6], [0, -5e6]]
|
||||
},
|
||||
{
|
||||
'type': 'Point',
|
||||
|
||||
@@ -19,7 +19,11 @@ var mousePositionControl = new ol.control.MousePosition({
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([mousePositionControl]),
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([mousePositionControl]),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
@@ -14,6 +15,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -7,7 +7,11 @@ goog.require('ol.source.OSM');
|
||||
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
new ol.control.ZoomToExtent({
|
||||
extent: [
|
||||
813079.7791264898, 5929220.284081122,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -12,6 +13,11 @@ var map = new ol.Map({
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [-25860000, 4130000],
|
||||
rotation: Math.PI / 6,
|
||||
|
||||
@@ -10,7 +10,11 @@ goog.require('ol.source.OSM');
|
||||
var scaleLineControl = new ol.control.ScaleLine();
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
scaleLineControl
|
||||
]),
|
||||
layers: [
|
||||
|
||||
@@ -33,7 +33,17 @@
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Select features example</h4>
|
||||
<p id="shortdesc">Example of using the Select interaction. Select features by clicking polygons. Hold the Shift-key to toggle the feature in the selection.</p>
|
||||
<p id="shortdesc">Example of using the Select interaction. Choose between <code>Single-click</code>, <code>Click</code> and <code>Hover</code> as the event type for selection in the combobox below. When using <code>Single-click</code> or <code>Click</code> you can hold do <code>Shift</code> key to toggle the feature in the selection.</p>
|
||||
<p>Note: when <code>Single-click</code> is used double-clicks won't select features. This in contrast to <code>Click</code>, where a double-click will both select the feature and zoom the map (because of the <code>DoubleClickZoom</code> interaction). Note that <code>Single-click</code> is less responsive than <code>Click</code> because of the delay it uses to detect double-clicks.</p>
|
||||
<form class="form-inline">
|
||||
<label>Action type </label>
|
||||
<select id="type">
|
||||
<option value="none" selected>None</option>
|
||||
<option value="singleclick">Single-click</option>
|
||||
<option value="click">Click</option>
|
||||
<option value="mousemove">Hover</option>
|
||||
</select>
|
||||
</form>
|
||||
<div id="docs">
|
||||
<p>See the <a href="select-features.js" target="_blank">select-features.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.Select');
|
||||
goog.require('ol.layer.Tile');
|
||||
@@ -18,10 +19,7 @@ var vector = new ol.layer.Vector({
|
||||
})
|
||||
});
|
||||
|
||||
var select = new ol.interaction.Select();
|
||||
|
||||
var map = new ol.Map({
|
||||
interactions: ol.interaction.defaults().extend([select]),
|
||||
layers: [raster, vector],
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
@@ -29,3 +27,46 @@ var map = new ol.Map({
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
var select = null; // ref to currently selected interaction
|
||||
|
||||
// select interaction working on "singleclick"
|
||||
var selectSingleClick = new ol.interaction.Select();
|
||||
|
||||
// select interaction working on "click"
|
||||
var selectClick = new ol.interaction.Select({
|
||||
condition: ol.events.condition.click
|
||||
});
|
||||
|
||||
// select interaction working on "mousemove"
|
||||
var selectMouseMove = new ol.interaction.Select({
|
||||
condition: ol.events.condition.mouseMove
|
||||
});
|
||||
|
||||
var selectElement = document.getElementById('type');
|
||||
|
||||
var changeInteraction = function() {
|
||||
if (select !== null) {
|
||||
map.removeInteraction(select);
|
||||
}
|
||||
var value = selectElement.value;
|
||||
if (value == 'singleclick') {
|
||||
select = selectSingleClick;
|
||||
} else if (value == 'click') {
|
||||
select = selectClick;
|
||||
} else if (value == 'mousemove') {
|
||||
select = selectMouseMove;
|
||||
} else {
|
||||
select = null;
|
||||
}
|
||||
if (select !== null) {
|
||||
map.addInteraction(select);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* onchange callback on the select element.
|
||||
*/
|
||||
selectElement.onchange = changeInteraction;
|
||||
changeInteraction();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -10,6 +11,11 @@ var map = new ol.Map({
|
||||
source: new ol.source.OSM()
|
||||
})
|
||||
],
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -11,6 +12,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.format.OSMXML');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
@@ -90,8 +91,8 @@ var styles = {
|
||||
var vectorSource = new ol.source.ServerVector({
|
||||
format: new ol.format.OSMXML(),
|
||||
loader: function(extent, resolution, projection) {
|
||||
var transform = ol.proj.getTransform(projection, 'EPSG:4326');
|
||||
var epsg4326Extent = transform(extent, []);
|
||||
var epsg4326Extent =
|
||||
ol.proj.transformExtent(extent, projection, 'EPSG:4326');
|
||||
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
|
||||
epsg4326Extent.join(',');
|
||||
$.ajax(url).then(function(response) {
|
||||
@@ -131,6 +132,11 @@ var raster = new ol.layer.Tile({
|
||||
var map = new ol.Map({
|
||||
layers: [raster, vector],
|
||||
target: document.getElementById('map'),
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [739218, 5906096],
|
||||
maxZoom: 19,
|
||||
|
||||
@@ -10,10 +10,6 @@ goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
|
||||
var loadFeatures = function(response) {
|
||||
vectorSource.addFeatures(vectorSource.readFeatures(response));
|
||||
};
|
||||
|
||||
var vectorSource = new ol.source.ServerVector({
|
||||
format: new ol.format.GeoJSON(),
|
||||
loader: function(extent, resolution, projection) {
|
||||
@@ -32,6 +28,10 @@ var vectorSource = new ol.source.ServerVector({
|
||||
projection: 'EPSG:3857'
|
||||
});
|
||||
|
||||
var loadFeatures = function(response) {
|
||||
vectorSource.addFeatures(vectorSource.readFeatures(response));
|
||||
};
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: vectorSource,
|
||||
style: new ol.style.Style({
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Tiled WMS with Proj4js projection example</title>
|
||||
<title>Tiled WMS with custom projection example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -31,21 +31,18 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Tiled WMS with Proj4js projection example</h4>
|
||||
<h4 id="title">Tiled WMS with custom projection example</h4>
|
||||
<p id="shortdesc">Example of two tiled WMS layers (Pixelmap 1:1'000'000 and national parks) using the projection EPSG:21781.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="wms-custom-proj.js" target="_blank">wms-custom-proj.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">wms, tile, tilelayer, proj4js, projection</div>
|
||||
<div id="tags">wms, tile, tilelayer, projection</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="jquery.min.js" type="text/javascript"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>
|
||||
|
||||
|
||||
@@ -5,13 +5,41 @@ goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.source.TileWMS');
|
||||
|
||||
|
||||
var projection = ol.proj.configureProj4jsProjection({
|
||||
|
||||
// By default OpenLayers does not know about the EPSG:21781 (Swiss) projection.
|
||||
// So we create a projection instance for EPSG:21781 and pass it to
|
||||
// ol.proj.addProjection to make it available to the library.
|
||||
|
||||
var projection = new ol.proj.Projection({
|
||||
code: 'EPSG:21781',
|
||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
|
||||
// The extent is used to determine zoom level 0. Recommended values for a
|
||||
// projection's validity extent can be found at http://epsg.io/.
|
||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
|
||||
units: 'm'
|
||||
});
|
||||
ol.proj.addProjection(projection);
|
||||
|
||||
// We also declare EPSG:21781/EPSG:4326 transform functions. These functions
|
||||
// are necessary for the ScaleLine control and when calling ol.proj.transform
|
||||
// for setting the view's initial center (see below).
|
||||
|
||||
ol.proj.addCoordinateTransforms('EPSG:4326', projection,
|
||||
function(coordinate) {
|
||||
return [
|
||||
WGStoCHy(coordinate[1], coordinate[0]),
|
||||
WGStoCHx(coordinate[1], coordinate[0])
|
||||
];
|
||||
},
|
||||
function(coordinate) {
|
||||
return [
|
||||
CHtoWGSlng(coordinate[0], coordinate[1]),
|
||||
CHtoWGSlat(coordinate[0], coordinate[1])
|
||||
];
|
||||
});
|
||||
|
||||
var extent = [420000, 30000, 900000, 350000];
|
||||
var layers = [
|
||||
@@ -61,8 +89,160 @@ var map = new ol.Map({
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
projection: projection,
|
||||
center: [660000, 190000],
|
||||
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
|
||||
extent: extent,
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Swiss projection transform functions downloaded from
|
||||
* http://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/software/products/skripts.html
|
||||
*/
|
||||
|
||||
// Convert WGS lat/long (° dec) to CH y
|
||||
function WGStoCHy(lat, lng) {
|
||||
|
||||
// Converts degrees dec to sex
|
||||
lat = DECtoSEX(lat);
|
||||
lng = DECtoSEX(lng);
|
||||
|
||||
// Converts degrees to seconds (sex)
|
||||
lat = DEGtoSEC(lat);
|
||||
lng = DEGtoSEC(lng);
|
||||
|
||||
// Axiliary values (% Bern)
|
||||
var lat_aux = (lat - 169028.66) / 10000;
|
||||
var lng_aux = (lng - 26782.5) / 10000;
|
||||
|
||||
// Process Y
|
||||
var y = 600072.37 +
|
||||
211455.93 * lng_aux -
|
||||
10938.51 * lng_aux * lat_aux -
|
||||
0.36 * lng_aux * Math.pow(lat_aux, 2) -
|
||||
44.54 * Math.pow(lng_aux, 3);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
// Convert WGS lat/long (° dec) to CH x
|
||||
function WGStoCHx(lat, lng) {
|
||||
|
||||
// Converts degrees dec to sex
|
||||
lat = DECtoSEX(lat);
|
||||
lng = DECtoSEX(lng);
|
||||
|
||||
// Converts degrees to seconds (sex)
|
||||
lat = DEGtoSEC(lat);
|
||||
lng = DEGtoSEC(lng);
|
||||
|
||||
// Axiliary values (% Bern)
|
||||
var lat_aux = (lat - 169028.66) / 10000;
|
||||
var lng_aux = (lng - 26782.5) / 10000;
|
||||
|
||||
// Process X
|
||||
var x = 200147.07 +
|
||||
308807.95 * lat_aux +
|
||||
3745.25 * Math.pow(lng_aux, 2) +
|
||||
76.63 * Math.pow(lat_aux, 2) -
|
||||
194.56 * Math.pow(lng_aux, 2) * lat_aux +
|
||||
119.79 * Math.pow(lat_aux, 3);
|
||||
|
||||
return x;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Convert CH y/x to WGS lat
|
||||
function CHtoWGSlat(y, x) {
|
||||
|
||||
// Converts militar to civil and to unit = 1000km
|
||||
// Axiliary values (% Bern)
|
||||
var y_aux = (y - 600000) / 1000000;
|
||||
var x_aux = (x - 200000) / 1000000;
|
||||
|
||||
// Process lat
|
||||
var lat = 16.9023892 +
|
||||
3.238272 * x_aux -
|
||||
0.270978 * Math.pow(y_aux, 2) -
|
||||
0.002528 * Math.pow(x_aux, 2) -
|
||||
0.0447 * Math.pow(y_aux, 2) * x_aux -
|
||||
0.0140 * Math.pow(x_aux, 3);
|
||||
|
||||
// Unit 10000" to 1 " and converts seconds to degrees (dec)
|
||||
lat = lat * 100 / 36;
|
||||
|
||||
return lat;
|
||||
|
||||
}
|
||||
|
||||
// Convert CH y/x to WGS long
|
||||
function CHtoWGSlng(y, x) {
|
||||
|
||||
// Converts militar to civil and to unit = 1000km
|
||||
// Axiliary values (% Bern)
|
||||
var y_aux = (y - 600000) / 1000000;
|
||||
var x_aux = (x - 200000) / 1000000;
|
||||
|
||||
// Process long
|
||||
var lng = 2.6779094 +
|
||||
4.728982 * y_aux +
|
||||
0.791484 * y_aux * x_aux +
|
||||
0.1306 * y_aux * Math.pow(x_aux, 2) -
|
||||
0.0436 * Math.pow(y_aux, 3);
|
||||
|
||||
// Unit 10000" to 1 " and converts seconds to degrees (dec)
|
||||
lng = lng * 100 / 36;
|
||||
|
||||
return lng;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Convert SEX DMS angle to DEC
|
||||
function SEXtoDEC(angle) {
|
||||
|
||||
// Extract DMS
|
||||
var deg = parseInt(angle, 10);
|
||||
var min = parseInt((angle - deg) * 100, 10);
|
||||
var sec = (((angle - deg) * 100) - min) * 100;
|
||||
|
||||
// Result in degrees sex (dd.mmss)
|
||||
return deg + (sec / 60 + min) / 60;
|
||||
|
||||
}
|
||||
|
||||
// Convert DEC angle to SEX DMS
|
||||
function DECtoSEX(angle) {
|
||||
|
||||
// Extract DMS
|
||||
var deg = parseInt(angle, 10);
|
||||
var min = parseInt((angle - deg) * 60, 10);
|
||||
var sec = (((angle - deg) * 60) - min) * 60;
|
||||
|
||||
// Result in degrees sex (dd.mmss)
|
||||
return deg + min / 100 + sec / 10000;
|
||||
|
||||
}
|
||||
|
||||
// Convert Degrees angle to seconds
|
||||
function DEGtoSEC(angle) {
|
||||
|
||||
// Extract DMS
|
||||
var deg = parseInt(angle, 10);
|
||||
var min = parseInt((angle - deg) * 100, 10);
|
||||
var sec = (((angle - deg) * 100) - min) * 100;
|
||||
|
||||
// Avoid rounding problems with seconds=0
|
||||
var parts = String(angle).split('.');
|
||||
if (parts.length == 2 && parts[1].length == 2) {
|
||||
min = Number(parts[1]);
|
||||
sec = 0;
|
||||
}
|
||||
|
||||
// Result in degrees sex (dd.mmss)
|
||||
return sec + min * 60 + deg * 3600;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Single image WMS with custom projection example</title>
|
||||
<title>Single image WMS with Proj4js projection example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Single image WMS with custom projection example</h4>
|
||||
<h4 id="title">Single image WMS with Proj4js projection example</h4>
|
||||
<p id="shortdesc">Example of two single image WMS layers.</p>
|
||||
<div id="docs">
|
||||
<p>Pixelmap 1:1'000'000 with National Parks overlay using the projection EPSG:21781.</p>
|
||||
<p>See the <a href="wms-image-custom-proj.js" target="_blank">wms-image-custom-proj.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">wms, single image, projection</div>
|
||||
<div id="tags">wms, single image, proj4js, projection</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -45,8 +45,8 @@
|
||||
</div>
|
||||
|
||||
<script src="jquery.min.js" type="text/javascript"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
|
||||
<script src="http://epsg.io/21781.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>
|
||||
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.layer.Image');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.ImageWMS');
|
||||
|
||||
|
||||
var projection = ol.proj.configureProj4jsProjection({
|
||||
code: 'EPSG:21781',
|
||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
|
||||
});
|
||||
// Transparent Proj4js support: ol.proj.get() creates and returns a projection
|
||||
// known to Proj4js if it is unknown to OpenLayers, and registers functions to
|
||||
// transform between all registered projections.
|
||||
// EPSG:21781 is known to Proj4js because its definition was loaded in the html.
|
||||
var projection = ol.proj.get('EPSG:21781');
|
||||
// The extent is used to determine zoom level 0. Recommended values for a
|
||||
// projection's validity extent can be found at http://epsg.io/.
|
||||
projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]);
|
||||
|
||||
var extent = [420000, 30000, 900000, 350000];
|
||||
var layers = [
|
||||
@@ -49,12 +55,15 @@ var layers = [
|
||||
];
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([
|
||||
new ol.control.ScaleLine()
|
||||
]),
|
||||
layers: layers,
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
projection: projection,
|
||||
center: [660000, 190000],
|
||||
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
|
||||
extent: extent,
|
||||
zoom: 2
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
@@ -53,6 +54,11 @@ var map = new ol.Map({
|
||||
})
|
||||
],
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
view: new ol.View({
|
||||
center: [-11158582, 4813697],
|
||||
zoom: 4
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>WMTS from capabilities example</title>
|
||||
<title>XYZ Retina tiles example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -31,20 +31,22 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">WMTS from capabilities example</h4>
|
||||
<p id="shortdesc">Example of a WMTS source built from a WMTS getCapabilities response.</p>
|
||||
<h4 id="title">XYZ with Retina tiles example</h4>
|
||||
<p id="shortdesc">Example of Retina / HiDPI mercator tiles (512x512px) available as XYZ.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="wmts-from-capabilities.js" target="_blank">wmts-from-capabilities.js source</a> to see how this is done.</p>
|
||||
<p>The ol.source.XYZ must contain <code>tilePixelRatio</code> parameter. The tiles were prepared from a GeoTIFF file with <a href="http://www.maptiler.com/">MapTiler</a>.</p>
|
||||
<p>See the <a href="xyz-retina.js" target="_blank">xyz-retina.js source</a> for details on how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">wmts</div>
|
||||
<div id="tags">retina, hidpi, xyz, maptiler, @2x, devicePixelRatio</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=wmts-from-capabilities" type="text/javascript"></script>
|
||||
<script src="jquery.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=xyz-retina" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
41
examples/xyz-retina.js
Normal file
41
examples/xyz-retina.js
Normal file
@@ -0,0 +1,41 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.OSM');
|
||||
goog.require('ol.source.XYZ');
|
||||
|
||||
|
||||
var attribution = new ol.Attribution({
|
||||
html: 'Tiles rendered with <a href="http://www.maptiler.com/"> © USGS'
|
||||
});
|
||||
|
||||
var mapMinZoom = 1;
|
||||
var mapMaxZoom = 15;
|
||||
var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062];
|
||||
|
||||
var map = new ol.Map({
|
||||
target: 'map',
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.XYZ({
|
||||
url: 'http://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png',
|
||||
tilePixelRatio: 2, // THIS IS IMPORTANT
|
||||
maxExtent: ol.proj.transformExtent(
|
||||
mapExtent, 'EPSG:4326', 'EPSG:3857'),
|
||||
minZoom: mapMinZoom,
|
||||
maxZoom: mapMaxZoom
|
||||
})
|
||||
})
|
||||
],
|
||||
view: new ol.View({
|
||||
projection: 'EPSG:3857',
|
||||
center: ol.proj.transform([-112.18688965, 36.057944835],
|
||||
'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 12
|
||||
})
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
goog.require('ol.source.XYZ');
|
||||
@@ -13,6 +14,11 @@ var attribution = new ol.Attribution({
|
||||
|
||||
var map = new ol.Map({
|
||||
target: 'map',
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM({
|
||||
|
||||
@@ -8,63 +8,6 @@
|
||||
* @externs
|
||||
*/
|
||||
|
||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
|
||||
|
||||
|
||||
/** @type {Date} */
|
||||
HTMLInputElement.prototype.valueAsDate;
|
||||
|
||||
|
||||
/** @type {number} */
|
||||
HTMLInputElement.prototype.valueAsNumber;
|
||||
|
||||
|
||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
|
||||
|
||||
|
||||
/** @type {?number} */
|
||||
DeviceRotationRate.prototype.alpha;
|
||||
|
||||
|
||||
/** @type {?number} */
|
||||
DeviceRotationRate.prototype.beta;
|
||||
|
||||
|
||||
/** @type {?number} */
|
||||
DeviceRotationRate.prototype.gamma;
|
||||
|
||||
|
||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
|
||||
|
||||
|
||||
/** @type {?number} */
|
||||
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
|
||||
|
||||
|
||||
/** @type {?number} */
|
||||
DeviceOrientationEvent.prototype.webkitCompassHeading;
|
||||
|
||||
|
||||
// IE 11 fullscreen API
|
||||
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
|
||||
|
||||
|
||||
/** @return {void} */
|
||||
Element.prototype.msRequestFullscreen = function() {};
|
||||
|
||||
|
||||
/** @return {void} */
|
||||
Element.prototype.msExitFullscreen = function() {};
|
||||
|
||||
|
||||
/** @type {boolean} */
|
||||
Document.prototype.msFullscreenEnabled;
|
||||
|
||||
|
||||
/** @type {Element} */
|
||||
Document.prototype.msFullscreenElement;
|
||||
|
||||
|
||||
/** @type {number} */
|
||||
Touch.prototype.force;
|
||||
|
||||
|
||||
2296
externs/jquery-1.7.js
vendored
Normal file
2296
externs/jquery-1.7.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
330
externs/olx.js
330
externs/olx.js
@@ -10,7 +10,7 @@ var olx;
|
||||
/**
|
||||
* @typedef {{html: string,
|
||||
* tileRanges: (Object.<string, Array.<ol.TileRange>>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.AttributionOptions;
|
||||
|
||||
@@ -32,7 +32,7 @@ olx.AttributionOptions.prototype.tileRanges;
|
||||
/**
|
||||
* @typedef {{loadTilesWhileAnimating: (boolean|undefined),
|
||||
* loadTilesWhileInteracting: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.DeviceOptions;
|
||||
|
||||
@@ -55,7 +55,7 @@ olx.DeviceOptions.prototype.loadTilesWhileInteracting;
|
||||
|
||||
/**
|
||||
* @typedef {{tracking: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.DeviceOrientationOptions;
|
||||
|
||||
@@ -71,7 +71,7 @@ olx.DeviceOrientationOptions.prototype.tracking;
|
||||
* @typedef {{tracking: (boolean|undefined),
|
||||
* trackingOptions: (GeolocationPositionOptions|undefined),
|
||||
* projection: ol.proj.ProjectionLike}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.GeolocationOptions;
|
||||
|
||||
@@ -111,7 +111,7 @@ olx.GeolocationOptions.prototype.projection;
|
||||
* renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined),
|
||||
* target: (Element|string|undefined),
|
||||
* view: (ol.View|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.MapOptions;
|
||||
|
||||
@@ -216,7 +216,7 @@ olx.MapOptions.prototype.view;
|
||||
* positioning: (ol.OverlayPositioning|string|undefined),
|
||||
* stopEvent: (boolean|undefined),
|
||||
* insertFirst: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.OverlayOptions;
|
||||
|
||||
@@ -274,37 +274,6 @@ olx.OverlayOptions.prototype.stopEvent;
|
||||
olx.OverlayOptions.prototype.insertFirst;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with config options for the Proj4js projection.
|
||||
* @typedef {{code: string,
|
||||
* extent: (ol.Extent|undefined),
|
||||
* global: (boolean|undefined)}}
|
||||
* @todo api
|
||||
*/
|
||||
olx.Proj4jsProjectionOptions;
|
||||
|
||||
|
||||
/**
|
||||
* The SRS identifier code, e.g. `EPSG:31256`.
|
||||
* @type {string}
|
||||
*/
|
||||
olx.Proj4jsProjectionOptions.prototype.code;
|
||||
|
||||
|
||||
/**
|
||||
* The validity extent for the SRS.
|
||||
* @type {ol.Extent|undefined}
|
||||
*/
|
||||
olx.Proj4jsProjectionOptions.prototype.extent;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the projection is valid for the whole globe. Default is `false`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
olx.Proj4jsProjectionOptions.prototype.global;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with config options for the projection.
|
||||
* @typedef {{code: string,
|
||||
@@ -312,7 +281,7 @@ olx.Proj4jsProjectionOptions.prototype.global;
|
||||
* extent: (ol.Extent|undefined),
|
||||
* axisOrientation: (string|undefined),
|
||||
* global: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.ProjectionOptions;
|
||||
|
||||
@@ -368,7 +337,7 @@ olx.ProjectionOptions.prototype.global;
|
||||
* rotation: (number|undefined),
|
||||
* zoom: (number|undefined),
|
||||
* zoomFactor: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.ViewOptions;
|
||||
|
||||
@@ -506,7 +475,7 @@ olx.ViewOptions.prototype.zoomFactor;
|
||||
* start: (number|undefined),
|
||||
* duration: (number|undefined),
|
||||
* easing: (function(number):number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.animation.BounceOptions;
|
||||
|
||||
@@ -546,7 +515,7 @@ olx.animation.BounceOptions.prototype.easing;
|
||||
* start: (number|undefined),
|
||||
* duration: (number|undefined),
|
||||
* easing: (function(number):number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.animation.PanOptions;
|
||||
|
||||
@@ -586,7 +555,7 @@ olx.animation.PanOptions.prototype.easing;
|
||||
* start: (number|undefined),
|
||||
* duration: (number|undefined),
|
||||
* easing: (function(number):number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.animation.RotateOptions;
|
||||
|
||||
@@ -634,7 +603,7 @@ olx.animation.RotateOptions.prototype.easing;
|
||||
* start: (number|undefined),
|
||||
* duration: (number|undefined),
|
||||
* easing: (function(number):number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.animation.ZoomOptions;
|
||||
|
||||
@@ -672,7 +641,7 @@ olx.animation.ZoomOptions.prototype.easing;
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.AttributionOptions;
|
||||
|
||||
@@ -691,10 +660,46 @@ olx.control.AttributionOptions.prototype.className;
|
||||
olx.control.AttributionOptions.prototype.target;
|
||||
|
||||
|
||||
/**
|
||||
* Specify if attributions can be collapsed. If you use an OSM source,
|
||||
* should be set to `false` — see
|
||||
* {@link http://www.openstreetmap.org/copyright OSM Copyright} —
|
||||
* Default is `true`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.collapsible;
|
||||
|
||||
|
||||
/**
|
||||
* Specify if attributions should be collapsed at startup. Default is `true`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.collapsed;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button tip. Default is `Attributions`
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.tipLabel;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the collapsed attributions button. Default is `i`
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.label;
|
||||
|
||||
/**
|
||||
* Text label to use for the expanded attributions button. Default is `»`
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.collapseLabel;
|
||||
|
||||
/**
|
||||
* @typedef {{element: (Element|undefined),
|
||||
* target: (Element|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ControlOptions;
|
||||
|
||||
@@ -718,12 +723,10 @@ olx.control.ControlOptions.prototype.target;
|
||||
/**
|
||||
* @typedef {{attribution: (boolean|undefined),
|
||||
* attributionOptions: (olx.control.AttributionOptions|undefined),
|
||||
* logo: (boolean|undefined),
|
||||
* logoOptions: (olx.control.LogoOptions|undefined),
|
||||
* zoom: (boolean|undefined),
|
||||
* rotateOptions: (olx.control.RotateOptions|undefined),
|
||||
* zoomOptions: (olx.control.ZoomOptions|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.DefaultsOptions;
|
||||
|
||||
@@ -742,20 +745,6 @@ olx.control.DefaultsOptions.prototype.attribution;
|
||||
olx.control.DefaultsOptions.prototype.attributionOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Logo. Default is `true`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
olx.control.DefaultsOptions.prototype.logo;
|
||||
|
||||
|
||||
/**
|
||||
* Logo options.
|
||||
* @type {olx.control.LogoOptions|undefined}
|
||||
*/
|
||||
olx.control.DefaultsOptions.prototype.logoOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Rotate. Default is `true`.
|
||||
* @type {boolean|undefined}
|
||||
@@ -789,7 +778,7 @@ olx.control.DefaultsOptions.prototype.zoomOptions;
|
||||
* tipLabel: (string|undefined),
|
||||
* keys: (boolean|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.FullScreenOptions;
|
||||
|
||||
@@ -822,35 +811,13 @@ olx.control.FullScreenOptions.prototype.keys;
|
||||
olx.control.FullScreenOptions.prototype.target;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @todo api
|
||||
*/
|
||||
olx.control.LogoOptions;
|
||||
|
||||
|
||||
/**
|
||||
* CSS class name. Default is `ol-logo`.
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
olx.control.LogoOptions.prototype.className;
|
||||
|
||||
|
||||
/**
|
||||
* Target.
|
||||
* @type {Element|undefined}
|
||||
*/
|
||||
olx.control.LogoOptions.prototype.target;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* coordinateFormat: (ol.CoordinateFormatType|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* target: (Element|undefined),
|
||||
* undefinedHTML: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.MousePositionOptions;
|
||||
|
||||
@@ -895,7 +862,7 @@ olx.control.MousePositionOptions.prototype.undefinedHTML;
|
||||
* minWidth: (number|undefined),
|
||||
* target: (Element|undefined),
|
||||
* units: (ol.control.ScaleLineUnits|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ScaleLineOptions;
|
||||
|
||||
@@ -935,7 +902,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
||||
* tipLabel: (string|undefined),
|
||||
* target: (Element|undefined),
|
||||
* autoHide: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.RotateOptions;
|
||||
|
||||
@@ -991,7 +958,7 @@ olx.control.RotateOptions.prototype.target;
|
||||
* zoomOutTipLabel: (string|undefined),
|
||||
* delta: (number|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ZoomOptions;
|
||||
|
||||
@@ -1056,7 +1023,7 @@ olx.control.ZoomOptions.prototype.target;
|
||||
* @typedef {{className: (string|undefined),
|
||||
* maxResolution: (number|undefined),
|
||||
* minResolution: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ZoomSliderOptions;
|
||||
|
||||
@@ -1087,7 +1054,7 @@ olx.control.ZoomSliderOptions.prototype.minResolution;
|
||||
* target: (Element|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* extent: (ol.Extent|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ZoomToExtentOptions;
|
||||
|
||||
@@ -1124,7 +1091,7 @@ olx.control.ZoomToExtentOptions.prototype.extent;
|
||||
/**
|
||||
* @typedef {{defaultProjection: ol.proj.ProjectionLike,
|
||||
* geometryName: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.GeoJSONOptions;
|
||||
|
||||
@@ -1145,7 +1112,7 @@ olx.format.GeoJSONOptions.prototype.geometryName;
|
||||
|
||||
/**
|
||||
* @typedef {{factor: (number|undefined)}}
|
||||
* @todo stability experimental
|
||||
* @api
|
||||
*/
|
||||
olx.format.PolylineOptions;
|
||||
|
||||
@@ -1160,7 +1127,7 @@ olx.format.PolylineOptions.prototype.factor;
|
||||
|
||||
/**
|
||||
* @typedef {{defaultProjection: ol.proj.ProjectionLike}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.TopoJSONOptions;
|
||||
|
||||
@@ -1174,7 +1141,7 @@ olx.format.TopoJSONOptions.prototype.defaultProjection;
|
||||
|
||||
/**
|
||||
* @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.IGCOptions;
|
||||
|
||||
@@ -1189,7 +1156,7 @@ olx.format.IGCOptions.prototype.altitudeMode;
|
||||
|
||||
/**
|
||||
* @typedef {{defaultStyle: (Array.<ol.style.Style>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.KMLOptions;
|
||||
|
||||
@@ -1210,7 +1177,7 @@ olx.format.KMLOptions.prototype.defaultStyle;
|
||||
* multiCurve: (boolean|undefined),
|
||||
* multiSurface: (boolean|undefined),
|
||||
* schemaLocation: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.GMLOptions;
|
||||
|
||||
@@ -1280,7 +1247,7 @@ olx.format.GMLOptions.prototype.schemaLocation;
|
||||
* @typedef {{featureNS: string,
|
||||
* featureType: string,
|
||||
* schemaLocation: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.WFSOptions;
|
||||
|
||||
@@ -1317,7 +1284,7 @@ olx.format.WFSOptions.prototype.schemaLocation;
|
||||
* maxFeatures: (number|undefined),
|
||||
* geometryName: (string|undefined),
|
||||
* bbox: (ol.Extent|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.WFSWriteGetFeatureOptions;
|
||||
|
||||
@@ -1394,7 +1361,7 @@ olx.format.WFSWriteGetFeatureOptions.prototype.bbox;
|
||||
* handle: (string|undefined),
|
||||
* nativeElements: Array.<Object>,
|
||||
* gmlOptions: (olx.format.GMLOptions|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.WFSWriteTransactionOptions;
|
||||
|
||||
@@ -1451,7 +1418,7 @@ olx.format.WFSWriteTransactionOptions.prototype.gmlOptions;
|
||||
|
||||
/**
|
||||
* @typedef {{splitCollection: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.format.WKTOptions;
|
||||
|
||||
@@ -1475,7 +1442,7 @@ olx.format.WKTOptions.prototype.splitCollection;
|
||||
* pinchZoom: (boolean|undefined),
|
||||
* zoomDelta: (number|undefined),
|
||||
* zoomDuration: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DefaultsOptions;
|
||||
|
||||
@@ -1553,7 +1520,7 @@ olx.interaction.DefaultsOptions.prototype.zoomDuration;
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined),
|
||||
* delta: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DoubleClickZoomOptions;
|
||||
|
||||
@@ -1575,7 +1542,7 @@ olx.interaction.DoubleClickZoomOptions.prototype.delta;
|
||||
/**
|
||||
* @typedef {{formatConstructors: (Array.<function(new: ol.format.Feature)>|undefined),
|
||||
* reprojectTo: ol.proj.ProjectionLike}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragAndDropOptions;
|
||||
|
||||
@@ -1597,7 +1564,7 @@ olx.interaction.DragAndDropOptions.prototype.reprojectTo;
|
||||
/**
|
||||
* @typedef {{condition: (ol.events.ConditionType|undefined),
|
||||
* style: ol.style.Style}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragBoxOptions;
|
||||
|
||||
@@ -1620,7 +1587,7 @@ olx.interaction.DragBoxOptions.prototype.style;
|
||||
|
||||
/**
|
||||
* @typedef {{kinetic: (ol.Kinetic|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragPanOptions;
|
||||
|
||||
@@ -1634,7 +1601,7 @@ olx.interaction.DragPanOptions.prototype.kinetic;
|
||||
|
||||
/**
|
||||
* @typedef {{condition: (ol.events.ConditionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragRotateAndZoomOptions;
|
||||
|
||||
@@ -1650,7 +1617,7 @@ olx.interaction.DragRotateAndZoomOptions.prototype.condition;
|
||||
|
||||
/**
|
||||
* @typedef {{condition: (ol.events.ConditionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragRotateOptions;
|
||||
|
||||
@@ -1667,7 +1634,7 @@ olx.interaction.DragRotateOptions.prototype.condition;
|
||||
/**
|
||||
* @typedef {{condition: (ol.events.ConditionType|undefined),
|
||||
* style: ol.style.Style}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DragZoomOptions;
|
||||
|
||||
@@ -1697,7 +1664,7 @@ olx.interaction.DragZoomOptions.prototype.style;
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined),
|
||||
* geometryName: (string|undefined),
|
||||
* condition: (ol.events.ConditionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.DrawOptions;
|
||||
|
||||
@@ -1765,7 +1732,7 @@ olx.interaction.DrawOptions.prototype.condition;
|
||||
/**
|
||||
* @typedef {{condition: (ol.events.ConditionType|undefined),
|
||||
* pixelDelta: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.KeyboardPanOptions;
|
||||
|
||||
@@ -1791,7 +1758,7 @@ olx.interaction.KeyboardPanOptions.prototype.pixelDelta;
|
||||
* @typedef {{duration: (number|undefined),
|
||||
* condition: (ol.events.ConditionType|undefined),
|
||||
* delta: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.KeyboardZoomOptions;
|
||||
|
||||
@@ -1824,7 +1791,7 @@ olx.interaction.KeyboardZoomOptions.prototype.delta;
|
||||
* pixelTolerance: (number|undefined),
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined),
|
||||
* features: ol.Collection}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.ModifyOptions;
|
||||
|
||||
@@ -1863,7 +1830,7 @@ olx.interaction.ModifyOptions.prototype.features;
|
||||
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.MouseWheelZoomOptions;
|
||||
|
||||
@@ -1877,7 +1844,7 @@ olx.interaction.MouseWheelZoomOptions.prototype.duration;
|
||||
|
||||
/**
|
||||
* @typedef {{threshold: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PinchRotateOptions;
|
||||
|
||||
@@ -1891,7 +1858,7 @@ olx.interaction.PinchRotateOptions.prototype.threshold;
|
||||
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PinchZoomOptions;
|
||||
|
||||
@@ -1910,7 +1877,7 @@ olx.interaction.PinchZoomOptions.prototype.duration;
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined),
|
||||
* removeCondition: (ol.events.ConditionType|undefined),
|
||||
* toggleCondition: (ol.events.ConditionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.SelectOptions;
|
||||
|
||||
@@ -1918,8 +1885,8 @@ olx.interaction.SelectOptions;
|
||||
/**
|
||||
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||
* to indicate whether that event should be handled.
|
||||
* By default, this is {@link ol.events.condition.never}, though note that the
|
||||
* default toggle condition allows features to be added.
|
||||
* By default, this is {@link ol.events.condition.never}. Use this if you want
|
||||
* to use different events for add and remove instead of `toggle`.
|
||||
* @type {ol.events.ConditionType|undefined}
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.addCondition;
|
||||
@@ -1928,7 +1895,12 @@ olx.interaction.SelectOptions.prototype.addCondition;
|
||||
/**
|
||||
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||
* to indicate whether that event should be handled.
|
||||
* By default, {@link ol.events.condition.singleClick} toggles the selection.
|
||||
* This is the event for the selected features as a whole. By default, this is
|
||||
* {@link ol.events.condition.singleClick}. Clicking on a feature selects that
|
||||
* feature and removes any that were in the selection. Clicking outside any
|
||||
* feature removes all from the selection.
|
||||
* See `toggle`, `add`, `remove` options for adding/removing extra features to/
|
||||
* from the selection.
|
||||
* @type {ol.events.ConditionType|undefined}
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.condition;
|
||||
@@ -1946,7 +1918,7 @@ olx.interaction.SelectOptions.prototype.layers;
|
||||
|
||||
|
||||
/**
|
||||
* FeatureOverlay style.
|
||||
* Style for the selected features (those in the FeatureOverlay).
|
||||
* @type {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined}
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.style;
|
||||
@@ -1955,7 +1927,8 @@ olx.interaction.SelectOptions.prototype.style;
|
||||
/**
|
||||
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||
* to indicate whether that event should be handled.
|
||||
* By default, this is {@link ol.events.condition.never}.
|
||||
* By default, this is {@link ol.events.condition.never}. Use this if you want
|
||||
* to use different events for add and remove instead of `toggle`.
|
||||
* @type {ol.events.ConditionType|undefined}
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.removeCondition;
|
||||
@@ -1964,8 +1937,12 @@ olx.interaction.SelectOptions.prototype.removeCondition;
|
||||
/**
|
||||
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||
* to indicate whether that event should be handled.
|
||||
* By default, {@link ol.events.condition.shiftKeyOnly} toggles the
|
||||
* feature in the current selection.
|
||||
* This is in addition to the `condition` event. By default,
|
||||
* {@link ol.events.condition.shiftKeyOnly}, i.e. pressing `shift` as well as
|
||||
* the `condition` event, adds that feature to the current selection if it is
|
||||
* not currently selected, and removes it if it is.
|
||||
* See `add` and `remove` if you want to use different events instead of a
|
||||
* toggle.
|
||||
* @type {ol.events.ConditionType|undefined}
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.toggleCondition;
|
||||
@@ -1980,7 +1957,7 @@ olx.interaction.SelectOptions.prototype.toggleCondition;
|
||||
* visible: (boolean|undefined),
|
||||
* minResolution: (number|undefined),
|
||||
* maxResolution: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.BaseOptions;
|
||||
|
||||
@@ -2051,7 +2028,7 @@ olx.layer.BaseOptions.prototype.maxResolution;
|
||||
* visible: (boolean|undefined),
|
||||
* minResolution: (number|undefined),
|
||||
* maxResolution: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.LayerOptions;
|
||||
|
||||
@@ -2129,7 +2106,7 @@ olx.layer.LayerOptions.prototype.maxResolution;
|
||||
* minResolution: (number|undefined),
|
||||
* maxResolution: (number|undefined),
|
||||
* layers: (Array.<ol.layer.Base>|ol.Collection|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.GroupOptions;
|
||||
|
||||
@@ -2212,7 +2189,7 @@ olx.layer.GroupOptions.prototype.layers;
|
||||
* saturation: (number|undefined),
|
||||
* source: ol.source.Vector,
|
||||
* visible: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.HeatmapOptions;
|
||||
|
||||
@@ -2330,7 +2307,7 @@ olx.layer.HeatmapOptions.prototype.visible;
|
||||
* minResolution: (number|undefined),
|
||||
* maxResolution: (number|undefined),
|
||||
* useInterimTilesOnError: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.TileOptions;
|
||||
|
||||
@@ -2424,7 +2401,7 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
|
||||
* source: ol.source.Vector,
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined),
|
||||
* visible: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.layer.VectorOptions;
|
||||
|
||||
@@ -2512,7 +2489,7 @@ olx.layer.VectorOptions.prototype.visible;
|
||||
* @typedef {{features: (Array.<ol.Feature>|ol.Collection|undefined),
|
||||
* map: (ol.Map|undefined),
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.FeatureOverlayOptions;
|
||||
|
||||
@@ -2543,7 +2520,7 @@ olx.FeatureOverlayOptions.prototype.style;
|
||||
* key: string,
|
||||
* imagerySet: string,
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.BingMapsOptions;
|
||||
|
||||
@@ -2582,7 +2559,7 @@ olx.source.BingMapsOptions.prototype.tileLoadFunction;
|
||||
* format: ol.format.Feature,
|
||||
* logo: (string|undefined),
|
||||
* projection: ol.proj.ProjectionLike}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.FormatVectorOptions;
|
||||
|
||||
@@ -2632,7 +2609,7 @@ olx.source.FormatVectorOptions.prototype.projection;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.GeoJSONOptions;
|
||||
|
||||
@@ -2711,7 +2688,7 @@ olx.source.GeoJSONOptions.prototype.urls;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.GPXOptions;
|
||||
|
||||
@@ -2794,7 +2771,7 @@ olx.source.GPXOptions.prototype.urls;
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* tilePixelRatio: (number|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TileImageOptions;
|
||||
|
||||
@@ -2893,7 +2870,7 @@ olx.source.TileImageOptions.prototype.tileUrlFunction;
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TileVectorOptions;
|
||||
|
||||
@@ -2986,7 +2963,7 @@ olx.source.TileVectorOptions.prototype.urls;
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TopoJSONOptions;
|
||||
|
||||
@@ -3054,7 +3031,7 @@ olx.source.TopoJSONOptions.prototype.url;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.IGCOptions;
|
||||
|
||||
@@ -3107,7 +3084,7 @@ olx.source.IGCOptions.prototype.urls;
|
||||
* ratio: (number|undefined),
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* params: (Object|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.MapGuideOptions;
|
||||
|
||||
@@ -3195,7 +3172,7 @@ olx.source.MapGuideOptions.prototype.params;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.KMLOptions;
|
||||
|
||||
@@ -3274,7 +3251,7 @@ olx.source.KMLOptions.prototype.urls;
|
||||
/**
|
||||
* @typedef {{layer: string,
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.MapQuestOptions;
|
||||
|
||||
@@ -3297,7 +3274,7 @@ olx.source.MapQuestOptions.prototype.tileLoadFunction;
|
||||
* @typedef {{extent: (ol.Extent|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TileDebugOptions;
|
||||
|
||||
@@ -3329,7 +3306,7 @@ olx.source.TileDebugOptions.prototype.tileGrid;
|
||||
* maxZoom: (number|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* url: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.OSMOptions;
|
||||
|
||||
@@ -3382,7 +3359,7 @@ olx.source.OSMOptions.prototype.url;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.OSMXMLOptions;
|
||||
|
||||
@@ -3473,7 +3450,7 @@ olx.source.OSMXMLOptions.prototype.urls;
|
||||
* ratio: (number|undefined),
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* state: (ol.source.State|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ImageCanvasOptions;
|
||||
|
||||
@@ -3552,7 +3529,7 @@ olx.source.ImageCanvasOptions.prototype.state;
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* source: ol.source.Vector,
|
||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ImageVectorOptions;
|
||||
|
||||
@@ -3628,7 +3605,7 @@ olx.source.ImageVectorOptions.prototype.style;
|
||||
* ratio: (number|undefined),
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* url: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ImageWMSOptions;
|
||||
|
||||
@@ -3722,7 +3699,7 @@ olx.source.ImageWMSOptions.prototype.url;
|
||||
* opaque: (boolean|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* url: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.StamenOptions;
|
||||
|
||||
@@ -3778,7 +3755,7 @@ olx.source.StamenOptions.prototype.url;
|
||||
* logo: (string|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* url: string}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ImageStaticOptions;
|
||||
|
||||
@@ -3847,7 +3824,7 @@ olx.source.ImageStaticOptions.prototype.url;
|
||||
* strategy: (function(ol.Extent, number): Array.<ol.Extent>|undefined),
|
||||
* logo: (string|undefined),
|
||||
* projection: ol.proj.ProjectionLike}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ServerVectorOptions;
|
||||
|
||||
@@ -3906,7 +3883,7 @@ olx.source.ServerVectorOptions.prototype.projection;
|
||||
* @typedef {{crossOrigin: (null|string|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* url: string}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TileJSONOptions;
|
||||
|
||||
@@ -3947,7 +3924,7 @@ olx.source.TileJSONOptions.prototype.url;
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.TileWMSOptions;
|
||||
|
||||
@@ -4069,7 +4046,7 @@ olx.source.TileWMSOptions.prototype.urls;
|
||||
* logo: (string|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* state: (ol.source.State|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.VectorOptions;
|
||||
|
||||
@@ -4129,7 +4106,7 @@ olx.source.VectorOptions.prototype.state;
|
||||
* text: (string|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.StaticVectorOptions;
|
||||
|
||||
@@ -4237,7 +4214,7 @@ olx.source.StaticVectorOptions.prototype.urls;
|
||||
* maxZoom: (number|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* urls: (Array.<string>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.WMTSOptions;
|
||||
|
||||
@@ -4380,11 +4357,12 @@ olx.source.WMTSOptions.prototype.urls;
|
||||
* maxZoom: (number|undefined),
|
||||
* minZoom: (number|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* tilePixelRatio: (number|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
|
||||
* url: (string|undefined),
|
||||
* urls: (Array.<string>|undefined),
|
||||
* wrapX: (boolean|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.XYZOptions;
|
||||
|
||||
@@ -4445,6 +4423,16 @@ olx.source.XYZOptions.prototype.minZoom;
|
||||
olx.source.XYZOptions.prototype.tileLoadFunction;
|
||||
|
||||
|
||||
/**
|
||||
* The pixel ratio used by the tile service. For example, if the tile
|
||||
* service advertizes 256px by 256px tiles but actually sends 512px
|
||||
* by 512px images (for retina/hidpi devices) then `tilePixelRatio`
|
||||
* should be set to `2`. Default is `1`.
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
olx.source.XYZOptions.prototype.tilePixelRatio;
|
||||
|
||||
|
||||
/**
|
||||
* Optional function to get tile URL given a tile coordinate and the projection.
|
||||
* Required if url or urls are not provided.
|
||||
@@ -4481,7 +4469,7 @@ olx.source.XYZOptions.prototype.wrapX;
|
||||
* url: !string,
|
||||
* tierSizeCalculation: (string|undefined),
|
||||
* size: ol.Size}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.source.ZoomifyOptions;
|
||||
|
||||
@@ -4533,7 +4521,7 @@ olx.source.ZoomifyOptions.prototype.size;
|
||||
* radius: number,
|
||||
* snapToPixel: (boolean|undefined),
|
||||
* stroke: (ol.style.Stroke|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.CircleOptions;
|
||||
|
||||
@@ -4574,7 +4562,7 @@ olx.style.CircleOptions.prototype.stroke;
|
||||
|
||||
/**
|
||||
* @typedef {{color: (ol.Color|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.FillOptions;
|
||||
|
||||
@@ -4601,7 +4589,7 @@ olx.style.FillOptions.prototype.color;
|
||||
* rotation: (number|undefined),
|
||||
* size: (ol.Size|undefined),
|
||||
* src: (string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.IconOptions;
|
||||
|
||||
@@ -4726,7 +4714,7 @@ olx.style.IconOptions.prototype.src;
|
||||
* lineDash: (Array.<number>|undefined),
|
||||
* miterLimit: (number|undefined),
|
||||
* width: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.StrokeOptions;
|
||||
|
||||
@@ -4784,7 +4772,7 @@ olx.style.StrokeOptions.prototype.width;
|
||||
* textBaseline: (string|undefined),
|
||||
* fill: (ol.style.Fill|undefined),
|
||||
* stroke: (ol.style.Stroke|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.TextOptions;
|
||||
|
||||
@@ -4867,7 +4855,7 @@ olx.style.TextOptions.prototype.stroke;
|
||||
* stroke: (ol.style.Stroke|undefined),
|
||||
* text: (ol.style.Text|undefined),
|
||||
* zIndex: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.style.StyleOptions;
|
||||
|
||||
@@ -4914,7 +4902,7 @@ olx.style.StyleOptions.prototype.zIndex;
|
||||
* resolutions: !Array.<number>,
|
||||
* tileSize: (number|undefined),
|
||||
* tileSizes: (Array.<number>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.TileGridOptions;
|
||||
|
||||
@@ -4968,7 +4956,7 @@ olx.tilegrid.TileGridOptions.prototype.tileSizes;
|
||||
* matrixIds: !Array.<string>,
|
||||
* tileSize: (number|undefined),
|
||||
* tileSizes: (Array.<number>|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.WMTSOptions;
|
||||
|
||||
@@ -5017,7 +5005,7 @@ olx.tilegrid.WMTSOptions.prototype.tileSizes;
|
||||
|
||||
/**
|
||||
* @typedef {{maxZoom: number}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.XYZOptions;
|
||||
|
||||
@@ -5031,7 +5019,7 @@ olx.tilegrid.XYZOptions.prototype.maxZoom;
|
||||
|
||||
/**
|
||||
* @typedef {{resolutions: !Array.<number>}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.tilegrid.ZoomifyOptions;
|
||||
|
||||
@@ -5048,7 +5036,7 @@ olx.tilegrid.ZoomifyOptions.prototype.resolutions;
|
||||
* constrainResolution: (boolean|undefined),
|
||||
* nearest: (boolean|undefined),
|
||||
* minResolution: (number|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.View.fitGeometryOptions;
|
||||
|
||||
@@ -5106,7 +5094,7 @@ olx.View.fitGeometryOptions.prototype.minResolution;
|
||||
* viewState: olx.ViewState,
|
||||
* viewHints: Array.<number>,
|
||||
* wantedTiles: Object.<string, Object.<string, boolean>>}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.FrameState;
|
||||
|
||||
@@ -5128,7 +5116,7 @@ olx.FrameState.prototype.viewState;
|
||||
* projection: ol.proj.Projection,
|
||||
* resolution: number,
|
||||
* rotation: number}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.ViewState;
|
||||
|
||||
|
||||
@@ -1,92 +1,22 @@
|
||||
/**
|
||||
* @externs
|
||||
* @see http://trac.osgeo.org/proj4js/
|
||||
* @see http://proj4js.org/
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
* @param {...*} var_args
|
||||
* @return {undefined|Array.<number>|Object.<{
|
||||
* forward: function(Array.<number>): Array.<number>,
|
||||
* inverse: function(Array.<number>): Array.<number>}>}
|
||||
*/
|
||||
var Proj4js = {};
|
||||
var proj4 = function(var_args) {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {Object.<string, string>}
|
||||
* @param {string} name
|
||||
* @param {(string|Object)=} opt_def
|
||||
* @return {undefined|Object.<string, Object.<{axis: string, units: string,
|
||||
* to_meter: number}>>}
|
||||
*/
|
||||
Proj4js.defs;
|
||||
|
||||
|
||||
/**
|
||||
* @type {function(string)}
|
||||
*/
|
||||
Proj4js.reportError;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
*/
|
||||
Proj4js.Point = function(x, y) {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Proj4js.Point.prototype.x;
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Proj4js.Point.prototype.y;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} srsCode
|
||||
* @param {Function=} opt_callback
|
||||
*/
|
||||
Proj4js.Proj = function(srsCode, opt_callback) {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Proj4js.Proj.prototype.axis;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Proj4js.Proj.prototype.title;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Proj4js.Proj.prototype.units;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Proj4js.Proj.prototype.srsCode;
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Proj4js.Proj.prototype.to_meter;
|
||||
|
||||
|
||||
/**
|
||||
* @nosideeffects
|
||||
* @param {Proj4js.Proj} source
|
||||
* @param {Proj4js.Proj} dest
|
||||
* @param {Proj4js.Point|{x:number, y:number}} point
|
||||
* @return {Proj4js.Point}
|
||||
*/
|
||||
Proj4js.transform = function(source, dest, point) {return null;};
|
||||
proj4.defs = function(name, opt_def) {};
|
||||
|
||||
@@ -32,7 +32,7 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
|
||||
|
||||
/**
|
||||
* @type {ol.Coordinate}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
this.coordinate = map.getEventCoordinate(this.originalEvent);
|
||||
|
||||
@@ -73,7 +73,7 @@ ol.control.Control = function(options) {
|
||||
/**
|
||||
* Application subclasses may override this.
|
||||
* @param {ol.Map} map Map.
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
ol.control.Control.prototype.setMap = function(map) {
|
||||
// ...
|
||||
@@ -88,7 +88,7 @@ Object literals cannot be exported like classes. To make sure that their propert
|
||||
/**
|
||||
* @typedef {{element: (Element|undefined),
|
||||
* target: (Element|string|undefined)}}
|
||||
* @todo api
|
||||
* @api
|
||||
*/
|
||||
olx.control.ControlOptions;
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Style with rules example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Style with rules example</h4>
|
||||
<p id="shortdesc">Draws features with rule based styles.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="style-rules.js" target="_blank">style-rules.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">vector, geojson, style</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=style-rules" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,134 +0,0 @@
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
var style = new ol.style.Style({rules: [
|
||||
new ol.style.Rule({
|
||||
filter: 'where == "outer"',
|
||||
symbolizers: [
|
||||
new ol.style.Stroke({
|
||||
color: ol.expr.parse('color'),
|
||||
width: 4,
|
||||
opacity: 1,
|
||||
zIndex: 1
|
||||
})
|
||||
]
|
||||
}),
|
||||
new ol.style.Rule({
|
||||
filter: 'where == "inner"',
|
||||
symbolizers: [
|
||||
new ol.style.Stroke({
|
||||
color: '#013',
|
||||
width: 4,
|
||||
opacity: 1
|
||||
}),
|
||||
new ol.style.Stroke({
|
||||
color: ol.expr.parse('color'),
|
||||
width: 2,
|
||||
opacity: 1
|
||||
})
|
||||
]
|
||||
}),
|
||||
new ol.style.Rule({
|
||||
filter: 'geometryType("Point")',
|
||||
symbolizers: [
|
||||
new ol.style.Shape({
|
||||
size: 40,
|
||||
fill: new ol.style.Fill({color: '#013'})
|
||||
}),
|
||||
new ol.style.Text({
|
||||
color: '#bada55',
|
||||
text: ol.expr.parse('label'),
|
||||
fontFamily: 'Calibri,sans-serif',
|
||||
fontSize: 14
|
||||
})
|
||||
]
|
||||
})
|
||||
]});
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
style: style,
|
||||
source: new ol.source.Vector({
|
||||
features: [
|
||||
new ol.Feature({
|
||||
color: '#BADA55',
|
||||
where: 'inner',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[-10000000, -10000000], [10000000, 10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
color: '#BADA55',
|
||||
where: 'inner',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[-10000000, 10000000], [10000000, -10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
color: '#013',
|
||||
where: 'outer',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[-10000000, -10000000], [-10000000, 10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
color: '#013',
|
||||
where: 'outer',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[-10000000, 10000000], [10000000, 10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
color: '#013',
|
||||
where: 'outer',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[10000000, 10000000], [10000000, -10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
color: '#013',
|
||||
where: 'outer',
|
||||
geometry: new ol.geom.LineString(
|
||||
[[10000000, -10000000], [-10000000, -10000000]])
|
||||
}),
|
||||
new ol.Feature({
|
||||
label: 'South',
|
||||
geometry: new ol.geom.Point([0, -6000000])
|
||||
}),
|
||||
new ol.Feature({
|
||||
label: 'West',
|
||||
geometry: new ol.geom.Point([-6000000, 0])
|
||||
}),
|
||||
new ol.Feature({
|
||||
label: 'North',
|
||||
geometry: new ol.geom.Point([0, 6000000])
|
||||
}),
|
||||
new ol.Feature({
|
||||
label: 'East',
|
||||
geometry: new ol.geom.Point([6000000, 0])
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [vector],
|
||||
controls: ol.control.defaults({
|
||||
attribution: false
|
||||
}),
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
})
|
||||
});
|
||||
@@ -1,80 +0,0 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Overlay');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.GeoJSON');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.ShapeType');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
|
||||
var raster = new ol.layer.Tile({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
});
|
||||
|
||||
// build up some GeoJSON features
|
||||
var count = 20000;
|
||||
var features = new Array(count);
|
||||
var e = 18000000;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
features[i] = {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
i: i,
|
||||
size: i % 2 ? 10 : 20
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [
|
||||
2 * e * Math.random() - e, 2 * e * Math.random() - e
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
projection: ol.proj.get('EPSG:3857'),
|
||||
parser: new ol.parser.GeoJSON(),
|
||||
data: {
|
||||
type: 'FeatureCollection',
|
||||
features: features
|
||||
}
|
||||
}),
|
||||
style: new ol.style.Style({rules: [
|
||||
new ol.style.Rule({
|
||||
symbolizers: [
|
||||
new ol.style.Shape({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: ol.expr.parse('size'),
|
||||
stroke: new ol.style.Stroke({color: '#666666'}),
|
||||
fill: new ol.style.Fill({color: '#bada55'})
|
||||
})
|
||||
]
|
||||
})
|
||||
]})
|
||||
});
|
||||
|
||||
var popup = new ol.Overlay({
|
||||
element: document.getElementById('popup')
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [vector],
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
}),
|
||||
overlays: [popup]
|
||||
});
|
||||
@@ -1,56 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Vector layer with styling from SLD example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./">OpenLayers 3 Examples</a>
|
||||
<ul class="nav pull-right">
|
||||
<li><iframe class="github-watch-button" src="http://ghbtns.com/github-btn.html?user=openlayers&repo=ol3&type=watch&count=true"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" height="20" width="90"></iframe></li>
|
||||
<li><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="openlayers"> </a></li>
|
||||
<li><div class="g-plusone-wrapper"><div class="g-plusone" data-size="medium" data-annotation="none"></div></div></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span4">
|
||||
<h4 id="title">Vector layer example</h4>
|
||||
<p id="shortdesc">Example of a countries vector layer with country labels at higher zoom levels, styling info coming from SLD.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="vector-layer-sld.js" target="_blank">vector-layer-sld.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">vector, geojson, style, SLD, Styled Layer Descriptor</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=vector-layer-sld" type="text/javascript"></script>
|
||||
<script src="../resources/social-links.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,54 +0,0 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.GeoJSON');
|
||||
goog.require('ol.parser.ogc.SLD');
|
||||
goog.require('ol.source.MapQuest');
|
||||
goog.require('ol.source.Vector');
|
||||
|
||||
|
||||
var raster = new ol.layer.Tile({
|
||||
source: new ol.source.MapQuest({layer: 'sat'})
|
||||
});
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'data/countries.sld', true);
|
||||
|
||||
|
||||
/**
|
||||
* onload handler for the XHR request.
|
||||
*/
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([
|
||||
new ol.control.ScaleLine()
|
||||
]),
|
||||
layers: [raster],
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
})
|
||||
});
|
||||
var units = map.getView().getView2D().getProjection().getUnits();
|
||||
var sld = new ol.parser.ogc.SLD().read(xhr.responseText, {
|
||||
units: units
|
||||
});
|
||||
var style = sld.namedLayers['countries'].userStyles[0];
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
parser: new ol.parser.GeoJSON(),
|
||||
url: 'data/countries.geojson'
|
||||
}),
|
||||
style: style
|
||||
});
|
||||
map.getLayers().push(vector);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
@@ -1,49 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>WMTS Capabilities parsing example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span4">
|
||||
<h4 id="title">WMTS Capabilities parsing example</h4>
|
||||
<p id="shortdesc">Example of parsing a WMTS Capabilities document.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="wmts-capabilities.js" target="_blank">wmts-capabilities.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">wmts, WMTSCapabilities</div>
|
||||
</div>
|
||||
|
||||
<div class="span8">
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,26 +0,0 @@
|
||||
goog.require('ol.parser.ogc.WMTSCapabilities');
|
||||
goog.require('ol.proj.common');
|
||||
|
||||
ol.proj.common.add();
|
||||
Proj4js.defs['EPSG:31256'] = '+proj=tmerc +lat_0=0 ' +
|
||||
'+lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel ' +
|
||||
'+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' +
|
||||
'+units=m +no_defs';
|
||||
var parser = new ol.parser.ogc.WMTSCapabilities(), result;
|
||||
var url = 'data/WMTSCapabilities.xml';
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
|
||||
/**
|
||||
* onload handler for the XHR request.
|
||||
*/
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
result = parser.read(xhr.responseXML);
|
||||
document.getElementById('log').innerHTML =
|
||||
window.JSON.stringify(result, undefined, 2);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
@@ -1,42 +0,0 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.parser.ogc.WMTSCapabilities');
|
||||
goog.require('ol.source.WMTS');
|
||||
|
||||
|
||||
var map, capabilities;
|
||||
var parser = new ol.parser.ogc.WMTSCapabilities();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'data/WMTSCapabilities.xml', true);
|
||||
|
||||
|
||||
/**
|
||||
* onload handler for the XHR request.
|
||||
*/
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
capabilities = parser.read(xhr.responseXML);
|
||||
map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.WMTS(ol.source.WMTS.optionsFromCapabilities(
|
||||
capabilities, 'fmzk'))
|
||||
}),
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.WMTS(ol.source.WMTS.optionsFromCapabilities(
|
||||
capabilities, 'beschriftung'))
|
||||
})
|
||||
],
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: [1823849, 6143760],
|
||||
zoom: 11
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
@@ -1,59 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>IGN WMTS example</title>
|
||||
<style>
|
||||
.ol-logo ul li {
|
||||
margin-right: 3px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">IGN WMTS example</h4>
|
||||
<p id="shortdesc">Demonstrates displaying IGN (France) WMTS layers.</p>
|
||||
<div id="docs">
|
||||
<p>In this example two IGN WMTS layers are displayed: <em>Ortho imagery and Cadastral parcels.</em>.
|
||||
For more information on IGN's WMTS service see the
|
||||
<a href="http://professionnels.ign.fr/api-sig">IGN Géoportail API web page</a> (french).</p>
|
||||
<p>See the <a href="wmts-ign.js" target="_blank">wmts-ign.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">french, ign, geoportail, wmts</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wmts-ign" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,86 +0,0 @@
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.parser.ogc.WMTSCapabilities');
|
||||
goog.require('ol.source.WMTS');
|
||||
|
||||
|
||||
// The WMTS Capabilities document includes IGNF:WGS84G as a supported
|
||||
// CRS. We include the Proj4js definition of that projection to prevent
|
||||
// Proj4js from requesting that definition from spatialreference.org.
|
||||
|
||||
Proj4js.defs['IGNF:WGS84G'] = '+title=World Geodetic System 1984 ' +
|
||||
'+proj=longlat +towgs84=0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,' +
|
||||
'0.000000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs <>';
|
||||
|
||||
// API key valid for "localhost" and "ol3js.org". Expiration date
|
||||
// is 21/06/2014.
|
||||
var key = 'crrypaoz7j1ifbalcobnumb0';
|
||||
|
||||
var map = new ol.Map({
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'map'
|
||||
});
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
// data/IGNWMTSCapabilities.xml downloaded from
|
||||
// http://wxs.ign.fr/cle/geoportail/wmts?SERVICE=WMTS&REQUEST=GetCapabilities
|
||||
// Stored locally because of the Same Origin Policy.
|
||||
xhr.open('GET', 'data/IGNWMTSCapabilities.xml', true);
|
||||
|
||||
|
||||
/**
|
||||
* onload handler for the XHR request.
|
||||
*/
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
var parser = new ol.parser.ogc.WMTSCapabilities();
|
||||
var capabilities = parser.read(xhr.responseXML);
|
||||
|
||||
var wmtsUrl = 'http://wxs.ign.fr/' + key + '/geoportail/wmts';
|
||||
|
||||
var layerIdentifiers = [
|
||||
'ORTHOIMAGERY.ORTHOPHOTOS',
|
||||
'CADASTRALPARCELS.PARCELS'
|
||||
];
|
||||
var layerLogos = [
|
||||
'http://gpp3-wxs.ign.fr/static/logos/PLANETOBSERVER/PLANETOBSERVER.gif',
|
||||
'http://gpp3-wxs.ign.fr/static/logos/IGN/IGN.gif'
|
||||
];
|
||||
|
||||
var attribution = new ol.Attribution({
|
||||
html: '<a href="http://www.geoportail.fr/" target="_blank">' +
|
||||
'<img src="http://api.ign.fr/geoportail/api/js/latest/' +
|
||||
'theme/geoportal/img/logo_gp.gif"></a>'
|
||||
});
|
||||
|
||||
var sourceOptions;
|
||||
var source;
|
||||
var layer;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < layerIdentifiers.length; ++i) {
|
||||
sourceOptions = ol.source.WMTS.optionsFromCapabilities(
|
||||
capabilities, layerIdentifiers[i]);
|
||||
// we need to set the URL because it must include the key.
|
||||
sourceOptions.urls = [wmtsUrl];
|
||||
sourceOptions.attributions = [attribution];
|
||||
sourceOptions.logo = layerLogos[i];
|
||||
source = new ol.source.WMTS(sourceOptions);
|
||||
layer = new ol.layer.Tile({source: source});
|
||||
map.addLayer(layer);
|
||||
}
|
||||
|
||||
var view = new ol.View2D();
|
||||
view.fitExtent(
|
||||
[257596.65942095537, 6250898.984085131,
|
||||
262082.55751844167, 6251854.446938695],
|
||||
/** @type {ol.Size} */ (map.getSize()));
|
||||
map.setView(view);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
@@ -1,96 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.ExceptionReport');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.ExceptionReport = function() {
|
||||
var exceptionReader = function(node, exceptionReport) {
|
||||
var exception = {
|
||||
code: node.getAttribute('exceptionCode'),
|
||||
locator: node.getAttribute('locator'),
|
||||
texts: []
|
||||
};
|
||||
exceptionReport.exceptions.push(exception);
|
||||
this.readChildNodes(node, exception);
|
||||
};
|
||||
var exceptionTextReader = function(node, exception) {
|
||||
var text = this.getChildValue(node);
|
||||
exception.texts.push(text);
|
||||
};
|
||||
this.readers = {
|
||||
'http://www.opengis.net/ogc': {
|
||||
'ServiceExceptionReport': function(node, obj) {
|
||||
obj['exceptionReport'] = {};
|
||||
obj['exceptionReport']['exceptions'] = [];
|
||||
this.readChildNodes(node, obj['exceptionReport']);
|
||||
},
|
||||
'ServiceException': function(node, exceptionReport) {
|
||||
var exception = {};
|
||||
exception['code'] = node.getAttribute('code');
|
||||
exception['locator'] = node.getAttribute('locator');
|
||||
exception['text'] = this.getChildValue(node);
|
||||
exceptionReport['exceptions'].push(exception);
|
||||
}
|
||||
},
|
||||
'http://www.opengis.net/ows': {
|
||||
'ExceptionReport': function(node, obj) {
|
||||
obj.success = false;
|
||||
obj.exceptionReport = {
|
||||
version: node.getAttribute('version'),
|
||||
language: node.getAttribute('language'),
|
||||
exceptions: []
|
||||
};
|
||||
this.readChildNodes(node, obj.exceptionReport);
|
||||
},
|
||||
'Exception': function(node, exceptionReport) {
|
||||
exceptionReader.apply(this, arguments);
|
||||
},
|
||||
'ExceptionText': function(node, exception) {
|
||||
exceptionTextReader.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
'http://www.opengis.net/ows/1.1': {
|
||||
'ExceptionReport': function(node, obj) {
|
||||
obj.exceptionReport = {
|
||||
version: node.getAttribute('version'),
|
||||
language: node.getAttribute('xml:lang'),
|
||||
exceptions: []
|
||||
};
|
||||
this.readChildNodes(node, obj.exceptionReport);
|
||||
},
|
||||
'Exception': function(node, exceptionReport) {
|
||||
exceptionReader.apply(this, arguments);
|
||||
},
|
||||
'ExceptionText': function(node, exception) {
|
||||
exceptionTextReader.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.ExceptionReport, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* Read OGC exception report data from a string, and return an object with
|
||||
* information about the exceptions.
|
||||
*
|
||||
* @param {string|Document} data to read/parse.
|
||||
* @return {Object} Information about the exceptions that occurred.
|
||||
*/
|
||||
ol.parser.ogc.ExceptionReport.prototype.read = function(data) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
var exceptionInfo = {};
|
||||
exceptionInfo['exceptionReport'] = null;
|
||||
if (data) {
|
||||
this.readChildNodes(data, exceptionInfo);
|
||||
}
|
||||
return exceptionInfo;
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Versioned');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.ogc.ExceptionReport');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
*/
|
||||
ol.parser.ogc.Versioned = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
this.options = options;
|
||||
this.defaultVersion = options.defaultVersion || null;
|
||||
this.version = options.version;
|
||||
this.profile = options.profile;
|
||||
if (goog.isDef(options.allowFallback)) {
|
||||
this.allowFallback = options.allowFallback;
|
||||
} else {
|
||||
this.allowFallback = false;
|
||||
}
|
||||
if (goog.isDef(options.stringifyOutput)) {
|
||||
this.stringifyOutput = options.stringifyOutput;
|
||||
} else {
|
||||
this.stringifyOutput = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} root root element.
|
||||
* @param {Object=} opt_options optional configuration object.
|
||||
* @return {string} the version to use.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.getVersion = function(root, opt_options) {
|
||||
var version;
|
||||
// read
|
||||
if (root) {
|
||||
version = this.version;
|
||||
if (!version) {
|
||||
version = root.getAttribute('version');
|
||||
if (!version) {
|
||||
version = this.defaultVersion;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// write
|
||||
version = (opt_options && opt_options.version) ||
|
||||
this.version || this.defaultVersion;
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} version the version to use.
|
||||
* @return {Object} the parser to use.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.getParser = function(version) {
|
||||
version = version || this.defaultVersion;
|
||||
var profile = this.profile ? '_' + this.profile : '';
|
||||
if (!this.parser || this.parser.VERSION != version) {
|
||||
var format = this.parsers['v' + version.replace(/\./g, '_') + profile];
|
||||
if (!format) {
|
||||
if (profile !== '' && this.allowFallback) {
|
||||
// fallback to the non-profiled version of the parser
|
||||
profile = '';
|
||||
format = this.parsers['v' + version.replace(/\./g, '_') + profile];
|
||||
}
|
||||
if (!format) {
|
||||
throw 'Can\'t find a parser for version ' +
|
||||
version + profile;
|
||||
}
|
||||
}
|
||||
this.parser = new format(this.options);
|
||||
}
|
||||
return this.parser;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Write a document.
|
||||
*
|
||||
* @param {Object} obj An object representing the document.
|
||||
* @param {Object=} opt_options Optional configuration object.
|
||||
* @return {Element|string} the XML created.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.write = function(obj, opt_options) {
|
||||
var version = this.getVersion(null, opt_options);
|
||||
this.parser = this.getParser(version);
|
||||
var root = this.parser.write(obj, opt_options);
|
||||
if (this.stringifyOutput === false) {
|
||||
return root;
|
||||
} else {
|
||||
return goog.dom.xml.serialize(root);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document} data Data to read.
|
||||
* @param {Object=} opt_options Options for the reader.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.read = function(data, opt_options) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var version = this.getVersion(root);
|
||||
this.parser = this.getParser(version);
|
||||
var obj = this.parser.read(data, opt_options);
|
||||
var errorProperty = this.parser.errorProperty || null;
|
||||
if (errorProperty !== null && obj[errorProperty] === undefined) {
|
||||
// an error must have happened, so parse it and report back
|
||||
var format = new ol.parser.ogc.ExceptionReport();
|
||||
obj.error = format.read(data);
|
||||
}
|
||||
obj.version = version;
|
||||
return obj;
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
goog.provide('ol.parser.Parser');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.parser.Parser = function() {};
|
||||
@@ -1,296 +0,0 @@
|
||||
goog.provide('ol.parser.XML');
|
||||
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.Parser');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.Parser}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.parser.XML = function() {
|
||||
if (goog.global.ActiveXObject) {
|
||||
this.xmldom = new ActiveXObject('Microsoft.XMLDOM');
|
||||
}
|
||||
this.regExes = {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
};
|
||||
};
|
||||
goog.inherits(ol.parser.XML, ol.parser.Parser);
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying one of the named readers given the node
|
||||
* namespace and local name. Readers take two args (node, obj) and
|
||||
* generally extend or modify the second.
|
||||
*
|
||||
* @param {Element|Document} node The node to be read (required).
|
||||
* @param {Object} obj The object to be modified (optional).
|
||||
* @return {Object} The input object, modified (or a new one if none was
|
||||
* provided).
|
||||
*/
|
||||
ol.parser.XML.prototype.readNode = function(node, obj) {
|
||||
if (!obj) {
|
||||
obj = {};
|
||||
}
|
||||
var group = this.readers[node.namespaceURI] ||
|
||||
this.readers[this.defaultNamespaceURI];
|
||||
if (group) {
|
||||
var local = node.localName || node.nodeName.split(':').pop();
|
||||
var reader = group[local] || group['*'];
|
||||
if (reader) {
|
||||
reader.apply(this, [node, obj]);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying the named readers to all children of a node.
|
||||
* For each child of type 1 (element), <readSelf> is called.
|
||||
*
|
||||
* @param {Element|Document} node The node to be read (required).
|
||||
* @param {Object} obj The object to be modified (optional).
|
||||
* @return {Object} The input object, modified.
|
||||
*/
|
||||
ol.parser.XML.prototype.readChildNodes = function(node, obj) {
|
||||
if (!obj) {
|
||||
obj = {};
|
||||
}
|
||||
var children = node.childNodes;
|
||||
var child;
|
||||
for (var i = 0, len = children.length; i < len; ++i) {
|
||||
child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
this.readNode(child, obj);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the textual value of the node if it exists, or return an
|
||||
* optional default string. Returns an empty string if no first child
|
||||
* exists and no default value is supplied.
|
||||
*
|
||||
* @param {Element} node The element used to look for a first child value.
|
||||
* @param {string} def Optional string to return in the event that no
|
||||
* first child value exists.
|
||||
* @return {string} The value of the first child of the given node.
|
||||
*/
|
||||
ol.parser.XML.prototype.getChildValue = function(node, def) {
|
||||
var value = def || '';
|
||||
if (node) {
|
||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||
switch (child.nodeType) {
|
||||
case 3: // text node
|
||||
case 4: // cdata section
|
||||
value += child.nodeValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get an attribute node given the namespace URI and local name.
|
||||
*
|
||||
* @param {Element} node Node on which to search for attribute nodes.
|
||||
* @param {string} uri Namespace URI.
|
||||
* @param {string} name Local name of the attribute (without the prefix).
|
||||
* @return {?Element} An attribute node or null if none found.
|
||||
*/
|
||||
ol.parser.XML.prototype.getAttributeNodeNS = function(node, uri, name) {
|
||||
var attributeNode = null;
|
||||
if (node.getAttributeNodeNS) {
|
||||
attributeNode = node.getAttributeNodeNS(uri, name);
|
||||
} else {
|
||||
var attributes = node.attributes;
|
||||
var potentialNode, fullName;
|
||||
for (var i = 0, len = attributes.length; i < len; ++i) {
|
||||
potentialNode = attributes[i];
|
||||
if (potentialNode.namespaceURI == uri) {
|
||||
fullName = (potentialNode.prefix) ?
|
||||
(potentialNode.prefix + ':' + name) : name;
|
||||
if (fullName == potentialNode.nodeName) {
|
||||
attributeNode = potentialNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributeNode;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get an attribute value given the namespace URI and local name.
|
||||
*
|
||||
* @param {Element} node Node on which to search for an attribute.
|
||||
* @param {string} uri Namespace URI.
|
||||
* @param {string} name Local name of the attribute (without the prefix).
|
||||
* @return {string} An attribute value or and empty string if none found.
|
||||
*/
|
||||
ol.parser.XML.prototype.getAttributeNS = function(node, uri, name) {
|
||||
var attributeValue = '';
|
||||
if (node.getAttributeNS) {
|
||||
attributeValue = node.getAttributeNS(uri, name) || '';
|
||||
} else {
|
||||
var attributeNode = this.getAttributeNodeNS(node, uri, name);
|
||||
if (attributeNode) {
|
||||
attributeValue = attributeNode.nodeValue;
|
||||
}
|
||||
}
|
||||
return attributeValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a new element with namespace. This node can be appended to
|
||||
* another node with the standard node.appendChild method. For
|
||||
* cross-browser support, this method must be used instead of
|
||||
* document.createElementNS.
|
||||
*
|
||||
* @param {string} name The qualified name of the element (prefix:localname).
|
||||
* @param {string=} opt_uri Namespace URI for the element.
|
||||
* @return {Element} A DOM element with namespace.
|
||||
*/
|
||||
ol.parser.XML.prototype.createElementNS = function(name, opt_uri) {
|
||||
var uri = opt_uri ? opt_uri : this.defaultNamespaceURI;
|
||||
var element;
|
||||
if (this.xmldom) {
|
||||
element = this.xmldom.createNode(1, name, uri);
|
||||
} else {
|
||||
element = document.createElementNS(uri, name);
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying one of the named writers and appending the
|
||||
* results to a node.
|
||||
*
|
||||
* @param {string} name The name of a node to generate. Only use a local name.
|
||||
* @param {Object|string|number} obj Structure containing data for the writer.
|
||||
* @param {?string=} opt_uri The name space uri to which the node
|
||||
* belongs.
|
||||
* @param {Element=} opt_parent Result will be appended to this node. If no
|
||||
* parent is supplied, the node will not be appended to anything.
|
||||
* @return {?Element} The child node.
|
||||
*/
|
||||
ol.parser.XML.prototype.writeNode = function(name, obj, opt_uri, opt_parent) {
|
||||
var child = null;
|
||||
if (goog.isDef(this.writers)) {
|
||||
var uri = opt_uri ? opt_uri : this.defaultNamespaceURI;
|
||||
child = this.writers[uri][name].apply(this, [obj]);
|
||||
if (opt_parent && child) {
|
||||
opt_parent.appendChild(child);
|
||||
}
|
||||
}
|
||||
return child;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a text node. This node can be appended to another node with
|
||||
* the standard node.appendChild method. For cross-browser support,
|
||||
* this method must be used instead of document.createTextNode.
|
||||
*
|
||||
* @param {string} text The text of the node.
|
||||
* @return {Element} A DOM text node.
|
||||
*/
|
||||
ol.parser.XML.prototype.createTextNode = function(text) {
|
||||
var node;
|
||||
if (this.xmldom) {
|
||||
node = this.xmldom.createTextNode(text);
|
||||
} else {
|
||||
node = document.createTextNode(text);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new attribute or changes the value of an attribute with the given
|
||||
* namespace and name.
|
||||
*
|
||||
* @param {Element} node Element node on which to set the attribute.
|
||||
* @param {string} uri Namespace URI for the attribute.
|
||||
* @param {string} name Qualified name (prefix:localname) for the attribute.
|
||||
* @param {string} value Attribute value.
|
||||
*/
|
||||
ol.parser.XML.prototype.setAttributeNS = function(node, uri, name, value) {
|
||||
if (node.setAttributeNS) {
|
||||
node.setAttributeNS(uri, name, value);
|
||||
} else {
|
||||
if (this.xmldom) {
|
||||
if (uri) {
|
||||
var attribute = node.ownerDocument.createNode(
|
||||
2, name, uri);
|
||||
attribute.nodeValue = value;
|
||||
node.setAttributeNode(attribute);
|
||||
} else {
|
||||
node.setAttribute(name, value);
|
||||
}
|
||||
} else {
|
||||
throw new Error('setAttributeNS not implemented');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes a node.
|
||||
*
|
||||
* @param {Element} node Element node to serialize.
|
||||
* @return {string} The serialized XML string.
|
||||
*/
|
||||
ol.parser.XML.prototype.serialize = function(node) {
|
||||
if (this.xmldom) {
|
||||
return node.xml;
|
||||
} else if (node.nodeType == 1) {
|
||||
// Add nodes to a document before serializing. Everything else
|
||||
// is serialized as is. This is also needed to get all namespaces
|
||||
// defined in some browsers such as Chrome (xmlns attributes).
|
||||
var doc = document.implementation.createDocument('', '', null);
|
||||
if (doc.importNode) {
|
||||
doc.appendChild(doc.importNode(node, true));
|
||||
} else {
|
||||
doc.appendChild(node);
|
||||
}
|
||||
return goog.dom.xml.serialize(doc);
|
||||
} else {
|
||||
return goog.dom.xml.serialize(node);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a document fragment node that can be appended to another node
|
||||
* created by createElementNS. This will call
|
||||
* document.createDocumentFragment outside of IE. In IE, the ActiveX
|
||||
* object's createDocumentFragment method is used.
|
||||
*
|
||||
* @return {Element} A document fragment.
|
||||
*/
|
||||
ol.parser.XML.prototype.createDocumentFragment = function() {
|
||||
var element;
|
||||
if (this.xmldom) {
|
||||
element = this.xmldom.createDocumentFragment();
|
||||
} else {
|
||||
element = document.createDocumentFragment();
|
||||
}
|
||||
return element;
|
||||
};
|
||||
@@ -1,881 +0,0 @@
|
||||
/**
|
||||
* @typedef {Object} ol.AttributionOptions
|
||||
* @property {string} html HTML markup for this attribution.
|
||||
* @property {Object.<string, Array.<ol.TileRange>>|undefined} tileRanges
|
||||
* Tile ranges (FOR INTERNAL USE ONLY).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.DeviceOrientationOptions
|
||||
* @property {boolean|undefined} tracking Start tracking. Default is `false`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.GeolocationOptions
|
||||
* @property {boolean|undefined} tracking Start Tracking. Default is `false`.
|
||||
* @property {GeolocationPositionOptions|undefined} trackingOptions Tracking options.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.GetFeatureInfoOptions
|
||||
* @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
|
||||
* @property {Array.<ol.layer.Layer>|undefined} layers Layers to restrict the
|
||||
* query to. All map layers will be queried if not provided.
|
||||
* @property {function(Array.<Array.<string|undefined>>)} success Callback for
|
||||
* successful queries. The passed argument is the resulting feature
|
||||
* information for each layer, with array indices being the same as in the
|
||||
* passed `layers` array or in the layer collection as returned from
|
||||
* `ol.Map#getLayers()` if no `layers` were provided.
|
||||
* @property {function()|undefined} error Callback for unsuccessful queries.
|
||||
* Note that queries with no matching features trigger the success callback,
|
||||
* not the error callback.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.GetFeaturesOptions
|
||||
* @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
|
||||
* @property {Array.<ol.layer.Layer>|undefined} layers Layers to restrict the
|
||||
* query to. All layers will be queried if not provided.
|
||||
* @property {function(Array.<Array.<ol.Feature|undefined>>)} success Callback
|
||||
* for successful queries. The passed argument is the resulting features for
|
||||
* each layer, with array indices being the same as in the passed `layers`
|
||||
* array or in the layer collection as returned from `ol.Map#getLayers()` if
|
||||
* no layers were provided.
|
||||
* @property {function()|undefined} error Callback for unsuccessful queries.
|
||||
* Note that queries with no matching features trigger the success callback,
|
||||
* not the error callback.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object literal with config options for the map.
|
||||
* @typedef {Object} ol.MapOptions
|
||||
* @property {ol.Collection|Array.<ol.control.Control>|undefined} controls
|
||||
* Controls initially added to the map.
|
||||
* @property {ol.Collection|Array.<ol.interaction.Interaction>|undefined} interactions
|
||||
* Interactions that are initially added to the map.
|
||||
* @property {Array.<ol.layer.Base>|ol.Collection|undefined} layers Layers.
|
||||
* @property {ol.Collection|Array.<ol.Overlay>|undefined} overlays
|
||||
* Overlays initially added to the map.
|
||||
* @property {ol.RendererHint|undefined} renderer Renderer.
|
||||
* @property {Array.<ol.RendererHint>|undefined} renderers Renderers.
|
||||
* @property {Element|string|undefined} target The container for the map.
|
||||
* @property {ol.IView|undefined} view The map's view. Currently
|
||||
* {@link ol.View2D} is available as view.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object literal with config options for the overlay.
|
||||
* @typedef {Object} ol.OverlayOptions
|
||||
* @property {Element|undefined} element The overlay element.
|
||||
* @property {ol.Coordinate|undefined} position The overlay position in map
|
||||
* projection.
|
||||
* @property {ol.OverlayPositioning|undefined} positioning Positioning.
|
||||
* @property {boolean|undefined} stopEvent Whether event propagation to the map
|
||||
* viewport should be stopped. Default is `true`. If `true` the overlay is
|
||||
* placed in the same container as that of the controls
|
||||
* (`ol-overlaycontainer-stopevent`).
|
||||
* @property {boolean|undefined} insertFirst Whether the overlay is inserted
|
||||
* first in the overlay container, or appended. Default is `true`. If the
|
||||
* overlay is placed in the same container as that of the controls (see
|
||||
* the `stopEvent` option) you will probably set `insertFirst` to `true`
|
||||
* so the overlay is displayed below the controls.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object literal with config options for the Proj4js projection.
|
||||
* @typedef {Object} ol.Proj4jsProjectionOptions
|
||||
* @property {string} code The SRS identifier code, e.g. `EPSG:31256`.
|
||||
* @property {ol.Extent|undefined} extent The validity extent for the SRS.
|
||||
* @property {boolean|undefined} global Whether the projection is valid for the
|
||||
* whole globe. Default is `false`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object literal with config options for the projection.
|
||||
* @typedef {Object} ol.ProjectionOptions
|
||||
* @property {string} code The SRS identifier code, e.g. `EPSG:4326`.
|
||||
* @property {ol.proj.Units} units Units.
|
||||
* @property {ol.Extent|undefined} extent The validity extent for the SRS.
|
||||
* @property {string|undefined} axisOrientation The axis orientation as
|
||||
* specified in Proj4. The default is `enu`.
|
||||
* @property {boolean|undefined} global Whether the projection is valid for the
|
||||
* whole globe. Default is `false`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object literal with config options for the view.
|
||||
* @typedef {Object} ol.View2DOptions
|
||||
* @property {ol.Coordinate|undefined} center The initial center for the view.
|
||||
* The coordinate system for the center is specified with the `projection`
|
||||
* option. Default is `undefined`, and layer sources will not be fetched if
|
||||
* this is not set.
|
||||
* @property {ol.Extent|undefined} extent The extent that constrains the center,
|
||||
* in other words, center cannot be set outside this extent.
|
||||
* Default is `undefined`.
|
||||
* @property {number|undefined} maxResolution The maximum resolution used to
|
||||
* determine the resolution constraint. It is used together with `maxZoom`
|
||||
* and `zoomFactor`. If unspecified it is calculated in such a way that the
|
||||
* projection's validity extent fits in a 256x256 px tile. If the projection
|
||||
* is Spherical Mercator (the default) then `maxResolution` defaults to
|
||||
* `40075016.68557849 / 256 = 156543.03392804097`.
|
||||
* @property {number|undefined} maxZoom The maximum zoom level used to determine
|
||||
* the resolution constraint. It is used together with `maxResolution` and
|
||||
* `zoomFactor`. Default is `28`.
|
||||
* @property {ol.proj.ProjectionLike} projection The projection. Default is
|
||||
* `EPSG:3857` (Spherical Mercator).
|
||||
* @property {number|undefined} resolution The initial resolution for the view.
|
||||
* The units are `projection` units per pixel (e.g. meters per pixel).
|
||||
* An alternative to setting this is to set `zoom`. Default is `undefined`,
|
||||
* and layer sources will not be fetched if neither this nor `zoom` are
|
||||
* defined.
|
||||
* @property {Array.<number>|undefined} resolutions Resolutions to determine the
|
||||
* resolution constraint. If set the `maxResolution`, `maxZoom` and
|
||||
* `zoomFactor` options are ignored.
|
||||
* @property {number|undefined} rotation The initial rotation for the view
|
||||
* in radians (positive rotation clockwise). Default is `0`.
|
||||
* @property {number|undefined} zoom Only used if `resolution` is not defined.
|
||||
* Zoom level used to calculate the initial resolution for the view.
|
||||
* The initial resolution is determined using the
|
||||
* `ol.View2D#constrainResolution` method.
|
||||
* @property {number|undefined} zoomFactor The zoom factor used to determine the
|
||||
* resolution constraint. Used together with `maxResolution` and `maxZoom`.
|
||||
* Default is `2`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.animation.BounceOptions
|
||||
* @property {number} resolution The resolution to start the bounce from, typically `map.getView().getResolution()`.
|
||||
* @property {number|undefined} start The start time of the animation. Default is immediately.
|
||||
* @property {number|undefined} duration The duration of the animation in milliseconds. Default is `1000`.
|
||||
* @property {function(number):number|undefined} easing The easing function to use. Default is `ol.easing.upAndDown`
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.animation.PanOptions
|
||||
* @property {ol.Coordinate} source The location to start panning from, typically `map.getView().getCenter()`.
|
||||
* @property {number|undefined} start The start time of the animation. Default is immediately.
|
||||
* @property {number|undefined} duration The duration of the animation in milliseconds. Default is `1000`.
|
||||
* @property {function(number):number|undefined} easing The easing function to use. Default is `ol.easing.inAndOut`
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.animation.RotateOptions
|
||||
* @property {number} rotation The rotation to apply, in radians.
|
||||
* @property {number|undefined} start The start time of the animation. Default is immediately.
|
||||
* @property {number|undefined} duration The duration of the animation in milliseconds. Default is `1000`.
|
||||
* @property {function(number):number|undefined} easing The easing function to use. Default is `ol.easing.inAndOut`
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.animation.ZoomOptions
|
||||
* @property {number} resolution number The resolution to begin zooming from, typically `map.getView().getResolution()`.
|
||||
* @property {number|undefined} start The start time of the animation. Default is immediately.
|
||||
* @property {number|undefined} duration The duration of the animation in milliseconds. Default is `1000`.
|
||||
* @property {function(number):number|undefined} easing Easing function.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.AttributionOptions
|
||||
* @property {string|undefined} className CSS class name. Default is `ol-attribution`.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.ControlOptions
|
||||
* @property {Element|undefined} element Element.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.DefaultsOptions
|
||||
* @property {boolean|undefined} attribution Attribution.
|
||||
* @property {ol.control.AttributionOptions|undefined} attributionOptions
|
||||
* Attribution options.
|
||||
* @property {boolean|undefined} logo Logo.
|
||||
* @property {ol.control.LogoOptions|undefined} logoOptions Logo options.
|
||||
* @property {boolean|undefined} zoom Zoom.
|
||||
* @property {ol.control.ZoomOptions|undefined} zoomOptions Zoom options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.FullScreenOptions
|
||||
* @property {string|undefined} className CSS class name. Default is `ol-full-screen`.
|
||||
* @property {boolean|undefined} keys Full keyboard access.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.LogoOptions
|
||||
* @property {string|undefined} className CSS class name. Default is `ol-logo`.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.MousePositionOptions
|
||||
* @property {string|undefined} className CSS class name. Default is `ol-mouse-position`.
|
||||
* @property {ol.CoordinateFormatType|undefined} coordinateFormat Coordinate
|
||||
* format.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @property {string|undefined} undefinedHTML Markup for undefined coordinates.
|
||||
* Default is `` (empty string).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.ScaleLineOptions
|
||||
* @property {string|undefined} className CSS Class name. Default is `ol-scale-line`.
|
||||
* @property {number|undefined} minWidth Minimum width in pixels.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @property {ol.control.ScaleLineUnits|undefined} units Units.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.ZoomOptions
|
||||
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
|
||||
* @property {string|undefined} className CSS class name. Default is `ol-zoom`.
|
||||
* @property {number|undefined} delta The zoom delta applied on each click.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.ZoomSliderOptions
|
||||
* @property {string|undefined} className CSS class name.
|
||||
* @property {number|undefined} maxResolution Maximum resolution.
|
||||
* @property {number|undefined} minResolution Minimum resolution.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.control.ZoomToExtentOptions
|
||||
* @property {string|undefined} className Class name. Default is `ol-zoom-extent`.
|
||||
* @property {Element|undefined} target Target.
|
||||
* @property {ol.Extent|undefined} extent The extent to zoom to. If
|
||||
* undefined the validity extent of the view projection is used.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.DoubleClickZoomOptions
|
||||
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
|
||||
* @property {number|undefined} delta The zoom delta applied on each double
|
||||
* click, default is `1`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.DragPanOptions
|
||||
* @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the pan.
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is no modifiers.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.DragRotateOptions
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is both shift and alt keys.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.DragRotateAndZoomOptions
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is shify key.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.DragZoomOptions
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is shift key.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interactions for the map. Default is `true` for all options.
|
||||
* @typedef {Object} ol.interaction.DefaultsOptions
|
||||
* @property {boolean|undefined} altShiftDragRotate Whether Alt-Shift-drag
|
||||
* rotate is desired.
|
||||
* @property {boolean|undefined} doubleClickZoom Whether double click zoom is
|
||||
* desired.
|
||||
* @property {boolean|undefined} dragPan Whether drag-pan is desired.
|
||||
* @property {boolean|undefined} keyboard Whether keyboard interaction is
|
||||
* desired.
|
||||
* @property {boolean|undefined} mouseWheelZoom Whether mousewheel zoom is
|
||||
* desired.
|
||||
* @property {boolean|undefined} shiftDragZoom Whether Shift-drag zoom is
|
||||
* desired.
|
||||
* @property {boolean|undefined} touchPan Whether touch pan is
|
||||
* desired.
|
||||
* @property {boolean|undefined} touchRotate Whether touch rotate is desired.
|
||||
* @property {boolean|undefined} touchZoom Whether touch zoom is desired.
|
||||
* @property {number|undefined} zoomDelta Zoom delta.
|
||||
* @property {number|undefined} zoomDuration Zoom duration.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.KeyboardPanOptions
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is no modifiers.
|
||||
* @property {number|undefined} pixelDelta Pixel The amount to pan on each key
|
||||
* press
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.KeyboardZoomOptions
|
||||
* @property {number|undefined} duration Animation duration in milliseconds. Default is `100`.
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||
* or not, default is no modifiers.
|
||||
* @property {number|undefined} delta The amount to zoom on each key press.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.MouseWheelZoomOptions
|
||||
* @property {number|undefined} duration Animation duration in milliseconds. Default is `250`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.SelectOptions
|
||||
* @property {ol.events.ConditionType|undefined} addCondition A conditional
|
||||
* modifier (e.g. shift key) that determines if the selection is added to
|
||||
* the current selection. By default, a shift-click adds to the current
|
||||
* selection.
|
||||
* @property {ol.events.ConditionType|undefined} condition A conditional
|
||||
* modifier (e.g. shift key) that determines if the interaction is active
|
||||
* (i.e. selection occurs) or not. By default, a click with no modifier keys
|
||||
* toggles the selection.
|
||||
* @property {undefined|function(ol.layer.Layer):boolean} layerFilter Filter
|
||||
* function to restrict selection to a subset of layers.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.TouchPanOptions
|
||||
* @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the
|
||||
* pan.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.TouchRotateOptions
|
||||
* @property {number|undefined} threshold Minimal angle to start a rotation.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.interaction.TouchZoomOptions
|
||||
* @property {number|undefined} duration Animation duration in milliseconds. Default is `400`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.BaseOptions
|
||||
* @property {number|undefined} brightness Brightness.
|
||||
* @property {number|undefined} contrast Contrast.
|
||||
* @property {number|undefined} hue Hue.
|
||||
* @property {number|undefined} opacity Opacity.
|
||||
* @property {number|undefined} saturation Saturation.
|
||||
* @property {boolean|undefined} visible Visibility.
|
||||
* @property {number|undefined} minResolution The minimum resolution
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.LayerOptions
|
||||
* @property {number|undefined} brightness Brightness.
|
||||
* @property {number|undefined} contrast Contrast.
|
||||
* @property {number|undefined} hue Hue.
|
||||
* @property {number|undefined} opacity Opacity. 0-1. Default is `1`.
|
||||
* @property {number|undefined} saturation Saturation.
|
||||
* @property {ol.source.Source} source Source for this layer.
|
||||
* @property {boolean|undefined} visible Visibility. Default is `true` (visible).
|
||||
* @property {number|undefined} minResolution The minimum resolution
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.GroupOptions
|
||||
* @property {number|undefined} brightness Brightness.
|
||||
* @property {number|undefined} contrast Contrast.
|
||||
* @property {number|undefined} hue Hue.
|
||||
* @property {number|undefined} opacity Opacity.
|
||||
* @property {number|undefined} saturation Saturation.
|
||||
* @property {boolean|undefined} visible Visibility.
|
||||
* @property {number|undefined} minResolution The minimum resolution
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @property {Array.<ol.layer.Base>|ol.Collection|undefined} layers Child layers.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.TileOptions
|
||||
* @property {number|undefined} brightness Brightness.
|
||||
* @property {number|undefined} contrast Contrast.
|
||||
* @property {number|undefined} hue Hue.
|
||||
* @property {number|undefined} opacity Opacity. 0-1. Default is `1`.
|
||||
* @property {number|undefined} preload Preload.
|
||||
* @property {number|undefined} saturation Saturation.
|
||||
* @property {ol.source.Source} source Source for this layer.
|
||||
* @property {boolean|undefined} visible Visibility. Default is `true` (visible).
|
||||
* @property {number|undefined} minResolution The minimum resolution
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.VectorLayerOptions
|
||||
* @property {function(Array.<ol.Feature>):string|undefined} transformFeatureInfo
|
||||
* Function to render an array of
|
||||
* features into feature info markup. If not provided, a comma separated
|
||||
* list of the unique ids of the resulting features will be returned.
|
||||
* @property {number|undefined} opacity Opacity. 0-1. Default is `1`.
|
||||
* @property {ol.source.Source} source Source for this layer.
|
||||
* @property {ol.style.Style|undefined} style Style.
|
||||
* @property {boolean|undefined} visible Visibility. Default is `true` (visible).
|
||||
* @property {number|undefined} minResolution The minimum resolution
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.KMLOptions
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the KML? Default is `true`.
|
||||
* @property {boolean|undefined} extractStyles Should we extract styles from the
|
||||
* KML? Default is `false`.
|
||||
* @property {number|undefined} maxDepth Maximum depth to follow network links.
|
||||
* Default is `0`, which means we don't follow network links at all.
|
||||
* @property {Array.<string>|undefined} trackAttributes Track attributes to
|
||||
* parse.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GMLReadOptions
|
||||
* @property {string|undefined} axisOrientation The axis orientation.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GMLWriteOptions
|
||||
* @property {ol.proj.ProjectionLike} srsName The srsName to use when writing.
|
||||
* @property {string|undefined} axisOrientation The axis orientation.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GMLOptions
|
||||
* @property {boolean|undefined} curve Write gml:Curve instead of
|
||||
* gml:LineString elements. This also affects the elements in multi-part
|
||||
* geometries. Default is `false`. This only applies to GML version 3.
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the GML? Default is `true`.
|
||||
* @property {string|undefined} featureNS The feature namespace. If not set it
|
||||
* will be automatically configured from the GML.
|
||||
* @property {Array.<string>|string|undefined} featureType The local
|
||||
* (without prefix) feature typeName(s).
|
||||
* @property {string|undefined} geometryName Name of geometry element.
|
||||
* Defaults to `geometry`. If null, it will be set on <read> when the
|
||||
* first geometry is parsed.
|
||||
* @property {boolean|undefined} multiCurve Write gml:MultiCurve instead of
|
||||
* gml:MultiLineString. Since the latter is deprecated in GML 3, the
|
||||
* default is `true`. This only applies to GML version 3.
|
||||
* @property {boolean|undefined} multiSurface Write gml:multiSurface instead
|
||||
* of gml:MultiPolygon. Since the latter is deprecated in GML 3, the
|
||||
* default is `true`. This only applies to GML version 3.
|
||||
* @property {string|undefined} schemaLocation Optional schemaLocation to use
|
||||
* when writing out the GML, this will override the default provided.
|
||||
* @property {boolean|undefined} surface Write gml:Surface instead of
|
||||
* gml:Polygon elements. This also affects the elements in multi-part
|
||||
* geometries. Default is `false`. This only applies to GML version 3.
|
||||
* @property {ol.parser.GMLReadOptions|undefined} readOptions readOptions to
|
||||
* use for this instance.
|
||||
* @property {ol.parser.GMLWriteOptions|undefined} writeOptions writeOptions
|
||||
* to use for this instance.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GPXOptions
|
||||
* @property {string|undefined} creator The creator attribute to be added to
|
||||
* the written GPX files. Defaults to `OpenLayers`.
|
||||
* @property {string|undefined} defaultDesc Default description for the
|
||||
* waypoints/tracks in the case where the feature has no `description`
|
||||
* attribute. Default is `No description available`.
|
||||
* @property {boolean|undefined} extractAttributes Should we extract attributes
|
||||
* from the GPX? Default is `true`.
|
||||
* @property {boolean|undefined} extractWaypoints Extract waypoints from GPX.
|
||||
* Default is `true`.
|
||||
* @property {boolean|undefined} extractTracks Extract tracks from GPX.
|
||||
* Default is `true`.
|
||||
* @property {boolean|undefined} extractRoutes Extract routes from GPX.
|
||||
* Default is `true`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.parser.GPXWriteOptions
|
||||
* @property {Array.<ol.Feature>|ol.Feature} features The features to write
|
||||
* out.
|
||||
* @property {Object|undefined} metadata Metadata key/value pair with keys:
|
||||
* name, desc and author.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.BingMapsOptions
|
||||
* @property {string|undefined} culture Culture.
|
||||
* @property {string} key Bing Maps API key. Get yours at
|
||||
* http://bingmapsportal.com/.
|
||||
* @property {string} style Style.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.MapQuestOptions
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.TileDebugOptions
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.OSMOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {number|undefined} maxZoom Max zoom.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {string|undefined} url URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.ImageWMSOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
|
||||
* requests.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {ol.source.WMSGetFeatureInfoOptions|undefined}
|
||||
* getFeatureInfoOptions Options for GetFeatureInfo.
|
||||
* @property {Object.<string,*>} params WMS request parameters. At least a
|
||||
* `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is
|
||||
* `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` and `CRS` (`SRS` for WMS
|
||||
* version < 1.3.0) will be set dynamically.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {number|undefined} ratio Ratio. 1 means image requests are the size
|
||||
* of the map viewport, 2 means twice the size of the map viewport, and so
|
||||
* on.
|
||||
* @property {Array.<number>|undefined} resolutions Resolutions. If specified,
|
||||
* requests will be made for these resolutions only.
|
||||
* @property {string|undefined} url WMS service URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.StamenOptions
|
||||
* @property {string} layer Layer.
|
||||
* @property {number|undefined} minZoom Minimum zoom.
|
||||
* @property {number|undefined} maxZoom Maximum zoom.
|
||||
* @property {boolean|undefined} opaque Whether the layer is opaque.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {string|undefined} url URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.ImageStaticOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
|
||||
* requests.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {ol.Extent|undefined} imageExtent Extent of the image.
|
||||
* @property {ol.Size|undefined} imageSize Size of the image.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {string|undefined} url URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.TileJSONOptions
|
||||
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
|
||||
* requests.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {string} url URL.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.TileWMSOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {Object.<string,*>} params WMS request parameters. At least a
|
||||
* `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is
|
||||
* `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` and `CRS` (`SRS` for WMS
|
||||
* version < 1.3.0) will be set dynamically.
|
||||
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
|
||||
* requests.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {ol.source.WMSGetFeatureInfoOptions|undefined}
|
||||
* getFeatureInfoOptions Options for GetFeatureInfo.
|
||||
* @property {string|undefined} logo Logo.
|
||||
* @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid.
|
||||
* @property {number|undefined} maxZoom Maximum zoom.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {string|undefined} url WMS service URL.
|
||||
* @property {Array.<string>|undefined} urls WMS service urls. Use this instead
|
||||
* of `url` when the WMS supports multiple urls for GetMap requests.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.VectorOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {Object|string|undefined} data Data to parse.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {string|undefined} logo Logo.
|
||||
* @property {ol.parser.Parser} parser Parser instance to parse data
|
||||
* provided as `data` or fetched from `url`.
|
||||
* @property {ol.proj.ProjectionLike|undefined} projection Projection. Usually the
|
||||
* projection is provided by the parser, so this only needs to be set if
|
||||
* the parser does not know the SRS (e.g. in some GML flavors), or if the
|
||||
* projection determined by the parser needs to be overridden.
|
||||
* @property {string|undefined} url Server url providing the vector data.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.Vector2Options
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {Array.<ol.geom2.LineStringCollection>|undefined}
|
||||
* lineStringCollections Line string collections.
|
||||
* @property {Array.<ol.geom2.PointCollection>|undefined} pointCollections
|
||||
* Point collections.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.WMSGetFeatureInfoOptions
|
||||
* @property {ol.source.WMSGetFeatureInfoMethod} method Method for requesting
|
||||
* GetFeatureInfo. Default is `ol.source.WMSGetFeatureInfoMethod.IFRAME`.
|
||||
* @property {Object} params Params for the GetFeatureInfo request. Default is
|
||||
* `{'INFO_FORMAT': 'text/html'}`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.WMTSOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {string|null|undefined} crossOrigin crossOrigin setting for image
|
||||
* requests.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {string|undefined} logo Logo.
|
||||
* @property {ol.tilegrid.WMTS} tileGrid Tile grid.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {ol.source.WMTSRequestEncoding|undefined} requestEncoding Request
|
||||
* encoding.
|
||||
* @property {string} layer Layer.
|
||||
* @property {string} style Style.
|
||||
* @property {string|undefined} version WMTS version. Default to `1.0.0`.
|
||||
* @property {string|undefined} format Format.
|
||||
* @property {string} matrixSet Matrix set.
|
||||
* @property {Object|undefined} dimensions Dimensions.
|
||||
* @property {string|undefined} url URL.
|
||||
* @property {number|undefined} maxZoom Maximum zoom.
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {Array.<string>|undefined} urls Urls.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.source.XYZOptions
|
||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||
* @property {null|string|undefined} crossOrigin Cross origin setting for image
|
||||
* requests.
|
||||
* @property {ol.Extent|undefined} extent Extent.
|
||||
* @property {string|undefined} logo Logo.
|
||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||
* @property {number|undefined} maxZoom Optional max zoom level. Default is `18`.
|
||||
* @property {number|undefined} minZoom Unsupported (TODO: remove this).
|
||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||
* function to load a tile given a URL.
|
||||
* @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional
|
||||
* function to get tile URL given a tile coordinate and the projection.
|
||||
* Required if url or urls are not provided.
|
||||
* @property {string|undefined} url URL template. Must include `{x}`, `{y}`,
|
||||
* and `{z}` placeholders.
|
||||
* @property {Array.<string>|undefined} urls An array of URL templates.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.IconOptions
|
||||
* @property {string|ol.expr.Expression} url Icon image URL.
|
||||
* @property {number|ol.expr.Expression|undefined} width Width of the icon
|
||||
* in pixels. Default is the width of the icon image.
|
||||
* @property {number|ol.expr.Expression|undefined} height Height of the
|
||||
* icon in pixels. Default is the height of the icon image.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Icon opacity
|
||||
* (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} rotation Rotation in
|
||||
* radians (positive rotation clockwise).
|
||||
* @property {number|ol.expr.Expression|undefined} xOffset Pixel offset from the
|
||||
* point to the center of the icon (positive values shift image left).
|
||||
* @property {number|ol.expr.Expression|undefined} yOffset Pixel offset from the
|
||||
* point to the center of the icon (positive values shift image down).
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.FillOptions
|
||||
* @property {string|ol.expr.Expression|undefined} color Fill color as hex color
|
||||
* code.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.RuleOptions
|
||||
* @property {ol.expr.Expression|string|undefined} filter Filter.
|
||||
* @property {number|undefined} maxResolution Optional maximum resolution. If
|
||||
* a value is provided, the rule will apply at resolutions less than
|
||||
* this value.
|
||||
* @property {number|undefined} minResolution Optional minimum resolution. If
|
||||
* a value is provided, the rule will apply at resolutions greater than or
|
||||
* equal to this value.
|
||||
* @property {Array.<ol.style.Symbolizer>|undefined} symbolizers Symbolizers.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.ShapeOptions
|
||||
* @property {ol.style.ShapeType|undefined} type Type.
|
||||
* @property {number|ol.expr.Expression|undefined} size Size in pixels.
|
||||
* @property {ol.style.Fill|undefined} fill Fill symbolizer for shape.
|
||||
* @property {ol.style.Stroke|undefined} stroke Stroke symbolizer for shape.
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.StrokeOptions
|
||||
* @property {string|ol.expr.Expression|undefined} color Stroke color as hex
|
||||
* color code.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Stroke opacity (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} width Stroke width in pixels.
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.StyleOptions
|
||||
* @property {Array.<ol.style.Rule>|undefined} rules Rules.
|
||||
* @property {Array.<ol.style.Symbolizer>|undefined} symbolizers Symbolizers
|
||||
* (that apply if no rules are provided or where none of the provided rules
|
||||
* apply).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.style.TextOptions
|
||||
* @property {string|ol.expr.Expression|undefined} color Color.
|
||||
* @property {string|ol.expr.Expression|undefined} fontFamily Font family.
|
||||
* @property {number|ol.expr.Expression|undefined} fontSize Font size in pixels.
|
||||
* @property {string|ol.expr.Expression|undefined} fontWeight Font weight.
|
||||
* @property {string|ol.expr.Expression} text Text for the label.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1).
|
||||
* @property {ol.style.Stroke|undefined} stroke Stroke symbolizer for text.
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.tilegrid.TileGridOptions
|
||||
* @property {number|undefined} minZoom Minimum zoom.
|
||||
* @property {ol.Coordinate|undefined} origin Origin.
|
||||
* @property {Array.<ol.Coordinate>|undefined} origins Origins.
|
||||
* @property {!Array.<number>} resolutions Resolutions.
|
||||
* @property {ol.Size|undefined} tileSize Tile size.
|
||||
* @property {Array.<ol.Size>|undefined} tileSizes Tile sizes.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.tilegrid.WMTSOptions
|
||||
* @property {ol.Coordinate|undefined} origin Origin.
|
||||
* @property {Array.<ol.Coordinate>|undefined} origins Origins.
|
||||
* @property {!Array.<number>} resolutions Resolutions.
|
||||
* @property {!Array.<string>} matrixIds matrix IDs.
|
||||
* @property {ol.Size|undefined} tileSize Tile size.
|
||||
* @property {Array.<ol.Size>|undefined} tileSizes Tile sizes.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.tilegrid.XYZOptions
|
||||
* @property {number} maxZoom Maximum zoom.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
@@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @namespace ol.expr
|
||||
*/
|
||||
@@ -1,309 +0,0 @@
|
||||
goog.provide('ol.expr');
|
||||
goog.provide('ol.expr.functions');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Parser');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
|
||||
|
||||
/**
|
||||
* Evaluate an expression with a feature. The feature attributes will be used
|
||||
* as the evaluation scope. The `ol.expr.lib` functions will be used as
|
||||
* function scope. The feature itself will be used as the `this` argument.
|
||||
*
|
||||
* @param {ol.expr.Expression} expr The expression.
|
||||
* @param {ol.Feature=} opt_feature The feature.
|
||||
* @return {*} The result of the expression.
|
||||
*/
|
||||
ol.expr.evaluateFeature = function(expr, opt_feature) {
|
||||
var scope;
|
||||
if (goog.isDef(opt_feature)) {
|
||||
scope = opt_feature.getAttributes();
|
||||
}
|
||||
return expr.evaluate(scope, ol.expr.lib, opt_feature);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse an expression.
|
||||
* @param {string} source The expression source (e.g. `'foo + 2'`).
|
||||
* @return {ol.expr.Expression} An expression instance that can be
|
||||
* evaluated within some scope to provide a value.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.expr.parse = function(source) {
|
||||
var parser = new ol.expr.Parser();
|
||||
return parser.parse(source);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Register a library function to be used in expressions.
|
||||
* @param {string} name The function name (e.g. 'myFunc').
|
||||
* @param {function(this:ol.Feature)} func The function to be called in an
|
||||
* expression. This function will be called with a feature as the `this`
|
||||
* argument when the expression is evaluated in the context of a features.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.expr.register = function(name, func) {
|
||||
ol.expr.lib[name] = func;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether an expression is a call expression that calls one of the
|
||||
* `ol.expr.lib` functions.
|
||||
*
|
||||
* @param {ol.expr.Expression} expr The candidate expression.
|
||||
* @return {string|undefined} If the candidate expression is a call to a lib
|
||||
* function, the return will be the function name. If not, the return will be
|
||||
* `undefined`.
|
||||
*/
|
||||
ol.expr.isLibCall = function(expr) {
|
||||
var name;
|
||||
if (expr instanceof ol.expr.Call) {
|
||||
var callee = expr.getCallee();
|
||||
if (callee instanceof ol.expr.Identifier) {
|
||||
name = callee.getName();
|
||||
if (!ol.expr.lib.hasOwnProperty(name)) {
|
||||
name = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Library of well-known functions. These are available to expressions parsed
|
||||
* with `ol.expr.parse`.
|
||||
*
|
||||
* @type {Object.<string, function(...)>}
|
||||
*/
|
||||
ol.expr.lib = {};
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration of library function names.
|
||||
*
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.expr.functions = {
|
||||
CONCAT: 'concat',
|
||||
COUNTER: 'counter',
|
||||
EXTENT: 'extent',
|
||||
FID: 'fid',
|
||||
GEOMETRY_TYPE: 'geometryType',
|
||||
RENDER_INTENT: 'renderIntent',
|
||||
INTERSECTS: 'intersects',
|
||||
CONTAINS: 'contains',
|
||||
DWITHIN: 'dwithin',
|
||||
WITHIN: 'within',
|
||||
LIKE: 'like',
|
||||
IEQ: 'ieq',
|
||||
INEQ: 'ineq'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Concatenate strings. All provided arguments will be cast to string and
|
||||
* concatenated.
|
||||
* @param {...string} var_args Strings to concatenate.
|
||||
* @return {string} All input arguments concatenated as strings.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.CONCAT] = function(var_args) {
|
||||
var str = '';
|
||||
for (var i = 0, ii = arguments.length; i < ii; ++i) {
|
||||
str += String(arguments[i]);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a counter which increases every time this function is called.
|
||||
* @param {number=} opt_start Start. If not provided, the counter starts at 1.
|
||||
* @return {number} Counter.
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.COUNTER] = (function() {
|
||||
var counter = 0;
|
||||
return function(opt_start) {
|
||||
var result = ++counter;
|
||||
if (goog.isDef(opt_start)) {
|
||||
result += opt_start;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a feature's extent intersects the provided extent.
|
||||
* @param {number} minX Minimum x-coordinate value.
|
||||
* @param {number} minY Minimum y-coordinate value.
|
||||
* @param {number} maxX Maximum x-coordinate value.
|
||||
* @param {number} maxY Maximum y-coordinate value.
|
||||
* @param {string=} opt_projection Projection of the extent.
|
||||
* @param {string=} opt_attribute Name of the geometry attribute to use.
|
||||
* @return {boolean} The provided extent intersects the feature's extent.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.EXTENT] = function(minX, minY, maxX, maxY,
|
||||
opt_projection, opt_attribute) {
|
||||
var intersects = false;
|
||||
var geometry = goog.isDef(opt_attribute) ?
|
||||
this.get(opt_attribute) : this.getGeometry();
|
||||
if (geometry) {
|
||||
intersects = ol.extent.intersects(geometry.getBounds(),
|
||||
[minX, minY, maxX, maxY]);
|
||||
}
|
||||
return intersects;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the feature identifier matches any of the provided values.
|
||||
* @param {...string} var_args Feature identifiers.
|
||||
* @return {boolean} The feature's identifier matches one of the given values.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.FID] = function(var_args) {
|
||||
var matches = false;
|
||||
var id = this.getId();
|
||||
if (goog.isDef(id)) {
|
||||
for (var i = 0, ii = arguments.length; i < ii; ++i) {
|
||||
if (arguments[i] === id) {
|
||||
matches = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if two strings are like one another, based on simple pattern
|
||||
* matching.
|
||||
* @param {string} value The string to test.
|
||||
* @param {string} pattern The comparison pattern.
|
||||
* @param {string} wildCard The wildcard character to use.
|
||||
* @param {string} singleChar The single character to use.
|
||||
* @param {string} escapeChar The escape character to use.
|
||||
* @param {boolean} matchCase Should we match case or not?
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.LIKE] = function(value, pattern, wildCard,
|
||||
singleChar, escapeChar, matchCase) {
|
||||
if (wildCard == '.') {
|
||||
throw new Error('"." is an unsupported wildCard character for ' +
|
||||
'the "like" function');
|
||||
}
|
||||
// set UMN MapServer defaults for unspecified parameters
|
||||
wildCard = goog.isDef(wildCard) ? wildCard : '*';
|
||||
singleChar = goog.isDef(singleChar) ? singleChar : '.';
|
||||
escapeChar = goog.isDef(escapeChar) ? escapeChar : '!';
|
||||
pattern = pattern.replace(
|
||||
new RegExp('\\' + escapeChar + '(.|$)', 'g'), '\\$1');
|
||||
pattern = pattern.replace(
|
||||
new RegExp('\\' + singleChar, 'g'), '.');
|
||||
pattern = pattern.replace(
|
||||
new RegExp('\\' + wildCard, 'g'), '.*');
|
||||
pattern = pattern.replace(
|
||||
new RegExp('\\\\.\\*', 'g'), '\\' + wildCard);
|
||||
pattern = pattern.replace(
|
||||
new RegExp('\\\\\\.', 'g'), '\\' + singleChar);
|
||||
var modifiers = (matchCase === false) ? 'gi' : 'g';
|
||||
return new RegExp(pattern, modifiers).test(value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Case insensitive comparison for equality.
|
||||
* @param {*} first First value.
|
||||
* @param {*} second Second value.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.IEQ] = function(first, second) {
|
||||
if (goog.isString(first) && goog.isString(second)) {
|
||||
return first.toUpperCase() == second.toUpperCase();
|
||||
} else {
|
||||
return first == second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Case insensitive comparison for non-equality.
|
||||
* @param {*} first First value.
|
||||
* @param {*} second Second value.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.INEQ] = function(first, second) {
|
||||
if (goog.isString(first) && goog.isString(second)) {
|
||||
return first.toUpperCase() != second.toUpperCase();
|
||||
} else {
|
||||
return first != second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a feature's default geometry is of the given type.
|
||||
* @param {ol.geom.GeometryType} type Geometry type.
|
||||
* @return {boolean} The feature's default geometry is of the given type.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.GEOMETRY_TYPE] = function(type) {
|
||||
var same = false;
|
||||
var geometry = this.getGeometry();
|
||||
if (geometry) {
|
||||
same = geometry.getType() === type;
|
||||
}
|
||||
return same;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a feature's renderIntent matches the given one.
|
||||
* @param {string} renderIntent Render intent.
|
||||
* @return {boolean} The feature's renderIntent matches the given one.
|
||||
* @this {ol.Feature}
|
||||
*/
|
||||
ol.expr.lib[ol.expr.functions.RENDER_INTENT] = function(renderIntent) {
|
||||
return this.getRenderIntent() == renderIntent;
|
||||
};
|
||||
|
||||
|
||||
ol.expr.lib[ol.expr.functions.INTERSECTS] = function(geom, opt_projection,
|
||||
opt_attribute) {
|
||||
throw new Error('Spatial function not implemented: ' +
|
||||
ol.expr.functions.INTERSECTS);
|
||||
};
|
||||
|
||||
|
||||
ol.expr.lib[ol.expr.functions.WITHIN] = function(geom, opt_projection,
|
||||
opt_attribute) {
|
||||
throw new Error('Spatial function not implemented: ' +
|
||||
ol.expr.functions.WITHIN);
|
||||
};
|
||||
|
||||
|
||||
ol.expr.lib[ol.expr.functions.CONTAINS] = function(geom, opt_projeciton,
|
||||
opt_attribute) {
|
||||
throw new Error('Spatial function not implemented: ' +
|
||||
ol.expr.functions.CONTAINS);
|
||||
};
|
||||
|
||||
|
||||
ol.expr.lib[ol.expr.functions.DWITHIN] = function(geom, distance, units,
|
||||
opt_projection, opt_attribute) {
|
||||
throw new Error('Spatial function not implemented: ' +
|
||||
ol.expr.functions.DWITHIN);
|
||||
};
|
||||
@@ -1,626 +0,0 @@
|
||||
goog.provide('ol.expr.Call');
|
||||
goog.provide('ol.expr.Comparison');
|
||||
goog.provide('ol.expr.ComparisonOp');
|
||||
goog.provide('ol.expr.Expression');
|
||||
goog.provide('ol.expr.Identifier');
|
||||
goog.provide('ol.expr.Literal');
|
||||
goog.provide('ol.expr.Logical');
|
||||
goog.provide('ol.expr.LogicalOp');
|
||||
goog.provide('ol.expr.Math');
|
||||
goog.provide('ol.expr.MathOp');
|
||||
goog.provide('ol.expr.Member');
|
||||
goog.provide('ol.expr.Not');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Base class for all expressions. Instances of ol.expr.Expression
|
||||
* correspond to a limited set of ECMAScript 5.1 expressions.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11
|
||||
*
|
||||
* This base class should not be constructed directly. Instead, use one of
|
||||
* the subclass constructors.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.expr.Expression = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* Evaluate the expression and return the result.
|
||||
*
|
||||
* @param {Object=} opt_scope Evaluation scope. All properties of this object
|
||||
* will be available as variables when evaluating the expression. If not
|
||||
* provided, `null` will be used.
|
||||
* @param {Object=} opt_fns Optional scope for looking up functions. If not
|
||||
* provided, functions will be looked in the evaluation scope.
|
||||
* @param {Object=} opt_this Object to use as this when evaluating call
|
||||
* expressions. If not provided, `this` will resolve to a new object.
|
||||
* @return {*} Result of the expression.
|
||||
*/
|
||||
ol.expr.Expression.prototype.evaluate = goog.abstractMethod;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A call expression (e.g. `foo(bar)`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.Expression} callee An expression that resolves to a
|
||||
* function.
|
||||
* @param {Array.<ol.expr.Expression>} args Arguments.
|
||||
*/
|
||||
ol.expr.Call = function(callee, args) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.callee_ = callee;
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.expr.Expression>}
|
||||
* @private
|
||||
*/
|
||||
this.args_ = args;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Call, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Call.prototype.evaluate = function(opt_scope, opt_fns, opt_this) {
|
||||
var fnScope = goog.isDefAndNotNull(opt_fns) ? opt_fns : opt_scope;
|
||||
var fn = this.callee_.evaluate(fnScope);
|
||||
if (!fn || !goog.isFunction(fn)) {
|
||||
throw new Error('Expected function but found ' + fn);
|
||||
}
|
||||
var thisArg = goog.isDef(opt_this) ? opt_this : {};
|
||||
|
||||
var len = this.args_.length;
|
||||
var values = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
values[i] = this.args_[i].evaluate(opt_scope, opt_fns, opt_this);
|
||||
}
|
||||
return fn.apply(thisArg, values);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the argument list.
|
||||
* @return {Array.<ol.expr.Expression>} The argument.
|
||||
*/
|
||||
ol.expr.Call.prototype.getArgs = function() {
|
||||
return this.args_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the callee expression.
|
||||
* @return {ol.expr.Expression} The callee expression.
|
||||
*/
|
||||
ol.expr.Call.prototype.getCallee = function() {
|
||||
return this.callee_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.expr.ComparisonOp = {
|
||||
EQ: '==',
|
||||
NEQ: '!=',
|
||||
STRICT_EQ: '===',
|
||||
STRICT_NEQ: '!==',
|
||||
GT: '>',
|
||||
LT: '<',
|
||||
GTE: '>=',
|
||||
LTE: '<='
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A comparison expression (e.g. `foo >= 42`, `bar != "chicken"`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.ComparisonOp} operator Comparison operator.
|
||||
* @param {ol.expr.Expression} left Left expression.
|
||||
* @param {ol.expr.Expression} right Right expression.
|
||||
*/
|
||||
ol.expr.Comparison = function(operator, left, right) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.ComparisonOp}
|
||||
* @private
|
||||
*/
|
||||
this.operator_ = operator;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.left_ = left;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.right_ = right;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Comparison, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a given string is a valid comparison operator.
|
||||
* @param {string} candidate Operator to test.
|
||||
* @return {boolean} The operator is valid.
|
||||
*/
|
||||
ol.expr.Comparison.isValidOp = (function() {
|
||||
var valid = {};
|
||||
for (var key in ol.expr.ComparisonOp) {
|
||||
valid[ol.expr.ComparisonOp[key]] = true;
|
||||
}
|
||||
return function isValidOp(candidate) {
|
||||
return !!valid[candidate];
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Comparison.prototype.evaluate = function(opt_scope, opt_fns, opt_this) {
|
||||
var result;
|
||||
var rightVal = this.right_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
var leftVal = this.left_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
|
||||
var op = this.operator_;
|
||||
if (op === ol.expr.ComparisonOp.EQ) {
|
||||
result = leftVal == rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.NEQ) {
|
||||
result = leftVal != rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.STRICT_EQ) {
|
||||
result = leftVal === rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.STRICT_NEQ) {
|
||||
result = leftVal !== rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.GT) {
|
||||
result = leftVal > rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.LT) {
|
||||
result = leftVal < rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.GTE) {
|
||||
result = leftVal >= rightVal;
|
||||
} else if (op === ol.expr.ComparisonOp.LTE) {
|
||||
result = leftVal <= rightVal;
|
||||
} else {
|
||||
throw new Error('Unsupported comparison operator: ' + this.operator_);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the comparison operator.
|
||||
* @return {string} The comparison operator.
|
||||
*/
|
||||
ol.expr.Comparison.prototype.getOperator = function() {
|
||||
return this.operator_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the left expression.
|
||||
* @return {ol.expr.Expression} The left expression.
|
||||
*/
|
||||
ol.expr.Comparison.prototype.getLeft = function() {
|
||||
return this.left_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the right expression.
|
||||
* @return {ol.expr.Expression} The right expression.
|
||||
*/
|
||||
ol.expr.Comparison.prototype.getRight = function() {
|
||||
return this.right_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An identifier expression (e.g. `foo`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {string} name An identifier name.
|
||||
*/
|
||||
ol.expr.Identifier = function(name) {
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
this.name_ = name;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Identifier, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Identifier.prototype.evaluate = function(opt_scope) {
|
||||
if (!goog.isDefAndNotNull(opt_scope)) {
|
||||
throw new Error('Attempt to evaluate identifier with no scope');
|
||||
}
|
||||
return opt_scope[this.name_];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the identifier name.
|
||||
* @return {string} The identifier name.
|
||||
*/
|
||||
ol.expr.Identifier.prototype.getName = function() {
|
||||
return this.name_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A literal expression (e.g. `"chicken"`, `42`, `true`, `null`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {string|number|boolean|Date|null} value A literal value.
|
||||
*/
|
||||
ol.expr.Literal = function(value) {
|
||||
|
||||
/**
|
||||
* @type {string|number|boolean|Date|null}
|
||||
* @private
|
||||
*/
|
||||
this.value_ = value;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Literal, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Literal.prototype.evaluate = function() {
|
||||
return this.value_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the literal value.
|
||||
* @return {string|number|boolean|Date|null} The literal value.
|
||||
*/
|
||||
ol.expr.Literal.prototype.getValue = function() {
|
||||
return this.value_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.expr.LogicalOp = {
|
||||
AND: '&&',
|
||||
OR: '||'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A binary logical expression (e.g. `foo && bar`, `bar || "chicken"`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.LogicalOp} operator Logical operator.
|
||||
* @param {ol.expr.Expression} left Left expression.
|
||||
* @param {ol.expr.Expression} right Right expression.
|
||||
*/
|
||||
ol.expr.Logical = function(operator, left, right) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.LogicalOp}
|
||||
* @private
|
||||
*/
|
||||
this.operator_ = operator;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.left_ = left;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.right_ = right;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Logical, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a given string is a valid logical operator.
|
||||
* @param {string} candidate Operator to test.
|
||||
* @return {boolean} The operator is valid.
|
||||
*/
|
||||
ol.expr.Logical.isValidOp = (function() {
|
||||
var valid = {};
|
||||
for (var key in ol.expr.LogicalOp) {
|
||||
valid[ol.expr.LogicalOp[key]] = true;
|
||||
}
|
||||
return function isValidOp(candidate) {
|
||||
return !!valid[candidate];
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Logical.prototype.evaluate = function(opt_scope, opt_fns,
|
||||
opt_this) {
|
||||
var result;
|
||||
var rightVal = this.right_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
var leftVal = this.left_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
|
||||
if (this.operator_ === ol.expr.LogicalOp.AND) {
|
||||
result = leftVal && rightVal;
|
||||
} else if (this.operator_ === ol.expr.LogicalOp.OR) {
|
||||
result = leftVal || rightVal;
|
||||
} else {
|
||||
throw new Error('Unsupported logical operator: ' + this.operator_);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the logical operator.
|
||||
* @return {string} The logical operator.
|
||||
*/
|
||||
ol.expr.Logical.prototype.getOperator = function() {
|
||||
return this.operator_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the left expression.
|
||||
* @return {ol.expr.Expression} The left expression.
|
||||
*/
|
||||
ol.expr.Logical.prototype.getLeft = function() {
|
||||
return this.left_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the right expression.
|
||||
* @return {ol.expr.Expression} The right expression.
|
||||
*/
|
||||
ol.expr.Logical.prototype.getRight = function() {
|
||||
return this.right_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.expr.MathOp = {
|
||||
ADD: '+',
|
||||
SUBTRACT: '-',
|
||||
MULTIPLY: '*',
|
||||
DIVIDE: '/',
|
||||
MOD: '%'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A math expression (e.g. `foo + 42`, `bar % 10`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.MathOp} operator Math operator.
|
||||
* @param {ol.expr.Expression} left Left expression.
|
||||
* @param {ol.expr.Expression} right Right expression.
|
||||
*/
|
||||
ol.expr.Math = function(operator, left, right) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.MathOp}
|
||||
* @private
|
||||
*/
|
||||
this.operator_ = operator;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.left_ = left;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.right_ = right;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Math, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a given string is a valid math operator.
|
||||
* @param {string} candidate Operator to test.
|
||||
* @return {boolean} The operator is valid.
|
||||
*/
|
||||
ol.expr.Math.isValidOp = (function() {
|
||||
var valid = {};
|
||||
for (var key in ol.expr.MathOp) {
|
||||
valid[ol.expr.MathOp[key]] = true;
|
||||
}
|
||||
return function isValidOp(candidate) {
|
||||
return !!valid[candidate];
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Math.prototype.evaluate = function(opt_scope, opt_fns, opt_this) {
|
||||
var result;
|
||||
var rightVal = this.right_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
var leftVal = this.left_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
|
||||
var op = this.operator_;
|
||||
if (op === ol.expr.MathOp.ADD) {
|
||||
result = leftVal + rightVal;
|
||||
} else if (op === ol.expr.MathOp.SUBTRACT) {
|
||||
result = Number(leftVal) - Number(rightVal);
|
||||
} else if (op === ol.expr.MathOp.MULTIPLY) {
|
||||
result = Number(leftVal) * Number(rightVal);
|
||||
} else if (op === ol.expr.MathOp.DIVIDE) {
|
||||
result = Number(leftVal) / Number(rightVal);
|
||||
} else if (op === ol.expr.MathOp.MOD) {
|
||||
result = Number(leftVal) % Number(rightVal);
|
||||
} else {
|
||||
throw new Error('Unsupported math operator: ' + this.operator_);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the math operator.
|
||||
* @return {string} The math operator.
|
||||
*/
|
||||
ol.expr.Math.prototype.getOperator = function() {
|
||||
return this.operator_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the left expression.
|
||||
* @return {ol.expr.Expression} The left expression.
|
||||
*/
|
||||
ol.expr.Math.prototype.getLeft = function() {
|
||||
return this.left_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the right expression.
|
||||
* @return {ol.expr.Expression} The right expression.
|
||||
*/
|
||||
ol.expr.Math.prototype.getRight = function() {
|
||||
return this.right_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A member expression (e.g. `foo.bar`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.Expression} object An expression that resolves to an
|
||||
* object.
|
||||
* @param {ol.expr.Identifier} property Identifier with name of property.
|
||||
*/
|
||||
ol.expr.Member = function(object, property) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.object_ = object;
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Identifier}
|
||||
* @private
|
||||
*/
|
||||
this.property_ = property;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Member, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Member.prototype.evaluate = function(opt_scope, opt_fns,
|
||||
opt_this) {
|
||||
var obj = this.object_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
if (!goog.isObject(obj)) {
|
||||
throw new Error('Expected member expression to evaluate to an object ' +
|
||||
'but got ' + obj);
|
||||
}
|
||||
return this.property_.evaluate(/** @type {Object} */ (obj));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the object expression.
|
||||
* @return {ol.expr.Expression} The object.
|
||||
*/
|
||||
ol.expr.Member.prototype.getObject = function() {
|
||||
return this.object_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the property expression.
|
||||
* @return {ol.expr.Identifier} The property.
|
||||
*/
|
||||
ol.expr.Member.prototype.getProperty = function() {
|
||||
return this.property_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A logical not expression (e.g. `!foo`).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.expr.Expression}
|
||||
* @param {ol.expr.Expression} argument Expression to negate.
|
||||
*/
|
||||
ol.expr.Not = function(argument) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.argument_ = argument;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.Not, ol.expr.Expression);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.expr.Not.prototype.evaluate = function(opt_scope, opt_fns, opt_this) {
|
||||
return !this.argument_.evaluate(opt_scope, opt_fns, opt_this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the argument (the negated expression).
|
||||
* @return {ol.expr.Expression} The argument.
|
||||
*/
|
||||
ol.expr.Not.prototype.getArgument = function() {
|
||||
return this.argument_;
|
||||
};
|
||||
@@ -1,900 +0,0 @@
|
||||
/**
|
||||
* The logic and naming of methods here are inspired by Esprima (BSD Licensed).
|
||||
* Esprima (http://esprima.org) includes the following copyright notices:
|
||||
*
|
||||
* Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
* Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
||||
* Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
* Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
|
||||
* Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||
* Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
|
||||
* Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
* Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||
* Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*/
|
||||
|
||||
goog.provide('ol.expr.Char'); // TODO: remove this - see #785
|
||||
goog.provide('ol.expr.Lexer');
|
||||
goog.provide('ol.expr.Token');
|
||||
goog.provide('ol.expr.TokenType');
|
||||
goog.provide('ol.expr.UnexpectedToken');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.debug.Error');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
ol.expr.Char = {
|
||||
AMPERSAND: 38,
|
||||
BACKSLASH: 92,
|
||||
BANG: 33, // !
|
||||
CARRIAGE_RETURN: 13,
|
||||
COMMA: 44,
|
||||
DIGIT_0: 48,
|
||||
DIGIT_7: 55,
|
||||
DIGIT_9: 57,
|
||||
DOLLAR: 36,
|
||||
DOUBLE_QUOTE: 34,
|
||||
DOT: 46,
|
||||
EQUAL: 61,
|
||||
FORM_FEED: 0xC,
|
||||
GREATER: 62,
|
||||
LEFT_PAREN: 40,
|
||||
LESS: 60,
|
||||
LINE_FEED: 10,
|
||||
LINE_SEPARATOR: 0x2028,
|
||||
LOWER_A: 97,
|
||||
LOWER_E: 101,
|
||||
LOWER_F: 102,
|
||||
LOWER_X: 120,
|
||||
LOWER_Z: 122,
|
||||
MINUS: 45,
|
||||
NONBREAKING_SPACE: 0xA0,
|
||||
PARAGRAPH_SEPARATOR: 0x2029,
|
||||
PERCENT: 37,
|
||||
PIPE: 124,
|
||||
PLUS: 43,
|
||||
RIGHT_PAREN: 41,
|
||||
SINGLE_QUOTE: 39,
|
||||
SLASH: 47,
|
||||
SPACE: 32,
|
||||
STAR: 42,
|
||||
TAB: 9,
|
||||
TILDE: 126,
|
||||
UNDERSCORE: 95,
|
||||
UPPER_A: 65,
|
||||
UPPER_E: 69,
|
||||
UPPER_F: 70,
|
||||
UPPER_X: 88,
|
||||
UPPER_Z: 90,
|
||||
VERTICAL_TAB: 0xB
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.expr.TokenType = {
|
||||
BOOLEAN_LITERAL: 'Boolean',
|
||||
EOF: '<end>',
|
||||
IDENTIFIER: 'Identifier',
|
||||
KEYWORD: 'Keyword',
|
||||
NULL_LITERAL: 'Null',
|
||||
NUMERIC_LITERAL: 'Numeric',
|
||||
PUNCTUATOR: 'Punctuator',
|
||||
STRING_LITERAL: 'String',
|
||||
UNKNOWN: 'Unknown'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: (ol.expr.TokenType),
|
||||
* value: (string|number|boolean|null),
|
||||
* index: (number)}}
|
||||
*/
|
||||
ol.expr.Token;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lexer constructor. Provides a tokenizer for a limited subset of ECMAScript
|
||||
* 5.1 expressions (http://www.ecma-international.org/ecma-262/5.1/#sec-11).
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} source Source code.
|
||||
*/
|
||||
ol.expr.Lexer = function(source) {
|
||||
|
||||
/**
|
||||
* Source code.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
this.source_ = source;
|
||||
|
||||
/**
|
||||
* Source length.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.length_ = source.length;
|
||||
|
||||
/**
|
||||
* Current character index.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.index_ = 0;
|
||||
|
||||
/**
|
||||
* Next character index (only set after `peek`ing).
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.nextIndex_ = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan the next token and throw if it isn't a punctuator that matches input.
|
||||
* @param {string} value Token value.
|
||||
*/
|
||||
ol.expr.Lexer.prototype.expect = function(value) {
|
||||
var match = this.match(value);
|
||||
if (!match) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: this.getCurrentChar_(),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
this.skip();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Increment the current character index.
|
||||
*
|
||||
* @param {number} delta Delta by which the index is advanced.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.increment_ = function(delta) {
|
||||
this.index_ += delta;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.3
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is a decimal digit.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isDecimalDigit_ = function(code) {
|
||||
return (
|
||||
code >= ol.expr.Char.DIGIT_0 &&
|
||||
code <= ol.expr.Char.DIGIT_9);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.6.1.2
|
||||
*
|
||||
* @param {string} id A string identifier.
|
||||
* @return {boolean} The identifier is a future reserved word.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isFutureReservedWord_ = function(id) {
|
||||
return (
|
||||
id === 'class' ||
|
||||
id === 'enum' ||
|
||||
id === 'export' ||
|
||||
id === 'extends' ||
|
||||
id === 'import' ||
|
||||
id === 'super');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.3
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is a hex digit.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isHexDigit_ = function(code) {
|
||||
return this.isDecimalDigit_(code) ||
|
||||
(code >= ol.expr.Char.LOWER_A &&
|
||||
code <= ol.expr.Char.LOWER_F) ||
|
||||
(code >= ol.expr.Char.UPPER_A &&
|
||||
code <= ol.expr.Char.UPPER_F);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
* Doesn't deal with non-ascii identifiers.
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is a valid identifier part.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isIdentifierPart_ = function(code) {
|
||||
return this.isIdentifierStart_(code) ||
|
||||
(code >= ol.expr.Char.DIGIT_0 &&
|
||||
code <= ol.expr.Char.DIGIT_9);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
* Doesn't yet deal with non-ascii identifiers.
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is a valid identifier start.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isIdentifierStart_ = function(code) {
|
||||
return (code === ol.expr.Char.DOLLAR) ||
|
||||
(code === ol.expr.Char.UNDERSCORE) ||
|
||||
(code >= ol.expr.Char.UPPER_A &&
|
||||
code <= ol.expr.Char.UPPER_Z) ||
|
||||
(code >= ol.expr.Char.LOWER_A &&
|
||||
code <= ol.expr.Char.LOWER_Z);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the given identifier is an ECMAScript keyword. These cannot
|
||||
* be used as identifiers in programs. There is no real reason these could not
|
||||
* be used in ol.exprs - but they are reserved for future use.
|
||||
*
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.6.1.1
|
||||
*
|
||||
* @param {string} id Identifier.
|
||||
* @return {boolean} The identifier is a keyword.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isKeyword_ = function(id) {
|
||||
return (
|
||||
id === 'break' ||
|
||||
id === 'case' ||
|
||||
id === 'catch' ||
|
||||
id === 'continue' ||
|
||||
id === 'debugger' ||
|
||||
id === 'default' ||
|
||||
id === 'delete' ||
|
||||
id === 'do' ||
|
||||
id === 'else' ||
|
||||
id === 'finally' ||
|
||||
id === 'for' ||
|
||||
id === 'function' ||
|
||||
id === 'if' ||
|
||||
id === 'in' ||
|
||||
id === 'instanceof' ||
|
||||
id === 'new' ||
|
||||
id === 'return' ||
|
||||
id === 'switch' ||
|
||||
id === 'this' ||
|
||||
id === 'throw' ||
|
||||
id === 'try' ||
|
||||
id === 'typeof' ||
|
||||
id === 'var' ||
|
||||
id === 'void' ||
|
||||
id === 'while' ||
|
||||
id === 'with');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is a line terminator.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isLineTerminator_ = function(code) {
|
||||
return (code === ol.expr.Char.LINE_FEED) ||
|
||||
(code === ol.expr.Char.CARRIAGE_RETURN) ||
|
||||
(code === ol.expr.Char.LINE_SEPARATOR) ||
|
||||
(code === ol.expr.Char.PARAGRAPH_SEPARATOR);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.3
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is an octal digit.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isOctalDigit_ = function(code) {
|
||||
return (
|
||||
code >= ol.expr.Char.DIGIT_0 &&
|
||||
code <= ol.expr.Char.DIGIT_7);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.2
|
||||
*
|
||||
* @param {number} code The unicode of a character.
|
||||
* @return {boolean} The character is whitespace.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.isWhitespace_ = function(code) {
|
||||
return (code === ol.expr.Char.SPACE) ||
|
||||
(code === ol.expr.Char.TAB) ||
|
||||
(code === ol.expr.Char.VERTICAL_TAB) ||
|
||||
(code === ol.expr.Char.FORM_FEED) ||
|
||||
(code === ol.expr.Char.NONBREAKING_SPACE) ||
|
||||
(code >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005' +
|
||||
'\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'
|
||||
.indexOf(String.fromCharCode(code)) > 0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the unicode of the character at the given offset from the current index.
|
||||
*
|
||||
* @param {number} delta Offset from current index.
|
||||
* @return {number} The character code.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.getCharCode_ = function(delta) {
|
||||
return this.source_.charCodeAt(this.index_ + delta);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the character at the current index.
|
||||
*
|
||||
* @return {string} The current character.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.getCurrentChar_ = function() {
|
||||
return this.source_[this.index_];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the unicode of the character at the current index.
|
||||
*
|
||||
* @return {number} The current character code.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.getCurrentCharCode_ = function() {
|
||||
return this.getCharCode_(0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the upcoming token matches the given punctuator.
|
||||
* @param {string} value Punctuator value.
|
||||
* @return {boolean} The token matches.
|
||||
*/
|
||||
ol.expr.Lexer.prototype.match = function(value) {
|
||||
var token = this.peek();
|
||||
return (
|
||||
token.type === ol.expr.TokenType.PUNCTUATOR &&
|
||||
token.value === value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan the next token.
|
||||
*
|
||||
* @return {ol.expr.Token} Next token.
|
||||
*/
|
||||
ol.expr.Lexer.prototype.next = function() {
|
||||
var code = this.skipWhitespace_();
|
||||
|
||||
if (this.index_ >= this.length_) {
|
||||
return {
|
||||
type: ol.expr.TokenType.EOF,
|
||||
value: null,
|
||||
index: this.index_
|
||||
};
|
||||
}
|
||||
|
||||
// check for common punctuation
|
||||
if (code === ol.expr.Char.LEFT_PAREN ||
|
||||
code === ol.expr.Char.RIGHT_PAREN) {
|
||||
return this.scanPunctuator_(code);
|
||||
}
|
||||
|
||||
// check for string literal
|
||||
if (code === ol.expr.Char.SINGLE_QUOTE ||
|
||||
code === ol.expr.Char.DOUBLE_QUOTE) {
|
||||
return this.scanStringLiteral_(code);
|
||||
}
|
||||
|
||||
// check for identifier
|
||||
if (this.isIdentifierStart_(code)) {
|
||||
return this.scanIdentifier_(code);
|
||||
}
|
||||
|
||||
// check dot punctuation or decimal
|
||||
if (code === ol.expr.Char.DOT) {
|
||||
if (this.isDecimalDigit_(this.getCharCode_(1))) {
|
||||
return this.scanNumericLiteral_(code);
|
||||
}
|
||||
return this.scanPunctuator_(code);
|
||||
}
|
||||
|
||||
// check for numeric literal
|
||||
if (this.isDecimalDigit_(code)) {
|
||||
return this.scanNumericLiteral_(code);
|
||||
}
|
||||
|
||||
// all the rest is punctuation
|
||||
return this.scanPunctuator_(code);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Peek at the next token, but don't advance the index.
|
||||
*
|
||||
* @return {ol.expr.Token} The upcoming token.
|
||||
*/
|
||||
ol.expr.Lexer.prototype.peek = function() {
|
||||
var currentIndex = this.index_;
|
||||
var token = this.next();
|
||||
this.nextIndex_ = this.index_;
|
||||
this.index_ = currentIndex;
|
||||
return token;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan hex literal as numeric token.
|
||||
*
|
||||
* @param {number} code The current character code.
|
||||
* @return {ol.expr.Token} Numeric literal token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanHexLiteral_ = function(code) {
|
||||
var str = '';
|
||||
var start = this.index_ - 2;
|
||||
|
||||
while (this.index_ < this.length_) {
|
||||
if (!this.isHexDigit_(code)) {
|
||||
break;
|
||||
}
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
}
|
||||
|
||||
if (str.length === 0 || this.isIdentifierStart_(code)) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(code),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
|
||||
goog.asserts.assert(!isNaN(parseInt('0x' + str, 16)), 'Valid hex: ' + str);
|
||||
|
||||
return {
|
||||
type: ol.expr.TokenType.NUMERIC_LITERAL,
|
||||
value: parseInt('0x' + str, 16),
|
||||
index: start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan identifier token.
|
||||
*
|
||||
* @param {number} code The current character code.
|
||||
* @return {ol.expr.Token} Identifier token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanIdentifier_ = function(code) {
|
||||
goog.asserts.assert(this.isIdentifierStart_(code),
|
||||
'Must be called with a valid identifier');
|
||||
|
||||
var start = this.index_;
|
||||
this.increment_(1);
|
||||
|
||||
while (this.index_ < this.length_) {
|
||||
code = this.getCurrentCharCode_();
|
||||
if (this.isIdentifierPart_(code)) {
|
||||
this.increment_(1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var id = this.source_.slice(start, this.index_);
|
||||
|
||||
var type;
|
||||
if (id.length === 1) {
|
||||
type = ol.expr.TokenType.IDENTIFIER;
|
||||
} else if (this.isKeyword_(id)) {
|
||||
type = ol.expr.TokenType.KEYWORD;
|
||||
} else if (id === 'null') {
|
||||
type = ol.expr.TokenType.NULL_LITERAL;
|
||||
} else if (id === 'true' || id === 'false') {
|
||||
type = ol.expr.TokenType.BOOLEAN_LITERAL;
|
||||
} else {
|
||||
type = ol.expr.TokenType.IDENTIFIER;
|
||||
}
|
||||
|
||||
return {
|
||||
type: type,
|
||||
value: id,
|
||||
index: start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan numeric literal token.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.3
|
||||
*
|
||||
* @param {number} code The current character code.
|
||||
* @return {ol.expr.Token} Numeric literal token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanNumericLiteral_ = function(code) {
|
||||
goog.asserts.assert(
|
||||
code === ol.expr.Char.DOT || this.isDecimalDigit_(code),
|
||||
'Valid start for numeric literal: ' + String.fromCharCode(code));
|
||||
|
||||
// start assembling numeric string
|
||||
var str = '';
|
||||
var start = this.index_;
|
||||
|
||||
if (code !== ol.expr.Char.DOT) {
|
||||
|
||||
if (code === ol.expr.Char.DIGIT_0) {
|
||||
var nextCode = this.getCharCode_(1);
|
||||
|
||||
// hex literals start with 0X or 0x
|
||||
if (nextCode === ol.expr.Char.UPPER_X ||
|
||||
nextCode === ol.expr.Char.LOWER_X) {
|
||||
this.increment_(2);
|
||||
return this.scanHexLiteral_(this.getCurrentCharCode_());
|
||||
}
|
||||
|
||||
// octals start with 0
|
||||
if (this.isOctalDigit_(nextCode)) {
|
||||
this.increment_(1);
|
||||
return this.scanOctalLiteral_(nextCode);
|
||||
}
|
||||
|
||||
// numbers like 09 not allowed
|
||||
if (this.isDecimalDigit_(nextCode)) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(nextCode),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// scan all decimal chars
|
||||
while (this.isDecimalDigit_(code)) {
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
}
|
||||
}
|
||||
|
||||
// scan fractional part
|
||||
if (code === ol.expr.Char.DOT) {
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
|
||||
// scan all decimal chars
|
||||
while (this.isDecimalDigit_(code)) {
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
}
|
||||
}
|
||||
|
||||
// scan exponent
|
||||
if (code === ol.expr.Char.UPPER_E ||
|
||||
code === ol.expr.Char.LOWER_E) {
|
||||
str += 'E';
|
||||
this.increment_(1);
|
||||
|
||||
code = this.getCurrentCharCode_();
|
||||
if (code === ol.expr.Char.PLUS ||
|
||||
code === ol.expr.Char.MINUS) {
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
}
|
||||
|
||||
if (!this.isDecimalDigit_(code)) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(code),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
|
||||
// scan all decimal chars (TODO: unduplicate this)
|
||||
while (this.isDecimalDigit_(code)) {
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
code = this.getCurrentCharCode_();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isIdentifierStart_(code)) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(code),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
|
||||
goog.asserts.assert(!isNaN(parseFloat(str)), 'Valid number: ' + str);
|
||||
|
||||
return {
|
||||
type: ol.expr.TokenType.NUMERIC_LITERAL,
|
||||
value: parseFloat(str),
|
||||
index: start
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan octal literal as numeric token.
|
||||
*
|
||||
* @param {number} code The current character code.
|
||||
* @return {ol.expr.Token} Numeric literal token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanOctalLiteral_ = function(code) {
|
||||
goog.asserts.assert(this.isOctalDigit_(code));
|
||||
|
||||
var str = '0' + String.fromCharCode(code);
|
||||
var start = this.index_ - 1;
|
||||
this.increment_(1);
|
||||
|
||||
while (this.index_ < this.length_) {
|
||||
code = this.getCurrentCharCode_();
|
||||
if (!this.isOctalDigit_(code)) {
|
||||
break;
|
||||
}
|
||||
str += String.fromCharCode(code);
|
||||
this.increment_(1);
|
||||
}
|
||||
|
||||
code = this.getCurrentCharCode_();
|
||||
if (this.isIdentifierStart_(code) ||
|
||||
this.isDecimalDigit_(code)) {
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(code),
|
||||
index: this.index_
|
||||
});
|
||||
}
|
||||
|
||||
goog.asserts.assert(!isNaN(parseInt(str, 8)), 'Valid octal: ' + str);
|
||||
|
||||
return {
|
||||
type: ol.expr.TokenType.NUMERIC_LITERAL,
|
||||
value: parseInt(str, 8),
|
||||
index: start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan punctuator token (a subset of allowed tokens in 7.7).
|
||||
*
|
||||
* @param {number} code The current character code.
|
||||
* @return {ol.expr.Token} Punctuator token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanPunctuator_ = function(code) {
|
||||
var start = this.index_;
|
||||
|
||||
// single char punctuation that also doesn't start longer punctuation
|
||||
// (we disallow assignment, so no += etc.)
|
||||
if (code === ol.expr.Char.DOT ||
|
||||
code === ol.expr.Char.LEFT_PAREN ||
|
||||
code === ol.expr.Char.RIGHT_PAREN ||
|
||||
code === ol.expr.Char.COMMA ||
|
||||
code === ol.expr.Char.PLUS ||
|
||||
code === ol.expr.Char.MINUS ||
|
||||
code === ol.expr.Char.STAR ||
|
||||
code === ol.expr.Char.SLASH ||
|
||||
code === ol.expr.Char.PERCENT ||
|
||||
code === ol.expr.Char.TILDE) {
|
||||
|
||||
this.increment_(1);
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: String.fromCharCode(code),
|
||||
index: start
|
||||
};
|
||||
}
|
||||
|
||||
// check for 2-character punctuation
|
||||
var nextCode = this.getCharCode_(1);
|
||||
|
||||
// assignment or comparison (and we don't allow assignment)
|
||||
if (nextCode === ol.expr.Char.EQUAL) {
|
||||
if (code === ol.expr.Char.BANG || code === ol.expr.Char.EQUAL) {
|
||||
// we're looking at !=, ==, !==, or ===
|
||||
this.increment_(2);
|
||||
|
||||
// check for triple
|
||||
if (this.getCurrentCharCode_() === ol.expr.Char.EQUAL) {
|
||||
this.increment_(1);
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: String.fromCharCode(code) + '==',
|
||||
index: start
|
||||
};
|
||||
} else {
|
||||
// != or ==
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: String.fromCharCode(code) + '=',
|
||||
index: start
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (code === ol.expr.Char.GREATER ||
|
||||
code === ol.expr.Char.LESS) {
|
||||
this.increment_(2);
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: String.fromCharCode(code) + '=',
|
||||
index: start
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// remaining 2-charcter punctuators are || and &&
|
||||
if (code === nextCode &&
|
||||
(code === ol.expr.Char.PIPE ||
|
||||
code === ol.expr.Char.AMPERSAND)) {
|
||||
|
||||
this.increment_(2);
|
||||
var str = String.fromCharCode(code);
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: str + str,
|
||||
index: start
|
||||
};
|
||||
}
|
||||
|
||||
// we don't allow 4-character punctuator (>>>=)
|
||||
// and the allowed 3-character punctuators (!==, ===) are already consumed
|
||||
|
||||
// other single character punctuators
|
||||
if (code === ol.expr.Char.GREATER ||
|
||||
code === ol.expr.Char.LESS ||
|
||||
code === ol.expr.Char.BANG ||
|
||||
code === ol.expr.Char.AMPERSAND ||
|
||||
code === ol.expr.Char.PIPE) {
|
||||
|
||||
this.increment_(1);
|
||||
return {
|
||||
type: ol.expr.TokenType.PUNCTUATOR,
|
||||
value: String.fromCharCode(code),
|
||||
index: start
|
||||
};
|
||||
}
|
||||
|
||||
throw new ol.expr.UnexpectedToken({
|
||||
type: ol.expr.TokenType.UNKNOWN,
|
||||
value: String.fromCharCode(code),
|
||||
index: this.index_
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scan string literal token.
|
||||
*
|
||||
* @param {number} quote The current character code.
|
||||
* @return {ol.expr.Token} String literal token.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.scanStringLiteral_ = function(quote) {
|
||||
goog.asserts.assert(quote === ol.expr.Char.SINGLE_QUOTE ||
|
||||
quote === ol.expr.Char.DOUBLE_QUOTE,
|
||||
'Strings must start with a quote: ' + String.fromCharCode(quote));
|
||||
|
||||
var start = this.index_;
|
||||
this.increment_(1);
|
||||
|
||||
var str = '';
|
||||
var code;
|
||||
while (this.index_ < this.length_) {
|
||||
code = this.getCurrentCharCode_();
|
||||
this.increment_(1);
|
||||
if (code === quote) {
|
||||
quote = 0;
|
||||
break;
|
||||
}
|
||||
// look for escaped quote or backslash
|
||||
if (code === ol.expr.Char.BACKSLASH) {
|
||||
str += this.getCurrentChar_();
|
||||
this.increment_(1);
|
||||
} else {
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (quote !== 0) {
|
||||
// unterminated string literal
|
||||
throw new ol.expr.UnexpectedToken(this.peek());
|
||||
}
|
||||
|
||||
return {
|
||||
type: ol.expr.TokenType.STRING_LITERAL,
|
||||
value: str,
|
||||
index: start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* After peeking, skip may be called to advance the cursor without re-scanning.
|
||||
*/
|
||||
ol.expr.Lexer.prototype.skip = function() {
|
||||
this.index_ = this.nextIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Skip all whitespace.
|
||||
* @return {number} The character code of the first non-whitespace character.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Lexer.prototype.skipWhitespace_ = function() {
|
||||
var code = NaN;
|
||||
while (this.index_ < this.length_) {
|
||||
code = this.getCurrentCharCode_();
|
||||
if (this.isWhitespace_(code)) {
|
||||
this.increment_(1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Error object for unexpected tokens.
|
||||
* @param {ol.expr.Token} token The unexpected token.
|
||||
* @param {string=} opt_message Custom error message.
|
||||
* @constructor
|
||||
* @extends {goog.debug.Error}
|
||||
*/
|
||||
ol.expr.UnexpectedToken = function(token, opt_message) {
|
||||
var message = goog.isDef(opt_message) ? opt_message :
|
||||
'Unexpected token ' + token.value + ' at index ' + token.index;
|
||||
|
||||
goog.debug.Error.call(this, message);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Token}
|
||||
*/
|
||||
this.token = token;
|
||||
|
||||
};
|
||||
goog.inherits(ol.expr.UnexpectedToken, goog.debug.Error);
|
||||
|
||||
|
||||
/** @override */
|
||||
ol.expr.UnexpectedToken.prototype.name = 'UnexpectedToken';
|
||||
@@ -1,478 +0,0 @@
|
||||
/**
|
||||
* The logic and naming of methods here are inspired by Esprima (BSD Licensed).
|
||||
* Esprima (http://esprima.org) includes the following copyright notices:
|
||||
*
|
||||
* Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
* Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
||||
* Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
* Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
|
||||
* Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||
* Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
|
||||
* Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
* Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||
* Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
*/
|
||||
|
||||
goog.provide('ol.expr.Parser');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Comparison');
|
||||
goog.require('ol.expr.ComparisonOp');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Lexer');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.Logical');
|
||||
goog.require('ol.expr.LogicalOp');
|
||||
goog.require('ol.expr.Math');
|
||||
goog.require('ol.expr.MathOp');
|
||||
goog.require('ol.expr.Member');
|
||||
goog.require('ol.expr.Not');
|
||||
goog.require('ol.expr.Token');
|
||||
goog.require('ol.expr.TokenType');
|
||||
goog.require('ol.expr.UnexpectedToken');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instances of ol.expr.Parser parse a very limited set of ECMAScript
|
||||
* expressions (http://www.ecma-international.org/ecma-262/5.1/#sec-11).
|
||||
*
|
||||
* - Primary Expression (11.1):
|
||||
* - Identifier (e.g. `foo`)
|
||||
* - Literal (e.g. `"some string"` or `42`)
|
||||
* - Grouped (e.g. `(foo)`)
|
||||
* - Left-Hand-Side Expression (11.2):
|
||||
* - Property Accessors
|
||||
* - Dot notation only
|
||||
* - Function Calls
|
||||
* - Identifier with arguments only (e.g. `foo(bar, 42)`)
|
||||
* - Unary Operators (11.4)
|
||||
* - Logical Not (e.g. `!foo`)
|
||||
* - Multiplicitave Operators (11.5)
|
||||
* - Additive Operators (11.6)
|
||||
* - Relational Operators (11.8)
|
||||
* - <, >, <=, and >= only
|
||||
* - Equality Operators (11.9)
|
||||
* - Binary Logical Operators (11.11)
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.expr.Parser = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine the precedence for the given token.
|
||||
*
|
||||
* @param {ol.expr.Token} token A token.
|
||||
* @return {number} The precedence for the given token. Higher gets more
|
||||
* precedence.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.binaryPrecedence_ = function(token) {
|
||||
var precedence = 0;
|
||||
if (token.type !== ol.expr.TokenType.PUNCTUATOR) {
|
||||
return precedence;
|
||||
}
|
||||
|
||||
switch (token.value) {
|
||||
case ol.expr.LogicalOp.OR:
|
||||
precedence = 1;
|
||||
break;
|
||||
case ol.expr.LogicalOp.AND:
|
||||
precedence = 2;
|
||||
break;
|
||||
case ol.expr.ComparisonOp.EQ:
|
||||
case ol.expr.ComparisonOp.NEQ:
|
||||
case ol.expr.ComparisonOp.STRICT_EQ:
|
||||
case ol.expr.ComparisonOp.STRICT_NEQ:
|
||||
precedence = 3;
|
||||
break;
|
||||
case ol.expr.ComparisonOp.GT:
|
||||
case ol.expr.ComparisonOp.LT:
|
||||
case ol.expr.ComparisonOp.GTE:
|
||||
case ol.expr.ComparisonOp.LTE:
|
||||
precedence = 4;
|
||||
break;
|
||||
case ol.expr.MathOp.ADD:
|
||||
case ol.expr.MathOp.SUBTRACT:
|
||||
precedence = 5;
|
||||
break;
|
||||
case ol.expr.MathOp.MULTIPLY:
|
||||
case ol.expr.MathOp.DIVIDE:
|
||||
case ol.expr.MathOp.MOD:
|
||||
precedence = 6;
|
||||
break;
|
||||
default:
|
||||
// punctuator is not a supported binary operator, that's fine
|
||||
break;
|
||||
}
|
||||
|
||||
return precedence;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a binary expression.
|
||||
*
|
||||
* @param {string} operator Operator.
|
||||
* @param {ol.expr.Expression} left Left expression.
|
||||
* @param {ol.expr.Expression} right Right expression.
|
||||
* @return {ol.expr.Expression} The expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createBinaryExpression_ = function(operator,
|
||||
left, right) {
|
||||
var expr;
|
||||
if (ol.expr.Comparison.isValidOp(operator)) {
|
||||
expr = new ol.expr.Comparison(
|
||||
/** @type {ol.expr.ComparisonOp.<string>} */ (operator),
|
||||
left, right);
|
||||
} else if (ol.expr.Logical.isValidOp(operator)) {
|
||||
expr = new ol.expr.Logical(
|
||||
/** @type {ol.expr.LogicalOp.<string>} */ (operator),
|
||||
left, right);
|
||||
} else if (ol.expr.Math.isValidOp(operator)) {
|
||||
expr = new ol.expr.Math(
|
||||
/** @type {ol.expr.MathOp.<string>} */ (operator),
|
||||
left, right);
|
||||
} else {
|
||||
throw new Error('Unsupported binary operator: ' + operator);
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a call expression.
|
||||
*
|
||||
* @param {ol.expr.Expression} callee Expression for function.
|
||||
* @param {Array.<ol.expr.Expression>} args Arguments array.
|
||||
* @return {ol.expr.Call} Call expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createCallExpression_ = function(callee, args) {
|
||||
return new ol.expr.Call(callee, args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create an identifier expression.
|
||||
*
|
||||
* @param {string} name Identifier name.
|
||||
* @return {ol.expr.Identifier} Identifier expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createIdentifier_ = function(name) {
|
||||
return new ol.expr.Identifier(name);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a literal expression.
|
||||
*
|
||||
* @param {string|number|boolean|null} value Literal value.
|
||||
* @return {ol.expr.Literal} The literal expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createLiteral_ = function(value) {
|
||||
return new ol.expr.Literal(value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a member expression.
|
||||
*
|
||||
* // TODO: make exp {ol.expr.Member|ol.expr.Identifier}
|
||||
* @param {ol.expr.Expression} object Expression.
|
||||
* @param {ol.expr.Identifier} property Member name.
|
||||
* @return {ol.expr.Member} The member expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createMemberExpression_ = function(object,
|
||||
property) {
|
||||
return new ol.expr.Member(object, property);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a unary expression. The only true unary operator supported here is
|
||||
* "!". For +/-, we apply the operator to literal expressions and return
|
||||
* another literal.
|
||||
*
|
||||
* @param {ol.expr.Token} op Operator.
|
||||
* @param {ol.expr.Expression} argument Expression.
|
||||
* @return {ol.expr.Expression} The unary expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.createUnaryExpression_ = function(op, argument) {
|
||||
goog.asserts.assert(op.value === '!' || op.value === '+' || op.value === '-');
|
||||
var expr;
|
||||
if (op.value === '!') {
|
||||
expr = new ol.expr.Not(argument);
|
||||
} else if (!(argument instanceof ol.expr.Literal)) {
|
||||
throw new ol.expr.UnexpectedToken(op);
|
||||
} else {
|
||||
// we've got +/- literal
|
||||
if (op.value === '+') {
|
||||
expr = this.createLiteral_(
|
||||
+ /** @type {number|string|boolean|null} */ (argument.evaluate()));
|
||||
} else {
|
||||
expr = this.createLiteral_(
|
||||
- /** @type {number|string|boolean|null} */ (argument.evaluate()));
|
||||
}
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse an expression.
|
||||
*
|
||||
* @param {string} source Expression source.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
*/
|
||||
ol.expr.Parser.prototype.parse = function(source) {
|
||||
var lexer = new ol.expr.Lexer(source);
|
||||
var expr = this.parseExpression_(lexer);
|
||||
var token = lexer.peek();
|
||||
if (token.type !== ol.expr.TokenType.EOF) {
|
||||
throw new ol.expr.UnexpectedToken(token);
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse call arguments
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.2.4
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {Array.<ol.expr.Expression>} Arguments.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseArguments_ = function(lexer) {
|
||||
var args = [];
|
||||
|
||||
lexer.expect('(');
|
||||
|
||||
if (!lexer.match(')')) {
|
||||
while (true) {
|
||||
args.push(this.parseBinaryExpression_(lexer));
|
||||
if (lexer.match(')')) {
|
||||
break;
|
||||
}
|
||||
lexer.expect(',');
|
||||
}
|
||||
}
|
||||
lexer.skip();
|
||||
|
||||
return args;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse a binary expression. Supported binary expressions:
|
||||
*
|
||||
* - Multiplicative Operators (`*`, `/`, `%`)
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.5
|
||||
|
||||
* - Additive Operators (`+`, `-`)
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.6
|
||||
*
|
||||
* - Relational Operators (`<`, `>`, `<=`, `>=`)
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.8
|
||||
*
|
||||
* - Equality Operators (`==`, `!=`, `===`, `!==`)
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.9
|
||||
*
|
||||
* - Binary Logical Operators (`&&`, `||`)
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.11
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseBinaryExpression_ = function(lexer) {
|
||||
var left = this.parseUnaryExpression_(lexer);
|
||||
|
||||
var operator = lexer.peek();
|
||||
var precedence = this.binaryPrecedence_(operator);
|
||||
if (precedence === 0) {
|
||||
// not a supported binary operator
|
||||
return left;
|
||||
}
|
||||
lexer.skip();
|
||||
|
||||
var right = this.parseUnaryExpression_(lexer);
|
||||
var stack = [left, operator, right];
|
||||
|
||||
precedence = this.binaryPrecedence_(lexer.peek());
|
||||
while (precedence > 0) {
|
||||
// TODO: cache operator precedence in stack
|
||||
while (stack.length > 2 &&
|
||||
(precedence <= this.binaryPrecedence_(stack[stack.length - 2]))) {
|
||||
right = stack.pop();
|
||||
operator = stack.pop();
|
||||
left = stack.pop();
|
||||
stack.push(this.createBinaryExpression_(operator.value, left, right));
|
||||
}
|
||||
stack.push(lexer.next());
|
||||
stack.push(this.parseUnaryExpression_(lexer));
|
||||
precedence = this.binaryPrecedence_(lexer.peek());
|
||||
}
|
||||
|
||||
var i = stack.length - 1;
|
||||
var expr = stack[i];
|
||||
while (i > 1) {
|
||||
expr = this.createBinaryExpression_(stack[i - 1].value, stack[i - 2], expr);
|
||||
i -= 2;
|
||||
}
|
||||
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse a group expression.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.1.6
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseGroupExpression_ = function(lexer) {
|
||||
lexer.expect('(');
|
||||
var expr = this.parseExpression_(lexer);
|
||||
lexer.expect(')');
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse left-hand-side expression. Limited to Member Expressions
|
||||
* and Call Expressions.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.2
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseLeftHandSideExpression_ = function(lexer) {
|
||||
var expr = this.parsePrimaryExpression_(lexer);
|
||||
var token = lexer.peek();
|
||||
if (token.value === '(') {
|
||||
// only allow calls on identifiers (e.g. `foo()` not `foo.bar()`)
|
||||
if (!(expr instanceof ol.expr.Identifier)) {
|
||||
// TODO: more helpful error messages for restricted syntax
|
||||
throw new ol.expr.UnexpectedToken(token);
|
||||
}
|
||||
var args = this.parseArguments_(lexer);
|
||||
expr = this.createCallExpression_(expr, args);
|
||||
} else {
|
||||
// TODO: throw if not Identifier
|
||||
while (token.value === '.') {
|
||||
var property = this.parseNonComputedMember_(lexer);
|
||||
expr = this.createMemberExpression_(expr, property);
|
||||
token = lexer.peek();
|
||||
}
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse non-computed member.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.2
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Identifier} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseNonComputedMember_ = function(lexer) {
|
||||
lexer.expect('.');
|
||||
|
||||
var token = lexer.next();
|
||||
if (token.type !== ol.expr.TokenType.IDENTIFIER &&
|
||||
token.type !== ol.expr.TokenType.KEYWORD &&
|
||||
token.type !== ol.expr.TokenType.BOOLEAN_LITERAL &&
|
||||
token.type !== ol.expr.TokenType.NULL_LITERAL) {
|
||||
throw new ol.expr.UnexpectedToken(token);
|
||||
}
|
||||
|
||||
return this.createIdentifier_(String(token.value));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse primary expression.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.1
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parsePrimaryExpression_ = function(lexer) {
|
||||
var token = lexer.peek();
|
||||
if (token.value === '(') {
|
||||
return this.parseGroupExpression_(lexer);
|
||||
}
|
||||
lexer.skip();
|
||||
var expr;
|
||||
var type = token.type;
|
||||
if (type === ol.expr.TokenType.IDENTIFIER) {
|
||||
expr = this.createIdentifier_(/** @type {string} */ (token.value));
|
||||
} else if (type === ol.expr.TokenType.STRING_LITERAL ||
|
||||
type === ol.expr.TokenType.NUMERIC_LITERAL) {
|
||||
// numeric and string literals are already the correct type
|
||||
expr = this.createLiteral_(token.value);
|
||||
} else if (type === ol.expr.TokenType.BOOLEAN_LITERAL) {
|
||||
// because booleans are valid member properties, tokens are still string
|
||||
expr = this.createLiteral_(token.value === 'true');
|
||||
} else if (type === ol.expr.TokenType.NULL_LITERAL) {
|
||||
expr = this.createLiteral_(null);
|
||||
} else {
|
||||
throw new ol.expr.UnexpectedToken(token);
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse expression with a unary operator. Limited to logical not operator.
|
||||
* http://www.ecma-international.org/ecma-262/5.1/#sec-11.4
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseUnaryExpression_ = function(lexer) {
|
||||
var expr;
|
||||
var operator = lexer.peek();
|
||||
if (operator.type !== ol.expr.TokenType.PUNCTUATOR) {
|
||||
expr = this.parseLeftHandSideExpression_(lexer);
|
||||
} else if (operator.value === '!' || operator.value === '-' ||
|
||||
operator.value === '+') {
|
||||
lexer.skip();
|
||||
expr = this.parseUnaryExpression_(lexer);
|
||||
expr = this.createUnaryExpression_(operator, expr);
|
||||
} else {
|
||||
expr = this.parseLeftHandSideExpression_(lexer);
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse an expression.
|
||||
*
|
||||
* @param {ol.expr.Lexer} lexer Lexer.
|
||||
* @return {ol.expr.Expression} Expression.
|
||||
* @private
|
||||
*/
|
||||
ol.expr.Parser.prototype.parseExpression_ = function(lexer) {
|
||||
return this.parseBinaryExpression_(lexer);
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @namespace ol.parser
|
||||
*/
|
||||
@@ -1,37 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Filter');
|
||||
goog.require('ol.parser.ogc.Filter_v1_0_0');
|
||||
goog.require('ol.parser.ogc.Filter_v1_1_0');
|
||||
goog.require('ol.parser.ogc.Versioned');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable OGC Filter version 1.0.0.
|
||||
*/
|
||||
ol.ENABLE_OGCFILTER_1_0_0 = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable OGC Filter version 1.1.0.
|
||||
*/
|
||||
ol.ENABLE_OGCFILTER_1_1_0 = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
* @extends {ol.parser.ogc.Versioned}
|
||||
*/
|
||||
ol.parser.ogc.Filter = function(opt_options) {
|
||||
opt_options = opt_options || {};
|
||||
opt_options['defaultVersion'] = '1.0.0';
|
||||
this.parsers = {};
|
||||
if (ol.ENABLE_OGCFILTER_1_0_0) {
|
||||
this.parsers['v1_0_0'] = ol.parser.ogc.Filter_v1_0_0;
|
||||
}
|
||||
if (ol.ENABLE_OGCFILTER_1_1_0) {
|
||||
this.parsers['v1_1_0'] = ol.parser.ogc.Filter_v1_1_0;
|
||||
}
|
||||
goog.base(this, opt_options);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.Filter, ol.parser.ogc.Versioned);
|
||||
@@ -1,654 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Filter_v1');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Comparison');
|
||||
goog.require('ol.expr.ComparisonOp');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.Logical');
|
||||
goog.require('ol.expr.LogicalOp');
|
||||
goog.require('ol.expr.Not');
|
||||
goog.require('ol.expr.functions');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1 = function() {
|
||||
this.defaultNamespaceURI = 'http://www.opengis.net/ogc';
|
||||
this.errorProperty = 'filter';
|
||||
this.readers = {
|
||||
'http://www.opengis.net/ogc': {
|
||||
_expression: function(node) {
|
||||
var expressions = [];
|
||||
var obj, value, numValue, expr;
|
||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||
switch (child.nodeType) {
|
||||
case 1:
|
||||
obj = this.readNode(child);
|
||||
if (obj.property) {
|
||||
expressions.push(obj.property);
|
||||
} else if (goog.isDef(obj.value)) {
|
||||
expressions.push(obj.value);
|
||||
}
|
||||
break;
|
||||
case 3: // text node
|
||||
case 4: // cdata section
|
||||
value = goog.string.trim(child.nodeValue);
|
||||
// no need to concatenate empty strings
|
||||
if (value) {
|
||||
// check for numeric values
|
||||
numValue = goog.string.toNumber(value);
|
||||
if (!isNaN(numValue)) {
|
||||
value = numValue;
|
||||
}
|
||||
expressions.push(new ol.expr.Literal(value));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if we have more than one property or literal, we concatenate them
|
||||
var num = expressions.length;
|
||||
if (num === 1) {
|
||||
expr = expressions[0];
|
||||
} else {
|
||||
expr = new ol.expr.Call(
|
||||
new ol.expr.Identifier(ol.expr.functions.CONCAT),
|
||||
expressions);
|
||||
}
|
||||
return expr;
|
||||
},
|
||||
'Filter': function(node, obj) {
|
||||
var container = {
|
||||
filters: []
|
||||
};
|
||||
this.readChildNodes(node, container);
|
||||
if (goog.isDef(container.fids)) {
|
||||
obj.filter = new ol.expr.Call(
|
||||
new ol.expr.Identifier(ol.expr.functions.FID),
|
||||
goog.object.getValues(container.fids));
|
||||
} else if (container.filters.length > 0) {
|
||||
obj.filter = container.filters[0];
|
||||
}
|
||||
},
|
||||
'FeatureId': function(node, obj) {
|
||||
var fid = node.getAttribute('fid');
|
||||
if (fid) {
|
||||
if (!goog.isDef(obj.fids)) {
|
||||
obj.fids = {};
|
||||
}
|
||||
if (!obj.fids.hasOwnProperty(fid)) {
|
||||
obj.fids[fid] = new ol.expr.Literal(fid);
|
||||
}
|
||||
}
|
||||
},
|
||||
'And': function(node, obj) {
|
||||
var container = {filters: []};
|
||||
this.readChildNodes(node, container);
|
||||
var filter = this.aggregateLogical_(container.filters,
|
||||
ol.expr.LogicalOp.AND);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
'Or': function(node, obj) {
|
||||
var container = {filters: []};
|
||||
this.readChildNodes(node, container);
|
||||
var filter = this.aggregateLogical_(container.filters,
|
||||
ol.expr.LogicalOp.OR);
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
'Not': function(node, obj) {
|
||||
var container = {filters: []};
|
||||
this.readChildNodes(node, container);
|
||||
// Not is unary so can only contain 1 child filter
|
||||
obj.filters.push(new ol.expr.Not(
|
||||
container.filters[0]));
|
||||
},
|
||||
'PropertyIsNull': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.EQ,
|
||||
container.property,
|
||||
new ol.expr.Literal(null)));
|
||||
},
|
||||
'PropertyIsLessThan': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.LT,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsGreaterThan': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.GT,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsLessThanOrEqualTo': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.LTE,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsGreaterThanOrEqualTo': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.GTE,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsBetween': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Logical(ol.expr.LogicalOp.AND,
|
||||
new ol.expr.Comparison(ol.expr.ComparisonOp.GTE,
|
||||
container.property, container.lowerBoundary),
|
||||
new ol.expr.Comparison(ol.expr.ComparisonOp.LTE,
|
||||
container.property, container.upperBoundary)));
|
||||
},
|
||||
'Literal': function(node, obj) {
|
||||
var nodeValue = this.getChildValue(node);
|
||||
var value = goog.string.toNumber(nodeValue);
|
||||
obj.value = new ol.expr.Literal(isNaN(value) ? nodeValue : value);
|
||||
},
|
||||
'PropertyName': function(node, obj) {
|
||||
obj.property = new ol.expr.Identifier(this.getChildValue(node));
|
||||
},
|
||||
'LowerBoundary': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
obj.lowerBoundary = readers._expression.call(this, node);
|
||||
},
|
||||
'UpperBoundary': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
obj.upperBoundary = readers._expression.call(this, node);
|
||||
},
|
||||
_spatial: function(node, obj, identifier) {
|
||||
var args = [], container = {};
|
||||
this.readChildNodes(node, container);
|
||||
if (goog.isDef(container.geometry)) {
|
||||
args.push(new ol.expr.Literal(this.gmlParser_.createGeometry(
|
||||
container)));
|
||||
} else {
|
||||
args = [new ol.expr.Literal(container.bounds[0]),
|
||||
new ol.expr.Literal(container.bounds[1]),
|
||||
new ol.expr.Literal(container.bounds[2]),
|
||||
new ol.expr.Literal(container.bounds[3])];
|
||||
}
|
||||
if (goog.isDef(container.distance)) {
|
||||
args.push(container.distance);
|
||||
}
|
||||
if (goog.isDef(container.distanceUnits)) {
|
||||
args.push(container.distanceUnits);
|
||||
}
|
||||
args.push(new ol.expr.Literal(container.projection));
|
||||
if (goog.isDef(container.property)) {
|
||||
args.push(container.property);
|
||||
}
|
||||
obj.filters.push(new ol.expr.Call(new ol.expr.Identifier(
|
||||
identifier), args));
|
||||
},
|
||||
'BBOX': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
readers._spatial.call(this, node, obj,
|
||||
ol.expr.functions.EXTENT);
|
||||
},
|
||||
'Intersects': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
readers._spatial.call(this, node, obj,
|
||||
ol.expr.functions.INTERSECTS);
|
||||
},
|
||||
'Within': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
readers._spatial.call(this, node, obj,
|
||||
ol.expr.functions.WITHIN);
|
||||
},
|
||||
'Contains': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
readers._spatial.call(this, node, obj,
|
||||
ol.expr.functions.CONTAINS);
|
||||
},
|
||||
'DWithin': function(node, obj) {
|
||||
var readers = this.readers[this.defaultNamespaceURI];
|
||||
readers._spatial.call(this, node, obj,
|
||||
ol.expr.functions.DWITHIN);
|
||||
},
|
||||
'Distance': function(node, obj) {
|
||||
var value = goog.string.toNumber(this.getChildValue(node));
|
||||
obj.distance = new ol.expr.Literal(value);
|
||||
obj.distanceUnits = new ol.expr.Literal(node.getAttribute('units'));
|
||||
}
|
||||
}
|
||||
};
|
||||
this.writers = {
|
||||
'http://www.opengis.net/ogc': {
|
||||
'Filter': function(filter) {
|
||||
var node = this.createElementNS('ogc:Filter');
|
||||
this.writeNode(this.getFilterType_(filter), filter, null, node);
|
||||
return node;
|
||||
},
|
||||
'_featureIds': function(filter) {
|
||||
var node = this.createDocumentFragment();
|
||||
var args = filter.getArgs();
|
||||
for (var i = 0, ii = args.length; i < ii; i++) {
|
||||
goog.asserts.assert(args[i] instanceof ol.expr.Literal);
|
||||
this.writeNode('FeatureId', args[i].getValue(), null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'FeatureId': function(fid) {
|
||||
var node = this.createElementNS('ogc:FeatureId');
|
||||
node.setAttribute('fid', fid);
|
||||
return node;
|
||||
},
|
||||
'And': function(filter) {
|
||||
var node = this.createElementNS('ogc:And');
|
||||
var subFilters = [];
|
||||
this.getSubfiltersForLogical_(filter, subFilters);
|
||||
for (var i = 0, ii = subFilters.length; i < ii; ++i) {
|
||||
var subFilter = subFilters[i];
|
||||
if (goog.isDefAndNotNull(subFilter)) {
|
||||
this.writeNode(this.getFilterType_(subFilter), subFilter,
|
||||
null, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'Or': function(filter) {
|
||||
var node = this.createElementNS('ogc:Or');
|
||||
var subFilters = [];
|
||||
this.getSubfiltersForLogical_(filter, subFilters);
|
||||
for (var i = 0, ii = subFilters.length; i < ii; ++i) {
|
||||
var subFilter = subFilters[i];
|
||||
if (goog.isDefAndNotNull(subFilter)) {
|
||||
this.writeNode(this.getFilterType_(subFilter), subFilter,
|
||||
null, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'Not': function(filter) {
|
||||
var node = this.createElementNS('ogc:Not');
|
||||
var childFilter = filter.getArgument();
|
||||
this.writeNode(this.getFilterType_(childFilter), childFilter, null,
|
||||
node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsLessThan': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsLessThan');
|
||||
this.writeNode('PropertyName', filter.getLeft(), null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsGreaterThan': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsGreaterThan');
|
||||
this.writeNode('PropertyName', filter.getLeft(), null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsLessThanOrEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsLessThanOrEqualTo');
|
||||
this.writeNode('PropertyName', filter.getLeft(), null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsGreaterThanOrEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsGreaterThanOrEqualTo');
|
||||
this.writeNode('PropertyName', filter.getLeft(), null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsBetween': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsBetween');
|
||||
var property = filter.getLeft().getLeft();
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
var lower, upper;
|
||||
var filters = new Array(2);
|
||||
filters[0] = filter.getLeft();
|
||||
filters[1] = filter.getRight();
|
||||
for (var i = 0; i < 2; ++i) {
|
||||
var expr = filters[i].getRight();
|
||||
if (filters[i].getOperator() === ol.expr.ComparisonOp.GTE) {
|
||||
lower = expr;
|
||||
} else if (filters[i].getOperator() === ol.expr.ComparisonOp.LTE) {
|
||||
upper = expr;
|
||||
}
|
||||
}
|
||||
this.writeNode('LowerBoundary', lower, null, node);
|
||||
this.writeNode('UpperBoundary', upper, null, node);
|
||||
return node;
|
||||
},
|
||||
'PropertyName': function(expr) {
|
||||
goog.asserts.assert(expr instanceof ol.expr.Identifier);
|
||||
var node = this.createElementNS('ogc:PropertyName');
|
||||
node.appendChild(this.createTextNode(expr.getName()));
|
||||
return node;
|
||||
},
|
||||
'Literal': function(expr) {
|
||||
goog.asserts.assert(expr instanceof ol.expr.Literal);
|
||||
var node = this.createElementNS('ogc:Literal');
|
||||
node.appendChild(this.createTextNode(expr.getValue()));
|
||||
return node;
|
||||
},
|
||||
'LowerBoundary': function(expr) {
|
||||
var node = this.createElementNS('ogc:LowerBoundary');
|
||||
this.writeOgcExpression(expr, node);
|
||||
return node;
|
||||
},
|
||||
'UpperBoundary': function(expr) {
|
||||
var node = this.createElementNS('ogc:UpperBoundary');
|
||||
this.writeOgcExpression(expr, node);
|
||||
return node;
|
||||
},
|
||||
'INTERSECTS': function(filter) {
|
||||
return this.writeSpatial_(filter, 'Intersects');
|
||||
},
|
||||
'WITHIN': function(filter) {
|
||||
return this.writeSpatial_(filter, 'Within');
|
||||
},
|
||||
'CONTAINS': function(filter) {
|
||||
return this.writeSpatial_(filter, 'Contains');
|
||||
},
|
||||
'DWITHIN': function(filter) {
|
||||
var node = this.writeSpatial_(filter, 'DWithin');
|
||||
this.writeNode('Distance', filter, null, node);
|
||||
return node;
|
||||
},
|
||||
'Distance': function(filter) {
|
||||
var node = this.createElementNS('ogc:Distance');
|
||||
var args = filter.getArgs();
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
node.setAttribute('units', args[2].getValue());
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
node.appendChild(this.createTextNode(args[1].getValue()));
|
||||
return node;
|
||||
},
|
||||
'Function': function(filter) {
|
||||
var node = this.createElementNS('ogc:Function');
|
||||
node.setAttribute('name', filter.getCallee().getName());
|
||||
var params = filter.getArgs();
|
||||
for (var i = 0, len = params.length; i < len; i++) {
|
||||
this.writeOgcExpression(params[i], node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PropertyIsNull': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsNull');
|
||||
this.writeNode('PropertyName', filter.getLeft(), null, node);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.Filter_v1, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.filterMap_ = {
|
||||
'&&': 'And',
|
||||
'||': 'Or',
|
||||
'!': 'Not',
|
||||
'==': 'PropertyIsEqualTo',
|
||||
'!=': 'PropertyIsNotEqualTo',
|
||||
'<': 'PropertyIsLessThan',
|
||||
'>': 'PropertyIsGreaterThan',
|
||||
'<=': 'PropertyIsLessThanOrEqualTo',
|
||||
'>=': 'PropertyIsGreaterThanOrEqualTo',
|
||||
'..': 'PropertyIsBetween',
|
||||
'like': 'PropertyIsLike',
|
||||
'null': 'PropertyIsNull',
|
||||
'extent': 'BBOX',
|
||||
'dwithin': 'DWITHIN',
|
||||
'within': 'WITHIN',
|
||||
'contains': 'CONTAINS',
|
||||
'intersects': 'INTERSECTS',
|
||||
'fid': '_featureIds',
|
||||
'ieq': 'PropertyIsEqualTo',
|
||||
'ineq': 'PropertyIsNotEqualTo'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Expression} filter The filter to determine the type of.
|
||||
* @return {string} The type of filter.
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.getFilterType_ = function(filter) {
|
||||
var type;
|
||||
if (filter instanceof ol.expr.Logical ||
|
||||
filter instanceof ol.expr.Comparison) {
|
||||
type = filter.getOperator();
|
||||
var left = filter.getLeft();
|
||||
var right = filter.getRight();
|
||||
var isNull = (type === ol.expr.ComparisonOp.EQ &&
|
||||
right instanceof ol.expr.Literal && right.getValue() === null);
|
||||
if (isNull) {
|
||||
type = 'null';
|
||||
}
|
||||
var isBetween = (type === ol.expr.LogicalOp.AND &&
|
||||
left instanceof ol.expr.Comparison &&
|
||||
right instanceof ol.expr.Comparison &&
|
||||
left.getLeft() instanceof ol.expr.Identifier &&
|
||||
right.getLeft() instanceof ol.expr.Identifier &&
|
||||
left.getLeft().getName() === right.getLeft().getName() &&
|
||||
(left.getOperator() === ol.expr.ComparisonOp.LTE ||
|
||||
left.getOperator() === ol.expr.ComparisonOp.GTE) &&
|
||||
(right.getOperator() === ol.expr.ComparisonOp.LTE ||
|
||||
right.getOperator() === ol.expr.ComparisonOp.GTE));
|
||||
if (isBetween) {
|
||||
type = '..';
|
||||
}
|
||||
} else if (filter instanceof ol.expr.Call) {
|
||||
var callee = filter.getCallee();
|
||||
goog.asserts.assert(callee instanceof ol.expr.Identifier);
|
||||
type = callee.getName();
|
||||
} else if (filter instanceof ol.expr.Not) {
|
||||
type = '!';
|
||||
}
|
||||
var filterType = ol.parser.ogc.Filter_v1.filterMap_[type];
|
||||
if (!filterType) {
|
||||
throw new Error('Filter writing not supported for rule type: ' + type);
|
||||
}
|
||||
return filterType;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document|Element} data Data to read.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.read = function(data) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
if (data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var obj = {};
|
||||
this.readNode(data, obj);
|
||||
return obj.filter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Expression} filter The filter to write out.
|
||||
* @return {string} The serialized filter.
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.write = function(filter) {
|
||||
var root = this.writeNode('Filter', filter);
|
||||
this.setAttributeNS(
|
||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
return this.serialize(root);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Expression} expr The value write out.
|
||||
* @param {Element} node The node to append to.
|
||||
* @return {Element} The node to which was appended.
|
||||
* @protected
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.writeOgcExpression = function(expr, node) {
|
||||
if (expr instanceof ol.expr.Call) {
|
||||
if (ol.expr.isLibCall(expr) === ol.expr.functions.CONCAT) {
|
||||
var args = expr.getArgs();
|
||||
for (var i = 0, ii = args.length; i < ii; ++i) {
|
||||
this.writeOgcExpression(args[i], node);
|
||||
}
|
||||
} else {
|
||||
this.writeNode('Function', expr, null, node);
|
||||
}
|
||||
} else if (expr instanceof ol.expr.Literal) {
|
||||
this.writeNode('Literal', expr, null, node);
|
||||
} else if (expr instanceof ol.expr.Identifier) {
|
||||
this.writeNode('PropertyName', expr, null, node);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Logical} filter The filter to retrieve the sub filters from.
|
||||
* @param {Array.<ol.expr.Expression>} subFilters The sub filters retrieved.
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.getSubfiltersForLogical_ = function(filter,
|
||||
subFilters) {
|
||||
var operator = filter.getOperator();
|
||||
var filters = new Array(2);
|
||||
filters[0] = filter.getLeft();
|
||||
filters[1] = filter.getRight();
|
||||
for (var i = 0; i < 2; ++i) {
|
||||
if (filters[i] instanceof ol.expr.Logical && filters[i].getOperator() ===
|
||||
operator) {
|
||||
this.getSubfiltersForLogical_(filters[i], subFilters);
|
||||
} else {
|
||||
subFilters.push(filters[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Since ol.expr.Logical can only have a left and a right, we need to nest
|
||||
* sub filters coming from OGC Filter.
|
||||
* @param {Array.<ol.expr.Expression>} filters The filters to aggregate.
|
||||
* @param {ol.expr.LogicalOp} operator The logical operator to use.
|
||||
* @return {ol.expr.Logical} The logical filter created.
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.aggregateLogical_ = function(filters,
|
||||
operator) {
|
||||
var subFilters = [];
|
||||
var newFilters = [];
|
||||
// we only need to do this if we have more than 2 items
|
||||
if (filters.length > 2) {
|
||||
while (filters.length) {
|
||||
subFilters.push(filters.pop());
|
||||
if (subFilters.length === 2) {
|
||||
newFilters.push(new ol.expr.Logical(operator,
|
||||
subFilters[0], subFilters[1]));
|
||||
subFilters.length = 0;
|
||||
}
|
||||
}
|
||||
// there could be a single item left now
|
||||
if (subFilters.length === 1) {
|
||||
newFilters.push(subFilters[0]);
|
||||
}
|
||||
return this.aggregateLogical_(newFilters, operator);
|
||||
} else {
|
||||
return new ol.expr.Logical(operator, filters[0], filters[1]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3}
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.getGmlParser = function() {
|
||||
return this.gmlParser_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.parser.ogc.GML_v2|ol.parser.ogc.GML_v3} gml The GML parser to
|
||||
* use.
|
||||
* @protected
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.setGmlParser = function(gml) {
|
||||
this.gmlParser_ = gml;
|
||||
if (this.featureNS) {
|
||||
gml.setFeatureNS(this.featureNS);
|
||||
}
|
||||
for (var uri in this.gmlParser_.readers) {
|
||||
for (var key in this.gmlParser_.readers[uri]) {
|
||||
if (!goog.isDef(this.readers[uri])) {
|
||||
this.readers[uri] = {};
|
||||
}
|
||||
this.readers[uri][key] = goog.bind(this.gmlParser_.readers[uri][key],
|
||||
this.gmlParser_);
|
||||
}
|
||||
}
|
||||
for (uri in this.gmlParser_.writers) {
|
||||
for (key in this.gmlParser_.writers[uri]) {
|
||||
if (!goog.isDef(this.writers[uri])) {
|
||||
this.writers[uri] = {};
|
||||
}
|
||||
this.writers[uri][key] = goog.bind(this.gmlParser_.writers[uri][key],
|
||||
this.gmlParser_);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} featureNS Feature namespace.
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.setFeatureNS = function(featureNS) {
|
||||
this.featureNS = featureNS;
|
||||
if (goog.isDefAndNotNull(this.gmlParser_)) {
|
||||
this.setGmlParser(this.gmlParser_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} featureType Feature type.
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.setFeatureType = function(featureType) {
|
||||
this.featureType = featureType;
|
||||
if (goog.isDefAndNotNull(this.gmlParser_)) {
|
||||
this.gmlParser_.featureType = featureType;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} srsName SRS name.
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1.prototype.setSrsName = function(srsName) {
|
||||
this.srsName = srsName;
|
||||
if (goog.isDefAndNotNull(this.gmlParser_)) {
|
||||
this.gmlParser_.applyWriteOptions({},
|
||||
/** @type {olx.parser.GMLWriteOptions} */ ({srsName: srsName}));
|
||||
}
|
||||
};
|
||||
@@ -1,185 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Filter_v1_0_0');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Comparison');
|
||||
goog.require('ol.expr.ComparisonOp');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.functions');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.parser.ogc.Filter_v1');
|
||||
goog.require('ol.parser.ogc.GML_v2');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.Filter_v1}
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1_0_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.0.0';
|
||||
this.schemaLocation = 'http://www.opengis.net/ogc ' +
|
||||
'http://schemas.opengis.net/filter/1.0.0/filter.xsd';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/ogc'], {
|
||||
'PropertyIsEqualTo': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.EQ,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsNotEqualTo': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
obj.filters.push(new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.NEQ,
|
||||
container.property,
|
||||
container.value));
|
||||
},
|
||||
'PropertyIsLike': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
var args = [];
|
||||
args.push(container.property, container.value,
|
||||
new ol.expr.Literal(node.getAttribute('wildCard')),
|
||||
new ol.expr.Literal(node.getAttribute('singleChar')),
|
||||
new ol.expr.Literal(node.getAttribute('escape')));
|
||||
obj.filters.push(new ol.expr.Call(
|
||||
new ol.expr.Identifier(ol.expr.functions.LIKE), args));
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers['http://www.opengis.net/ogc'], {
|
||||
'PropertyIsEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsEqualTo');
|
||||
var property = filter.getLeft();
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsNotEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsNotEqualTo');
|
||||
var property = filter.getLeft();
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
this.writeOgcExpression(filter.getRight(), node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsLike': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsLike');
|
||||
var args = filter.getArgs();
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
node.setAttribute('wildCard', args[2].getValue());
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
node.setAttribute('singleChar', args[3].getValue());
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
node.setAttribute('escape', args[4].getValue());
|
||||
var property = args[0];
|
||||
if (goog.isDef(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
this.writeNode('Literal', args[1], null, node);
|
||||
return node;
|
||||
},
|
||||
'BBOX': function(filter) {
|
||||
var node = this.createElementNS('ogc:BBOX');
|
||||
var args = filter.getArgs();
|
||||
goog.asserts.assert(args[0] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
var bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
var projection;
|
||||
if (args[4] instanceof ol.expr.Literal) {
|
||||
projection = args[4].getValue();
|
||||
}
|
||||
var property = args[5];
|
||||
// PropertyName is mandatory in 1.0.0, but e.g. GeoServer also
|
||||
// accepts filters without it.
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
var box = this.writeNode('Box', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
box.setAttribute('srsName', projection);
|
||||
}
|
||||
node.appendChild(box);
|
||||
return node;
|
||||
}
|
||||
});
|
||||
this.setGmlParser(new ol.parser.ogc.GML_v2());
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.Filter_v1_0_0,
|
||||
ol.parser.ogc.Filter_v1);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Call} filter The filter to write out.
|
||||
* @param {string} name The name of the spatial operator.
|
||||
* @return {Element} The node created.
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1_0_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
var node = this.createElementNS('ogc:' + name);
|
||||
var args = filter.getArgs();
|
||||
var property, geom = null, bbox, call, projection;
|
||||
if (args[0] instanceof ol.expr.Literal && goog.isNumber(args[0].getValue())) {
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
projection = args[4];
|
||||
property = args[5];
|
||||
} else if (args[0] instanceof ol.expr.Literal &&
|
||||
args[0].getValue() instanceof ol.geom.Geometry) {
|
||||
geom = args[0].getValue();
|
||||
if (name === 'DWithin') {
|
||||
projection = args[3];
|
||||
property = args[4];
|
||||
} else {
|
||||
projection = args[1];
|
||||
property = args[2];
|
||||
}
|
||||
} else if (args[0] instanceof ol.expr.Call) {
|
||||
call = args[0];
|
||||
if (name === 'DWithin') {
|
||||
projection = args[3];
|
||||
property = args[4];
|
||||
} else {
|
||||
projection = args[1];
|
||||
property = args[2];
|
||||
}
|
||||
}
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
if (goog.isDef(call)) {
|
||||
this.writeNode('Function', call, null, node);
|
||||
} else {
|
||||
var child;
|
||||
if (geom !== null) {
|
||||
child = this.gmlParser_.writeGeometry(geom);
|
||||
} else if (bbox.length === 4) {
|
||||
child = this.writeNode('Box', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
}
|
||||
if (goog.isDef(child)) {
|
||||
goog.asserts.assert(projection instanceof ol.expr.Literal);
|
||||
if (goog.isDefAndNotNull(projection.getValue())) {
|
||||
child.setAttribute('srsName', projection.getValue());
|
||||
}
|
||||
node.appendChild(child);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
};
|
||||
@@ -1,242 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Filter_v1_1_0');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Comparison');
|
||||
goog.require('ol.expr.ComparisonOp');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.functions');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.parser.ogc.Filter_v1');
|
||||
goog.require('ol.parser.ogc.GML_v3');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.Filter_v1}
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1_1_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.1.0';
|
||||
this.schemaLocation = 'http://www.opengis.net/ogc ' +
|
||||
'http://schemas.opengis.net/filter/1.1.0/filter.xsd';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/ogc'], {
|
||||
'PropertyIsEqualTo': function(node, obj) {
|
||||
var matchCase = node.getAttribute('matchCase');
|
||||
var container = {}, filter;
|
||||
this.readChildNodes(node, container);
|
||||
if (matchCase === 'false' || matchCase === '0') {
|
||||
filter = new ol.expr.Call(new ol.expr.Identifier(ol.expr.functions.IEQ),
|
||||
[container.property, container.value]);
|
||||
} else {
|
||||
filter = new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.EQ,
|
||||
container.property,
|
||||
container.value);
|
||||
}
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
'PropertyIsNotEqualTo': function(node, obj) {
|
||||
var matchCase = node.getAttribute('matchCase');
|
||||
var container = {}, filter;
|
||||
this.readChildNodes(node, container);
|
||||
if (matchCase === 'false' || matchCase === '0') {
|
||||
filter = new ol.expr.Call(new ol.expr.Identifier(
|
||||
ol.expr.functions.INEQ),
|
||||
[container.property, container.value]);
|
||||
} else {
|
||||
filter = new ol.expr.Comparison(
|
||||
ol.expr.ComparisonOp.NEQ,
|
||||
container.property,
|
||||
container.value);
|
||||
}
|
||||
obj.filters.push(filter);
|
||||
},
|
||||
'PropertyIsLike': function(node, obj) {
|
||||
var container = {};
|
||||
this.readChildNodes(node, container);
|
||||
var args = [];
|
||||
args.push(container.property, container.value,
|
||||
new ol.expr.Literal(node.getAttribute('wildCard')),
|
||||
new ol.expr.Literal(node.getAttribute('singleChar')),
|
||||
new ol.expr.Literal(node.getAttribute('escapeChar')),
|
||||
new ol.expr.Literal(node.getAttribute('matchCase')));
|
||||
obj.filters.push(new ol.expr.Call(
|
||||
new ol.expr.Identifier(ol.expr.functions.LIKE), args));
|
||||
}
|
||||
});
|
||||
goog.object.extend(this.writers['http://www.opengis.net/ogc'], {
|
||||
'PropertyIsEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsEqualTo');
|
||||
var property, value;
|
||||
if (filter instanceof ol.expr.Call) {
|
||||
var args = filter.getArgs();
|
||||
property = args[0];
|
||||
value = args[1];
|
||||
node.setAttribute('matchCase', false);
|
||||
} else {
|
||||
property = filter.getLeft();
|
||||
value = filter.getRight();
|
||||
}
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
this.writeOgcExpression(value, node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsNotEqualTo': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsNotEqualTo');
|
||||
var property, value;
|
||||
if (filter instanceof ol.expr.Call) {
|
||||
var args = filter.getArgs();
|
||||
property = args[0];
|
||||
value = args[1];
|
||||
node.setAttribute('matchCase', false);
|
||||
} else {
|
||||
property = filter.getLeft();
|
||||
value = filter.getRight();
|
||||
}
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
this.writeOgcExpression(value, node);
|
||||
return node;
|
||||
},
|
||||
'PropertyIsLike': function(filter) {
|
||||
var node = this.createElementNS('ogc:PropertyIsLike');
|
||||
var args = filter.getArgs();
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
node.setAttribute('wildCard', args[2].getValue());
|
||||
node.setAttribute('singleChar', args[3].getValue());
|
||||
node.setAttribute('escapeChar', args[4].getValue());
|
||||
if (goog.isDefAndNotNull(args[5])) {
|
||||
goog.asserts.assert(args[5] instanceof ol.expr.Literal);
|
||||
node.setAttribute('matchCase', args[5].getValue());
|
||||
}
|
||||
var property = args[0];
|
||||
if (goog.isDef(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
this.writeNode('Literal', args[1], null, node);
|
||||
return node;
|
||||
},
|
||||
'BBOX': function(filter) {
|
||||
var node = this.createElementNS('ogc:BBOX');
|
||||
var args = filter.getArgs();
|
||||
goog.asserts.assert(args[0] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[4] instanceof ol.expr.Literal);
|
||||
var bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
var projection = args[4].getValue();
|
||||
var property = args[5];
|
||||
// PropertyName is optional in 1.1.0
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
var box = this.writeNode('Envelope', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
box.setAttribute('srsName', projection);
|
||||
}
|
||||
node.appendChild(box);
|
||||
return node;
|
||||
},
|
||||
'SortBy': function(sortProperties) {
|
||||
var node = this.createElementNS('ogc:SortBy');
|
||||
for (var i = 0, l = sortProperties.length; i < l; i++) {
|
||||
this.writeNode('SortProperty', sortProperties[i], null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'SortProperty': function(sortProperty) {
|
||||
var node = this.createElementNS('ogc:SortProperty');
|
||||
this.writeNode('PropertyName', sortProperty['property'], null, node);
|
||||
goog.asserts.assert(sortProperty['order'] instanceof ol.expr.Literal);
|
||||
this.writeNode('SortOrder',
|
||||
(sortProperty['order'].getValue() == 'DESC') ? 'DESC' : 'ASC', null,
|
||||
node);
|
||||
return node;
|
||||
},
|
||||
'SortOrder': function(value) {
|
||||
var node = this.createElementNS('ogc:SortOrder');
|
||||
node.appendChild(this.createTextNode(value));
|
||||
return node;
|
||||
}
|
||||
});
|
||||
this.setGmlParser(new ol.parser.ogc.GML_v3());
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.Filter_v1_1_0,
|
||||
ol.parser.ogc.Filter_v1);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.expr.Call} filter The filter to write out.
|
||||
* @param {string} name The name of the spatial operator.
|
||||
* @return {Element} The node created.
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.Filter_v1_1_0.prototype.writeSpatial_ = function(filter, name) {
|
||||
var node = this.createElementNS('ogc:' + name);
|
||||
var args = filter.getArgs();
|
||||
var property, geom = null, bbox, call, projection;
|
||||
if (args[0] instanceof ol.expr.Literal && goog.isNumber(args[0].getValue())) {
|
||||
goog.asserts.assert(args[1] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[2] instanceof ol.expr.Literal);
|
||||
goog.asserts.assert(args[3] instanceof ol.expr.Literal);
|
||||
bbox = [
|
||||
args[0].getValue(), args[1].getValue(),
|
||||
args[2].getValue(), args[3].getValue()
|
||||
];
|
||||
projection = args[4];
|
||||
property = args[5];
|
||||
} else if (args[0] instanceof ol.expr.Literal &&
|
||||
args[0].getValue() instanceof ol.geom.Geometry) {
|
||||
geom = args[0].getValue();
|
||||
if (name === 'DWithin') {
|
||||
projection = args[3];
|
||||
property = args[4];
|
||||
} else {
|
||||
projection = args[1];
|
||||
property = args[2];
|
||||
}
|
||||
} else if (args[0] instanceof ol.expr.Call) {
|
||||
call = args[0];
|
||||
if (name === 'DWithin') {
|
||||
projection = args[3];
|
||||
property = args[4];
|
||||
} else {
|
||||
projection = args[1];
|
||||
property = args[2];
|
||||
}
|
||||
}
|
||||
if (goog.isDefAndNotNull(property)) {
|
||||
this.writeNode('PropertyName', property, null, node);
|
||||
}
|
||||
if (goog.isDef(call)) {
|
||||
this.writeNode('Function', call, null, node);
|
||||
} else {
|
||||
var child;
|
||||
if (geom !== null) {
|
||||
child = this.writeNode('_geometry', {value: geom},
|
||||
this.gmlParser_.featureNS).firstChild;
|
||||
} else if (bbox.length === 4) {
|
||||
child = this.writeNode('Envelope', bbox,
|
||||
'http://www.opengis.net/gml');
|
||||
}
|
||||
if (goog.isDef(child)) {
|
||||
goog.asserts.assert(projection instanceof ol.expr.Literal);
|
||||
if (goog.isDefAndNotNull(projection.getValue())) {
|
||||
child.setAttribute('srsName', projection.getValue());
|
||||
}
|
||||
node.appendChild(child);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
};
|
||||
@@ -1,214 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.OWSCommon_v1');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.OWSCommon_v1 = function() {
|
||||
this.readers = {
|
||||
'http://www.opengis.net/ows': {
|
||||
'ServiceIdentification': function(node, obj) {
|
||||
obj['serviceIdentification'] = {};
|
||||
this.readChildNodes(node, obj['serviceIdentification']);
|
||||
},
|
||||
'Title': function(node, obj) {
|
||||
obj['title'] = this.getChildValue(node);
|
||||
},
|
||||
'Abstract': function(node, serviceIdentification) {
|
||||
serviceIdentification['abstract'] = this.getChildValue(node);
|
||||
},
|
||||
'Keywords': function(node, serviceIdentification) {
|
||||
serviceIdentification['keywords'] = {};
|
||||
this.readChildNodes(node, serviceIdentification['keywords']);
|
||||
},
|
||||
'Keyword': function(node, keywords) {
|
||||
keywords[this.getChildValue(node)] = true;
|
||||
},
|
||||
'ServiceType': function(node, serviceIdentification) {
|
||||
serviceIdentification['serviceType'] = {
|
||||
'codeSpace': node.getAttribute('codeSpace'),
|
||||
'value': this.getChildValue(node)};
|
||||
},
|
||||
'ServiceTypeVersion': function(node, serviceIdentification) {
|
||||
serviceIdentification['serviceTypeVersion'] = this.getChildValue(node);
|
||||
},
|
||||
'Fees': function(node, serviceIdentification) {
|
||||
serviceIdentification['fees'] = this.getChildValue(node);
|
||||
},
|
||||
'AccessConstraints': function(node, serviceIdentification) {
|
||||
serviceIdentification['accessConstraints'] =
|
||||
this.getChildValue(node);
|
||||
},
|
||||
'ServiceProvider': function(node, obj) {
|
||||
obj['serviceProvider'] = {};
|
||||
this.readChildNodes(node, obj['serviceProvider']);
|
||||
},
|
||||
'ProviderName': function(node, serviceProvider) {
|
||||
serviceProvider['providerName'] = this.getChildValue(node);
|
||||
},
|
||||
'ProviderSite': function(node, serviceProvider) {
|
||||
serviceProvider['providerSite'] = this.getAttributeNS(node,
|
||||
'http://www.w3.org/1999/xlink', 'href');
|
||||
},
|
||||
'ServiceContact': function(node, serviceProvider) {
|
||||
serviceProvider['serviceContact'] = {};
|
||||
this.readChildNodes(node, serviceProvider['serviceContact']);
|
||||
},
|
||||
'IndividualName': function(node, serviceContact) {
|
||||
serviceContact['individualName'] = this.getChildValue(node);
|
||||
},
|
||||
'PositionName': function(node, serviceContact) {
|
||||
serviceContact['positionName'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactInfo': function(node, serviceContact) {
|
||||
serviceContact['contactInfo'] = {};
|
||||
this.readChildNodes(node, serviceContact['contactInfo']);
|
||||
},
|
||||
'Phone': function(node, contactInfo) {
|
||||
contactInfo['phone'] = {};
|
||||
this.readChildNodes(node, contactInfo['phone']);
|
||||
},
|
||||
'Voice': function(node, phone) {
|
||||
phone['voice'] = this.getChildValue(node);
|
||||
},
|
||||
'Address': function(node, contactInfo) {
|
||||
contactInfo['address'] = {};
|
||||
this.readChildNodes(node, contactInfo['address']);
|
||||
},
|
||||
'DeliveryPoint': function(node, address) {
|
||||
address['deliveryPoint'] = this.getChildValue(node);
|
||||
},
|
||||
'City': function(node, address) {
|
||||
address['city'] = this.getChildValue(node);
|
||||
},
|
||||
'AdministrativeArea': function(node, address) {
|
||||
address['administrativeArea'] = this.getChildValue(node);
|
||||
},
|
||||
'PostalCode': function(node, address) {
|
||||
address['postalCode'] = this.getChildValue(node);
|
||||
},
|
||||
'Country': function(node, address) {
|
||||
address['country'] = this.getChildValue(node);
|
||||
},
|
||||
'ElectronicMailAddress': function(node, address) {
|
||||
address['electronicMailAddress'] = this.getChildValue(node);
|
||||
},
|
||||
'Role': function(node, serviceContact) {
|
||||
serviceContact['role'] = this.getChildValue(node);
|
||||
},
|
||||
'OperationsMetadata': function(node, obj) {
|
||||
obj['operationsMetadata'] = {};
|
||||
this.readChildNodes(node, obj['operationsMetadata']);
|
||||
},
|
||||
'Operation': function(node, operationsMetadata) {
|
||||
var name = node.getAttribute('name');
|
||||
operationsMetadata[name] = {};
|
||||
this.readChildNodes(node, operationsMetadata[name]);
|
||||
},
|
||||
'DCP': function(node, operation) {
|
||||
operation['dcp'] = {};
|
||||
this.readChildNodes(node, operation['dcp']);
|
||||
},
|
||||
'HTTP': function(node, dcp) {
|
||||
dcp['http'] = {};
|
||||
this.readChildNodes(node, dcp['http']);
|
||||
},
|
||||
'Get': function(node, http) {
|
||||
if (!http['get']) {
|
||||
http['get'] = [];
|
||||
}
|
||||
var obj = {
|
||||
'url': this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
|
||||
'href')
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
http['get'].push(obj);
|
||||
},
|
||||
'Post': function(node, http) {
|
||||
if (!http['post']) {
|
||||
http['post'] = [];
|
||||
}
|
||||
var obj = {
|
||||
'url': this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
|
||||
'href')
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
http['post'].push(obj);
|
||||
},
|
||||
'Parameter': function(node, operation) {
|
||||
if (!operation['parameters']) {
|
||||
operation['parameters'] = {};
|
||||
}
|
||||
var name = node.getAttribute('name');
|
||||
operation['parameters'][name] = {};
|
||||
this.readChildNodes(node, operation['parameters'][name]);
|
||||
},
|
||||
'Constraint': function(node, obj) {
|
||||
if (!obj['constraints']) {
|
||||
obj['constraints'] = {};
|
||||
}
|
||||
var name = node.getAttribute('name');
|
||||
obj['constraints'][name] = {};
|
||||
this.readChildNodes(node, obj['constraints'][name]);
|
||||
},
|
||||
'Value': function(node, allowedValues) {
|
||||
allowedValues[this.getChildValue(node)] = true;
|
||||
},
|
||||
'OutputFormat': function(node, obj) {
|
||||
obj['formats'].push({'value': this.getChildValue(node)});
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'WGS84BoundingBox': function(node, obj) {
|
||||
var boundingBox = {};
|
||||
boundingBox['crs'] = node.getAttribute('crs');
|
||||
if (obj['BoundingBox']) {
|
||||
obj['BoundingBox'].push(boundingBox);
|
||||
} else {
|
||||
obj['projection'] = boundingBox['crs'];
|
||||
boundingBox = obj;
|
||||
}
|
||||
this.readChildNodes(node, boundingBox);
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
// FIXME: We consider that BoundingBox is the same as WGS84BoundingBox
|
||||
// LowerCorner = "min_x min_y"
|
||||
// UpperCorner = "max_x max_y"
|
||||
// It should normally depend on the projection
|
||||
var readers = this.readers[node.namespaceURI];
|
||||
readers['WGS84BoundingBox'].apply(this, [node, obj]);
|
||||
},
|
||||
'LowerCorner': function(node, obj) {
|
||||
var str = this.getChildValue(node).replace(
|
||||
this.regExes.trimSpace, '');
|
||||
str = str.replace(this.regExes.trimComma, ',');
|
||||
var pointList = str.split(this.regExes.splitSpace);
|
||||
obj['left'] = pointList[0];
|
||||
obj['bottom'] = pointList[1];
|
||||
},
|
||||
'UpperCorner': function(node, obj) {
|
||||
var str = this.getChildValue(node).replace(
|
||||
this.regExes.trimSpace, '');
|
||||
str = str.replace(this.regExes.trimComma, ',');
|
||||
var pointList = str.split(this.regExes.splitSpace);
|
||||
obj['right'] = pointList[0];
|
||||
obj['top'] = pointList[1];
|
||||
obj['bounds'] = [
|
||||
parseFloat(obj['left']), parseFloat(obj['right']),
|
||||
parseFloat(obj['bottom']), parseFloat(obj['top'])
|
||||
];
|
||||
delete obj['left'];
|
||||
delete obj['bottom'];
|
||||
delete obj['right'];
|
||||
delete obj['top'];
|
||||
},
|
||||
'Language': function(node, obj) {
|
||||
obj['language'] = this.getChildValue(node);
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.OWSCommon_v1, ol.parser.XML);
|
||||
@@ -1,45 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.OWSCommon_v1_1_0');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.OWSCommon_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.OWSCommon_v1}
|
||||
*/
|
||||
ol.parser.ogc.OWSCommon_v1_1_0 = function() {
|
||||
goog.base(this);
|
||||
this.readers['http://www.opengis.net/ows/1.1'] =
|
||||
this.readers['http://www.opengis.net/ows'];
|
||||
goog.object.extend(this.readers['http://www.opengis.net/ows/1.1'], {
|
||||
'AllowedValues': function(node, parameter) {
|
||||
parameter['allowedValues'] = {};
|
||||
this.readChildNodes(node, parameter['allowedValues']);
|
||||
},
|
||||
'AnyValue': function(node, parameter) {
|
||||
parameter['anyValue'] = true;
|
||||
},
|
||||
'DataType': function(node, parameter) {
|
||||
parameter['dataType'] = this.getChildValue(node);
|
||||
},
|
||||
'Range': function(node, allowedValues) {
|
||||
allowedValues['range'] = {};
|
||||
this.readChildNodes(node, allowedValues['range']);
|
||||
},
|
||||
'MinimumValue': function(node, range) {
|
||||
range['minValue'] = this.getChildValue(node);
|
||||
},
|
||||
'MaximumValue': function(node, range) {
|
||||
range['maxValue'] = this.getChildValue(node);
|
||||
},
|
||||
'Identifier': function(node, obj) {
|
||||
obj['identifier'] = this.getChildValue(node);
|
||||
},
|
||||
'SupportedCRS': function(node, obj) {
|
||||
obj['supportedCRS'] = this.getChildValue(node);
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.OWSCommon_v1_1_0,
|
||||
ol.parser.ogc.OWSCommon_v1);
|
||||
@@ -1,27 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.SLD');
|
||||
goog.require('ol.parser.ogc.SLD_v1_0_0');
|
||||
goog.require('ol.parser.ogc.Versioned');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable SLD version 1.0.0.
|
||||
*/
|
||||
ol.ENABLE_SLD_1_0_0 = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
* @extends {ol.parser.ogc.Versioned}
|
||||
*/
|
||||
ol.parser.ogc.SLD = function(opt_options) {
|
||||
opt_options = opt_options || {};
|
||||
opt_options['defaultVersion'] = '1.0.0';
|
||||
this.parsers = {};
|
||||
if (ol.ENABLE_SLD_1_0_0) {
|
||||
this.parsers['v1_0_0'] = ol.parser.ogc.SLD_v1_0_0;
|
||||
}
|
||||
goog.base(this, opt_options);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD, ol.parser.ogc.Versioned);
|
||||
@@ -1,732 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.SLD_v1');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.parser.XML');
|
||||
goog.require('ol.parser.ogc.Filter_v1_0_0');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Icon');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read Styled Layer Descriptor (SLD).
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1 = function() {
|
||||
this.defaultNamespaceURI = 'http://www.opengis.net/sld';
|
||||
this.readers = {};
|
||||
this.readers[this.defaultNamespaceURI] = {
|
||||
'StyledLayerDescriptor': function(node, sld) {
|
||||
sld.version = node.getAttribute('version');
|
||||
this.readChildNodes(node, sld);
|
||||
},
|
||||
'Name': function(node, obj) {
|
||||
obj.name = this.getChildValue(node);
|
||||
},
|
||||
'Title': function(node, obj) {
|
||||
obj.title = this.getChildValue(node);
|
||||
},
|
||||
'Abstract': function(node, obj) {
|
||||
obj.description = this.getChildValue(node);
|
||||
},
|
||||
'NamedLayer': function(node, sld) {
|
||||
var layer = {
|
||||
userStyles: [],
|
||||
namedStyles: []
|
||||
};
|
||||
this.readChildNodes(node, layer);
|
||||
sld.namedLayers[layer.name] = layer;
|
||||
},
|
||||
'NamedStyle': function(node, layer) {
|
||||
layer.namedStyles.push(
|
||||
this.getChildValue(node.firstChild)
|
||||
);
|
||||
},
|
||||
'UserStyle': function(node, layer) {
|
||||
var obj = {rules: []};
|
||||
this.featureTypeCounter = -1;
|
||||
this.readChildNodes(node, obj);
|
||||
layer.userStyles.push(new ol.style.Style(obj));
|
||||
},
|
||||
'FeatureTypeStyle': function(node, style) {
|
||||
++this.featureTypeCounter;
|
||||
var obj = {
|
||||
rules: style.rules
|
||||
};
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Rule': function(node, obj) {
|
||||
var config = {symbolizers: []};
|
||||
this.readChildNodes(node, config);
|
||||
var rule = new ol.style.Rule(config);
|
||||
obj.rules.push(rule);
|
||||
},
|
||||
'ElseFilter': function(node, rule) {
|
||||
rule.elseFilter = true;
|
||||
},
|
||||
'MinScaleDenominator': function(node, rule) {
|
||||
rule.minResolution = this.getResolutionFromScaleDenominator_(
|
||||
parseFloat(this.getChildValue(node)));
|
||||
},
|
||||
'MaxScaleDenominator': function(node, rule) {
|
||||
rule.maxResolution = this.getResolutionFromScaleDenominator_(
|
||||
parseFloat(this.getChildValue(node)));
|
||||
},
|
||||
'TextSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.color = goog.isDef(config.fill) ? config.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fontColor;
|
||||
delete config.fill;
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Text(/** @type {olx.style.TextOptions} */(config))
|
||||
);
|
||||
},
|
||||
'Label': function(node, symbolizer) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
var value = ogcreaders._expression.call(this, node);
|
||||
if (value) {
|
||||
symbolizer.text = value;
|
||||
}
|
||||
},
|
||||
'Font': function(node, symbolizer) {
|
||||
this.readChildNodes(node, symbolizer);
|
||||
},
|
||||
'Halo': function(node, symbolizer) {
|
||||
var obj = {};
|
||||
this.readChildNodes(node, obj);
|
||||
symbolizer.stroke = new ol.style.Stroke({
|
||||
color: goog.isDef(obj.fill.fillColor) ? obj.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloColor,
|
||||
width: goog.isDef(obj.haloRadius) ? obj.haloRadius * 2 :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloRadius,
|
||||
opacity: goog.isDef(obj.fill.fillOpacity) ? obj.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.haloOpacity
|
||||
});
|
||||
},
|
||||
'Radius': function(node, symbolizer) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
var radius = ogcreaders._expression.call(this, node);
|
||||
goog.asserts.assertInstanceof(radius, ol.expr.Literal,
|
||||
'radius expected to be an ol.expr.Literal');
|
||||
if (goog.isDef(radius)) {
|
||||
symbolizer.haloRadius = radius.getValue();
|
||||
}
|
||||
},
|
||||
'LineSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Stroke(config)
|
||||
);
|
||||
},
|
||||
'PolygonSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
if (goog.isDef(config.fill)) {
|
||||
var fill = {
|
||||
color: config.fill.fillColor.getValue(),
|
||||
opacity: goog.isDef(config.fill.fillOpacity) ?
|
||||
config.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillOpacity
|
||||
};
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Fill(fill)
|
||||
);
|
||||
delete config.fill;
|
||||
}
|
||||
if (goog.isDef(config.stroke)) {
|
||||
var stroke = {
|
||||
color: config.stroke.strokeColor.getValue(),
|
||||
opacity: goog.isDef(config.stroke.strokeOpacity) ?
|
||||
config.stroke.strokeOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeOpacity,
|
||||
width: goog.isDef(config.stroke.strokeWidth) ?
|
||||
config.stroke.strokeWidth :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeWidth
|
||||
};
|
||||
rule.symbolizers.push(
|
||||
new ol.style.Stroke(stroke)
|
||||
);
|
||||
delete config.stroke;
|
||||
}
|
||||
|
||||
},
|
||||
'PointSymbolizer': function(node, rule) {
|
||||
var config = {};
|
||||
this.readChildNodes(node, config);
|
||||
config.zIndex = this.featureTypeCounter;
|
||||
if (config.fill) {
|
||||
var fillConfig = {
|
||||
color: goog.isDef(config.fill.fillColor) ?
|
||||
config.fill.fillColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillColor,
|
||||
opacity: goog.isDef(config.fill.fillOpacity) ?
|
||||
config.fill.fillOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.fillOpacity
|
||||
};
|
||||
config.fill = new ol.style.Fill(fillConfig);
|
||||
}
|
||||
if (config.stroke) {
|
||||
var strokeConfig = {
|
||||
color: goog.isDef(config.stroke.strokeColor) ?
|
||||
config.stroke.strokeColor :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeColor,
|
||||
width: goog.isDef(config.stroke.strokeWidth) ?
|
||||
config.stroke.strokeWidth :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeWidth,
|
||||
opacity: goog.isDef(config.stroke.strokeOpacity) ?
|
||||
config.stroke.strokeOpacity :
|
||||
ol.parser.ogc.SLD_v1.defaults_.strokeOpacity
|
||||
};
|
||||
config.stroke = new ol.style.Stroke(strokeConfig);
|
||||
}
|
||||
var symbolizer;
|
||||
if (goog.isDef(config.externalGraphic)) {
|
||||
config.width = config.height = config.size;
|
||||
symbolizer = new ol.style.Icon(
|
||||
/** @type {olx.style.IconOptions} */(config));
|
||||
} else {
|
||||
symbolizer = new ol.style.Shape(config);
|
||||
}
|
||||
rule.symbolizers.push(symbolizer);
|
||||
},
|
||||
'Stroke': function(node, symbolizer) {
|
||||
var stroke = {};
|
||||
this.readChildNodes(node, stroke);
|
||||
symbolizer.stroke = stroke;
|
||||
},
|
||||
'Fill': function(node, symbolizer) {
|
||||
var fill = {};
|
||||
this.readChildNodes(node, fill);
|
||||
symbolizer.fill = fill;
|
||||
},
|
||||
'CssParameter': function(node, symbolizer) {
|
||||
var cssProperty = node.getAttribute('name');
|
||||
var symProperty = ol.parser.ogc.SLD_v1.cssMap_[cssProperty];
|
||||
if (symProperty) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
symbolizer[symProperty] = ogcreaders._expression.call(this, node);
|
||||
}
|
||||
},
|
||||
'Graphic': function(node, symbolizer) {
|
||||
var graphic = {};
|
||||
// painter's order not respected here, clobber previous with next
|
||||
this.readChildNodes(node, graphic);
|
||||
// directly properties with names that match symbolizer properties
|
||||
var properties = [
|
||||
'stroke', 'fill', 'rotation', 'opacity'
|
||||
];
|
||||
var prop, value;
|
||||
for (var i = 0, ii = properties.length; i < ii; ++i) {
|
||||
prop = properties[i];
|
||||
value = graphic[prop];
|
||||
if (goog.isDef(value)) {
|
||||
symbolizer[prop] = value;
|
||||
}
|
||||
}
|
||||
// set other generic properties with specific graphic property names
|
||||
if (goog.isDef(graphic.graphicName)) {
|
||||
symbolizer.type = graphic.graphicName;
|
||||
}
|
||||
if (goog.isDef(graphic.size)) {
|
||||
var pointRadius = graphic.size / 2;
|
||||
if (isNaN(pointRadius)) {
|
||||
// likely a property name
|
||||
symbolizer.size = graphic.size;
|
||||
} else {
|
||||
symbolizer.size = graphic.size / 2;
|
||||
}
|
||||
}
|
||||
if (goog.isDef(graphic.href)) {
|
||||
symbolizer.url = graphic.href;
|
||||
}
|
||||
},
|
||||
'ExternalGraphic': function(node, graphic) {
|
||||
this.readChildNodes(node, graphic);
|
||||
},
|
||||
'Mark': function(node, graphic) {
|
||||
this.readChildNodes(node, graphic);
|
||||
},
|
||||
'WellKnownName': function(node, graphic) {
|
||||
graphic.graphicName = this.getChildValue(node);
|
||||
},
|
||||
'Opacity': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.opacity = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'Size': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.size = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'Rotation': function(node, obj) {
|
||||
var ogcreaders = this.readers[this.filter_.defaultNamespaceURI];
|
||||
obj.rotation = ogcreaders._expression.call(this, node);
|
||||
},
|
||||
'OnlineResource': function(node, obj) {
|
||||
obj.href = this.getAttributeNS(
|
||||
node, 'http://www.w3.org/1999/xlink', 'href'
|
||||
);
|
||||
},
|
||||
'Format': function(node, graphic) {
|
||||
graphic.graphicFormat = this.getChildValue(node);
|
||||
}
|
||||
};
|
||||
this.writers = {};
|
||||
this.writers[this.defaultNamespaceURI] = {
|
||||
'StyledLayerDescriptor': function(sld) {
|
||||
var node = this.createElementNS('sld:StyledLayerDescriptor');
|
||||
node.setAttribute('version', this.version);
|
||||
if (goog.isDef(sld.name)) {
|
||||
this.writeNode('Name', sld.name, null, node);
|
||||
}
|
||||
if (goog.isDef(sld.title)) {
|
||||
this.writeNode('Title', sld.title, null, node);
|
||||
}
|
||||
if (goog.isDef(sld.description)) {
|
||||
this.writeNode('Abstract', sld.description, null, node);
|
||||
}
|
||||
goog.object.forEach(sld.namedLayers, function(layer) {
|
||||
this.writeNode('NamedLayer', layer, null, node);
|
||||
}, this);
|
||||
return node;
|
||||
},
|
||||
'Name': function(name) {
|
||||
var node = this.createElementNS('sld:Name');
|
||||
node.appendChild(this.createTextNode(name));
|
||||
return node;
|
||||
},
|
||||
'Title': function(title) {
|
||||
var node = this.createElementNS('sld:Title');
|
||||
node.appendChild(this.createTextNode(title));
|
||||
return node;
|
||||
},
|
||||
'Abstract': function(description) {
|
||||
var node = this.createElementNS('sld:Abstract');
|
||||
node.appendChild(this.createTextNode(description));
|
||||
return node;
|
||||
},
|
||||
'NamedLayer': function(layer) {
|
||||
var node = this.createElementNS('sld:NamedLayer');
|
||||
this.writeNode('Name', layer.name, null, node);
|
||||
var i, ii;
|
||||
if (layer.namedStyles) {
|
||||
for (i = 0, ii = layer.namedStyles.length; i < ii; ++i) {
|
||||
this.writeNode('NamedStyle', layer.namedStyles[i], null, node);
|
||||
}
|
||||
}
|
||||
if (layer.userStyles) {
|
||||
for (i = 0, ii = layer.userStyles.length; i < ii; ++i) {
|
||||
this.writeNode('UserStyle', layer.userStyles[i], null, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'NamedStyle': function(name) {
|
||||
var node = this.createElementNS('sld:NamedStyle');
|
||||
this.writeNode('Name', name, null, node);
|
||||
return node;
|
||||
},
|
||||
'UserStyle': function(style) {
|
||||
var node = this.createElementNS('sld:UserStyle');
|
||||
var name = style.getName(), title = style.getTitle();
|
||||
if (goog.isDef(name)) {
|
||||
this.writeNode('Name', name, null, node);
|
||||
}
|
||||
if (goog.isDef(title)) {
|
||||
this.writeNode('Title', title, null, node);
|
||||
}
|
||||
// TODO sorting by zIndex
|
||||
this.writeNode('FeatureTypeStyle', style, null, node);
|
||||
return node;
|
||||
},
|
||||
'FeatureTypeStyle': function(style) {
|
||||
var node = this.createElementNS('sld:FeatureTypeStyle');
|
||||
var rules = style.getRules();
|
||||
for (var i = 0, ii = rules.length; i < ii; ++i) {
|
||||
this.writeNode('Rule', rules[i], null, node);
|
||||
}
|
||||
var symbolizers = style.getSymbolizers();
|
||||
if (symbolizers.length > 0) {
|
||||
// wrap this in a Rule with an ElseFilter
|
||||
var rule = new ol.style.Rule({symbolizers: symbolizers});
|
||||
rule.elseFilter = true;
|
||||
this.writeNode('Rule', rule, null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'Rule': function(rule) {
|
||||
var node = this.createElementNS('sld:Rule');
|
||||
var filter = rule.getFilter();
|
||||
var name = rule.getName(), title = rule.getTitle();
|
||||
if (goog.isDef(name)) {
|
||||
this.writeNode('Name', name, null, node);
|
||||
}
|
||||
if (goog.isDef(title)) {
|
||||
this.writeNode('Title', title, null, node);
|
||||
}
|
||||
if (rule.elseFilter === true) {
|
||||
this.writeNode('ElseFilter', null, null, node);
|
||||
} else if (filter) {
|
||||
this.writeNode('Filter', filter, this.filter_.defaultNamespaceURI,
|
||||
node);
|
||||
}
|
||||
var minResolution = rule.getMinResolution();
|
||||
if (minResolution > 0) {
|
||||
this.writeNode('MinScaleDenominator',
|
||||
this.getScaleDenominatorFromResolution_(minResolution),
|
||||
null, node);
|
||||
}
|
||||
var maxResolution = rule.getMaxResolution();
|
||||
if (maxResolution < Infinity) {
|
||||
this.writeNode('MaxScaleDenominator',
|
||||
this.getScaleDenominatorFromResolution_(maxResolution),
|
||||
null, node);
|
||||
}
|
||||
var type, symbolizer, symbolizers = rule.getSymbolizers();
|
||||
if (symbolizers) {
|
||||
for (var i = 0, ii = symbolizers.length; i < ii; ++i) {
|
||||
symbolizer = symbolizers[i];
|
||||
if (symbolizer instanceof ol.style.Text) {
|
||||
type = 'Text';
|
||||
} else if (symbolizer instanceof ol.style.Stroke) {
|
||||
type = 'Line';
|
||||
} else if (symbolizer instanceof ol.style.Fill) {
|
||||
type = 'Polygon';
|
||||
} else if (symbolizer instanceof ol.style.Shape ||
|
||||
symbolizer instanceof ol.style.Icon) {
|
||||
type = 'Point';
|
||||
}
|
||||
if (goog.isDef(type)) {
|
||||
this.writeNode(type + 'Symbolizer', symbolizer, null, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PointSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:PointSymbolizer');
|
||||
this.writeNode('Graphic', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Mark': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Mark');
|
||||
this.writeNode('WellKnownName', symbolizer.getType(), null, node);
|
||||
var fill = symbolizer.getFill();
|
||||
if (!goog.isNull(fill)) {
|
||||
this.writeNode('Fill', fill, null, node);
|
||||
}
|
||||
var stroke = symbolizer.getStroke();
|
||||
if (!goog.isNull(stroke)) {
|
||||
this.writeNode('Stroke', stroke, null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'WellKnownName': function(name) {
|
||||
var node = this.createElementNS('sld:WellKnownName');
|
||||
node.appendChild(this.createTextNode(name));
|
||||
return node;
|
||||
},
|
||||
'Graphic': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Graphic');
|
||||
var size;
|
||||
if (symbolizer instanceof ol.style.Icon) {
|
||||
this.writeNode('ExternalGraphic', symbolizer, null, node);
|
||||
var opacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for graphicOpacity');
|
||||
this.writeNode('Opacity', opacity.getValue(), null, node);
|
||||
size = symbolizer.getWidth();
|
||||
} else if (symbolizer instanceof ol.style.Shape) {
|
||||
this.writeNode('Mark', symbolizer, null, node);
|
||||
size = symbolizer.getSize();
|
||||
}
|
||||
this.writeNode('Size', size, null, node);
|
||||
if (symbolizer instanceof ol.style.Icon) {
|
||||
var rotation = symbolizer.getRotation();
|
||||
goog.asserts.assertInstanceof(rotation, ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for rotation');
|
||||
this.writeNode('Rotation', rotation.getValue(), null, node);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
'PolygonSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:PolygonSymbolizer');
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Fill': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Fill');
|
||||
var fillColor = symbolizer.getColor();
|
||||
var msg = 'Only ol.expr.Literal supported for Fill properties';
|
||||
goog.asserts.assertInstanceof(fillColor, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: fillColor.getValue(),
|
||||
key: 'fillColor'
|
||||
}, null, node);
|
||||
var fillOpacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(fillOpacity, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: fillOpacity.getValue(),
|
||||
key: 'fillOpacity'
|
||||
}, null, node);
|
||||
return node;
|
||||
},
|
||||
'TextSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:TextSymbolizer');
|
||||
var text = symbolizer.getText();
|
||||
this.writeNode('Label', text, null, node);
|
||||
this.writeNode('Font', symbolizer, null, node);
|
||||
var stroke = symbolizer.getStroke();
|
||||
if (!goog.isNull(stroke)) {
|
||||
this.writeNode('Halo', stroke, null, node);
|
||||
}
|
||||
var color = symbolizer.getColor();
|
||||
goog.asserts.assertInstanceof(color, ol.expr.Literal,
|
||||
'font color should be ol.expr.Literal');
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Halo': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Halo');
|
||||
goog.asserts.assertInstanceof(symbolizer.getWidth(), ol.expr.Literal,
|
||||
'Only ol.expr.Literal supported for haloRadius');
|
||||
this.writeNode('Radius', symbolizer.getWidth().getValue() / 2, null,
|
||||
node);
|
||||
this.writeNode('Fill', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Radius': function(value) {
|
||||
var node = this.createElementNS('sld:Radius');
|
||||
node.appendChild(this.createTextNode(value));
|
||||
return node;
|
||||
},
|
||||
'LineSymbolizer': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:LineSymbolizer');
|
||||
this.writeNode('Stroke', symbolizer, null, node);
|
||||
return node;
|
||||
},
|
||||
'Stroke': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Stroke');
|
||||
var strokeColor = symbolizer.getColor();
|
||||
var msg = 'SLD writing of stroke properties only supported ' +
|
||||
'for ol.expr.Literal';
|
||||
goog.asserts.assertInstanceof(strokeColor, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeColor.getValue(),
|
||||
key: 'strokeColor'
|
||||
}, null, node);
|
||||
var strokeOpacity = symbolizer.getOpacity();
|
||||
goog.asserts.assertInstanceof(strokeOpacity, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeOpacity.getValue(),
|
||||
key: 'strokeOpacity'
|
||||
}, null, node);
|
||||
var strokeWidth = symbolizer.getWidth();
|
||||
goog.asserts.assertInstanceof(strokeWidth, ol.expr.Literal, msg);
|
||||
this.writeNode('CssParameter', {
|
||||
value: strokeWidth.getValue(),
|
||||
key: 'strokeWidth'
|
||||
}, null, node);
|
||||
// TODO strokeDashstyle and strokeLinecap
|
||||
return node;
|
||||
},
|
||||
'CssParameter': function(obj) {
|
||||
// not handling ogc:expressions for now
|
||||
var name = ol.parser.ogc.SLD_v1.getCssProperty_(obj.key);
|
||||
if (goog.isDef(name)) {
|
||||
var node = this.createElementNS('sld:CssParameter');
|
||||
node.setAttribute('name', name);
|
||||
node.appendChild(this.createTextNode(obj.value));
|
||||
return node;
|
||||
}
|
||||
},
|
||||
'Label': function(label) {
|
||||
var node = this.createElementNS('sld:Label');
|
||||
this.filter_.writeOgcExpression(label, node);
|
||||
return node;
|
||||
},
|
||||
'Font': function(symbolizer) {
|
||||
var node = this.createElementNS('sld:Font');
|
||||
this.writeNode('CssParameter', {
|
||||
key: 'fontFamily',
|
||||
value: symbolizer.getFontFamily().getValue()
|
||||
}, null, node);
|
||||
this.writeNode('CssParameter', {
|
||||
key: 'fontSize',
|
||||
value: symbolizer.getFontSize().getValue()
|
||||
}, null, node);
|
||||
// TODO fontWeight and fontStyle
|
||||
return node;
|
||||
},
|
||||
'MinScaleDenominator': function(scale) {
|
||||
var node = this.createElementNS('sld:MinScaleDenominator');
|
||||
node.appendChild(this.createTextNode(scale));
|
||||
return node;
|
||||
},
|
||||
'MaxScaleDenominator': function(scale) {
|
||||
var node = this.createElementNS('sld:MaxScaleDenominator');
|
||||
node.appendChild(this.createTextNode(scale));
|
||||
return node;
|
||||
},
|
||||
'Size': function(value) {
|
||||
var node = this.createElementNS('sld:Size');
|
||||
this.filter_.writeOgcExpression(value, node);
|
||||
return node;
|
||||
}
|
||||
};
|
||||
this.filter_ = new ol.parser.ogc.Filter_v1_0_0();
|
||||
for (var uri in this.filter_.readers) {
|
||||
for (var key in this.filter_.readers[uri]) {
|
||||
if (!goog.isDef(this.readers[uri])) {
|
||||
this.readers[uri] = {};
|
||||
}
|
||||
this.readers[uri][key] = goog.bind(this.filter_.readers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
for (var uri in this.filter_.writers) {
|
||||
for (var key in this.filter_.writers[uri]) {
|
||||
if (!goog.isDef(this.writers[uri])) {
|
||||
this.writers[uri] = {};
|
||||
}
|
||||
this.writers[uri][key] = goog.bind(this.filter_.writers[uri][key],
|
||||
this.filter_);
|
||||
}
|
||||
}
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD_v1, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.cssMap_ = {
|
||||
'stroke': 'strokeColor',
|
||||
'stroke-opacity': 'strokeOpacity',
|
||||
'stroke-width': 'strokeWidth',
|
||||
'stroke-linecap': 'strokeLinecap',
|
||||
'stroke-dasharray': 'strokeDashstyle',
|
||||
'fill': 'fillColor',
|
||||
'fill-opacity': 'fillOpacity',
|
||||
'font-family': 'fontFamily',
|
||||
'font-size': 'fontSize',
|
||||
'font-weight': 'fontWeight',
|
||||
'font-style': 'fontStyle'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.defaults_ = {
|
||||
fillOpacity: 1,
|
||||
strokeOpacity: 1,
|
||||
strokeWidth: 1,
|
||||
strokeColor: '#000000',
|
||||
haloColor: '#FFFFFF',
|
||||
haloOpacity: 1,
|
||||
haloRadius: 1,
|
||||
fillColor: '#808080',
|
||||
fontColor: '#000000'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {string} sym Symbolizer property.
|
||||
* @return {string|undefined} The css property that matches the symbolizer
|
||||
* property.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.getCssProperty_ = function(sym) {
|
||||
return goog.object.findKey(ol.parser.ogc.SLD_v1.cssMap_,
|
||||
function(value, key, obj) {
|
||||
return (sym === value);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number} scaleDenominator The scale denominator to convert to
|
||||
* resolution.
|
||||
* @return {number} resolution.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.getResolutionFromScaleDenominator_ =
|
||||
function(scaleDenominator) {
|
||||
var dpi = 25.4 / 0.28;
|
||||
var mpu = ol.METERS_PER_UNIT[this.units];
|
||||
return 1 / ((1 / scaleDenominator) * (mpu * 39.37) * dpi);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number} resolution The resolution to convert to scale denominator.
|
||||
* @return {number} scale denominator.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.getScaleDenominatorFromResolution_ =
|
||||
function(resolution) {
|
||||
var dpi = 25.4 / 0.28;
|
||||
var mpu = ol.METERS_PER_UNIT[this.units];
|
||||
return resolution * mpu * 39.37 * dpi;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document|Element} data Data to read.
|
||||
* @param {olx.parser.SLDReadOptions=} opt_options Read options.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.read = function(data, opt_options) {
|
||||
var units = 'm';
|
||||
if (goog.isDef(opt_options) && goog.isDef(opt_options.units)) {
|
||||
units = opt_options.units;
|
||||
}
|
||||
this.units = units;
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
if (data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var obj = {namedLayers: {}};
|
||||
this.readNode(data, obj);
|
||||
delete this.units;
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} style The style to write out.
|
||||
* @param {olx.parser.SLDWriteOptions=} opt_options Write options.
|
||||
* @return {string} The serialized SLD.
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1.prototype.write = function(style, opt_options) {
|
||||
var units = 'm';
|
||||
if (goog.isDef(opt_options) && goog.isDef(opt_options.units)) {
|
||||
units = opt_options.units;
|
||||
}
|
||||
this.units = units;
|
||||
var root = this.writeNode('StyledLayerDescriptor', style);
|
||||
this.setAttributeNS(
|
||||
root, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'xsi:schemaLocation', this.schemaLocation);
|
||||
var result = this.serialize(root);
|
||||
delete this.units;
|
||||
return result;
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.SLD_v1_0_0');
|
||||
|
||||
goog.require('ol.parser.ogc.SLD_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.SLD_v1}
|
||||
*/
|
||||
ol.parser.ogc.SLD_v1_0_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.0.0';
|
||||
this.schemaLocation = 'http://www.opengis.net/sld ' +
|
||||
'http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd';
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.SLD_v1_0_0,
|
||||
ol.parser.ogc.SLD_v1);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user