Skip to content

Commit

Permalink
first demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMascolo committed Jun 2, 2024
1 parent 2fe57d3 commit a3c2a2b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 369 deletions.
1 change: 1 addition & 0 deletions gis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ readme = "README.md"

[dependencies]
krabmaga = {path="/home/tirocinio/krABMaga"}
rand = "0.8"

[features]
visualization = ["krabmaga/visualization"]
Expand Down
69 changes: 8 additions & 61 deletions gis/maps/map.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,17 @@
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
5.0,
25.0
],
[
25.0,
25.0
]
],
"type": "LineString"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
25.0,
25.0
],
[
25.0,
5.0
]
],
"type": "LineString"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
25.0,
5.0
],
[
5.0,
5.0
]
],
"type": "LineString"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
5.0,
5.0
],
[
5.0,
25.0
[5.0, 25.0],
[25.0, 25.0],
[25.0, 5.0],
[5.0, 5.0],
[5.0, 25.0]
]
],
"type": "LineString"
]
}
}

]
}
}
2 changes: 1 addition & 1 deletion gis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
Visualization::default()
.with_window_dimensions(400., 400.)
.with_simulation_dimensions(dim.0 as f32, dim.1 as f32)
.with_background_color(Color::NONE)
.with_background_color(Color::WHITE)
.with_name("Gis")
.start::<MapVis, Map>(MapVis, state);
}
16 changes: 5 additions & 11 deletions gis/src/model/map.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use super::person::Person;
use crate::model::person::{Direction, Person};
use krabmaga::engine::fields::dense_number_grid_2d::DenseNumberGrid2D;
use krabmaga::engine::fields::field::Field;
use krabmaga::engine::fields::field_2d::Field2D;
use krabmaga::engine::location::{Int2D, Real2D};
use krabmaga::engine::{schedule::Schedule, state::State};

pub struct Map {
pub step: u64,
pub field: Field2D<Person>,
Expand All @@ -26,13 +25,10 @@ impl Map {
}
}

pub fn gis_value(&self, loc: Real2D) -> i32 {
pub fn gis_value(&self, loc: Int2D) -> i32 {
return self
.gis_field
.get_value(&Int2D {
x: loc.x as i32,
y: loc.y as i32,
})
.get_value(&Int2D { x: loc.x, y: loc.y })
.unwrap();
}
}
Expand Down Expand Up @@ -72,13 +68,11 @@ impl State for Map {
}

fn set_gis(&mut self, vec: Vec<i32>, schedule: &mut Schedule) {
let loc = Real2D { x: 15., y: 25. };
let loc = Real2D { x: 10., y: 10. };
let agent = Person {
id: 0 as u32,
loc,
dir_x: 1.0,
dir_y: 1.0,
direction: None,
direction: Some(Direction::Right),
};
self.people.push(agent.clone());
self.field.set_object_location(agent, loc);
Expand Down
Loading

0 comments on commit a3c2a2b

Please sign in to comment.