Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(olcs): Support skipping vector synchronization and update script target to match contributing doc. #1248

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ browse http://localhost:1234
The examples use a compiled version of OLCesium. If you want to use the source code directly you can define an alias.
See https://en.parceljs.org/module_resolution.html#aliases

### The `check` target
### The `checks` target

```bash
npm run check
npm run checks
```

Run this before every commit. It will catch many problems quickly.
Expand Down
9 changes: 9 additions & 0 deletions src/olcs/FeatureConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,10 @@ export default class FeatureConverter {
if (!feature) {
continue;
}
const skip = feature.get('olcs_skip');
if (skip) {
continue;
}
const layerStyle: StyleFunction | undefined = olLayer.getStyleFunction();
const styles = this.computePlainStyle(olLayer, feature, layerStyle,
resolution);
Expand Down Expand Up @@ -1203,6 +1207,11 @@ export default class FeatureConverter {
* @api
*/
convert(layer: VectorLayer<BackwardCompatibleFeature>, view: View, feature: Feature, context: OlFeatureToCesiumContext): PrimitiveCollection {
const skip = feature.get('olcs_skip');
if (skip) {
return null;
}

const proj = view.getProjection();
const resolution = view.getResolution();

Expand Down
13 changes: 13 additions & 0 deletions src/olcs/VectorSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export default class VectorSynchronizer extends olcsAbstractSynchronizer<VectorL
}

console.assert(source instanceof olSourceVector);

const skip = source.get('olcs_skip');
if (skip) {
return null;
}
console.assert(this.view);

const view = this.view;
Expand All @@ -121,6 +126,10 @@ export default class VectorSynchronizer extends olcsAbstractSynchronizer<VectorL
};

const onRemoveFeature = (feature: Feature) => {
const skip = feature.get('olcs_skip');
if (skip) {
return;
}
const id = getUid(feature);
const context: OlFeatureToCesiumContext = counterpart.context;
const bbs = context.featureToCesiumMap[id];
Expand Down Expand Up @@ -152,6 +161,10 @@ export default class VectorSynchronizer extends olcsAbstractSynchronizer<VectorL
olListenKeys.push(source.on('changefeature', (e: VectorSourceEvent) => {
const feature = e.feature;
console.assert(feature);
const skip = feature.get('olcs_skip');
if (skip) {
return;
}
onRemoveFeature(feature);
onAddFeature(feature);
}));
Expand Down