Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benediktschwab committed Jul 9, 2024
1 parent 75e7f60 commit 96b11c0
Show file tree
Hide file tree
Showing 49 changed files with 1,255 additions and 161 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request: {}


jobs:

build:
name: cargo build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build

test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt clippy
- name: rustfmt
run: cargo fmt --all -- --check
- name: clippy
run: cargo clippy
- name: test
run: cargo test --verbose
50 changes: 48 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
### JetBrains template
# Created by https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,macos,jetbrains+all

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

Expand Down Expand Up @@ -77,7 +80,49 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Rust template
### JetBrains+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
Expand All @@ -93,3 +138,4 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/rust,macos,jetbrains+all
24 changes: 14 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ members = [
"crates/*"
]

resolver = "2"

[workspace.package]
version = "0.0.1-alpha.1"
authors = ["Benedikt Schwab"]
version = "0.0.1-alpha.3"
authors = ["Benedikt Schwab <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/tum-gis/egml"
repository = "https://github.com/envis-space/egml"

[workspace.dependencies]
thiserror = "1.0"
tracing = "0.1.30"
tracing-subscriber = "0.3.8"
nalgebra = "0.31.1"
serde = "1.0"
quick-xml = "0.27.0"
geo = "0.23.1"
thiserror = "1.0.61"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
nalgebra = "0.33.0"
parry3d-f64 = "0.16.1"
serde = "1.0.204"
quick-xml = "0.36.0"
geo = "0.28.0"
itertools = "0.13.0"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# egml

A Rust library for processing [GML](https://www.ogc.org/standard/gml/) data.

> [!WARNING]
> The library is at an early stage of development.
## Contributing

The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.

4 changes: 2 additions & 2 deletions crates/egml-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "CLI tool for GML operations"
description = "CLI tool for processing GML data."


[dependencies]
egml = { version = "0.0.1-alpha.1", path = "../egml", registry = "custom" }
egml = { version = "0.0.1-alpha.3", path = "../egml" }

tracing = { workspace = true }
tracing-subscriber = { workspace = true }
10 changes: 10 additions & 0 deletions crates/egml-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# egml-cli

CLI tool for processing [GML](https://www.ogc.org/standard/gml/) data.

> [!WARNING]
> The library is at an early stage of development.
## Contributing

The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.
4 changes: 3 additions & 1 deletion crates/egml-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ fn main() {
let point_a = DirectPosition::new(0.0, 0.0, 0.0).unwrap();
let point_b = DirectPosition::new(1.0, 1.0, 1.0).unwrap();
let point_c = DirectPosition::new(0.0, 0.0, 2.0).unwrap();
LinearRing::new(vec![point_a, point_b, point_c]);
LinearRing::new(vec![point_a, point_b, point_c]).expect("should work");

let _test = "";
}
4 changes: 3 additions & 1 deletion crates/egml-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Core of the egml library"
description = "Core primitives and operations for processing GML data."

[dependencies]
thiserror = { workspace = true }
nalgebra = { workspace = true }
parry3d-f64 = { workspace = true }
itertools = { workspace = true }
10 changes: 10 additions & 0 deletions crates/egml-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# egml-core

Core primitives and operations for processing [GML](https://www.ogc.org/standard/gml/) data.

> [!WARNING]
> The library is at an early stage of development.
## Contributing

The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome.
13 changes: 10 additions & 3 deletions crates/egml-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
#[error("the data for key `{0}` is not available")]
#[error("Value not finite `{0}`")]
ValueNotFinite(&'static str),
#[error("the data for key `{0}` is not available")]
#[error("Not enough elements: `{0}`")]
NotEnoughElements(&'static str),
#[error("the data for key `{0}` is not available")]
#[error("Invalid number of elements: `{0}`")]
InvalidNumberOfElements(&'static str),
#[error("Must not be empty: `{0}`")]
MustNotBeEmpty(&'static str),
#[error("Contains equal elements")]
ContainsEqualElements,

#[error("Lower corner must be below upper corner: `{0}`")]
LowerCornerMustBeBelowUpperCorner(&'static str),
}
1 change: 1 addition & 0 deletions crates/egml-core/src/geometry/aggregates/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod multi_surface;
41 changes: 41 additions & 0 deletions crates/egml-core/src/geometry/aggregates/multi_surface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::error::Error;
use crate::geometry::primitives::polygon::Polygon;
use crate::{enlarge_envelopes, Envelope};

#[derive(Debug, Clone, PartialEq)]
pub struct MultiSurface {
members: Vec<Polygon>,
}

impl MultiSurface {
pub fn new(members: Vec<Polygon>) -> Result<Self, Error> {
if members.is_empty() {
return Err(Error::MustNotBeEmpty(""));
}

Ok(Self { members })
}

pub fn members(&self) -> &Vec<Polygon> {
self.members.as_ref()
}

pub fn set_members(&mut self, val: Vec<Polygon>) -> Result<(), Error> {
if val.is_empty() {
return Err(Error::MustNotBeEmpty(""));
}
self.members = val;
Ok(())
}

pub fn get_envelope(&self) -> Result<Envelope, Error> {
let envelopes: Vec<Envelope> = self
.members
.iter()
.map(|m| m.get_envelope())
.collect::<Vec<_>>();

let enlarged_envelope = enlarge_envelopes(&envelopes)?;
Ok(enlarged_envelope)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::error::Error;

#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)]
// TODO: implement ordering and comparisons
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct DirectPosition {
x: f64,
y: f64,
Expand Down Expand Up @@ -28,6 +29,10 @@ impl DirectPosition {
self.z
}

pub fn coords(&self) -> Vec<f64> {
vec![self.x, self.y, self.z]
}

pub fn set_x(&mut self, val: f64) -> Result<(), Error> {
if !val.is_finite() {
return Err(Error::ValueNotFinite("x"));
Expand All @@ -51,6 +56,17 @@ impl DirectPosition {
self.z = val;
Ok(())
}

pub const MIN: DirectPosition = DirectPosition {
x: f64::MIN,
y: f64::MIN,
z: f64::MIN,
};
pub const MAX: DirectPosition = DirectPosition {
x: f64::MAX,
y: f64::MAX,
z: f64::MAX,
};
}

impl From<DirectPosition> for nalgebra::Vector3<f64> {
Expand Down
Loading

0 comments on commit 96b11c0

Please sign in to comment.