Skip to content

Commit

Permalink
Fix incorrect access call to getStyleFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
gberaudo committed Nov 18, 2015
1 parent 8a5eb39 commit be069a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 22 additions & 7 deletions src/featureconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,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 @@ -915,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 @@ -924,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 @@ -964,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
4 changes: 2 additions & 2 deletions src/vectorsynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,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 be069a5

Please sign in to comment.