Crates.io | arcgis_rust |
lib.rs | arcgis_rust |
version | 0.1.2 |
source | src |
created_at | 2024-05-30 22:16:33.680135 |
updated_at | 2024-06-01 02:22:12.35202 |
description | A Rust-based geospatial intelligence library inspired by ArcGIS Runtime. |
homepage | https://github.com/dfridkin/arcGIS-Rust-runtime/ |
repository | https://github.com/dfridkin/arcGIS-Rust-runtime/ |
max_upload_size | |
id | 1257312 |
size | 90,748 |
🗺️ _~^~^~_ 🔧
\) / o o \ (/
'_ - _'
/ '-----' \
NOTE: This Runtime is still under development, please report any bugs or issues to help us make this runtime more reliable!
Welcome to ArcGIS Rust! This project is a Rust-based geospatial intelligence library inspired by ArcGIS Runtime. It provides core geospatial types, rendering capabilities, and task execution for geoprocessing and locator tasks.
This project aims to provide a comprehensive geospatial intelligence library in Rust. It includes:
wgpu
reqwest
To use this library in your project, add the following to your Cargo.toml
:
[dependencies]
arcgis_rust = { git = "https://github.com/dfridkin/arcgis-rust-runtime.git" }
geo = "0.23.0"
wgpu = "0.12.0"
winit = "0.26.0"
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Examples
Creating and Using Geospatial Types
use arcgis_rust::core::geometry::*;
use geo::point;
fn main() {
let point = point!(x: 1.0, y: 2.0);
println!("Point: {:?}", point);
let envelope = Envelope {
min: point!(x: 0.0, y: 0.0),
max: point!(x: 10.0, y: 10.0),
};
let point_inside = point!(x: 5.0, y: 5.0);
let point_outside = point!(x: 15.0, y: 15.0);
println!("Point inside: {}", envelope.contains(&point_inside));
println!("Point outside: {}", envelope.contains(&point_outside));
}
Executing a Geoprocessing Task
use arcgis_rust::tasks::geoprocessing::GeoprocessingTask;
use tokio;
#[tokio::main]
async fn main() {
let geoprocessing_task = GeoprocessingTask {
url: "https://example.com/arcgis/rest/services/GP/Service".to_string(),
};
match geoprocessing_task.execute("parameters").await {
Ok(result) => println!("Geoprocessing result: {}", result),
Err(e) => println!("Error: {}", e),
}
}
Core Module
Point
Represents a 2D point with x and y coordinates.
#[derive(Debug, Clone)]
pub struct Point {
pub x: f64,
pub y: f64,
}
Envelope
Represents a rectangular envelope defined by its minimum and maximum coordinates.
#[derive(Debug, Clone)]
pub struct Envelope {
pub min: Point<f64>,
pub max: Point<f64>,
pub fn contains(&self, point: &Point<f64>) -> bool;
}
Intersection
Calculate the intersection of two geometries.
use arcgis_rust::core::geometry::{Polygon, run_intersection};
let poly1 = polygon![
(x: 0.0, y: 0.0),
(x: 10.0, y: 0.0),
(x: 10.0, y: 10.0),
(x: 0.0, y: 10.0),
(x: 0.0, y: 0.0)
];
let poly2 = polygon![
(x: 5.0, y: 5.0),
(x: 15.0, y: 5.0),
(x: 15.0, y: 15.0),
(x: 5.0, y: 15.0),
(x: 5.0, y: 5.0)
];
let intersection = run_intersection(&poly1, &poly2);
println!("Intersection: {:?}", intersection);
Union
Merge multiple geometries into a single geometry.
use arcgis_rust::core::geometry::{Polygon, run_union};
let poly1 = polygon![
(x: 0.0, y: 0.0),
(x: 10.0, y: 0.0),
(x: 10.0, y: 10.0),
(x: 0.0, y: 10.0),
(x: 0.0, y: 0.0)
];
let poly2 = polygon![
(x: 5.0, y: 5.0),
(x: 15.0, y: 5.0),
(x: 15.0, y: 15.0),
(x: 5.0, y: 15.0),
(x: 5.0, y: 5.0)
];
let union = run_union(&poly1, &poly2);
println!("Union: {:?}", union);
Boundaries
Retrieve the boundary of a geometry.
use arcgis_rust::core::geometry::{Polygon, calculate_boundaries};
let poly = polygon![
(x: 0.0, y: 0.0),
(x: 10.0, y: 0.0),
(x: 10.0, y: 10.0),
(x: 0.0, y: 10.0),
(x: 0.0, y: 0.0)
];
let boundaries = calculate_boundaries(&poly);
println!("Boundaries: {:?}", boundaries);
Feature
Represents a geographic feature with geometry and attributes.
#[derive(Debug, Clone)]
pub struct Feature {
pub geometry: Geometry<f64>,
pub attributes: HashMap<String, String>,
}
FeatureLayer
Manages a collection of features.
pub struct FeatureLayer {
pub features: Vec<Feature>,
pub fn query(&self, envelope: &Envelope) -> Vec<&Feature>;
}
MapView
Manages the rendering of a map view.
pub struct MapView {
pub fn new(event_loop: &EventLoop<()>) -> Self;
pub fn add_layer(&mut self, layer: Box<dyn Layer>);
pub fn render(&self);
}
Layer
Trait for defining a renderable layer.
pub trait Layer {
fn render(&self);
}
GeoprocessingTask
Executes geoprocessing tasks.
pub struct GeoprocessingTask {
pub url: String,
pub async fn execute(&self, parameters: &str) -> Result<String, reqwest::Error>;
}
LocatorTask
Executes geocoding tasks.
pub struct LocatorTask {
pub url: String,
pub async fn geocode(&self, address: &str) -> Result<Point<f64>, reqwest::Error>;
}
We welcome contributions to make this project even more awesome! To contribute, please follow these steps:
Fork the repository.
Create a new branch (git checkout -b feature-branch).
Make your changes.
Commit your changes (git commit -m 'Add new feature').
Push to the branch (git push origin feature-branch).
Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding, and may your Rust adventures be filled with joy and discovery! 🦀❤️