Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Vector work #218

Merged
merged 207 commits into from

7 participants

@tschaub
Owner

Contents:

  • ol.geom package - Includes the right types, uses shared vertex arrays.
  • ol.Feature - Record type object with a default geometry.
  • ol.filter package - Used for filtering features. Includes geometry type, extent, and logical filters. Will eventually include property filters and additional spatial filters.
  • ol.Expression - Can be evaluated in the provided scope.
  • ol.style package - Point, line, and polygon symbolizers. Accept expressions and can generate literal symbolizers for rendering. Rule incorporates a filter and an array of symbolizers. Style is a collection of rules.
  • ol.renderer.canvas.Renderer - General purpose renderer for drawing features on a canvas. Needs to handle additional geometry types, polygons with holes, etc.
  • ol.RTree - Used for indexing geometries based on bounds.
  • ol.source.Vector - A cache of features. Uses geometry type and spatial index. Will eventually be used to fetch remote features.
  • ol.layer.Vector - Represents the view of a vector source. Still needs work to accept a style.
  • ol.renderer.canvas.VectorLayer - Renders vector features for a layer and maintains an internal cache of canvas tiles. More work could be done to scale existing tiles during animated zooming (currently, tiles are only scaled half way through the transition). Also needs to use literal symbolizers generated after evaluating rules from the layer's style.
  • ol.parser.geojson - Serializes GeoJSON as ol.Feature, ol.geom.Geometry, or arrays of either.
