Skip to content

Commit

Permalink
Merge pull request #288 from gberaudo/several_fixes
Browse files Browse the repository at this point in the history
Several small fixes
  • Loading branch information
gberaudo committed Nov 18, 2015
2 parents c68901a + be069a5 commit 19be567
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 16 deletions.
4 changes: 3 additions & 1 deletion build/ol3cesium.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"api", "observable"
],
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"language_in": "ECMASCRIPT5_STRICT",
"language_out": "ECMASCRIPT5_STRICT",
"warning_level": "VERBOSE",
"output_wrapper": "(function(){%output%})();",
"output_wrapper": "(function(){%output%}).call(window);",
"use_types_for_optimization": true,
"create_source_map": "dist/ol3cesium.js.map",
"source_map_format": "V3"
Expand Down
2 changes: 1 addition & 1 deletion examples/vectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div><input type="button" value="Add/remove one feature"
onclick="javascript:addOrRemoveOneFeature()" /></div>
<div><input type="button" value="Toggle clampToGround mode"
onclick="javascript:toggleClampToGround()" /></div>
onclick="javascript:toggleClampToGround(); ol3d.getAutoRenderLoop().restartRenderLoop()" /></div>
<div>Vectors are synchronized from the ol3 map to the Cesium scene.
<br/>3D positioning and some styling is supported.<br />The render loop is automatically stopped when idle.</div>
<script src="../ol3/build/ol.js"></script>
Expand Down
9 changes: 5 additions & 4 deletions src/abstractsynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ goog.require('ol.layer.Group');
* @param {!Cesium.Scene} scene
* @constructor
* @template T
* @struct
* @api
*/
olcs.AbstractSynchronizer = function(map, scene) {
Expand Down Expand Up @@ -247,12 +248,12 @@ olcs.AbstractSynchronizer.prototype.listenForGroupChanges_ = function(group) {
*/
olcs.AbstractSynchronizer.prototype.destroyAll = function() {
this.removeAllCesiumObjects(true); // destroy
goog.object.forEach(this.olGroupListenKeys, function(keys) {
goog.object.forEach(this.olGroupListenKeys_, function(keys) {
keys.forEach(ol.Observable.unByKey);
});
goog.object.forEach(this.olLayerListenKeys, ol.Observable.unByKey);
this.olGroupListenKeys = {};
this.olLayerListenKeys = {};
goog.object.forEach(this.olLayerListenKeys_, ol.Observable.unByKey);
this.olGroupListenKeys_ = {};
this.olLayerListenKeys_ = {};
this.layerMap = {};
};

Expand Down
3 changes: 2 additions & 1 deletion src/autorenderloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ goog.provide('olcs.AutoRenderLoop');
* @constructor
* @param {olcs.OLCesium} ol3d
* @param {boolean} debug
* @struct
*/
olcs.AutoRenderLoop = function(ol3d, debug) {
this.ol3d = ol3d;
Expand Down Expand Up @@ -245,7 +246,7 @@ olcs.AutoRenderLoop.prototype.notifyRepaintRequired = function() {
if (this.verboseRendering && this.stoppedRendering) {
console.log('starting rendering @ ' + Date.now());
}
this._lastCameraMoveTime = Date.now();
this.lastCameraMoveTime_ = Date.now();
// TODO: do not unblock if not blocked by us
this.ol3d.setBlockCesiumRendering(false);
this.stoppedRendering = false;
Expand Down
1 change: 1 addition & 0 deletions src/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ goog.require('olcs.core');
* @param {!ol.Map} map
* @constructor
* @api
* @struct
*/
olcs.Camera = function(scene, map) {
/**
Expand Down
1 change: 1 addition & 0 deletions src/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ olcs.DragBoxEventType = {
* @extends {goog.events.EventTarget}
* @param {Object=} opt_options Options.
* @api
* @struct
*/
olcs.DragBox = function(opt_options) {

Expand Down
30 changes: 23 additions & 7 deletions src/featureconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ goog.require('olcs.core.VectorLayerCounterpart');
* @param {!Cesium.Scene} scene Cesium scene.
* @constructor
* @api
* @struct
*/
olcs.FeatureConverter = function(scene) {

Expand Down Expand Up @@ -900,11 +901,6 @@ olcs.FeatureConverter.prototype.olFeatureToCesium =
*/
olcs.FeatureConverter.prototype.olVectorLayerToCesium =
function(olLayer, olView, featurePrimitiveMap) {
var source = olLayer.getSource();
if (source instanceof ol.source.ImageVector) {
source = source.getSource();
}
var features = source.getFeatures();
var proj = olView.getProjection();
var resolution = olView.getResolution();

Expand All @@ -914,6 +910,19 @@ olcs.FeatureConverter.prototype.olVectorLayerToCesium =
// are defined
throw new Error('View not ready');
}

var source = olLayer.getSource();
if (olLayer instanceof ol.layer.Image) {
if (source instanceof ol.source.ImageVector) {
source = source.getSource();
} else {
// Not supported
return new olcs.core.VectorLayerCounterpart(proj, this.scene);
}
}

goog.asserts.assertInstanceof(source, ol.source.Vector);
var features = source.getFeatures();
var counterpart = new olcs.core.VectorLayerCounterpart(proj, this.scene);
var context = counterpart.context;
for (var i = 0; i < features.length; ++i) {
Expand All @@ -923,7 +932,9 @@ olcs.FeatureConverter.prototype.olVectorLayerToCesium =
}
var layerStyle;
if (olLayer instanceof ol.layer.Image) {
layerStyle = olLayer.getSource().getStyleFunction();
var imageSource = olLayer.getSource();
goog.asserts.assertInstanceof(imageSource, ol.source.ImageVector);
layerStyle = imageSource.getStyleFunction();
} else {
layerStyle = olLayer.getStyleFunction();
}
Expand Down Expand Up @@ -963,7 +974,12 @@ olcs.FeatureConverter.prototype.convert =

var layerStyle;
if (layer instanceof ol.layer.Image) {
layerStyle = layer.getSource().getStyleFunction();
var imageSource = layer.getSource();
if (imageSource instanceof ol.source.ImageVector) {
layerStyle = imageSource.getStyleFunction();
} else {
return null;
}
} else {
layerStyle = layer.getStyleFunction();
}
Expand Down
1 change: 1 addition & 0 deletions src/ol3cesium.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ goog.require('olcs.VectorSynchronizer');
* @param {!olcsx.OLCesiumOptions} options Options.
* @constructor
* @api
* @struct
*/
olcs.OLCesium = function(options) {

Expand Down
1 change: 1 addition & 0 deletions src/rastersynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ goog.require('olcs.core');
* @constructor
* @extends {olcs.AbstractSynchronizer.<Cesium.ImageryLayer>}
* @api
* @struct
*/
olcs.RasterSynchronizer = function(map, scene) {
/**
Expand Down
5 changes: 3 additions & 2 deletions src/vectorsynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ goog.require('olcs.core.VectorLayerCounterpart');
* @constructor
* @extends {olcs.AbstractSynchronizer.<olcs.core.VectorLayerCounterpart>}
* @api
* @struct
*/
olcs.VectorSynchronizer = function(map, scene, opt_converter) {

Expand Down Expand Up @@ -94,8 +95,8 @@ olcs.VectorSynchronizer.prototype.createSingleLayerCounterparts =
goog.asserts.assertInstanceof(olLayer, ol.layer.Layer);

var source = olLayer.getSource();
if (olLayer.getSource() instanceof ol.source.ImageVector) {
source = olLayer.getSource().getSource();
if (source instanceof ol.source.ImageVector) {
source = source.getSource();
}

goog.asserts.assertInstanceof(source, ol.source.Vector);
Expand Down

0 comments on commit 19be567

Please sign in to comment.