Skip to content

Commit

Permalink
Merge pull request #4 from TizziGri/main
Browse files Browse the repository at this point in the history
123
  • Loading branch information
TizziGri committed May 13, 2023
2 parents 6a53ee2 + bbb780a commit 711316d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 15 deletions.
Binary file added Docs/Prototyp_Entwicklung3.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 68 additions & 15 deletions prototype-1/main.js
@@ -1,4 +1,6 @@

import { BUILDINGS } from "./buildings.js";
let people = null;
const oldPerson = "https://svgsilh.com/svg/1800224.svg";
const child = "https://svgsilh.com/svg/44050.svg";
// VARIABLES
Expand Down Expand Up @@ -55,6 +57,7 @@ setTimeout(() => {
// PHASE T + One Hour
setTimeout(() => {
polygon1 = L.polygon(oneHourPolygon).addTo(map);
return
createRandomPeople(2000, rathaus).forEach((p) => {
var myIcon = L.icon({
iconUrl: p.age > 50 ? oldPerson : child,
Expand All @@ -64,12 +67,15 @@ setTimeout(() => {
shadowSize: [68, 95],
shadowAnchor: [22, 94],
});
L.marker(p.position, { icon: myIcon, title: "ALTE PERSON" }).addTo(map);
p.title = p.age < 10 ? "U10" : p.age > 70 ? "Ü70" : null;
if (!p.title) return;
L.marker(p.position, { icon: myIcon, title: p.title }).addTo(map);
});

}, T + 1000);
// PHASE T + TWO HOUR
setTimeout(() => {
L.polygon(twoHourPolygon).addTo(map);
polygon2 = L.polygon(twoHourPolygon).addTo(map);
popUp = L.popup([46.94587, 7.44254])
.setContent("IN EINER STUNDE Person über 75 Jahre")
.openOn(map);
Expand Down Expand Up @@ -99,16 +105,18 @@ Papa.parse('data/geodaten.csv', {
return
}
// koordinaten ins array hinzufügen
geodata.push(coordpair);
if (geodata.length < 100) {
L.marker(coordpair).addTo(map);
}
bro.position = coordpair;
geodata.push(bro);
// if (geodata.length < 100) {
// L.marker(coordpair).addTo(map);
//}

});

people = geodata;
//console.log(geodata);


filterPeople(twoHourPolygon)
console.log(people[12])
}
});

Expand All @@ -125,12 +133,57 @@ const getRandomBuilding = () => {
*/
const createRandomPeople = (noPeople, center) => {
console.log(noPeople, center);
const peopleArray = [];
while (peopleArray.length < noPeople) {
peopleArray.push({
age: createRandomInt(100),
position: getRandomBuilding(),
});
}
let peopleArray = [];
people.forEach((person)=> {

if (peopleArray.length < noPeople) {

person.age= createRandomInt(100);

peopleArray.push(person);
}
});

return peopleArray;
};
function filterPeople(polygonPoints) {
const geoJson = [...polygonPoints]
geoJson.push(geoJson[0])
// Erstelle ein Polygon, das den Bereich definiert, in dem die Datenpunkte angezeigt werden sollen
const polygon = turf.polygon([
[
...geoJson
]
]);

// Iteriere über die Datenpunkte und überprüfe, ob sie sich innerhalb des Polygons befinden
people.forEach(function (person) {
try{
var latLng = L.latLng(...person.position);
var point = turf.point(person.position);
if (turf.booleanPointInPolygon(point, polygon)) {
// Datenpunkt liegt innerhalb des Polygons, zeige ihn auf der Karte an
var marker = L.marker(latLng).addTo(map);
marker.bindPopup(person.name);
}
}catch(e){
console.log(e)
console.log(person)
}

});
}
const test = L.polygon(twoHourPolygon)
const t2 = [...twoHourPolygon]
t2.push(t2[0])
console.log(test)
const poly = turf.polygon([
[
...t2
]
])
console.log('qwdqwdqwd')
console.log(turf.booleanContains(poly, turf.point([46.94781, 7.44087
])))
var area = turf.area(poly);
console.log(area)

0 comments on commit 711316d

Please sign in to comment.