Skip to content

Commit

Permalink
Merge pull request #172 from ndsev/transition-style
Browse files Browse the repository at this point in the history
Add attribute fields style filter
  • Loading branch information
Waguramu authored Dec 18, 2024
2 parents 4ea104f + fe1376e commit 46f2313
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 82 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ include(FetchContent)
set(CMAKE_CXX_STANDARD 20)

# Treat warnings as errors, with some exceptions for Cesium.
set (ERDBLICK_CXX_FLAGS
set(ERDBLICK_CXX_FLAGS
"-Wall -Wno-error=sign-conversion -Wno-sign-compare -Wno-sign-conversion -Wno-unused-local-typedefs -Wno-comment -Wno-effc++")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ERDBLICK_CXX_FLAGS} -Wno-bool-compare")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ERDBLICK_CXX_FLAGS} -Wno-error=shorten-64-to-32")
endif()

# External dependencies.
# Adjust CXX_FLAGS for Debug builds
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()

# External dependencies
message("Building for ${CMAKE_SYSTEM_NAME}.")

FetchContent_Declare(mapget
Expand Down Expand Up @@ -44,4 +48,3 @@ else()
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS erdblick-core)
endif()

6 changes: 5 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"inherits": "common",
"displayName": "Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS_DEBUG": "-g"
},
"environment": {
"EMCC_DEBUG": "1"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Each rule within the YAML `rules` array can have the following fields:
| `relation-recursive` | Specifies whether relations should be resolved recursively. Only done if `mode=="Highlight"`, and only works for relations within the same layer. | Boolean | `true`, `false` |
| `relation-merge-twoway` | Specifies whether bidirectional relations should be followed and merged. | Boolean | `true`, `false` |
| `attribute-type` | A regular expression to match against an attribute type. | String | `SPEED_LIMIT_.*` |
| `attribute-filter` | A [simfil](https://github.com/klebert-engineering/simfil) expression to evaluate against the attribute's fields. | String | `attributeValue.speedLimitKmh > 100` |
| `attribute-layer-type` | A regular expression to match against the attribute layer type name. | String | `Road.*Layer` |
| `attribute-validity-geom` | Set to `required`, `none` or `any` to control whether matching attributes must have a validity geometry. | String | `Road.*Layer` |
| `label-color` | Text color of the label. | String | `#00ccdd` |
Expand Down
40 changes: 32 additions & 8 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"assets": [
{
"glob": "**/*",
"input": "node_modules/cesium/Build/Cesium",
"input": "node_modules/cesium/Build/CesiumUnminified",
"output": "/bundle/cesium"
},
{
Expand Down Expand Up @@ -58,9 +58,7 @@
"node_modules/material-icons/iconfont/material-icons.css",
"erdblick_app/styles.scss"
],
"scripts": [

],
"scripts": [],
"customWebpackConfig": {
"path": "./webpack.config.js"
},
Expand All @@ -80,7 +78,34 @@
"maximumError": "4kb"
}
],
"outputHashing": "all"
"outputHashing": "all",
"assets": [
{
"glob": "**/*",
"input": "node_modules/cesium/Build/Cesium",
"output": "/bundle/cesium"
},
{
"glob": "**/*",
"input": "config/styles",
"output": "/bundle/styles"
},
{
"glob": "**/*",
"input": "images",
"output": "/bundle/images"
},
{
"glob": "**/*.json",
"input": "config",
"output": "/"
},
{
"glob": "VERSION",
"input": ".",
"output": "/bundle/"
}
]
},
"development": {
"buildOptimizer": false,
Expand Down Expand Up @@ -123,8 +148,7 @@
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
],
"assets": [],
"styles": [
"erdblick_app/styles.scss"
],
Expand All @@ -136,6 +160,6 @@
}
},
"cli": {
"analytics": false
"analytics": false
}
}
11 changes: 11 additions & 0 deletions erdblick_app/app/debugapi.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,15 @@ export class ErdblickDebugApi {
coreLib(): ErdblickCore_ {
return coreLib;
}

/** Run some simfil query to reproduce problems with search. */
runSimfilQuery(query: string = "**.transition") {
for (const [_, tile] of this.mapService.loadedTileLayers) {
tile.peek(parsedTile => {
let search = new coreLib.FeatureLayerSearch(parsedTile);
const matchingFeatures = search.filter(query);
search.delete();
})
}
}
}
1 change: 1 addition & 0 deletions erdblick_app/app/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const completionsList = [
{label: "offset-scale-by-distance", type: "property"},
{label: "first-of", type: "property"},
{label: "attribute-type", type: "property"},
{label: "attribute-filter", type: "property"},
{label: "attribute-layer-type", type: "property"},
{label: "point-merge-grid-cell", type: "property"},
{label: "FILL", type: "keyword"},
Expand Down
27 changes: 26 additions & 1 deletion erdblick_app/app/feature.panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ interface Column {
<p-treeTableToggler [rowNode]="rowNode" (click)="$event.stopPropagation()">
</p-treeTableToggler>
<span (click)="onKeyClick($event, rowData)"
style="cursor: pointer">{{ rowData['key'] }}
(mouseover)="onKeyHover($event, rowData)"
(mouseout)="onKeyHoverExit($event, rowData)"
style="cursor: pointer">
{{ rowData['key'] }}
</span>
<p-buttonGroup *ngIf="rowData['sourceDataReferences']"
class="source-data-ref-container">
Expand Down Expand Up @@ -402,6 +405,11 @@ export class FeaturePanelComponent implements OnInit, AfterViewInit, OnDestroy
rowData["mapId"],
rowData["value"],
coreLib.HighlightMode.HOVER_HIGHLIGHT).then();
} else if (rowData["hoverId"]) {
// this.mapService.highlightFeatures([{
// mapTileKey: this.inspectionService.selectedFeatures[rowData["featureIndex"]].featureTile.mapTileKey,
// featureId: rowData["hoverId"]
// }], false, coreLib.HighlightMode.HOVER_HIGHLIGHT).then();
}
}

