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 2 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 SoilID

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 = graphene.Field(SoilID, required=True)
from .shared_resources import resolve_shared_resource


Expand Down
106 changes: 101 additions & 5 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 @@ -90,6 +90,7 @@ type Query {
orderBy: String
): AuditLogNodeConnection
sharedResource(shareUuid: String!): SharedResourceNode
soilId: SoilID!
}

type GroupNode implements Node {
Expand Down Expand Up @@ -1527,6 +1528,106 @@ String, Boolean, Int, Float, List or Object.
"""
scalar GenericScalar

"""Soil ID algorithm queries."""
type SoilID {
locationBasedSoilMatches(latitude: Float!, longitude: Float!): LocationBasedSoilMatches!
dataBasedSoilMatches(latitude: Float!, longitude: Float!, data: SoilIDInputData!): DataBasedSoilMatches!
tm-ruxandra marked this conversation as resolved.
Show resolved Hide resolved
}

"""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 {
soilInfo: SoilInfo!
match: SoilMatch!
}

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

"""Information about a soil series."""
type SoilSeries {
name: String!
taxonomySubgroup: String!
description: String!
tm-ruxandra marked this conversation as resolved.
Show resolved Hide resolved
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!
knipec marked this conversation as resolved.
Show resolved Hide resolved
}

type SoilIdSoilData {
depthInterval: DepthInterval!
texture: SoilIdDepthDependentSoilDataTextureChoices
rockFragmentVolume: SoilIdDepthDependentSoilDataRockFragmentVolumeChoices
colorHue: Float
colorValue: Float
colorChroma: Float
}

"""
The likelihood score and rank within the match group for a particular soil type.
"""
type SoilMatch {
score: Float!
tm-ruxandra marked this conversation as resolved.
Show resolved Hide resolved
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 {
soilInfo: SoilInfo!
locationMatch: SoilMatch!
dataMatch: SoilMatch!
combinedMatch: SoilMatch!
}

"""Soil data provided to the soil ID algorithm."""
input SoilIDInputData {
slope: SoilIdSoilDataSlopeSteepnessSelectChoices
intervals: [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 Mutations {
addGroup(input: GroupAddMutationInput!): GroupAddMutationPayload!
addLandscape(input: LandscapeAddMutationInput!): LandscapeAddMutationPayload!
Expand Down Expand Up @@ -2193,11 +2294,6 @@ input DepthDependentSoilDataUpdateMutationInput {
clientMutationId: String
}

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

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