-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into temporal-annotations
- Loading branch information
Showing
8 changed files
with
384 additions
and
18 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
bats_ai/core/migrations/0006_alter_recording_recording_location.py
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 4.1.13 on 2024-02-02 16:19 | ||
|
||
import django.contrib.gis.db.models.fields | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('core', '0005_recording_public'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='recording', | ||
name='recording_location', | ||
field=django.contrib.gis.db.models.fields.GeometryField( | ||
blank=True, null=True, srid=4326 | ||
), | ||
), | ||
] |
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
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 |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<!-- eslint-disable @typescript-eslint/no-explicit-any --> | ||
<script lang="ts"> | ||
import { defineComponent, PropType, Ref, ref } from "vue"; | ||
import useState from "../use/useState"; | ||
import { watch } from "vue"; | ||
import geo, { GeoEvent } from "geojs"; | ||
|
||
export default defineComponent({ | ||
name: "MapLocation", | ||
components: {}, | ||
props: { | ||
editor: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
size: { | ||
type: Object as PropType<{ width: number; height: number }>, | ||
default: () => ({ width: 300, height: 300 }), | ||
}, | ||
location: { | ||
type: Object as PropType<{ x?: number; y?: number } | undefined>, | ||
default: () => undefined, | ||
}, | ||
updateMap: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}, | ||
emits: ['location'], | ||
setup(props, { emit }) { | ||
const usCenter = { x: -90.5855, y: 39.8333 }; | ||
const mapRef: Ref<HTMLDivElement | null> = ref(null); | ||
const map: Ref<any> = ref(); | ||
const mapLayer: Ref<any> = ref(); | ||
const markerLayer: Ref<any> = ref(); | ||
const markerFeature: Ref<any> = ref(); | ||
const markerLocation: Ref<{ x: number; y: number } | null> = ref(null); | ||
watch(mapRef, () => { | ||
if (mapRef.value) { | ||
const centerPoint = props.location && props.location.x && props.location.y ? props.location : usCenter; | ||
const zoomLevel = props.location && props.location.x && props.location.y ? 6 : 3; | ||
map.value = geo.map({ node: mapRef.value, center: centerPoint, zoom: zoomLevel }); | ||
mapLayer.value = map.value.createLayer("osm"); | ||
markerLayer.value = map.value.createLayer("feature", { features: ["marker"] }); | ||
markerFeature.value = markerLayer.value.createFeature("marker"); | ||
if (props.location?.x && props.location?.y) { | ||
markerLocation.value = { x: props.location?.x, y: props.location.y }; | ||
markerFeature.value | ||
.data([markerLocation.value]) | ||
.style({ | ||
symbol: geo.markerFeature.symbols.drop, | ||
symbolValue: 1 / 3, | ||
rotation: -Math.PI / 2, | ||
radius: 30, | ||
strokeWidth: 5, | ||
strokeColor: "blue", | ||
fillColor: "yellow", | ||
rotateWithMap: false, | ||
}) | ||
.draw(); | ||
} | ||
if (props.editor) { | ||
mapLayer.value.geoOn(geo.event.mouseclick, (e: GeoEvent) => { | ||
// Place a marker at the point | ||
const { x, y } = e.geo; | ||
markerLocation.value = { x, y }; | ||
markerFeature.value | ||
.data([markerLocation.value]) | ||
.style({ | ||
symbol: geo.markerFeature.symbols.drop, | ||
symbolValue: 1 / 3, | ||
rotation: -Math.PI / 2, | ||
radius: 30, | ||
strokeWidth: 5, | ||
strokeColor: "blue", | ||
fillColor: "yellow", | ||
rotateWithMap: false, | ||
}) | ||
.draw(); | ||
emit('location', { lon: x, lat:y }); | ||
|
||
}); | ||
} | ||
} | ||
}); | ||
watch(() => props.updateMap, () => { | ||
if (props.location?.x && props.location?.y && markerLocation.value) { | ||
markerLocation.value = { x: props.location?.x, y: props.location.y }; | ||
markerFeature.value | ||
.data([markerLocation.value]) | ||
.style({ | ||
symbol: geo.markerFeature.symbols.drop, | ||
symbolValue: 1 / 3, | ||
rotation: -Math.PI / 2, | ||
radius: 30, | ||
strokeWidth: 5, | ||
strokeColor: "blue", | ||
fillColor: "yellow", | ||
rotateWithMap: false, | ||
}) | ||
.draw(); | ||
const centerPoint = props.location && props.location.x && props.location.y ? props.location : usCenter; | ||
const zoomLevel = props.location && props.location.x && props.location.y ? 6 : 3; | ||
if (map.value) { | ||
map.value.zoom(zoomLevel); | ||
map.value.center(centerPoint); | ||
} | ||
|
||
} | ||
}); | ||
return { | ||
mapRef, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<v-card class="pa-0 ma-0"> | ||
<div ref="mapRef" :style="`width:${size.width}px; height:${size.height}px`" /> | ||
</v-card> | ||
</template> | ||
|
||
<style lang="scss" scoped></style> |
Oops, something went wrong.