Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latLng for explicit Feed geo point #154

Merged
merged 14 commits into from
Jul 28, 2023
Merged
2 changes: 1 addition & 1 deletion server/lib/orcasite/radio_legacy/radio_legacy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Orcasite.RadioLegacy do

import Ecto.Query, warn: false
alias Orcasite.Repo
alias Orcasite.RadioLegacy.{Feed, Detection, Candidate}
alias Orcasite.RadioLegacy.{Detection, Candidate}

def verify_can_submit_detection(
feed_id,
Expand Down
10 changes: 10 additions & 0 deletions server/lib/orcasite_web/graphql/types/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ defmodule OrcasiteWeb.Types.Feed do
end)
end

field :longitude_latitude, non_null(:json) do
resolve(fn
%{location_point: %{coordinates: {lng, lat}}}, _, _ ->
{:ok, %{lng: lng, lat: lat}}

_, _, _ ->
{:ok, %{}}
end)
end

field :thumb_url, non_null(:string) do
resolve(fn %{node_name: node_name}, _, _ ->
{:ok, feed_s3_url(node_name, "thumbnail.png")}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Map({
feeds,
}: {
setMap?: (map: LeafletMap) => void
currentFeed?: Pick<Feed, 'slug' | 'locationPoint'>
currentFeed?: Pick<Feed, 'slug' | 'longitudeLatitude'>
feeds: FeedsQuery['feeds']
}) {
const router = useRouter()
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function Map({
{feeds.map((feed) => (
<Marker
key={feed.slug}
position={feed.locationPoint.coordinates}
skanderm marked this conversation as resolved.
Show resolved Hide resolved
position={feed.longitudeLatitude}
icon={
feed.slug === currentFeed?.slug
? hydrophoneActiveIcon
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/MapLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const feedFromSlug = (feedSlug: string) => ({
name: feedSlug,
slug: feedSlug,
nodeName: feedSlug,
longitudeLatitude: {lng: -122.3, lat: 47.6},
// TODO: figure out which coordinates to use for dynamic feeds
locationPoint: {
coordinates: [47.6, -122.3],
Expand All @@ -46,7 +47,7 @@ function MapLayout({ children }: { children: ReactNode }) {
useEffect(() => {
if (feed && feed.slug !== currentFeed?.slug) {
setCurrentFeed(feed)
map?.panTo(feed.locationPoint.coordinates)
map?.panTo(feed.longitudeLatitude)
}
}, [feed, map, currentFeed])

Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Player({
}: {
currentFeed?: Pick<
Feed,
'id' | 'slug' | 'nodeName' | 'name' | 'locationPoint'
'id' | 'slug' | 'nodeName' | 'name' | 'locationPoint' | 'longitudeLatitude'
>
}) {
const [playerStatus, setPlayerStatus] = useState<PlayerStatus>('idle')
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function Player({
</Box>
<Box sx={{ mx: 4, flexGrow: 1, textAlign: 'end' }}>
{currentFeed &&
`${currentFeed.locationPoint.coordinates[0]}, ${currentFeed.locationPoint.coordinates[1]}`}
`${currentFeed.longitudeLatitude["lng"]}, ${currentFeed.longitudeLatitude["lat"]}`}
</Box>
</Box>
)
Expand Down
5 changes: 5 additions & 0 deletions ui/src/graphql/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export type Feed = {
id: Scalars['ID']['output']
introHtml: Scalars['String']['output']
locationPoint: Scalars['Json']['output']
longitudeLatitude: Scalars['Json']['output']
mapUrl: Scalars['String']['output']
name: Scalars['String']['output']
nodeName: Scalars['String']['output']
Expand Down Expand Up @@ -254,6 +255,7 @@ export type FeedQuery = {
slug: string
nodeName: string
locationPoint: any
longitudeLatitude: any
introHtml: string
thumbUrl: string
mapUrl: string
Expand All @@ -271,6 +273,7 @@ export type FeedsQuery = {
slug: string
nodeName: string
locationPoint: any
longitudeLatitude: any
thumbUrl: string
mapUrl: string
}>
Expand Down Expand Up @@ -335,6 +338,7 @@ export const FeedDocument = `
slug
nodeName
locationPoint
longitudeLatitude
introHtml
thumbUrl
mapUrl
Expand Down Expand Up @@ -363,6 +367,7 @@ export const FeedsDocument = `
slug
nodeName
locationPoint
longitudeLatitude
thumbUrl
mapUrl
}
Expand Down
1 change: 1 addition & 0 deletions ui/src/graphql/queries/getFeed.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query feed($slug: String!) {
slug
nodeName
locationPoint
longitudeLatitude
introHtml
thumbUrl
mapUrl
Expand Down
1 change: 1 addition & 0 deletions ui/src/graphql/queries/listFeeds.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query feeds {
slug
nodeName
locationPoint
longitudeLatitude
thumbUrl
mapUrl
}
Expand Down
Loading