Skip to content

Commit

Permalink
add filter for elevation
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitestudiodesign committed Jan 18, 2024
1 parent 0982041 commit 1199fae
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions apps/fishing-map/features/datasets/datasets.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export const datasets: Dataset[] = [
type: 'string',
},
elevation: {
min: 0,
type: 'number',
enum: [-2000, 0],
type: 'range',
},
timestamp: {
type: 'string',
Expand All @@ -96,7 +96,7 @@ export const datasets: Dataset[] = [
type: 'number',
},
},
fieldsAllowed: ['lat', 'lon', 'timestamp', 'latlon', 'seg_id', 'speed'],
fieldsAllowed: ['lat', 'lon', 'timestamp', 'latlon', 'seg_id', 'speed', 'elevation'],
createdAt: '2023-10-17T12:34:21.417Z',
endpoints: [
{
Expand Down Expand Up @@ -143,7 +143,7 @@ export const datasets: Dataset[] = [
type: 'enum',
label: 'fields',
array: true,
enum: ['LAT', 'LON', 'TIMESTAMP', 'SPEED', 'COURSE'],
enum: ['LAT', 'LON', 'TIMESTAMP', 'SPEED', 'COURSE', 'ELEVATION'],
},
{
label: 'format',
Expand Down
5 changes: 3 additions & 2 deletions apps/fishing-map/features/datasets/datasets.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export type SupportedActivityDatasetSchema =
export type SupportedEnvDatasetSchema =
| 'type'
| 'speed'
| 'elevation'
| 'flag'
| 'vessel_type'
| 'Height'
Expand Down Expand Up @@ -830,13 +831,13 @@ export const getSchemaFiltersInDataview = (
const filtersAllowed = fielsAllowedOrdered.map((id) => {
return getFiltersBySchema(dataview, id, {
vesselGroups,
compatibilityOperation: id === 'speed' ? 'some' : 'every',
compatibilityOperation: id === 'speed' || id === 'elevation' ? 'some' : 'every',
})
})
const filtersDisabled = fieldsDisabled.map((id) => {
return getFiltersBySchema(dataview, id, {
vesselGroups,
compatibilityOperation: id === 'speed' ? 'some' : 'every',
compatibilityOperation: id === 'speed' || id === 'elevation' ? 'some' : 'every',
})
})
return {
Expand Down
2 changes: 1 addition & 1 deletion apps/fishing-map/features/dataviews/dataviews.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const dataviews: Dataview[] = [
},
{
id: 'fields',
value: ['LONLAT', 'TIMESTAMP', 'SPEED'],
value: ['LONLAT', 'TIMESTAMP', 'SPEED', 'ELEVATION'],
},
{
id: 'format',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ function VesselLayerPanel({ dataview }: VesselLayerPanelProps): React.ReactEleme
<VesselLink vesselId={vesselId} datasetId={dataset?.id}>
<IconButton
size="small"
loading={loading}
icon={infoError ? 'warning' : 'info'}
type={infoError ? 'warning' : 'default'}
disabled={infoError}
Expand Down
1 change: 1 addition & 0 deletions libs/api-types/src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum Field {
timestamp = 'timestamp',
fishing = 'fishing',
speed = 'speed',
depth = 'depth',
course = 'course',
night = 'night',
distanceFromPort = 'distance_from_port',
Expand Down
6 changes: 4 additions & 2 deletions libs/data-transforms/src/segments/segments-to-geojson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const segmentsToFeatures = (segment: Segment | Segment[]): Feature<LineString>[]
return []
}
const times = segment.map((point) => point.timestamp)
const speed = segment.map((point) => point.speed)
const speeds = segment.map((point) => point.speed)
const elevations = segment.map((point) => point.elevation)
const coordinateProperties = segment?.reduce(
(acc, point) => {
const properties = point.properties || {}
Expand All @@ -39,7 +40,8 @@ const segmentsToFeatures = (segment: Segment | Segment[]): Feature<LineString>[]
coordinateProperties: {
...coordinateProperties,
times: times.some((time) => !!time) ? times : undefined,
speed: speed.some((time) => !!time) ? speed : undefined,
speed: speeds.some((speed) => !!speed) ? speeds : undefined,
elevation: elevations.some((elevation) => !!elevation) ? elevations : undefined,
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions libs/ui-components/src/slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ const borderColor =
: fallbackBorderColor

export const formatSliderNumber = (num: number): string => {
if (num >= 1000) return format('.2s')(num)
if (num > 9) return format('.0f')(num)
const absNum = Math.abs(num)
if (absNum >= 1000) return format('.2s')(num)
if (absNum > 9) return format('.0f')(num)
return format('.1f')(num)
}

Expand Down

0 comments on commit 1199fae

Please sign in to comment.