ahocevar and others added some commits
@ahocevar ahocevar Canvas tile renderer - first cut
Untested and no styling
3c305db
@tschaub tschaub Merge branch 'master' into vector 6f929ef
@tschaub tschaub Satisfying gjslint 39af56e
@tschaub tschaub Satisfying compiler 464be78
@tschaub tschaub Bare bones geom package 997c714
@tschaub tschaub Start of style package
These literals will be used internally only - created when evaluating
non-literal symbolizers (with properties that are expressions).
7cca691
@tschaub tschaub Render geometries to a canvas 7971ec1
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector 8a38f9a
@tschaub tschaub Merge from master 74281d2
@tschaub tschaub To be reworked as ol.renderer.canvas.VectorLayer 3ac4373
@tschaub tschaub To be reworked for rendering like geoms with same symbolizer 278d320
@tschaub tschaub Point, linestring, and linearring coordinates as Float32Array fd0a5f3
@tschaub tschaub Going with point, line, and polygon symbolizers
Separate fill and stroke symbolizers make a nicer API, but less efficient rendering
b92fdaf
@tschaub tschaub General purpose canvas renderer
Currently only renders points as circles.  Eventually will have methods for other geometry types and other symbolizer types.  Also provides static methods to render point symbolizers (returning a canvas that can be drawn on another).
140e9ba
@tschaub tschaub Render lines 0414e33
@tschaub tschaub Polygon rendering (no holes yet) 497eac8
@tschaub tschaub Add geojson module in io package 4c2ad60
@ahocevar ahocevar Tiled vector source
This source has features and provides tiles with the feature
geometries rendered, using the feature symbolizers. Needs more
work because it is still very unefficient, because it renders
all feature geometries to all tiles, and uses a collection of
features, which we do not have yet.
d0d397f
@ahocevar ahocevar Basic feature implementation d3e63bc
@ahocevar ahocevar Fixing compiler errors (mostly caused by typos) e060498
@ahocevar ahocevar Cache and bucket fixes 300c104
@tschaub tschaub Lint
Caught by `build.py precommit` not `build.py lint`.
3cf3ef6
@tschaub tschaub Getting the nanometer precision we deserve with web mercator 216d30d
@tschaub tschaub Add getBounds to geometry b4d44f8
@tschaub tschaub Shorter name for ol.Feature 7ef127c
@tschaub tschaub Disallowing mixed geometry collections for now 0fad239
@tschaub tschaub Geometry type enumeration 6ef2184
@tschaub tschaub Types for rings and mixed collections 89bc69c
@tschaub tschaub Initial filter package, geometry type filtering only for now 9543ce4
@tschaub tschaub Basic vector source and layer
The vector source maintains a cache of features.  These are indexed by geometry type in anticipation of the renderer's needs.
1a63bf0
@tschaub tschaub Skeleton canvas renderer for vector layer 0f33561
@tschaub tschaub Symbolizer literals will be cached by the renderer f80f4fa
@tschaub tschaub Shorter name e413281
@tschaub tschaub Initial tests for filter 45af404
@tschaub tschaub Shape extends point 92c8c9c
@tschaub tschaub Rendering vector layers 1dd17fc
@tschaub tschaub Vector rendering example
There is a ton of room for optimization here.  The vector layer renderer should only render dirty areas and could maintain a cache of rendered canvas tiles.  The vector source could have a simple spatial index for features (by tile coord).  Need to also discuss how to work with this animation framework (to avoid the excess work while waiting for tiles to load on every other layer).
c50fcec
@ahocevar ahocevar Removing no longer needed Tiled Vector Source. 16865fc
@ahocevar ahocevar Making default symbolizers compiler safe 4e6b864
@tschaub tschaub Unused var and some notes 35f6984
@tschaub tschaub Parsing GeoJSON FeatureCollection 07a56bf
@ahocevar ahocevar Tiled vector rendering
This needs more work still - see inline TODOs. It also has a
major bug - rendered vector features do not scale and do not
change their offset during panning. So only the initial view is
correct.
4a54cc6
@tschaub tschaub Toward tiled vector rendering 9bd1ab9
@ahocevar ahocevar Better, but still not all the way there fe605ce
@ahocevar ahocevar Started on proper date line wrapping
What we want in the end is vector tiles repeated just as raster
tiles. This change only avoids repeated tiles with the same
content being rendered and stored in the cache.
b0a7bad
@tschaub tschaub Set up example for debugging 8d5a45d
@tschaub tschaub Reverting b0a7bad
I think it's complicating things at this point to deal with this.  Unfortunately, it's not proper dateline wrapping as is (only arbitrary tile range extent wrapping).
033daa4
@tschaub tschaub Adding convenient tile labels for debugging
This will be removed when behavior is right.
f2b325b
@tschaub tschaub Properly rendering features to canvas tiles
It looks like this approach will work well for panning (as anticipated).  For animated zooming, it is not going to work as is.  It looks like the canvas tile generation is too much for this type of animation loop.  Though there are clearly still areas for optimization:

 * Don't create new tiles while animating between zoom levels.  Using existing tiles only while animating should bring a significant performance gain.
 * Simple spatial index for tiles - each tile coord in the matrix could have a feature lookup object (keyed by id).  This needs to account for rendered dimension (as witnessed by the point being cut by a tile).  Given that the current example uses only three features, adding the spatial index should only be a minor improvement.
 * Reuse a fixed set of canvas tiles that are generated at construction (and increased/decreased with view size changes).
 * If a fixed set of tiles is not used, at least new ones could be cloned from existing ones (minor).
 * Do some profiling to look for more ideas.

In addition, world-wrapping needs addressed.  I don't think this renderer is the right (or at least the only) place to address this.  And the cache of tiles needs to be managed for real.  But hey, at least we've got a working tiled vector renderer now.
4e3f984
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector a773715
@ahocevar ahocevar Some optimizations
* Tiles are now cut out of the sketch renderer in a separate
  pass. This ensures that point features at tile borders appear
  at both sides of the border. However, if such features get
  added in a later tileRange rendering pass, tiles from a
  previous rendering pass will still not have that feature.
* The tile canvas is only created once, and cloneNode(false) is
  used to get a canvas for a new tile.
