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

Adjust vector layers visibility #1237

Open
mattiatibu opened this issue Oct 10, 2024 · 0 comments
Open

Adjust vector layers visibility #1237

mattiatibu opened this issue Oct 10, 2024 · 0 comments

Comments

@mattiatibu
Copy link

mattiatibu commented Oct 10, 2024

Hi, I'm using your library for a project at work, I'm using ol-cesium 2.20 and angular 18 in a custom angular library.

For a task I need to adjust the visibility of some vector layer points in 3d view to hide them if they are positioned behind a building, is that possobile in ol-cesium? with Cesium is possible to use the property "disableDepthTestDistance: Number.POSITIVE_INFINITY" when creating a marker or a pointGrapthic entity, I'm using clamp to ground for the vector layer but I can't use "scene.testDepthAgainstTerrain=true" because it messes with the rendering of google 3d building tileset that i'm using.

If it isn't possible can I take each drawn primitive (> 10000 points) and change its properties for my needs or use another method to solve this problem?

`
//this is how i create the vector layer
createEmptyVector(layer: Layer2dList) {

const vectorSource = new VectorSource({
  format: new GeoJSON({
    dataProjection: layer.crs,
    featureProjection: 'EPSG:3857',
  }),
  wrapX: false,
  strategy: bboxStrategy,
  overlaps: false,
});

const vectorLayer = new VectorLayer({
  source: vectorSource,
  style: (layer.styles as any)[0].rules
});

this.setAttributesToOlLayer(layer, vectorLayer);
vectorLayer.set('altitudeMode', 'clampToGround');
return vectorLayer;

}
`

`//this is how i add the features because the vector layer didn't update properly when using ol-cesium in stack mode
//so i'.ve used a WMS in 2d and a vector in 3d to show thousends points
sync3dLayers(map3d: OLCesium, map2d: Map) {
if (!!map3d) {
map3d.getCesiumScene().camera.moveEnd.addEventListener(() => {

    let bbox = this.getBoundingBoxFromCamera(map3d)
    let polygon = this.featureService.bboxToPolygon(bbox!)
    const mapLayers = map2d.getAllLayers()
    this.layers3dVector.forEach((l) => {
      let vectorLayer = mapLayers.find((lay) => lay.get('id') === l.uuid)!
      let originalLayer = mapLayers.find((lay) => lay.get('id') === l.associated_layer)!
      if (originalLayer.getSource() instanceof TileWMS) {

        let source = vectorLayer.getSource()! as Vector
        this.featureService.getFeatureFromWMSLayerByMultiPolygon(originalLayer, new MultiPolygon([polygon])).subscribe(
          features => {

            let existing = source.getFeatures() as Feature<Geometry>[]
            let filtered: Feature<Geometry>[] = features.filter((f) => !existing.some((e) => e.get('id') === f.get('id')));
            filtered = filtered.map((feature) => {
              const geometry = feature.getGeometry();
              if (geometry) {
                geometry.transform(
                  'EPSG:4326', 'EPSG:3857'
                );
              }
              return feature;
            })
            source.addFeatures(filtered)

          
          }
        )
      }
    })

  })
}


//this is how i add the google tileset to the map:
addTileset(tileset: Cesium3DTileset, map3d: OLCesium) {
const scene = map3d.getCesiumScene()
scene.primitives.add(
tileset
);
}`

Thank you in advance for your help and thank you for your awesome library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant