Skip to content

Commit

Permalink
disable automatically drawing points when lines are visible
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Feb 26, 2025
1 parent 7c947c3 commit e158149
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 5 deletions.
37 changes: 35 additions & 2 deletions client/src/components/LayerTypeConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import SizingSelector from './Sizing/SizingSelector.vue';
import TextDisplayConfig from './Text/TextDisplayConfig.vue';
import { getLayerAvailableProperties, getVectorLayerDisplayConfig } from '../utils';
import HeatmapLayerControls from './Heatmap/HeatmapLayerControls.vue';
import { updateFilters } from '../map/mapFilters';

Check failure on line 17 in client/src/components/LayerTypeConfig.vue

View workflow job for this annotation

GitHub Actions / lint-client

'updateFilters' is defined but never used
import { updateLayerFilter } from '../map/mapVectorLayers';

Check failure on line 18 in client/src/components/LayerTypeConfig.vue

View workflow job for this annotation

GitHub Actions / lint-client

'updateLayerFilter' is defined but never used

export default defineComponent({
components: {
Expand Down Expand Up @@ -54,7 +56,7 @@ export default defineComponent({
return enabled;
});

type LayerActionItems = 'enabled' | 'selectable' | 'hoverable' | 'opacity' | 'zoomMinMax' | 'selectColor' | 'defaultSize' | 'legend' | 'color' | 'text' | 'heatmapControls';
type LayerActionItems = 'enabled' | 'selectable' | 'hoverable' | 'opacity' | 'zoomMinMax' | 'selectColor' | 'defaultSize' | 'legend' | 'color' | 'text' | 'heatmapControls' | 'drawPoints';
const layerActionItemsMap: Record<LayerActionItems, AnnotationTypes[]> = {
enabled: ['line', 'fill', 'circle', 'fill-extrusion', 'text', 'heatmap'],
selectable: ['line', 'fill', 'circle', 'fill-extrusion'],
Expand All @@ -67,11 +69,12 @@ export default defineComponent({
color: ['line', 'fill', 'circle', 'fill-extrusion', 'text'],
text: ['text'],
heatmapControls: ['heatmap'],
drawPoints: ['line'],
};

const actionItemVisible = computed(() => {
const enabledItems = new Set<LayerActionItems>();
const itemList: LayerActionItems[] = ['enabled', 'selectable', 'hoverable', 'legend', 'opacity', 'zoomMinMax', 'selectColor', 'defaultSize', 'color', 'text', 'heatmapControls'];
const itemList: LayerActionItems[] = ['enabled', 'selectable', 'hoverable', 'legend', 'opacity', 'zoomMinMax', 'selectColor', 'defaultSize', 'color', 'text', 'heatmapControls', 'drawPoints'];
itemList.forEach((key) => {
if (layerActionItemsMap[key].includes(props.layerType)) {
enabledItems.add(key);
Expand Down Expand Up @@ -102,6 +105,10 @@ export default defineComponent({
if (field === 'legend') {
displayConfig.legend = val;
}
if (field === 'drawPoints') {
displayConfig.drawPoints = val;
}

if (field === 'opacity') {
if (val) {
displayConfig.opacity = 0.75;
Expand Down Expand Up @@ -683,6 +690,32 @@ export default defineComponent({
</v-tooltip>
</v-col>
</v-row>
<v-row
v-if="actionItemVisible.has('drawPoints')"
dense
align="center"
justify="center"
>
<v-col cols="2">
<v-tooltip text="Draw Points">
<template #activator="{ props }">
<v-icon
class="pl-3"
v-bind="props"
>
mdi-circle-outline
</v-icon>
</template>
</v-tooltip>
</v-col>
<v-col>
<v-icon @click="updateLayerTypeField('drawPoints', !valueDisplayCheckbox('drawPoints'))">
{{
valueDisplayCheckbox('drawPoints') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
</v-icon>
<span class="pl-2">Draw Points</span>
</v-col>
</v-row>
<div v-if="actionItemVisible.has('heatmapControls')">
<heatmap-layer-controls :layer-id="layerId" :layer-type="layerType" />
</div>
Expand Down
6 changes: 5 additions & 1 deletion client/src/map/mapFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ const updateFilters = (map: maplibregl.Map, layer: VectorMapLayer) => {
if (!(layer.default_style.layers[key] as VectorLayerDisplayConfig).enabled) {
return;
}
const layerConfig = (layer.default_style.layers[key] as VectorLayerDisplayConfig);
const layerName = `Layer_${layer.id}_${key}`;
const typeFilters = annotationFilters[key];
if (typeFilters.length === 0) {
if (typeFilters.length === 0 && !layerConfig.drawPoints) {
return;
}
const lineFilter = [];
if (['fill', 'fill-extrusion'].includes(key)) {
lineFilter.push(['==', ['geometry-type'], 'Polygon'] as FilterSpecification);
}
if (!layerConfig.drawPoints && ['circle'].includes(key)) {
lineFilter.push(['==', ['geometry-type'], 'Point'] as FilterSpecification);
}
if (typeFilters.length) {
const filterSpecification = typeFilters.length > 0 ? ['all'] : [];
if (lineFilter.length) {
Expand Down
19 changes: 17 additions & 2 deletions client/src/map/mapVectorLayers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ const updateSelected = (map: maplibregl.Map) => {
});
};

const getLayerFilter = (type: AnnotationTypes) => {
const getLayerFilter = (type: AnnotationTypes, layer?: VectorMapLayer) => {
let drawPoints = false;
if (type === 'circle' && layer?.default_style.layers && layer.default_style.layers.line) {
if (layer.default_style.layers.line !== true) {
drawPoints = !!layer.default_style.layers.line.drawPoints;
}
}
if (['fill', 'fill-extrusion'].includes(type)) {
return ['==', ['geometry-type'], 'Polygon'] as FilterSpecification;
}
if (!drawPoints && ['circle'].includes(type)) {
return ['==', ['geometry-type'], 'Point'] as FilterSpecification;
}

return true as FilterSpecification;
};
Expand Down Expand Up @@ -150,6 +159,7 @@ const setLayerProperty = (
}
};


Check failure on line 162 in client/src/map/mapVectorLayers.ts

View workflow job for this annotation

GitHub Actions / lint-client

More than 1 blank line not allowed
const toggleVectorMapLayers = (map: maplibregl.Map) => {
const addLayers: VectorMapLayer[] = [];
const removeLayers: VectorMapLayer[] = [];
Expand Down Expand Up @@ -194,7 +204,7 @@ const toggleVectorMapLayers = (map: maplibregl.Map) => {
type: 'circle',
source: `VectorTile_${layer.id}`,
'source-layer': 'default',
filter: getLayerFilter('circle'),
filter: getLayerFilter('circle', layer),
paint: {
'circle-color': getSelected(),
'circle-radius': getCircleRadius(),
Expand Down Expand Up @@ -361,6 +371,11 @@ const updateVectorLayer = (layer: VectorMapLayer) => {
);
}
}
if (!layerDisplayConfig.drawPoints && layerType === 'line' && !layer.default_style.filters?.length) {
setLayerFilter(internalMap.value as maplibregl.Map, `Layer_${layer.id}_circle`, ['==', ['geometry-type'], 'Point'] as FilterSpecification);

Check warning on line 375 in client/src/map/mapVectorLayers.ts

View workflow job for this annotation

GitHub Actions / lint-client

This line has a length of 151. Maximum allowed is 130
} else if (layerType === 'line') {
setLayerFilter(internalMap.value as maplibregl.Map, `Layer_${layer.id}_circle`, true as FilterSpecification);
}
} else {
toggleLayerTypeVisibility(internalMap.value as maplibregl.Map, layer.id, layerType, false);
}
Expand Down
1 change: 1 addition & 0 deletions client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export interface VectorLayerDisplayConfig {
max?: number;
},
heatmap?: HeatMapConfig;
drawPoints?: boolean;
}

export interface HeatMapConfig {
Expand Down
26 changes: 26 additions & 0 deletions sample_data/overture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[{
"type": "Context",
"name": "Boston Overture",
"default_map_center": [
42.3555,
-71.0565
],
"default_map_zoom": 6,
"datasets": [
{
"name": "Overture Data",
"description": "Overture Data",
"category": "overture",
"metadata": {},
"files": [
{
"path": "./data/tva/overture.zip",
"url": "https://data.kitware.com/api/v1/item/67bc9e26de1cd5c0d8ba62d5/download",
"name": "Overture Data",
"type": "zip",
"metadata":{}
}
]
}
]
}]
16 changes: 16 additions & 0 deletions uvdat/core/tasks/map_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,22 @@ def convert_zip_to_geojson(file_item):
with zipfile.ZipFile(archive_path) as zip_archive:
filenames = zip_archive.namelist()

for filename in filenames:
if filename.endswith(('.geojson', '.json')):
try:
logger.info(f'Processing GeoJSON file: {filename}')
with zip_archive.open(filename) as geojson_file:
source_data = json.load(geojson_file)
source_projection = source_data.get('crs', {}).get('properties', {}).get('name')
geojson_data = geopandas.GeoDataFrame.from_features(source_data.get('features'))
if source_projection:
geojson_data = geojson_data.set_crs(source_projection, allow_override=True)
geojson_data = geojson_data.to_crs(4326)
geodata_list.append({'geojson': geojson_data, 'name': Path(filename).stem})
except Exception as e:
logger.error(f'Error processing GeoJSON file {filename}: {e}')


# Group shapefile components by basename
shapefile_groups = defaultdict(list)
for filename in filenames:
Expand Down

0 comments on commit e158149

Please sign in to comment.