65b3bb7
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector 1ecbc36
@ahocevar ahocevar Manage tile cache
This change implements a LRU policy for tile cachint, and keeps
128 tiles in the cache by default.
e61c268
@ahocevar ahocevar Use objects instead of arrays for geometry type cache
Also trying to reference features directly here instead of
storing feature ids in the index. We'll see if this is good when
we have an index for tile coords as well and want to filter
with multiple filters, accessing multiple indices.
9a0f509
@ahocevar ahocevar Don't use unshift 43dd9ca
@ahocevar ahocevar New filters for extent and logical filtering
These need unit tests.
428793c
@ahocevar ahocevar New R-Tree struct for spatial indexing.
This needs unit tests.
c58f0af
@ahocevar ahocevar Using spatial index and combined filters
This should significantly speed up feature access. Needs unit
tests.
dafa48d
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector
Conflicts:
	src/ol/renderer/canvas/canvasrenderer.js
	test/ol.html
386b97c
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector
Conflicts:
	src/ol/renderer/canvas/canvasrenderer.js
	test/ol.html
089b701
@ahocevar ahocevar Adding missing and removing unused goog.requires 61e4452
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector a13e6bd
@ahocevar ahocevar More goog.requires fixes 619803c
@ahocevar ahocevar Faster extent + geometry type queries
By maintaining separate R-Trees for each geometry type, we cover
the most critical query from the canvas renderer at higher
speeds. Using the filter's own evaluate method, we can now also
serve arbitrary queries, but they won't be fast.

Still needs unit tests.
4e971b6
@tschaub tschaub Don't generate new tiles while animating 11b8c0f
@tschaub tschaub Using ol.TileCache for managing canvas tiles 5bbd8fd
ahocevar and others added some commits
@ahocevar ahocevar Fixing RTree, and using it for retrieving geometries e155f87
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector 6b43435
@tschaub tschaub Fewer, bigger tiles 2082ba7
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 59a203b
@tschaub tschaub Adding ol.Expression
This simple expression constructor will be used for symbolizer properties and the layer will generate symbolizer literals for rendering by evaluating any expressions with a feature as the this argument and feature attributes as the scope.  This allows generating labels that concatenate multiple attribute values together or displaying point symbols that are sized according to a population attribute divided by an area attribute, for example.

This implementation will not work in environments where the content security policy disallows the use of the Function constructor.  This is the case on browser extensions.  A more content-security-policy-friendly implementation would be to come up with a restricted grammar and write a lex/parser.  This is the road I started down, but this verison is far less code, and I think the security policy limitations are minor at this point.  This version will always be faster/lighter than a parser, so one is written in the future, it should only be pulled in where content security policy mandates it.
be255ed
@ahocevar ahocevar Only attempt fast lane for AND filters 8cc6575
@ahocevar ahocevar Adding ol.source.Vector unit tests 8c03abd
@ahocevar ahocevar Making the linter happy 59fe714
@ahocevar ahocevar Regrouping tests 77b8688
@ahocevar ahocevar Adding extent filter tests d2a2201
@ahocevar ahocevar Adding goog.provide and goog.requires 266111e
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector e30b095
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 8defe3a
@tschaub tschaub Use post render frame for tile pruning
We should discuss whether post render functions must be run after each render frame or not.  If these can be run after multiple render frames, it would make sense to increase the timeout.  As it is, it looks like post render functions are run for every render.  Hard to see what the benefit is in this case.
e9fb83d
@tschaub tschaub Decoupling canvas tile grid from vector source grid
If we have a gridded vector source, the grid should have something to do with the source data (e.g. the vector data is available in a regular grid).  The vector layer renderer's internal grid is for rendering canvas tiles and doesn't have anything to do with the source.
ce4b95f
@tschaub tschaub Lint and names 46e31f9
@ahocevar ahocevar Adding RTree tests f15c295
@ahocevar ahocevar Making linter happy f6c93d8
@tschaub
Owner

Thanks @ahocevar, I neglected to push one change yesterday.

