Skip to content

Commit

Permalink
Merge pull request #150 from ndsev/merged-features
Browse files Browse the repository at this point in the history
Merged Point Features + Hover Highlight Styles
  • Loading branch information
Waguramu authored Sep 10, 2024
2 parents 710fbeb + 0ff9530 commit 746a1ac
Show file tree
Hide file tree
Showing 43 changed files with 1,443 additions and 601 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: build-release

on:
push:
branches:
- 'feature/renderer-wasm-demo'
pull_request:
workflow_dispatch:

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build-test

on:
push:
pull_request:
workflow_dispatch:

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install build dependencies
run: sudo apt-get install ninja-build

- name: Compile
run: |
mkdir build-test && cd build-test
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
- name: Run Tests
run: |
cd build-test/test
ctest --verbose --no-tests=error
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ FetchContent_MakeAvailable(yaml-cpp)
include(cmake/cesium.cmake)

# Erdblick Core Library

add_subdirectory(libs/core)

if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
add_subdirectory(test)
else()
# Angular Build
add_custom_target(erdblick-ui ALL
COMMAND bash "${CMAKE_SOURCE_DIR}/build-ui.bash" "${CMAKE_SOURCE_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS erdblick-core)
endif()

# Angular Build

add_custom_target(erdblick-ui ALL
COMMAND bash "${CMAKE_SOURCE_DIR}/build-ui.bash" "${CMAKE_SOURCE_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS erdblick-core
)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Each rule within the YAML `rules` array can have the following fields:
|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|--------------------------------------|
| `geometry` | List of geometry type(s) or single type the rule applies to. | At least one of `"point"`,`"mesh"`, `"line"`, `"polygon"`. | `["point", "mesh"]`, `line` |
| `aspect` | Specifies the aspect to which the rule applies: `"feature"`, `"relation"`, or `"attribute"`. | String | `"feature"`, `"relation"` |
| `mode` | Specifies the mode: `"normal"` or `"highlight"`. | String | `"normal"`, `"highlight"` |
| `mode` | Specifies the highlight mode: `"none"` or `"hover"` or `"selection"`. | String | `"none"`, `"hover"` |
| `type` | A regular expression to match against a feature type. | String | `"Lane\|Boundary"` |
| `filter` | A [simfil](https://github.com/klebert-engineering/simfil) filter expression over the feature's JSON representation. | String | `*roadClass == 4` |
| `selectable` | Indicates if the feature is selectable. | Boolean | `true`, `false` |
Expand All @@ -80,6 +80,7 @@ Each rule within the YAML `rules` array can have the following fields:
| `flat` | Clamps the feature to the ground (Does not work for meshes). | Boolean | `true`, `false` |
| `outline-color` | Point outline color. | String | `green`, `#fff` |
| `outline-width` | Point outline width in px. | Float | `3.6` |
| `point-merge-grid-cell` | WGS84/altutide meter tolerance for merging point visualizations. | Array of three Floats. | `[0.000000084, 0.000000084, 0.01]` |
| `near-far-scale` | For points, indicate (`near-alt-meters`, `near-scale`, `far-alt-meters`, `far-scale`). | Array of four Floats. | `[1.5e2,10,8.0e6,0]` |
| `offset` | Apply a fixed offset to each shape-point in meters. Can be used for z-ordering. | Array of three Floats. | `[0, 0, 5]` |
| `arrow` | For arrow-heads: One of `none`, `forward`, `backward`, `double`. Not compatible with `dashed`. | String | `single` |
Expand Down Expand Up @@ -230,6 +231,17 @@ For attributes, style expressions (e.g. `color-expression`) are evaluated in a c
set the `offset` field. The spatial `offset` will be multiplied, so it is possible to "stack" attributes
over a feature.

### About Merged Point Visualizations

By setting `point-merge-grid-cell`, a tolerance may be defined which allows merging the visual representations
of point features which share the same 3D spatial cell, map, layer, and style rule. This has two advantages:

* **Multi-Selection**: When selecting the merged representation, a multi-selection of all merged features happens.
* **Logical Evaluation using `$mergeCount`**: In some map formats, it may be desirable to apply a style based on the number of merged points.
This may be done to display a warning, or to check a matching requirement.
To this end, the `$mergeCount` variable is injected into each simfil evaluation context of a merged-point style rule.
Check out the default style for an example.

### About `first-of`

Normally, all style rules from a style sheet are naively applied to all matching features.
Expand Down
14 changes: 11 additions & 3 deletions cmake/cesium.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ set(CESIUM_LIBS
CesiumGltf
CesiumGltfWriter)

# Use fetch content for cloning the repository durring
# Use fetch content for cloning the repository during
# configure phase. We do not call `FetchContent_MakeAvailable`,
# but instead use `ExternalProject_Add` to compile Cesium in
# isolation.
FetchContent_Declare(cesiumnative_src
GIT_REPOSITORY "https://github.com/Klebert-Engineering/cesium-native.git"
GIT_TAG "main"
GIT_SUBMODULES_RECURSE YES
GIT_PROGRESS YES)
GIT_PROGRESS YES
PATCH_COMMAND git reset --hard HEAD && git -C extern/draco reset --hard HEAD && git apply "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cesium.patch"
UPDATE_DISCONNECTED YES
UPDATE_COMMAND "")

FetchContent_GetProperties(cesiumnative_src)
if (NOT cesiumnative_src_POPULATED)
Expand All @@ -49,6 +52,11 @@ foreach (lib ${CESIUM_LIBS})
endforeach()
message(STATUS "cesium byproducts: ${CESIUM_BYPRODUCTS}")

set(CESIUM_EXTRA_ARGS)
if (CMAKE_TOOLCHAIN_FILE)
list(APPEND CESIUM_EXTRA_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif()

ExternalProject_Add(cesiumnative
SOURCE_DIR ${cesiumnative_src_SOURCE_DIR}
CMAKE_ARGS
Expand All @@ -58,8 +66,8 @@ ExternalProject_Add(cesiumnative
-DCESIUM_TRACING_ENABLED=OFF
-DDRACO_JS_GLUE=OFF
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CESIUM_EXTRA_ARGS}
BUILD_BYPRODUCTS
${CESIUM_BYPRODUCTS}
INSTALL_COMMAND ""
Expand Down
47 changes: 47 additions & 0 deletions cmake/cesium.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
index c928fdf..cf6a63b 100644
--- a/extern/draco/src/draco/io/file_utils.h
+++ b/extern/draco/src/draco/io/file_utils.h
@@ -17,6 +17,7 @@

#include <string>
#include <vector>
+#include <cstdint>

namespace draco {

diff --git a/CesiumAsync/include/CesiumAsync/CacheItem.h b/CesiumAsync/include/CesiumAsync/CacheItem.h
index 20d1ca80..bd47492b 100644
--- a/CesiumAsync/include/CesiumAsync/CacheItem.h
+++ b/CesiumAsync/include/CesiumAsync/CacheItem.h
@@ -9,6 +9,7 @@
#include <ctime>
#include <map>
#include <vector>
+#include <cstdint>

namespace CesiumAsync {

diff --git a/CesiumAsync/include/CesiumAsync/IAssetResponse.h b/CesiumAsync/include/CesiumAsync/IAssetResponse.h
index 10519057..0944b26b 100644
--- a/CesiumAsync/include/CesiumAsync/IAssetResponse.h
+++ b/CesiumAsync/include/CesiumAsync/IAssetResponse.h
@@ -8,6 +8,7 @@
#include <cstddef>
#include <map>
#include <string>
+#include <cstdint>

namespace CesiumAsync {

diff --git a/CesiumIonClient/src/fillWithRandomBytes.h b/CesiumIonClient/src/fillWithRandomBytes.h
index 55765c72..654d09df 100644
--- a/CesiumIonClient/src/fillWithRandomBytes.h
+++ b/CesiumIonClient/src/fillWithRandomBytes.h
@@ -1,6 +1,7 @@
#pragma once

#include <gsl/span>
+#include <cstdint>

namespace CesiumIonClient {

60 changes: 55 additions & 5 deletions config/styles/default-style.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@
name: DefaultStyle
version: 1.0
options:
- label: Show Meshes/Polygons
id: showMesh
- label: Show Points
id: showPoint
- label: Show Lines
id: showLine

rules:
# Normal styles
- geometry: ["mesh", "polygon"]
filter: showMesh
color: teal
opacity: 0.8
- geometry: ["point", "line"]
offset: [0, 0, -0.4]
- geometry: ["line"]
filter: showLine
color: moccasin
opacity: 1.0
width: 1.0
- geometry: ["point", "line", "mesh", "polygon"]
width: 5.0
offset: [0, 0, -0.2]
- geometry: ["point"]
point-merge-grid-cell: [0.000000084, 0.000000084, 0.01]
filter: showPoint
color-expression: "$mergeCount > 1 and 'brown' or 'moccasin'"
opacity: 1.0
width: 15.0

# Hover/Selection styles
- geometry: ["mesh", "polygon"]
color: orange
opacity: 1.0
mode: hover
offset: [0, 0, -0.3]
- geometry: ["line"]
color: orange
opacity: 1.0
width: 10.0
mode: hover
offset: [0, 0, -0.1]
- geometry: ["point"]
color: orange
opacity: 1.0
width: 20.0
mode: hover
offset: [0, 0, 0.1]
- geometry: ["mesh", "polygon"]
color: red
opacity: 1.0
mode: selection
offset: [0, 0, -0.3]
- geometry: ["line"]
color: red
opacity: 1.0
width: 10.0
mode: selection
offset: [0, 0, -0.1]
- geometry: ["point"]
color: red
opacity: 1.0
width: 4.0
mode: highlight
width: 20.0
mode: selection
offset: [0, 0, 0.1]
4 changes: 4 additions & 0 deletions erdblick_app/app/cesium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export type Viewer = Cesium.Viewer;
export const Viewer = Cesium.Viewer;
export type PrimitiveCollection = Cesium.PrimitiveCollection;
export const PrimitiveCollection = Cesium.PrimitiveCollection;
export type PointPrimitiveCollection = Cesium.PointPrimitiveCollection;
export const PointPrimitiveCollection = Cesium.PointPrimitiveCollection;
export type LabelCollection = Cesium.LabelCollection;
export const LabelCollection = Cesium.LabelCollection;
export type BillboardCollection = Cesium.BillboardCollection;
export const BillboardCollection = Cesium.BillboardCollection;
export type Billboard = Cesium.Billboard;
Expand Down
Loading

0 comments on commit 746a1ac

Please sign in to comment.