From 263c2d6a3c289c5d0763d88ad98e9ae9c27fcb23 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 8 Sep 2019 11:00:14 +0200 Subject: [PATCH 1/6] Geodata (#291) * added geographic data to burgs CSV export * fixed projection problems in export added cell -> geojson export added a QGIS example style * adding routes data * adding river data * added PHP script to add random details to cells. --- .DS_Store | Bin 0 -> 8196 bytes .gitignore | 2 + QGIS/Style_Biomes.qml | 361 ++++++++++++++++++++++++++++++++++++ QGIS/add_random_points.php | 81 ++++++++ index.html | 215 ++++++++++----------- main.js | 48 ++--- maps/template_continent.txt | 11 ++ maps/template_squarish.txt | 14 ++ maps/template_vertical.txt | 13 ++ modules/save-and-load.js | 254 ++++++++++++++++++++----- modules/ui/burgs-editor.js | 12 +- modules/ui/options.js | 45 ++--- 12 files changed, 857 insertions(+), 199 deletions(-) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 QGIS/Style_Biomes.qml create mode 100644 QGIS/add_random_points.php create mode 100644 maps/template_continent.txt create mode 100644 maps/template_squarish.txt create mode 100644 maps/template_vertical.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0ac2ceb7804bead0e6c021d1da8b030e1a009ab5 GIT binary patch literal 8196 zcmZQzU|@7AO)+F(kYHe7;9!8z0^AH(0Z1N%F(jFwA_5@u7#IW?7*ZLElgf(=l5+Bs zpmL+sXb6mkz-S1JhQMeDjE2DA3IRrlb2xC+`w-btax?@+LtsRP0H}OWfVAxy9H4Xq zga%15FfuTJy8w&~3@oq!Vg&aC7(j9$tsokt6-0xyGBAQzU^Bp485p5j8NuBUkUmgv z0z`wgGcbZ}2Jyk#85qGfGcYhhv@F<_1{k?735?VmlzmaXJle#VP#|I;Nalq;N^%7&d4thE=epYEp|#Q ziU#ol5=%0YpzM(R{2VwtF)1uFwLD%x#5q5&Br!8DwFsmadA%@REQD1=K^I;b8Ea22#z)+0lb#{hahJ1z;hEj$c zw3I)*q8`nkXraKu5Xj)p;K>k-G;%k*{15jbn$I~H${8{lvKcZNQWz2$N*EH6LSUF> z0SvF^q#Fh&=jRqcN)9lIp(Z!q#RWQ)%MnwNomSR&&=EXdj23LU`6)!HE65;hCt4JN z9X3kPCIpxv#!7(t|E>%SxW@k>sz%At5Eu=CVHpC9EH1$=PSBPxHXnle+Mxb)0#p*z z2M2Y>8A1JWh(3@KP}d&Z9cP40DuPurGBAL&g5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 2 + diff --git a/QGIS/add_random_points.php b/QGIS/add_random_points.php new file mode 100644 index 00000000..46452498 --- /dev/null +++ b/QGIS/add_random_points.php @@ -0,0 +1,81 @@ +\n" ); +} + +// FIXME: This script created a few cases of self-intersection that must be fixed manually +// in QGIS: Vector -> Geometry Tools -> Check Validity + +$cells = json_decode(file_get_contents($argv[1]), true); + + +for ($i=0; $i<$iterations; $i++) { + $lookup = array(); + + foreach ($cells['features'] as &$cell) { + $points = $cell['geometry']['coordinates'][0]; + + $prev = null; + $newpoints = array(); + + foreach ($points as $point) { + if ($prev) { + $distance = sqrt(pow($prev[0] - $point[0], 2) + pow($prev[1] - $point[1], 2)); + if ($distance == 0) continue; + + if ($distance > $min_distance) { + $id_a = $prev[0]."-".$prev[1]; + $id_b = $point[0]."-".$point[1]; + + if (isset($lookup[$id_a."--".$id_b])) { + $newpoints[] = $lookup[$id_a."--".$id_b]; + } elseif (isset($lookup[$id_b."--".$id_a])) { + $newpoints[] = $lookup[$id_b."--".$id_a]; + } else { + $x = ($prev[0]+$point[0])/2.0; + $y = ($prev[1]+$point[1])/2.0; + + $r = mt_rand() / mt_getrandmax(); // 0-1 + $r = ($r+1) / 2; // 0.5 - 1.0 + + // if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx). + $dx = $point[0] - $x; + $dy = $point[1] - $y; + + if (mt_rand() / mt_getrandmax() < 0.5) { + $x_off = -$dy; + $y_off = $dx; + } else { + $x_off = $dy; + $y_off = -$dx; + } + + $x_off *= $r * $max_deviation; + $x_off = max(min($x_off, $max_abs), $max_abs*-1); + + $y_off *= $r * $max_deviation; + $y_off = max(min($y_off, $max_abs), $max_abs*-1); + + $p = array($x + $x_off, $y + $y_off); + $lookup[$id_a."--".$id_b] = $p; + $newpoints[] = $p; + } + } + } + $newpoints[] = $point; + $prev = $point; + } + $cell['geometry']['coordinates'][0] = $newpoints; + } +} + +echo json_encode($cells, JSON_PRETTY_PRINT); + +?> diff --git a/index.html b/index.html index 253e1e0f..02ae3577 100644 --- a/index.html +++ b/index.html @@ -172,7 +172,7 @@ - + @@ -254,50 +254,50 @@ - + - + - + - + - + - + - + - + - + @@ -306,7 +306,7 @@ - + @@ -315,7 +315,7 @@ - + @@ -324,7 +324,7 @@ - + @@ -342,7 +342,7 @@ - + @@ -351,7 +351,7 @@ - + @@ -359,37 +359,37 @@ - + - + - + - + - + - + @@ -421,7 +421,7 @@ - + @@ -429,23 +429,23 @@ - + - + - + - + @@ -455,7 +455,7 @@ - + @@ -463,14 +463,14 @@ - + - + @@ -479,26 +479,26 @@ - + - + - + - + @@ -506,25 +506,25 @@ - + - + - + - + @@ -532,13 +532,13 @@ - + - + @@ -549,7 +549,7 @@ - + @@ -557,7 +557,7 @@ - + @@ -565,7 +565,7 @@ - + @@ -575,7 +575,7 @@ - + @@ -585,7 +585,7 @@ - + @@ -595,7 +595,7 @@ - + @@ -613,7 +613,7 @@ - + @@ -622,7 +622,7 @@ - + @@ -630,44 +630,44 @@ - + - + - + - + - + - + - + @@ -685,14 +685,14 @@ - + - + @@ -703,24 +703,24 @@ - + - + - + - + @@ -730,7 +730,7 @@ - + @@ -738,14 +738,14 @@ - + - + @@ -754,20 +754,20 @@ - + - + - + @@ -976,7 +976,7 @@ - + @@ -1049,7 +1049,7 @@ #0000ff - + - + - + - + - - + + - + @@ -1159,7 +1159,7 @@ - + - + - + @@ -1217,7 +1217,7 @@ 1 - + - + @@ -1342,7 +1342,7 @@ 0.3 - + - + @@ -1387,7 +1387,7 @@ 5 - + - + @@ -1448,7 +1448,7 @@ - + @@ -1499,7 +1499,7 @@ - + @@ -1546,7 +1546,7 @@ - +
Please ensure the element is toggled on!Please ensure the element is toggled on!
Urban color @@ -1087,7 +1087,7 @@
Shift by axes @@ -1114,7 +1114,7 @@
Ocean layers @@ -1129,7 +1129,7 @@
Background @@ -1144,10 +1144,10 @@ #53679f
Type
Size @@ -1188,7 +1188,7 @@ .25
Shift by axes @@ -1197,7 +1197,7 @@
Style
Density @@ -1236,7 +1236,7 @@
Stroke
Labels size @@ -1359,7 +1359,7 @@
Color scheme
Simplify line @@ -1407,7 +1407,7 @@
Filter
@@ -1701,7 +1701,7 @@
- + @@ -1814,12 +1814,12 @@

Join our Discord server and Reddit community to ask questions, get help and share created maps. You may support the project on Patreon.

The project is under active development. For older versions see the changelog. To track the development progress see the devboard. Please report bugs here. You can also contact me directly via email.

A special thanks to all supporters!

-

Supporters: Aaron Meyer, Ahmad Amerih, AstralJacks, aymeric, Billy Dean Goehring, Branndon Edwards, - Chase Mayers, Curt Flood, cyninge, Dino Princip, E.M. White, es, Fondue, Fritjof Olsson, Gatsu, Johan Fröberg, Jonathan Moore, - Joseph Miranda, Kate, KC138, Luke Nelson, Markus Finster, Massimo Vella, Mikey, Nathan Mitchell, Paavi1, Pat, Ryan Westcott, - Sasquatch, Shawn Spencer, Sizz_TV, Timothée CALLET, UTG community, Vlad Tomash, Wil Sisney, William Merriott, Xariun, - Gun Metal Games, Scott Marner, Spencer Sherman, Valerii Matskevych, Alloyed Clavicle, Stewart Walsh, Ruthlyn Mollett (Javan), - Benjamin Mair-Pratt, Diagonath, Alexander Thomas, Ashley Wilson-Savoury, William Henry, Preston Brooks, JOSHUA QUALTIERI, +

Supporters: Aaron Meyer, Ahmad Amerih, AstralJacks, aymeric, Billy Dean Goehring, Branndon Edwards, + Chase Mayers, Curt Flood, cyninge, Dino Princip, E.M. White, es, Fondue, Fritjof Olsson, Gatsu, Johan Fröberg, Jonathan Moore, + Joseph Miranda, Kate, KC138, Luke Nelson, Markus Finster, Massimo Vella, Mikey, Nathan Mitchell, Paavi1, Pat, Ryan Westcott, + Sasquatch, Shawn Spencer, Sizz_TV, Timothée CALLET, UTG community, Vlad Tomash, Wil Sisney, William Merriott, Xariun, + Gun Metal Games, Scott Marner, Spencer Sherman, Valerii Matskevych, Alloyed Clavicle, Stewart Walsh, Ruthlyn Mollett (Javan), + Benjamin Mair-Pratt, Diagonath, Alexander Thomas, Ashley Wilson-Savoury, William Henry, Preston Brooks, JOSHUA QUALTIERI, Hilton Williams, Katharina Haase, Hisham Bedri, Ian arless, Karnat, Bird, Kevin and many others!