Expand All @@ -412,6 +420,23 @@ export class FeaturePanelComponent implements OnInit, AfterViewInit, OnDestroy
}
}

onKeyHover(event: any, rowData: any) {
event.stopPropagation();
if (rowData["hoverId"]) {
// this.mapService.highlightFeatures([{
// mapTileKey: this.inspectionService.selectedFeatures[rowData["featureIndex"]].featureTile.mapTileKey,
// featureId: rowData["hoverId"]
// }], false, coreLib.HighlightMode.HOVER_HIGHLIGHT).then();
}
}

onKeyHoverExit(event: any, rowData: any) {
event.stopPropagation();
// if (rowData["type"] == this.InspectionValueType.FEATUREID.value) {
// this.mapService.highlightFeatures([], false, coreLib.HighlightMode.HOVER_HIGHLIGHT).then();
// }
}

getStyleClassByType(valueType: number): string {
switch (valueType) {
case this.InspectionValueType.SECTION.value:
Expand Down
11 changes: 7 additions & 4 deletions erdblick_app/app/inspection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class InspectionService {
}

getFeatureTreeDataFromModel() {
let convertToTreeTableNodes = (dataNodes: Array<InspectionModelData>): TreeTableNode[] => {
let convertToTreeTableNodes = (dataNodes: Array<InspectionModelData>, featureIndex: number): TreeTableNode[] => {
let treeNodes: Array<TreeTableNode> = [];
for (const data of dataNodes) {
const node: TreeTableNode = {};
Expand Down Expand Up @@ -164,6 +164,8 @@ export class InspectionService {
}
if (data.hasOwnProperty("hoverId")) {
node.data["hoverId"] = data.hoverId;
// Necessary to query one of the selectedFeatures for its mapTileKey
node.data["featureIndex"] = featureIndex;
}
if (data.hasOwnProperty("mapId")) {
node.data["mapId"] = data.mapId;
Expand All @@ -174,15 +176,16 @@ export class InspectionService {
if (data.hasOwnProperty("sourceDataReferences")) {
node.data["sourceDataReferences"] = data.sourceDataReferences;
}
node.children = data.hasOwnProperty("children") ? convertToTreeTableNodes(data.children) : [];
node.children = data.hasOwnProperty("children") ? convertToTreeTableNodes(data.children, featureIndex) : [];
treeNodes.push(node);
}
return treeNodes;
}

let treeNodes: Array<TreeTableNode> = [];
if (this.selectedFeatureInspectionModel) {
for (const section of this.selectedFeatureInspectionModel) {
for (let i = 0; i < this.selectedFeatureInspectionModel.length; i++) {
const section = this.selectedFeatureInspectionModel[i];
const node: TreeTableNode = {};
node.data = {key: section.key, value: section.value, type: section.type};
if (section.hasOwnProperty("info")) {
Expand All @@ -191,7 +194,7 @@ export class InspectionService {
if (section.hasOwnProperty("sourceDataReferences")) {
node.data["sourceDataReferences"] = section.sourceDataReferences;
}
node.children = convertToTreeTableNodes(section.children);
node.children = convertToTreeTableNodes(section.children, i);
treeNodes.push(node);
}
}
Expand Down
36 changes: 31 additions & 5 deletions erdblick_app/app/sourcedataselection.dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,19 @@ export class SourceDataLayerSelectionDialogComponent {
this.mapIdsPerTileId.set(id, maps);
}

if (this.menuService.lastInspectedTileSourceDataOption.getValue()) {
const savedTileId = this.menuService.lastInspectedTileSourceDataOption.getValue()?.tileId;
let tileIdSelection = this.tileIds.find(element =>
Number(element.id) == savedTileId && !element.disabled && [...this.mapService.tileLayersForTileId(element.id as bigint)].length
);
if (tileIdSelection) {
this.setCurrentTileId(tileIdSelection);
}
return;
}

// Pre-select the tile ID.
let tileIdSelection = this.tileIds.find(element =>
const tileIdSelection = this.tileIds.find(element =>
!element.disabled && [...this.mapService.tileLayersForTileId(element.id as bigint)].length
);
if (tileIdSelection) {
Expand Down Expand Up @@ -165,13 +176,18 @@ export class SourceDataLayerSelectionDialogComponent {
this.onTileIdChange(tileId);

if (this.customMapId) {
let mapSelection = this.mapIds.find(entry => entry.id == this.customMapId);
const mapSelection = this.mapIds.find(entry => entry.id == this.customMapId);
if (mapSelection) {
this.selectedMapId = mapSelection;
}
else {
} else {
this.mapIds.unshift({ id: this.customMapId, name: this.customMapId });
}
} else if (this.menuService.lastInspectedTileSourceDataOption.getValue()) {
const savedMapId = this.menuService.lastInspectedTileSourceDataOption.getValue()?.mapId;
const mapSelection = this.mapIds.find(entry => entry.id == savedMapId);
if (mapSelection) {
this.selectedMapId = mapSelection;
}
}

if (this.mapIds.length) {
Expand All @@ -180,7 +196,17 @@ export class SourceDataLayerSelectionDialogComponent {
}
this.onMapIdChange(this.selectedMapId);
if (this.sourceDataLayers.length) {
this.selectedSourceDataLayer = this.sourceDataLayers[0];
if (this.menuService.lastInspectedTileSourceDataOption.getValue()) {
const savedLayerId = this.menuService.lastInspectedTileSourceDataOption.getValue()?.layerId;
const layerSelection = this.sourceDataLayers.find(entry => entry.id == savedLayerId);
if (layerSelection) {
this.selectedSourceDataLayer = layerSelection;
} else {
this.selectedSourceDataLayer = this.sourceDataLayers[0];
}
} else {
this.selectedSourceDataLayer = this.sourceDataLayers[0];
}
this.onLayerIdChange(this.selectedSourceDataLayer);
}
}
Expand Down
6 changes: 6 additions & 0 deletions libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ set(ERDBLICK_SOURCE_FILES
)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
# Defaulting to debug symbols if the build type is Debug
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
endif()

list(APPEND ERDBLICK_SOURCE_FILES src/bindings.cpp)
add_executable(erdblick-core ${ERDBLICK_SOURCE_FILES})
target_compile_definitions(erdblick-core PUBLIC EMSCRIPTEN)
Expand Down
17 changes: 10 additions & 7 deletions libs/core/include/erdblick/inspection.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include <cstdint>
#include <deque>
#include <unordered_map>
#include "cesium-interface/object.h"
#include "mapget/model/feature.h"
#include "mapget/model/sourceinfo.h"
#include "simfil/model/string-pool.h"
#include "sfl/small_vector.hpp"
#include <unordered_map>
#include <cstdint>
#include <deque>
#include "simfil/model/string-pool.h"
#include "mapget/model/featurelayer.h"

namespace erdblick
{
Expand Down Expand Up @@ -82,8 +82,10 @@ class InspectionConverter
OptionalValueAndType convertField(std::string_view const& fieldName, simfil::ModelNode::Ptr const& value);
OptionalValueAndType convertField(JsValue const& fieldName, simfil::ModelNode::Ptr const& value);

JsValue convertStringView(const simfil::StringId& f);
JsValue convertStringView(const std::string_view& f);
JsValue convertString(const simfil::StringId& f);
JsValue convertString(const std::string_view& f);
JsValue convertString(const std::string& f);
JsValue convertString(const char* s);

std::string featureId_;
uint32_t nextRelationIndex_ = 0;
Expand All @@ -94,6 +96,7 @@ class InspectionConverter
std::shared_ptr<simfil::StringPool> stringPool_;
std::unordered_map<std::string_view, JsValue> translatedFieldNames_;
std::unordered_map<std::string_view, InspectionNode*> relationsByType_;
mapget::TileFeatureLayer* tile_ = nullptr;
};

} // namespace erdblick
Expand Down
2 changes: 2 additions & 0 deletions libs/core/include/erdblick/rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class FeatureStyleRule
[[nodiscard]] bool relationMergeTwoWay() const;

[[nodiscard]] std::optional<std::regex> const& attributeType() const;
[[nodiscard]] std::optional<std::string> const& attributeFilter() const;
[[nodiscard]] std::optional<std::regex> const& attributeLayerType() const;
[[nodiscard]] std::optional<bool> const& attributeValidityGeometry() const;

Expand Down Expand Up @@ -166,6 +167,7 @@ class FeatureStyleRule
bool relationMergeTwoWay_ = false;

std::optional<std::regex> attributeType_;
std::optional<std::string> attributeFilter_;
std::optional<std::regex> attributeLayerType_;
std::optional<bool> attributeValidityGeometry_;

Expand Down
4 changes: 4 additions & 0 deletions libs/core/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
#include <cxxabi.h>

#include <sanitizer/lsan_interface.h>
#include <sanitizer/asan_interface.h>

#if defined(__has_feature)
#if __has_feature(address_sanitizer)
const char *__lsan_default_options() {
return "verbosity=1:malloc_context_size=64";
}
const char *__asan_default_options() {
return "verbosity=1:malloc_context_size=64:detect_container_overflow=0";
}
#endif
#endif

Expand Down
Loading

0 comments on commit 46f2313

Please sign in to comment.