-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from dbauszus-glx:mvt-geom-prop
wkt_properties feature format and mvt queries
- Loading branch information
Showing
7 changed files
with
282 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,121 @@ | ||
function initializeFieldStats(layer) { | ||
if (layer.style?.theme?.field_stats) { | ||
layer.style.theme.updated = true; | ||
layer.style.theme.field_stats[layer.style.theme.field] = { | ||
values: [] | ||
}; | ||
} | ||
if (layer.style?.theme?.field_stats) { | ||
layer.style.theme.updated = true; | ||
layer.style.theme.field_stats[layer.style.theme.field] = { | ||
values: [] | ||
}; | ||
} | ||
} | ||
|
||
export function geojson(layer, features) { | ||
|
||
const formatGeojson = new ol.format.GeoJSON | ||
|
||
initializeFieldStats(layer); | ||
const formatGeojson = new ol.format.GeoJSON | ||
|
||
return features.map((feature) => { | ||
initializeFieldStats(layer); | ||
|
||
const properties = feature.properties | ||
return features.map((feature) => { | ||
|
||
if (layer.style?.theme?.field_stats) { | ||
const properties = feature.properties | ||
|
||
layer.style.theme.field_stats[layer.style.theme.field].values.push(parseFloat(properties[layer.style.theme.field])); | ||
} | ||
if (layer.style?.theme?.field_stats) { | ||
|
||
return new ol.Feature({ | ||
id: feature.id, | ||
geometry: formatGeojson.readGeometry(feature.geometry, { | ||
dataProjection: 'EPSG:' + layer.srid, | ||
featureProjection: 'EPSG:' + layer.mapview.srid, | ||
}), | ||
properties | ||
}) | ||
layer.style.theme.field_stats[layer.style.theme.field].values.push(parseFloat(properties[layer.style.theme.field])); | ||
} | ||
|
||
return new ol.Feature({ | ||
id: feature.id, | ||
geometry: formatGeojson.readGeometry(feature.geometry, { | ||
dataProjection: 'EPSG:' + layer.srid, | ||
featureProjection: 'EPSG:' + layer.mapview.srid, | ||
}), | ||
properties | ||
}) | ||
|
||
}) | ||
} | ||
|
||
export function wkt(layer, features) { | ||
|
||
const formatWKT = new ol.format.WKT | ||
const formatWKT = new ol.format.WKT | ||
|
||
initializeFieldStats(layer); | ||
|
||
return features.map((feature) => { | ||
|
||
const properties = {} | ||
|
||
initializeFieldStats(layer); | ||
// Assign field key and value to properties object | ||
layer.params.fields?.forEach((field, i) => { | ||
|
||
return features.map((feature) => { | ||
if (layer.style?.theme?.field_stats?.[field]) { | ||
|
||
const properties = {} | ||
layer.style?.theme?.field_stats?.[field].values.push(parseFloat(feature[i + 2])); | ||
} | ||
|
||
// Assign field key and value to properties object | ||
layer.params.fields?.forEach((field, i) => { | ||
properties[field] = feature[i + 2] | ||
}) | ||
|
||
// Return feature from geometry with properties. | ||
return new ol.Feature({ | ||
id: feature.shift(), | ||
geometry: formatWKT.readGeometry(feature.shift(), { | ||
dataProjection: 'EPSG:' + layer.srid, | ||
featureProjection: 'EPSG:' + layer.mapview.srid, | ||
}), | ||
properties | ||
}) | ||
|
||
}) | ||
} | ||
|
||
if (layer.style?.theme?.field_stats?.[field]) { | ||
export function wkt_properties(layer, features) { | ||
|
||
layer.style?.theme?.field_stats?.[field].values.push(parseFloat(feature[i + 2])); | ||
} | ||
initializeFieldStats(layer); | ||
|
||
properties[field] = feature[i + 2] | ||
}) | ||
for (const feature of features) { | ||
|
||
// Return feature from geometry with properties. | ||
return new ol.Feature({ | ||
id: feature.shift(), | ||
geometry: formatWKT.readGeometry(feature.shift(), { | ||
dataProjection: 'EPSG:' + layer.srid, | ||
featureProjection: 'EPSG:' + layer.mapview.srid, | ||
}), | ||
properties | ||
}) | ||
const properties = {} | ||
|
||
// Assign field key and value to properties object | ||
layer.params.fields?.forEach((field, i) => { | ||
|
||
if (layer.style?.theme?.field_stats?.[field]) { | ||
|
||
layer.style?.theme?.field_stats?.[field].values.push(parseFloat(feature[i + 1])); | ||
} | ||
|
||
properties[field] = feature[i + 1] | ||
}) | ||
|
||
layer.featuresObject[feature.shift()] = properties | ||
} | ||
} | ||
|
||
export function cluster(layer, features) { | ||
|
||
layer.max_size = 1 | ||
layer.max_size = 1 | ||
|
||
return features.map((vals, i) => { | ||
return features.map((vals, i) => { | ||
|
||
const geometry = new ol.geom.Point(vals.shift()) | ||
const geometry = new ol.geom.Point(vals.shift()) | ||
|
||
const count = vals.shift() | ||
const count = vals.shift() | ||
|
||
layer.max_size = layer.max_size > count ? layer.max_size: count; | ||
layer.max_size = layer.max_size > count ? layer.max_size : count; | ||
|
||
const id = vals.shift() | ||
const id = vals.shift() | ||
|
||
const properties = {count} | ||
|
||
layer.params.fields.forEach((field, i) => { | ||
properties[field] = vals[i] | ||
}) | ||
const properties = { count } | ||
|
||
return new ol.Feature({ | ||
id, | ||
geometry, | ||
...properties | ||
}) | ||
layer.params.fields.forEach((field, i) => { | ||
properties[field] = vals[i] | ||
}) | ||
|
||
return new ol.Feature({ | ||
id, | ||
geometry, | ||
...properties | ||
}) | ||
|
||
}) | ||
} |
Oops, something went wrong.