Documentation
¶
Overview ¶
Package eooaoo computes auditable, point-based Extent of Occurrence (EOO) and Area of Occupancy (AOO) metrics using GDAL/PROJ.
Calculations normalize input coordinates to WGS84, preserve record provenance, project to an explicit equal-area analysis CRS, compute the convex-hull EOO, and evaluate occupied square-grid cells for AOO. The default AOO cell side is 2 km. Results record software, GDAL and PROJ versions, projection definitions, grid metadata, warnings and an input hash for reproducibility.
Two analysis strategies are available: ProjectionLocalLAEA, a local Lambert Azimuthal Equal Area projection centred on the distribution, and ProjectionIUCNCEA, a World Cylindrical Equal Area compatibility-oriented mode matching the projection documented by the IUCN EOO Calculator materials. ProjectionIUCNCEA does not imply IUCN certification.
The package computes spatial metrics only. It does not assign IUCN Red List categories and does not decide whether occurrence records are biologically suitable for an assessment.
Index ¶
- Constants
- func ApplyCuration(points []Point, m CurationManifest) ([]Point, CurationLog, error)
- func ExportGeoJSON(gpkg, dir string) error
- func GDALVersion() string
- func InputHash(points []Point) (string, error)
- func PROJVersion() string
- func WriteGeoPackage(path string, r Result) (err error)
- func WriteMapHTML(path, geojsonDir string, r Result) error
- type AOOResult
- type AnalysisProtocol
- type AuditConfig
- type AuditIssue
- type AuditRecord
- type AuditReport
- type BuildInfo
- type Cell
- type ComparisonWarning
- type Config
- type CurationDecision
- type CurationLog
- type CurationManifest
- type EOOInfluence
- type EOOResult
- type ExcludedRecord
- type Extent
- type InfluenceConfig
- type InfluenceGroup
- type Point
- type Projection
- type ProjectionComparison
- type ProjectionDelta
- type ProtocolEnvironment
- type Result
- type UsedPoint
Examples ¶
Constants ¶
const ( IssueInvalidRecord = "INVALID_RECORD" IssueInvalidCoordinate = "INVALID_COORDINATE" IssueZeroZero = "ZERO_ZERO_COORDINATE" IssueCoarsePrecision = "COARSE_COORDINATE_PRECISION" IssueUncertaintyExceedCell = "UNCERTAINTY_EXCEEDS_CELL_SIZE" IssueSourceQualityFlag = "SOURCE_QUALITY_FLAG" )
Audit issue codes. Codes are stable identifiers; messages may change.
const ( GuaranteeTranslationMinimum = "translation_minimum" GuaranteeTestedOriginsMinimum = "tested_origins_minimum" GuaranteeFixedOrigin = "fixed_origin" // FallbackExactWorkLimit means auto mode estimated more work for the // complete translation search than gridWorkLimit allows. FallbackExactWorkLimit = "EXACT_WORK_LIMIT" )
Grid search modes and guarantees reported in AOOResult.
const ( ProtocolVersion = "1" InclusionRulesVersion = "strict-v1: finite, in-domain coordinates; exact WGS84 equality merges records; lon 180 -> -180; lon 0 at the poles" HullMethod = "planar convex hull in the analysis CRS (monotone chain, exact orientation predicate)" AreaMethod = "GDAL planar polygon area in the analysis CRS" GridOrientation = "fixed analysis CRS axes; no rotation" GridBoundaryRule = "[left,right) x [bottom,top); no snapping" )
Method identifiers recorded in results and protocols. Changing what a calculation does under one of these names requires a new identifier.
const ( // ProjectionLocalLAEA selects a local Lambert Azimuthal Equal Area projection // centred on the assessment distribution. ProjectionLocalLAEA = "local-laea" // ProjectionIUCNCEA selects the World Cylindrical Equal Area strategy used for // methodological comparison with the projection documented by the IUCN EOO Calculator. ProjectionIUCNCEA = "iucn-cea" )
const AuditRulesVersion = "1"
AuditRulesVersion identifies the rule set; change it whenever a rule changes.
const CurationManifestVersion = "1"
CurationManifestVersion is the manifest format accepted by ApplyCuration.
const MaxPoints = 100000
MaxPoints is the maximum number of occurrence records accepted by one calculation.
const Version = "0.2.0"
Version is the public software version reported in calculation results.
Variables ¶
This section is empty.
Functions ¶
func ApplyCuration ¶ added in v0.2.0
func ApplyCuration(points []Point, m CurationManifest) ([]Point, CurationLog, error)
ApplyCuration verifies every decision against points before applying any of them and returns a new slice; points is not modified. The input hash must match, each selector must identify its record unambiguously, and every exclusion needs a justification.
func ExportGeoJSON ¶
ExportGeoJSON uses GDAL RFC7946 conversion (including antimeridian splitting). Splitting requires GDAL 3.8 or newer; earlier versions emit a single ring that spans the antimeridian instead of a MultiPolygon. Segmentization at 250 m is for display; authoritative areas are in the report and GeoPackage, never recomputed from the densified WGS84 display geometries.
func InputHash ¶ added in v0.2.0
InputHash returns the SHA-256 that Calculate records for these points.
func PROJVersion ¶
func PROJVersion() string
PROJVersion identifies the loaded native coordinate transformation library.
func WriteGeoPackage ¶
WriteGeoPackage stores exact analysis-plane geometries with their CRS. It refuses to overwrite an existing destination.
func WriteMapHTML ¶
WriteMapHTML creates a single HTML report with the GeoJSON data embedded in the document. MapLibre GL JS and the demonstration basemap are loaded from the network when the file is opened; occurrence/EOO/AOO data stay embedded.
Types ¶
type AOOResult ¶
type AOOResult struct {
AreaKM2 float64 `json:"area_km2"`
OccupiedCells int `json:"occupied_cells"`
CellSizeM float64 `json:"cell_size_m"`
ReferenceScale bool `json:"iucn_2km_scale"`
GridMode string `json:"grid_mode"`
RequestedGridMode string `json:"requested_grid_mode"`
EffectiveGridMode string `json:"effective_grid_mode"`
FallbackReason string `json:"fallback_reason,omitempty"`
ExactWorkEstimate int64 `json:"exact_work_estimate,omitempty"`
EstimatedPointEvaluations int64 `json:"estimated_point_evaluations"`
SampledSteps *int `json:"grid_steps_effective,omitempty"`
SearchGuarantee string `json:"search_guarantee"`
Origin [2]float64 `json:"origin_m"`
Candidates int `json:"candidate_origins"`
MinCells int `json:"min_cells"`
MaxCells int `json:"max_cells"`
TestedMinCells int `json:"tested_min_cells"`
TestedMaxCells int `json:"tested_max_cells"`
BaseOriginCells int `json:"base_origin_cells"`
BaseOriginAreaKM2 float64 `json:"base_origin_area_km2"`
CompleteTranslationSearch bool `json:"complete_translation_search"`
Orientation string `json:"orientation"`
BoundaryRule string `json:"boundary_rule"`
}
AOOResult contains the occupied-cell result and the grid-search metadata used to obtain it for the fixed orientation of the analysis CRS axes.
SearchGuarantee states what the reported count is a minimum of: translation_minimum (every translation at fixed orientation, exact mode), tested_origins_minimum (only the sampled origins) or fixed_origin (no search). TestedMinCells/TestedMaxCells span the evaluated origins only; their range is sensitivity to grid translation, not biological uncertainty. GridMode, MinCells, MaxCells and CompleteTranslationSearch are retained for v1 clients.
type AnalysisProtocol ¶ added in v0.2.0
type AnalysisProtocol struct {
ProtocolVersion string `json:"protocol_version"`
InputCRS string `json:"input_crs"`
ProjectionStrategy string `json:"projection_strategy"`
AnalysisPROJ string `json:"analysis_proj"`
Center *[2]float64 `json:"center_lon_lat,omitempty"`
CellSizeM float64 `json:"cell_size_m"`
Origin [2]float64 `json:"origin_m"`
GridMode string `json:"grid_mode"`
Orientation string `json:"orientation"`
BoundaryRule string `json:"boundary_rule"`
HullMethod string `json:"hull_method"`
AreaMethod string `json:"area_method"`
InclusionRules string `json:"inclusion_rules_version"`
Environment ProtocolEnvironment `json:"environment"`
}
AnalysisProtocol freezes every effective parameter needed to reproduce a calculation on a changed record set: full analysis CRS definition, projection centre, cell size, grid origin and orientation, boundary rule, hull and area methods, and the record-inclusion rules. Reproduction always uses a fixed grid, so added records cannot move the centre or the origin.
func (AnalysisProtocol) SHA256 ¶ added in v0.2.0
func (p AnalysisProtocol) SHA256() string
SHA256 hashes the canonical JSON serialization of the protocol without its Environment, so the hash identifies method and effective parameters only.
type AuditConfig ¶ added in v0.2.0
type AuditConfig struct {
InputCRS string `json:"input_crs,omitempty"`
// CellSizeM is the AOO cell side compared against coordinate uncertainty.
// Zero selects 2000.
CellSizeM float64 `json:"cell_size_m,omitempty"`
// CoarseDecimals enables COARSE_COORDINATE_PRECISION for records whose
// input X and Y are both whole multiples of 10^-CoarseDecimals input-CRS
// units. Nil disables the rule.
CoarseDecimals *int `json:"coarse_decimals,omitempty"`
// UncertaintyField names the record property holding coordinate
// uncertainty in metres. Empty disables UNCERTAINTY_EXCEEDS_CELL_SIZE.
UncertaintyField string `json:"uncertainty_field,omitempty"`
// SourceFlagField names the record property holding source quality flags,
// separated by commas or semicolons. Empty disables SOURCE_QUALITY_FLAG.
SourceFlagField string `json:"source_flag_field,omitempty"`
// ContextFields are record properties copied verbatim into every finding's
// evidence (e.g. locality), so a reviewer sees them next to the finding.
ContextFields []string `json:"context_fields,omitempty"`
}
AuditConfig enables and parameterizes the optional rules. Every threshold is explicit: nothing is inferred from field names unless a field is named here.
type AuditIssue ¶ added in v0.2.0
type AuditIssue struct {
Code string `json:"code"`
Severity string `json:"severity"`
InputIndex *int `json:"input_index"`
SourceRow *int `json:"source_row,omitempty"`
RecordID string `json:"record_id,omitempty"`
Evidence map[string]any `json:"evidence"`
Message string `json:"message"`
}
AuditIssue is one finding about one record. It never states a biological conclusion and never removes the record.
type AuditRecord ¶ added in v0.2.0
type AuditRecord struct {
Point
// SourceRow is the 1-based CSV line number including the header, or 0.
SourceRow int
ParseError string
}
AuditRecord is one input record as read by a permissive parser. ParseError is set when the record could not be turned into numeric coordinates (the strict calc parser would reject it); X/Y are then meaningless.
type AuditReport ¶ added in v0.2.0
type AuditReport struct {
SchemaVersion string `json:"schema_version"`
RulesVersion string `json:"rules_version"`
SoftwareVersion string `json:"software_version"`
Config AuditConfig `json:"config"`
InputCRS string `json:"input_crs"`
// InputSHA256 matches Result.InputSHA256 for the same records; it is null
// when some record has no numeric coordinates and so cannot be hashed the
// same way.
InputSHA256 *string `json:"input_sha256"`
SourceSHA256 string `json:"source_sha256,omitempty"`
InputRecords int `json:"input_records"`
InvalidRecords int `json:"invalid_records"`
RecordsWithIssues int `json:"records_with_issues"`
ValidUniqueCoords int `json:"valid_unique_coordinates"`
DuplicateRecordIDs int `json:"duplicate_record_ids"`
UncertaintyUnknown *int `json:"uncertainty_unknown,omitempty"`
CountsByCode map[string]int `json:"counts_by_code"`
CountsBySeverity map[string]int `json:"counts_by_severity"`
CalculationCompatible bool `json:"calculation_compatible"`
Issues []AuditIssue `json:"issues"`
Note string `json:"note"`
}
AuditReport summarizes data-quality findings without running a grid search or changing which records a calculation uses.
func AuditOccurrences ¶ added in v0.2.0
func AuditOccurrences(ctx context.Context, records []AuditRecord, cfg AuditConfig) (AuditReport, error)
AuditOccurrences diagnoses records one by one. It reuses Calculate's domain checks and CRS transformation but never runs the grid search and never changes the record set: suspect records are reported, not removed.
type BuildInfo ¶ added in v0.2.0
type BuildInfo struct {
GoVersion string `json:"go_version"`
ModuleVersion string `json:"module_version,omitempty"`
VCSRevision string `json:"vcs_revision,omitempty"`
VCSTime string `json:"vcs_time,omitempty"`
VCSModified *bool `json:"vcs_modified,omitempty"`
}
BuildInfo identifies the compiled code. Fields are only filled from metadata the Go toolchain embedded; a local build without VCS stamping reports no revision rather than an invented one.
type Cell ¶
type Cell struct {
Column int64 `json:"column"`
Row int64 `json:"row"`
UniquePoints int `json:"unique_points"`
Bounds [4]float64 `json:"bounds_m"`
}
Cell describes one occupied AOO cell in analysis-CRS metres.
type ComparisonWarning ¶ added in v0.2.0
ComparisonWarning is a structured caveat about what a delta can mean.
type Config ¶
type Config struct {
InputCRS string `json:"input_crs,omitempty"`
// ProjectionStrategy is local-laea (default) or iucn-cea.
ProjectionStrategy string `json:"projection_strategy,omitempty"`
// Center is [longitude, latitude] in WGS84. Nil selects a spherical mean.
// It is only valid with local-laea.
Center *[2]float64 `json:"center,omitempty"`
CellSizeM float64 `json:"cell_size_m,omitempty"`
// GridMode is auto, exact, sampled, or fixed. Orientation is never rotated.
GridMode string `json:"grid_mode,omitempty"`
GridSteps int `json:"grid_steps,omitempty"`
Origin [2]float64 `json:"origin_m"`
// ExtentWarningDeg triggers PROJECTION_SENSITIVE_EXTENT when the longitude
// or latitude span of the unique points exceeds it. Zero selects 20 degrees,
// a provisional value pending calibration on more taxa.
ExtentWarningDeg float64 `json:"extent_warning_deg,omitempty"`
}
Config controls coordinate interpretation, analysis projection and AOO grid search. Zero values select the documented defaults: EPSG:4326 input, local-laea, 2,000 m cells, auto grid search and 10 sampled steps when fallback is needed.
func ApplyProtocol ¶ added in v0.2.0
func ApplyProtocol(c Config, p AnalysisProtocol) (Config, error)
ApplyProtocol returns the fixed-grid Config that reproduces p. Fields already set in c must agree with the protocol; any disagreement, or a protocol whose methods differ from this software's, is an error raised before calculation.
type CurationDecision ¶ added in v0.2.0
type CurationDecision struct {
InputIndex int `json:"input_index"`
RecordID *string `json:"record_id,omitempty"`
Lon *float64 `json:"lon,omitempty"`
Lat *float64 `json:"lat,omitempty"`
Action string `json:"action"`
Justification string `json:"justification"`
}
CurationDecision selects one record by zero-based input index and states what the curator expects to find there, so a manifest written for one file cannot silently apply to another. At least one of RecordID or Lon/Lat is required; every field given must match exactly.
type CurationLog ¶ added in v0.2.0
type CurationLog struct {
SchemaVersion string `json:"schema_version"`
SoftwareVersion string `json:"software_version"`
ManifestSHA256 string `json:"manifest_sha256"`
InputSHA256 string `json:"input_sha256"`
OutputSHA256 string `json:"output_sha256"`
InputRecords int `json:"input_records"`
OutputRecords int `json:"output_records"`
Excluded []ExcludedRecord `json:"excluded"`
Note string `json:"note"`
}
CurationLog links the original and derived record sets.
type CurationManifest ¶ added in v0.2.0
type CurationManifest struct {
ManifestVersion string `json:"manifest_version"`
InputSHA256 string `json:"input_sha256"`
Description string `json:"description,omitempty"`
Curator string `json:"curator,omitempty"`
Decisions []CurationDecision `json:"decisions"`
}
CurationManifest is a versioned, reviewable list of explicit exclusions for one exact input, identified by the same hash Calculate records.
type EOOInfluence ¶ added in v0.2.0
type EOOInfluence struct {
SchemaVersion string `json:"schema_version"`
SoftwareVersion string `json:"software_version"`
InputSHA256 string `json:"input_sha256"`
GeometrySHA256 string `json:"geometry_sha256"`
ProtocolSHA256 string `json:"protocol_sha256"`
Projection Projection `json:"projection"`
CRSPolicy string `json:"crs_policy"`
OriginalRawEOOKM2 *float64 `json:"original_raw_eoo_km2"`
OriginalStatus string `json:"original_eoo_status"`
Status string `json:"status"`
HullVertexGroups int `json:"hull_vertex_groups"`
EvaluatedGroups int `json:"evaluated_groups"`
RankingComplete bool `json:"ranking_complete"`
Groups []InfluenceGroup `json:"groups"`
RecomputeProjection bool `json:"recompute_projection"`
Note string `json:"note"`
}
EOOInfluence reports how much raw EOO depends on each hull vertex. It is a sensitivity diagnostic: it never classifies a record as an error and never excludes records. The AOO floor is not applied to any value here.
func AnalyzeEOOInfluence ¶ added in v0.2.0
func AnalyzeEOOInfluence(ctx context.Context, points []Point, config Config, ic InfluenceConfig) (EOOInfluence, error)
AnalyzeEOOInfluence computes the original hull, freezes its complete analysis CRS and removes each hull-vertex coordinate group in turn, rebuilding the hull from all remaining points (interior points may become vertices). Groups are ordered by relative reduction, largest first; groups whose removal leaves no valid hull come first because they have no numeric delta. Remaining ties are broken by longitude then latitude.
type EOOResult ¶
type EOOResult struct {
RawAreaKM2 *float64 `json:"raw_area_km2"`
AssessmentAreaKM2 float64 `json:"assessment_area_km2"`
Status string `json:"status"`
AdjustedToAOO bool `json:"adjusted_to_aoo"`
Method string `json:"method"`
GeodesicAreaKM2 *float64 `json:"geodesic_area_km2"`
HullWKT string `json:"hull_wkt,omitempty"`
}
EOOResult contains raw convex-hull EOO and the assessment value after the explicit rule that assessment EOO must not be smaller than AOO.
Method names the hull construction and area measurement behind RawAreaKM2. GeodesicAreaKM2 is a diagnostic: the same hull vertices, transformed back to WGS84 and joined by ellipsoidal geodesics. It is a different polygon from the planar hull and is never used for the assessment value.
type ExcludedRecord ¶ added in v0.2.0
type ExcludedRecord struct {
InputIndex int `json:"input_index"`
RecordID string `json:"record_id,omitempty"`
Lon float64 `json:"lon"`
Lat float64 `json:"lat"`
Justification string `json:"justification"`
Record Point `json:"record"`
}
ExcludedRecord documents one record removed by a manifest decision.
type Extent ¶ added in v0.2.0
type Extent struct {
LonSpanDeg float64 `json:"lon_span_deg"`
LatSpanDeg float64 `json:"lat_span_deg"`
}
Extent is the angular extent of the unique WGS84 points. The longitude span is the shortest arc covering every point, so it is correct across ±180.
type InfluenceConfig ¶ added in v0.2.0
type InfluenceConfig struct {
// MaxCandidates limits how many hull-vertex groups are evaluated, in
// longitude/latitude order. Zero selects 1000. When more vertices exist
// the report is partial and its ranking is not global.
MaxCandidates int `json:"max_candidates,omitempty"`
// TopK limits how many evaluated groups are listed. Zero lists all.
TopK int `json:"top_k,omitempty"`
// RecomputeProjection additionally recalculates raw EOO for each removal
// with a freshly chosen automatic local-laea centre, to separate geometric
// influence from the effect of moving the projection centre.
RecomputeProjection bool `json:"recompute_projection,omitempty"`
}
InfluenceConfig bounds an EOO influence analysis.
type InfluenceGroup ¶ added in v0.2.0
type InfluenceGroup struct {
Longitude float64 `json:"lon"`
Latitude float64 `json:"lat"`
X float64 `json:"x_m"`
Y float64 `json:"y_m"`
InputIndices []int `json:"input_indices"`
RecordIDs []string `json:"record_ids"`
// RawEOOWithoutKM2 is the raw hull area of all remaining points in the
// frozen analysis CRS; null when the remaining hull is degenerate.
RawEOOWithoutKM2 *float64 `json:"raw_eoo_without_km2"`
StatusWithout string `json:"eoo_status_without"`
// ReductionKM2 is original raw EOO minus RawEOOWithoutKM2.
ReductionKM2 *float64 `json:"reduction_km2"`
RelativeReductionPct *float64 `json:"relative_reduction_percent"`
RecomputedRawEOOKM2 *float64 `json:"recomputed_projection_raw_eoo_km2,omitempty"`
RecomputedStatus string `json:"recomputed_projection_status,omitempty"`
RecomputedProjectionErr string `json:"recomputed_projection_error,omitempty"`
}
InfluenceGroup is one unique coordinate that is a vertex of the original hull, removed as a geometric unit together with every record at it.
type Point ¶
type Point struct {
X float64 `json:"lon"`
Y float64 `json:"lat"`
ID string `json:"id,omitempty"`
Taxon string `json:"taxon,omitempty"`
Properties map[string]any `json:"properties,omitempty"`
}
Point is one occurrence record. X/Y use traditional GIS axis order: longitude/easting and latitude/northing. JSON uses the canonical public field names lon/lat. Properties are retained for provenance; records at identical coordinates are merged only geometrically, never discarded.
type Projection ¶
type Projection struct {
Strategy string `json:"strategy"`
Reference string `json:"reference"`
InputCRS string `json:"input_crs"`
InputWKT string `json:"input_wkt"`
AnalysisPROJ string `json:"analysis_proj"`
AnalysisWKT string `json:"analysis_wkt"`
Center [2]float64 `json:"center_lon_lat"`
CenterMethod string `json:"center_method"`
MaxAngularDistanceDeg float64 `json:"max_angular_distance_deg"`
AxisOrder string `json:"axis_order"`
}
Projection records the effective input and analysis CRS definitions and the information needed to reproduce the projection choice.
type ProjectionComparison ¶
type ProjectionComparison struct {
SchemaVersion string `json:"schema_version"`
SoftwareVersion string `json:"software_version"`
InputSHA256 string `json:"input_sha256"`
LocalLAEA Result `json:"local_laea"`
IUCNCEA Result `json:"iucn_cea"`
Delta ProjectionDelta `json:"delta_iucn_cea_minus_local_laea"`
Warnings []ComparisonWarning `json:"warnings"`
Note string `json:"note"`
}
ProjectionComparison contains summary results for both supported projection strategies plus their signed differences. It exposes projection sensitivity; it does not select a universally preferred strategy. Warnings flag when the two AOO values were not obtained with the same search coverage, in which case the AOO delta mixes projection with grid-search effects.
func CompareProjections ¶
func CompareProjections(ctx context.Context, points []Point, config Config) (ProjectionComparison, error)
CompareProjections runs the same normalized records and grid configuration through the local LAEA and IUCN-compatible World Cylindrical Equal Area strategies. The delta is always iucn-cea minus local-laea.
type ProjectionDelta ¶
type ProjectionDelta struct {
EOORawKM2 *float64 `json:"eoo_raw_km2"`
EOORawPercent *float64 `json:"eoo_raw_percent"`
EOOAssessmentKM2 float64 `json:"eoo_assessment_km2"`
EOOAssessmentPercent *float64 `json:"eoo_assessment_percent"`
AOOKM2 float64 `json:"aoo_km2"`
AOOPercent *float64 `json:"aoo_percent"`
AOOOccupiedCells int `json:"aoo_occupied_cells"`
}
ProjectionDelta reports iucn-cea minus local-laea differences for the same normalized records and grid configuration. Percentage fields are nil when a baseline is zero or the corresponding raw EOO is unavailable.
type ProtocolEnvironment ¶ added in v0.2.0
type ProtocolEnvironment struct {
SoftwareVersion string `json:"software_version"`
GDALVersion string `json:"gdal_version"`
PROJVersion string `json:"proj_version"`
}
ProtocolEnvironment records the native stack that produced a result. It is reported but excluded from the protocol hash: a protocol fixes method and parameters, while bit-identical output across native versions is not promised.
type Result ¶
type Result struct {
SchemaVersion string `json:"schema_version"`
SoftwareVersion string `json:"software_version"`
GDALVersion string `json:"gdal_version"`
PROJVersion string `json:"proj_version"`
Taxon string `json:"taxon,omitempty"`
Build *BuildInfo `json:"build,omitempty"`
InputSHA256 string `json:"input_sha256"`
GeometrySHA256 string `json:"geometry_sha256"`
ProtocolSHA256 string `json:"protocol_sha256"`
InputRecords int `json:"input_records"`
UniqueCoordinates int `json:"unique_coordinates"`
DuplicateRecords int `json:"duplicate_records"`
Config Config `json:"config"`
Projection Projection `json:"projection"`
Extent Extent `json:"wgs84_extent"`
EOO EOOResult `json:"eoo"`
AOO AOOResult `json:"aoo"`
Warnings []string `json:"warnings"`
// Protocol freezes the effective parameters for temporal reproduction.
Protocol *AnalysisProtocol `json:"protocol,omitempty"`
Cells []Cell `json:"cells,omitempty"`
Points []UsedPoint `json:"points,omitempty"`
}
Result is the reproducible calculation record returned by Calculate. InputSHA256 hashes the ordered records with their metadata; GeometrySHA256 hashes only the sorted unique normalized coordinates; ProtocolSHA256 hashes the effective method and parameters (see AnalysisProtocol). Cells and Points are omitted by Summary and by default CLI/API responses.
func Calculate ¶
Calculate accepts exactly one assessment unit (taxon). Context cancellation is checked between transforms and inside the grid search. All input is strict: no silent dropping, imputing missing coordinates to zero, or auto-swapping axes.
Example ¶
package main
import (
"context"
"fmt"
eooaoo "github.com/lsbjordao/go-iucn-eoo-aoo"
)
func main() {
points := []eooaoo.Point{
{X: -43.2, Y: -22.9, ID: "demo-001", Taxon: "Mimosa demonstrativa"},
}
result, err := eooaoo.Calculate(context.Background(), points, eooaoo.Config{})
if err != nil {
panic(err)
}
fmt.Println(result.AOO.AreaKM2)
fmt.Println(result.EOO.RawAreaKM2 == nil)
}
Output: 4 true
func CalculateWithProtocol ¶ added in v0.2.0
func CalculateWithProtocol(ctx context.Context, points []Point, p AnalysisProtocol, c Config) (Result, error)
CalculateWithProtocol reproduces a frozen protocol on a (possibly changed) record set. Differences in software, GDAL or PROJ versions are reported as a warning, not hidden; identical output across native versions is not promised.
type UsedPoint ¶
type UsedPoint struct {
Longitude float64 `json:"lon"`
Latitude float64 `json:"lat"`
X float64 `json:"x_m"`
Y float64 `json:"y_m"`
// InputIndices are zero-based positions in the input slice.
InputIndices []int `json:"input_indices"`
Records []Point `json:"records"`
}
UsedPoint is one unique normalized WGS84 coordinate together with its analysis-plane coordinate and complete source-record provenance.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
eoo-aoo
command
|
|
|
examples
|
|
|
library
command
|
|
|
internal
|
|
|
input
Package input reads strict coordinate tables and WGS84 point GeoJSON.
|
Package input reads strict coordinate tables and WGS84 point GeoJSON. |
|
server
Package server exposes a bounded, stateless HTTP interface for local stacks.
|
Package server exposes a bounded, stateless HTTP interface for local stacks. |