Skip to content

Commit

Permalink
Merge pull request #70 from I-GUIDE/63-spatial-coverage-map-search-in…
Browse files Browse the repository at this point in the history
…-search-results

Add spatial coverage map to search results
  • Loading branch information
Maurier authored Aug 24, 2023
2 parents 057bb61 + 0d0db0e commit c125252
Show file tree
Hide file tree
Showing 3 changed files with 8,126 additions and 36 deletions.
6 changes: 2 additions & 4 deletions frontend/src/components/search-results/cd.search-results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
<cd-spatial-coverage-map
:loader="loader"
:loader-options="options"
:features="result.spatialCoverage"
:feature="result.spatialCoverage"
/>
</div>
</div>
Expand Down Expand Up @@ -764,9 +764,7 @@ export default class CdSearchResults extends Vue {
}
public hasSpatialFeatures(result: IResult): boolean {
// TODO: agree on spatial coverage schema and adjust mapping
return false;
// return result.spatialCoverage?.some((feature) => feature.geometry);
return result.spatialCoverage?.["@type"];
}
}
</script>
Expand Down
53 changes: 22 additions & 31 deletions frontend/src/components/search-results/cd.spatial-coverage-map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_ZOOM = 5;
components: {},
})
export default class CdSpatialCoverageMap extends Vue {
@Prop() features!: any;
@Prop() feature!: any;
@Prop() loader!: Loader;
@Prop() loaderOptions!: LoaderOptions;
Expand Down Expand Up @@ -95,36 +95,27 @@ export default class CdSpatialCoverageMap extends Vue {
}
protected loadDrawing() {
const features = this.features.map((f) => f.geometry).filter((f) => f);
if (features.length) {
const points: google.maps.ReadonlyLatLngLiteral[] = features
.filter((f) => f.type === "Point")
.map(
(f) =>
({
lat: f.coordinates[1],
lng: f.coordinates[0],
} as google.maps.ReadonlyLatLngLiteral)
);
const rectangles: google.maps.LatLngBoundsLiteral[] = features
.filter((f) => f.type === "Polygon")
.map(
(f) =>
({
north: f.coordinates[0],
south: f.coordinates[1],
east: f.coordinates[2],
west: f.coordinates[3],
} as google.maps.LatLngBoundsLiteral)
);
if (points.length) {
this.loadMarkers(points);
}
if (rectangles.length) {
this.loadRectangles(rectangles);
if (this.feature) {
if (this.feature["@type"] === "GeoCoordinates") {
const point: google.maps.ReadonlyLatLngLiteral = {
lat: this.feature.latitude,
lng: this.feature.longitude,
} as google.maps.ReadonlyLatLngLiteral;
this.loadMarkers([point]);
} else if (this.feature["@type"] === "GeoShape") {
const extents = this.feature.box
.trim()
.split(" ")
.map((n) => +n);
if (extents.length === 4) {
const rectangle: google.maps.LatLngBoundsLiteral = {
north: extents[0],
east: extents[1],
south: extents[2],
west: extents[3],
} as google.maps.LatLngBoundsLiteral;
this.loadRectangles([rectangle]);
}
}
}
}
Expand Down
8,103 changes: 8,102 additions & 1 deletion frontend/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit c125252

Please sign in to comment.