tschaub and others added some commits
@tschaub tschaub Merge branch 'vector' of github.com:openlayers/ol3 into vector c756902
@tschaub tschaub Spare space 184e1e7
@tschaub tschaub Rule is filter and symbolizer, style is collection of rules 360e371
@tschaub tschaub Expression literal 1faa621
@tschaub tschaub Symbolizers with method for creating literals 7141721
@tschaub tschaub Renaming literals 438664a
@tschaub tschaub Provides for tests 083404b
@tschaub tschaub Allow instanceof checks for geometries 0015e46
@tschaub tschaub Treating geometry as just another attribute
The first set geometry is considered the default.  As an added bonus, we're back to a single argument constructor.  Later, we could allow a schema to be set.  This would be done before setting values (calling constructor with no args).
735f490
@tschaub tschaub Moving GeoJSON into parser package
Need to discuss whether we want all to require constructing a new parser.  I liked the simple `ol.io.geojson.read` function.
9cac8ec
@tschaub tschaub Example syntax d642628
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector
Resolved conflicts:
  src/ol/renderer/canvas/canvasrenderer.js
176f18c
@tschaub tschaub Removing the typed arrays
Its not clear that we will be able to leverage the Float64Array.  It may also be that the overhead of constructing these small arrays negates any benefit of faster access.  And for all coordinate arrays, we'll need arrays that grow/shrink.
8f578b8
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 0f2f269
@tschaub tschaub Proper getAttributes method
With a59aa9b we can now provide an object with user set attributes.
7ce89f1
@tschaub tschaub Confirm that arbitrary attribute names can be used e23ca16
@ahocevar ahocevar Renaming the 'evaluate' method to 'applies' da78201
@ahocevar ahocevar Symbolizer and SymbolizerLiteral as base class, not interface fcd5804
@ahocevar ahocevar Giving vector layers the style they deserve
Now vector layers can have a style. ol.Style instances have an
apply method to get the symbolizer literals for a feature. If the
layer does not have a style defined, there is also a static
applyDefaultStyle function on ol.Style to get the default
symbolizer literals for a feature. The vector layer also got a
groupFeaturesBySymbolizerLiteral method, which returns an array
with features grouped by symbolizer, as needed by the canvas
renderer.
f4a4522
@ahocevar ahocevar Fixing return type to make Closure compiler happy bdfa2cc
@tschaub tschaub Allow geometries to use a shared vertex array
The ol.geom.SharedVertices structure represents a flattened array of vertex coordinates.  This is intended to support optimal WebGL rendering.
b52d283
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 93ab454
@tschaub tschaub Parser base class
GeoJSON is now a parser.  The idea is that we'll want to pass parsers to sources or protocols and want a known type.
69b6fae
@tschaub tschaub Helper functions for running tests after xhr 5d917eb
@ahocevar ahocevar ol.Filter is now a (base) class, not an interface any more
ol.Filter can now also be used to provide a simple filter that
just evaluates a user provided filter function against a
feature.
9d1f737
@ahocevar ahocevar Return an empty array for features without geometry
This ensures that the static applyDefaultStyle() method works
exactly the same way as the instance's apply() method.
db52ff9
@ahocevar ahocevar Use the actual value, not just the index in the array. 63c048e
@ahocevar ahocevar Adding unit tests for rule based styling 5535a26
@tschaub tschaub Removing abstract methods for now
Later we'll discuss having more specific FeatureParser and readFeatures type methods.
4af3256
@tschaub tschaub Test reading with shared vertices b247031
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 5a73529
@tschaub tschaub Work with new ol.projection package d3c4869
@ahocevar ahocevar Adding example for rule based styling
For the first time in the history of OpenLayers, we can render
features with multiple symbolizers now, which is also shown in
this new example.
d4ecf53
@tschaub tschaub Lint free externs 022917e
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector 44ca6c9
@ahocevar ahocevar Features can now have symbolizers
If specified, feature symbolizers take precedence over rule
based styling.
f112028
src/ol/geom/geometry.js
((16 lines not shown))
+ * @protected
+ */
+ this.vertices = null;
+
+};
+
+
+/**
+ * The dimension of this geometry (2 or 3).
+ * @type {number}
+ */
+ol.geom.Geometry.prototype.dimension;
+
+
+/**
+ * Get the rectangular 2D evelope for this geoemtry.
@fredj Owner
fredj added a note

s/evelope/envelope/g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tschaub and others added some commits
@tschaub tschaub Add externs for GeoJSON support 0558cfa
@tschaub tschaub Vector source isn't a tile source 0b05432
@tschaub tschaub Fewer function calls during bounds calculation fae79db
@tschaub tschaub Accept missing properties in symbolizer constructors
Still need to have some discussion about when to apply defaults.
978527f
@tschaub tschaub Proper bounds 9edf63f
@tschaub tschaub Feature parser interfaces
Parsers that read features from strings, objects, or dom elements should implement the right interface.  Among the read options is a callback that gets called after feature construction and before geometry construction.  This callback is called with the feature and the geometry type and returns a shared vertices structure.  The geometry is then constructed with this shared vertices structure before being added to the feature.
9c8ec42
@tschaub tschaub GeoJSON parser implements StringFeatureParser 8c8ddce
@tschaub tschaub Correct spelling (thanks @fredj) cae925a
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector c29fabe
@tschaub tschaub Get tile size for zoom level (see #258) dc19948
@tschaub tschaub Lint-free tests 1d6cd1b
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 54d8d45
@tschaub tschaub The shared vertices structure now works with integer arrays only
Previously, a lookup object containing start indexes was also used.  This allowed us to remove arrays of vertices and properly update the start indexes for remaining coordinate values.  In order to provide callers with stable identifiers and to work with arrays of integers alone, we cannot support a remove method.  I think this is worth revisiting.  Even if the array length cannot be changed in WebGL, we don't need to also impose the restriction outside.  Instead, the WebGL renderer could be notified when array sizes change and update itself accordingly.  I think there is more value in providing geometries with stable identifiers.

This common structure is used to store vertices for all geometry types.  A slight optimization could be made by creating yet another structure to store point vertices - since these don't need to have a counts array (always 1).  Creating a new structure would mean saving memory at the expense of more lib code to transport.  The coordinate value lookups are not negatively impacted by using the same structure for points and higher order geometries.  Since the first change above goes against my instincts, I'm not making this second change (to add another structure for shared point vertices).
a968a5c
@tschaub tschaub Moving the feature management to the layer
The source will be responsible for fetching vector data.
12bee31
Bart van den Eijnden Merge branch 'master' of github.com:openlayers/ol3 into vector aa4c4dd
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector d8b6d17
@tschaub tschaub Vector related exports e1c3faa
@tschaub tschaub Moving the feature management to the layer
The source will be responsible for fetching vector data.
9a0e7a9
@tschaub tschaub Vector related exports 4f2523f
@ahocevar ahocevar Rendering icons from external graphic urls ab19d25
@elemoine elemoine zoomFactor defaults to 2 29d3878
@elemoine elemoine View2D zoom may animate pan be5967a
@elemoine elemoine MouseWheelZoom interaction animates zoom 673ea07
@elemoine elemoine Debounce mousewheel zoom events ca31cf5
@elemoine elemoine Change View2D function names
Also make the TouchZoom interaction no longer use a private View2D function.
2c551b0
@elemoine elemoine Add a rotateNoConstraint View2D method 303520a
@elemoine elemoine Make TouchRotate interaction use rotateNoConstraint cae2340
@twpayne twpayne Correct Stamen source 78780fa
@twpayne twpayne Add Stamen example 8322591
@elemoine elemoine Add a snapToZero rotation constraint f20cf83
@elemoine elemoine Do not apply rotation constraint while rotating
This is on par to what the TouchRotate interaction does.
de8db17
@elemoine elemoine Make animating rotation possible 33eb13d
@elemoine elemoine Animate rotation when releasing mouse or fingers b9a286f
@elemoine elemoine 2DView refactoring
This refactoring makes animating zoom, as opposed to zoomByDelta, possible.
a4c47ed
@elemoine elemoine Animate zoom after pinch 066a81a
@ahocevar ahocevar Do not use tiledWMSOptions in closure function
See #269.
a912d48
@elemoine elemoine Animate double click/tap zoom 5644c27
@ahocevar ahocevar WMS GetMap request parameters shall be params
To avoid surprises, we configure everything that is a WMS GetMap
request parameter in the params object, and not as direct
configuration option. This affects the VERSION and TRANSPARENT
params.
c1f3a6c
@ahocevar ahocevar Moving VERSION into params 2ee19f6
@bbinet bbinet Add defaultNamespaceURI and errorProperty properties for WMTS.
Thanks @bartvde.
382022b
@elemoine elemoine Make hostexamples target more robust 221c807
@elemoine elemoine Check the examples against whitespace build first
This is to produce stack traces that are easier to understand when an example fails to load.
a0ba80b
@twpayne twpayne Improve comment parsing when checking for requires ba78812
@elemoine elemoine View2D NoConstraint methods renamed 5d99ead
@ahocevar ahocevar No projection configuration needed on the layer 95f3fe5
@tschaub tschaub Allow literal from symbolizer without feature c0c8faa
@tschaub tschaub Enforce that either stroke or fill is provided ac10bb6
@tschaub tschaub Merge branch 'vector' of github.com:openlayers/ol3 into vector
Conflicts:
	src/ol/style/shape.js
060edb2
@ahocevar ahocevar Merge branch 'master' of github.com:openlayers/ol3 into vector 6ee754a
@ahocevar ahocevar Respect width and height from symbolizer 345bb55
@ahocevar ahocevar Adding exports for icon and feature 2147674
@ahocevar ahocevar Adding missing export 2af82ab
@ahocevar ahocevar Adding gutter when requesting features for a tile
By doing so, we avoid features being cut off when the symbolizer
causes it to be rendered across tile borders.
100c8a1
@tschaub tschaub Draw multi-part geometries
Polygons still need holes.
7c4c3c5
@tschaub tschaub Method for parsing features
Shared structures are still per geometry type.  Need to be made per symbolizer type.
d7c547f
@tschaub tschaub Listen for layer changes and expire tiles
We need a more flexible event system.  We could have a VectorLayerEvent type and dispatch 'featuresadded' here.  But listeners want features typically and perhaps extent.  This won't be true for all vector layer events (suggesting a more specific VectorFeatureEvent type or something).
00fa7ff
@tschaub tschaub Render multi-part geometries
As noted in the comment, filtering/rendering once per geometry type will be replaced by rendering once per symbolizer type.
2e4dc43
@tschaub tschaub Disable bbox filtering for now
The RTree doesn't appear to be performing properly
84527c4
@tschaub tschaub Render countries from GeoJSON
This reveals a number of issues that still need to be addressed.
f961930
@ahocevar ahocevar Additional index dimension for RTree; use RTree again
The RTree can easily maintain an additional index dimension,
by passing a type with each added item. Now instead of
maintaining an RTree for each geometry type, we have a single
RTree with a type filter. With this change, using the RTree
finally speeds up rendering as expected.
f0039ee
@ahocevar ahocevar Collect features before rendering to the sketch canvas
This avoids features being rendered multiple times when they
cross tile borders. Currently this makes the style-rules.html
example extremely slow. Fix for that to come in my next commit.
f4a16e7
@tschaub tschaub Adding addFeatures back as an API method temporarily
Eventually, parseFeatures and addFeatures should be collapsed.
5752a69
@ahocevar ahocevar No need to continue rendering when we need to defer 5af71a4
@tschaub tschaub Export GeoJSON parser b28a1ef
@tschaub tschaub Nicer caps and joins
As mentioned in the TODOs, caps and joins should be user configurable on the symbolizers.
db4e624
@tschaub tschaub Avoid filling/stroking parts of multi-polygons twice f93bf2a
@tschaub tschaub Optional polygon stroke or fill 77355ca
@tschaub tschaub Style in example 5ce114c
@tschaub tschaub Use fillColor and strokeColor instead of fillStyle and strokeStyle
The color names are more intuitive.  And if we want to support pattern strokes or fills, we'll need additional proerties to represent other pattern properties.
faee18b
@tschaub tschaub Make shared vertices structures accessible 4918106
@tschaub tschaub Merge branch 'master' of github.com:openlayers/ol3 into vector 4422e3e
@tschaub tschaub Removing the style rules example for now
The addFeatures method on layer is going to go away temporarily (so all feature adding will take advantage of shared vertices structures).  Later we can accept feature arrays in parseFeatures and rename the method back to addFeatures.
85a1599
@tschaub tschaub The addFeatures method will be added back later
This needs to be made to take advantage of the shared vertices.
895bc4e
@tschaub tschaub Use new projection getter ee75c4b
@tschaub tschaub New example style 7f62b26
@tschaub
Owner

This is in a good state, and we'd appreciate if it could be reviewed for merging into master.

Remaining issues:

  • After panning/zooming, sometimes tiles are not displayed (#325 - not a major architecture issue, likely a bug in the canvas vector layer renderer that will soon reveal itself)

  • Shared vertices accept an offset (as requested) but this breaks the array transforms. Currently, offsets are not used, so there is not a problem, but we need to discuss the implications for coordinate transforms before they can be used (#326).

  • There is one shared vertices structure per major geometry type (point, line, polygon). We discussed having one shared structure per symbolizer type (shape, icon, line, polygon). The shape/icon distinction has not yet been made. But I believe that this should not block the work it will take to start implementing point, line, and polygon rendering in the WebGL renderer. After some work is done on the WebGL side, we should discuss if the shape/icon distinction is needed (or if the WebGL renderer will delegate to the Canvas renderer for both of these).

@tmcw

Is there a performance or features difference between this RTree impl and the imbcmdth/RTree library, which is used in Kothic & iD?

ahocevar added some commits
@ahocevar ahocevar Support GeoJSON as parsed object
With this change, we can programmatically create
GeoJSONFeatureCollection objects programmatically, without
reading a GeoJSON file.
389b8d1
@ahocevar ahocevar Bringing back the style-rules example
Features are now created programmatically as
GeoJSONFeatureCollection.
b971fc1
@ahocevar
Owner

@tmcw There is a features and size difference. Our RTree implementation adds another indexing dimension (look at the types property on the RTreeNode), so we have an efficient index by extent AND geometry type. In addition to this, our RTree is small in size because it uses ol3 data types for bounding boxes, so functionality like extent intersections does not have to be part of the RTree implementation.

@tmcw

@ahocevar Could it be usable as a standalone module for other projects?

@ahocevar
Owner

@tmcw It definitely can be used as a standalone module. It has only ol3 dependencies that the Closure Compiler can easily bake in. An API wrapper for the put and find methods on ol.RTree could be created to accept a plain array instead of an ol.Rectangle for the bounding box as argument, or you just also include ol.Rectangle in the build and use it.

@twpayne

This is in a good state, and we'd appreciate if it could be reviewed for merging into master.

Sure! I propose to spend Monday reviewing this (the PR is a little too big to review during my weekend!) but it's all shaping up very nicely.

@tschaub
Owner

You'll notice that evaluating features and generating symbolizer liberals at parsing time is not yet handled. But the callback is there. I ran out of time before leaving, but will create a separate pull request when I return (assuming this is merged first).

examples/style-rules.js
((111 lines not shown))
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#013',
+ 'where': 'outer'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[10000000, -10000000], [-10000000, -10000000]]
+ }
+ }]
+}, new ol.parser.GeoJSON(), ol.projection.get('EPSG:3857'));
+
+
+var map = new ol.Map({
+ layers: new ol.Collection([vector]),
@twpayne
twpayne added a note

Note that since #274 you don't need to create an ol.Collection explicitly.

@ahocevar Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@twpayne twpayne commented on the diff
examples/vector-layer.js
((38 lines not shown))
+ ]})
+});
+
+var geojson = new ol.parser.GeoJSON();
+var url = '../test/spec/ol/parser/geojson/countries.json';
+var xhr = new XMLHttpRequest();
+xhr.open('GET', url, true);
+
+
+/**
+ * onload handler for the XHR request.
+ */
+xhr.onload = function() {
+ if (xhr.status == 200) {
+ // this is silly to have to tell the layer the destination projection
+ var projection = map.getView().getProjection();
@twpayne
twpayne added a note

map is used before it is defined here.

@ahocevar Owner
@ahocevar Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@twpayne

With the style-rules example, the 0xBADA55 color lines disappear when I zoom in 18 times:
zoom-17
zoom-18

src/ol/structs/rtree.js
((3 lines not shown))
+goog.require('ol.Rectangle');
+
+
+
+/**
+ * @private
+ * @constructor
+ * @param {number} minX Minimum X.
+ * @param {number} minY Minimum Y.
+ * @param {number} maxX Maximum X.
+ * @param {number} maxY Maximum Y.
+ * @param {ol.RTreeNode_} parent Parent node.
+ * @param {number} level Level in the tree hierarchy.
+ * @extends {ol.Rectangle}
+ */
+ol.RTreeNode_ = function(minX, minY, maxX, maxY, parent, level) {
@twpayne
twpayne added a note

Should this class be renamed to ol.structs.RTreeNode_?

@ahocevar Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@twpayne
  • On my browser (Chrome on Mac OS X), the vector layers disappear while zooming. Presumably this is #325 ?

  • Is it possible to expose the vector data as a ol.source.TileSource so that the usual tile layer renderers can be used? This could avoid code duplication, and ensure that the vector tile layer render benefits from the bug fixes and optimizations in the canvas tile layer renderer.

  • This PR adds a lot of vector-specific code to src/ol/renderer/canvas/canvasrenderer.js. Should this not be in a separate module?

  • Thinking ahead to WebGL support, it will be impossible to use dynamically created arbitrary JavaScript functions on the GPU. Would it be possible to separate the style calculation phase (using Symbolizers) from the actual statically styled geometries? I think this can be done without loss of functionality.

@ahocevar
Owner
@ahocevar
Owner
@twpayne
Is it possible to expose the vector data as a ol.source.TileSource so
that the usual tile layer renderers can be used? This could avoid code
duplication, and ensure that the vector tile layer render benefits from the bug
fixes <https://github.com/openlayers/ol3/pull/324> and optimizations<https://github.com/openlayers/ol3/issues/263>in the canvas tile layer renderer.

We have thought about doing this. Yes, it should be possible. Ok if we
revisit this after merging?

Sure.

This PR adds a lot of vector-specific code to
src/ol/renderer/canvas/canvasrenderer.js. Should this not be in a
separate module?

It provides all the basic canvas rendering functionality. Not related to
vector layers or sources. But it could easily be shuffled to live somewhere
else if you prefer. What package/name would you suggest?

Um, I don't have any good ideas, but it should have vector in the name somewhere :)

@twpayne

With the style-rules example, the 0xBADA55 color lines disappear when I
zoom in 18 times
Hm. Does not happen for me. Maybe related to #325?

Something strange is certainly happening.

On Chrome: when zooming in (using the zoom button) the everything is OK for the first 17 levels, then at level 18 the black lines disappear, then at level 19 everything disappears.

On Firefox: when zooming in, everything is OK for the first 17 levels, then the black lines disappear, then as I zoom in further the green lines get thicker and thicker.

On Safari: behaviour is correct, feature is rendered correctly at all zoom levels (up to maximum (42?)).

@ahocevar
Owner
@ahocevar
Owner
@ahocevar
Owner

All comments have been addressed and remaining issues ticketed.

@twpayne

OK. As agreed, we've got some work to do to make it compatible with an eventual WebGL vector layer renderer, but we can do this together in master.

@ahocevar ahocevar merged commit 76d1a0c into master
@ahocevar ahocevar deleted the vector branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.