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

feat: soil id endpoints #1273

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions terraso_backend/apps/graphql/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
SoilDataUpdateDepthIntervalMutation,
SoilDataUpdateMutation,
)
from apps.soil_id.graphql.soil_id import soil_id

from .audit_logs import AuditLogNode
from .commons import TerrasoRelayNode
Expand Down Expand Up @@ -141,6 +142,7 @@ class Query(graphene.ObjectType):
sites = DjangoFilterConnectionField(SiteNode, required=True)
audit_logs = DjangoFilterConnectionField(AuditLogNode)
shared_resource = SharedResourceRelayNode.Field()
soil_id = soil_id
from .shared_resources import resolve_shared_resource


Expand Down
243 changes: 176 additions & 67 deletions terraso_backend/apps/graphql/schema/schema.graphql
knipec marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ schema {
}

type Query {
"""Soil ID algorithm Queries"""
soilId: SoilId!
group(
"""The ID of the object"""
id: ID!
Expand Down Expand Up @@ -92,6 +94,180 @@ type Query {
sharedResource(shareUuid: String!): SharedResourceNode
}

"""Soil ID algorithm queries."""
type SoilId {
locationBasedSoilMatches(latitude: Float!, longitude: Float!): LocationBasedSoilMatches!
dataBasedSoilMatches(latitude: Float!, longitude: Float!, data: SoilIdInputData!): DataBasedSoilMatches!
}

"""A ranked group of soil matches based solely on a coordinate pair."""
type LocationBasedSoilMatches {
matches: [LocationBasedSoilMatch!]!
}

"""A soil match based solely on a coordinate pair."""
type LocationBasedSoilMatch {
dataSource: String!
distanceToNearestMapUnitM: Float!
soilInfo: SoilInfo!
match: SoilMatchInfo!
}

"""Provides information about soil at a particular location."""
type SoilInfo {
soilSeries: SoilSeries!
ecologicalSite: EcologicalSite
landCapabilityClass: LandCapabilityClass!
soilData: SoilIdSoilData!
}

"""Information about a soil series."""
type SoilSeries {
name: String!
taxonomySubgroup: String!
description: String!
fullDescriptionUrl: String!
}

"""Information about an ecological site."""
type EcologicalSite {
name: String!
id: String!
url: String!
}

"""Caveat: may want to update these fields to an enum at some point."""
type LandCapabilityClass {
capabilityClass: String!
subClass: String!
}

"""Soil data associated with a soil match output by the soil algorithm."""
type SoilIdSoilData {
slope: Float
depthDependentData: [SoilIdDepthDependentData!]!
}

"""
Depth dependent soil data associated with a soil match output by the soil algorithm.
"""
type SoilIdDepthDependentData {
depthInterval: DepthInterval!
texture: SoilIdDepthDependentSoilDataTextureChoices
rockFragmentVolume: SoilIdDepthDependentSoilDataRockFragmentVolumeChoices
colorHue: Float
colorValue: Float
colorChroma: Float
}

type DepthInterval {
start: Int!
end: Int!
}

"""An enumeration."""
enum SoilIdDepthDependentSoilDataTextureChoices {
"""Sand"""
SAND

"""Loamy Sand"""
LOAMY_SAND

"""Sandy Loam"""
SANDY_LOAM

"""Silt Loam"""
SILT_LOAM

"""Silt"""
SILT

"""Loam"""
LOAM

"""Sandy Clay Loam"""
SANDY_CLAY_LOAM

"""Silty Clay Loam"""
SILTY_CLAY_LOAM

"""Clay Loam"""
CLAY_LOAM

"""Sandy Clay"""
SANDY_CLAY

"""Silty Clay"""
SILTY_CLAY

"""Clay"""
CLAY
}

"""An enumeration."""
enum SoilIdDepthDependentSoilDataRockFragmentVolumeChoices {
"""0 — 1%"""
VOLUME_0_1

"""1 — 15%"""
VOLUME_1_15

"""15 — 35%"""
VOLUME_15_35

"""35 — 60%"""
VOLUME_35_60

"""> 60%"""
VOLUME_60
}

"""
The likelihood score and rank within the match group for a particular soil type.
"""
type SoilMatchInfo {
score: Float!
rank: Int!
}

"""
A ranked group of soil matches based on a coordinate pair and soil data.
"""
type DataBasedSoilMatches {
matches: [DataBasedSoilMatch!]!
}

"""A soil match based on a coordinate pair and soil data."""
type DataBasedSoilMatch {
dataSource: String!
distanceToNearestMapUnitM: Float!
soilInfo: SoilInfo!
locationMatch: SoilMatchInfo!
dataMatch: SoilMatchInfo!
combinedMatch: SoilMatchInfo!
}

"""Soil data provided to the soil ID algorithm."""
input SoilIdInputData {
slope: Float
depthDependentData: [SoilIdInputDepthDependentData!]!
}

"""Depth dependent data provided to the soil ID algorithm."""
input SoilIdInputDepthDependentData {
depthInterval: DepthIntervalInput!
texture: SoilIdDepthDependentSoilDataTextureChoices = null
rockFragmentVolume: SoilIdDepthDependentSoilDataRockFragmentVolumeChoices = null
colorHue: Float
colorValue: Float
colorChroma: Float
}

input DepthIntervalInput {
start: Int!
end: Int!
}

type GroupNode implements Node {
slug: String!
name: String!
Expand Down Expand Up @@ -1119,11 +1295,6 @@ type SoilDataDepthIntervalNode {
depthInterval: DepthInterval!
}

type DepthInterval {
start: Int!
end: Int!
}

type DepthDependentSoilDataNode {
texture: SoilIdDepthDependentSoilDataTextureChoices
clayPercent: Int
Expand Down Expand Up @@ -1151,63 +1322,6 @@ type DepthDependentSoilDataNode {
depthInterval: DepthInterval!
}

"""An enumeration."""
enum SoilIdDepthDependentSoilDataTextureChoices {
"""Sand"""
SAND

"""Loamy Sand"""
LOAMY_SAND

"""Sandy Loam"""
SANDY_LOAM

"""Silt Loam"""
SILT_LOAM

"""Silt"""
SILT

"""Loam"""
LOAM

"""Sandy Clay Loam"""
SANDY_CLAY_LOAM

"""Silty Clay Loam"""
SILTY_CLAY_LOAM

"""Clay Loam"""
CLAY_LOAM

"""Sandy Clay"""
SANDY_CLAY

"""Silty Clay"""
SILTY_CLAY

"""Clay"""
CLAY
}

"""An enumeration."""
enum SoilIdDepthDependentSoilDataRockFragmentVolumeChoices {
"""0 — 1%"""
VOLUME_0_1

"""1 — 15%"""
VOLUME_1_15

"""15 — 35%"""
VOLUME_15_35

"""35 — 60%"""
VOLUME_35_60

"""> 60%"""
VOLUME_60
}

"""An enumeration."""
enum SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices {
"""Moist"""
Expand Down Expand Up @@ -2193,11 +2307,6 @@ input DepthDependentSoilDataUpdateMutationInput {
clientMutationId: String
}

input DepthIntervalInput {
start: Int!
end: Int!
}

type SoilDataUpdateDepthIntervalMutationPayload {
errors: GenericScalar
soilData: SoilDataNode
Expand Down
Loading
Loading