Permalink
Browse files

Merge pull request #3 from caveman99/master

PHP 5.3 changes, code works in PHP 5.x this way.
  • Loading branch information...
2 parents 765405d + 5242b54 commit 05b74235336ee0aa245b84ce4e9f86dc60a1ce82 @Flyingmana Flyingmana committed Jun 25, 2011
Showing with 261 additions and 255 deletions.
  1. +13 −11 src/Map.php
  2. +96 −92 src/helpers/e00.php
  3. +152 −152 src/helpers/map.php
View
@@ -59,15 +59,17 @@ class Geo_Map extends e00 {
* @param int $y image-height
* @return void
*/
- function Geo_Map($x=false,$y=false) {
- $this->e00($x,$y);
- $this->color['white'] = $this->color(255, 255, 255);
- $this->color['red'] = $this->color(255, 0, 0);
- $this->color['black'] = $this->color(0, 0, 0);
- $this->color['green'] = $this->color(178, 237, 90);
- $this->color['blue'] = $this->color(148, 208, 255);
- $this->color['grey'] = $this->color(192, 192, 192);
- $this->color['darkgrey'] = $this->color(124, 124, 124);
+ function __construct($x=false,$y=false) {
+ parent::__construct($x,$y);
+ $this->color['white'] = $this->color(255, 255, 255);
+ $this->color['red'] = $this->color(255, 0, 0);
+ $this->color['orange'] = $this->color(255, 191, 0);
+ $this->color['orangeyellow'] = $this->color(255, 239, 0);
+ $this->color['black'] = $this->color(0, 0, 0);
+ $this->color['green'] = $this->color(178, 237, 90);
+ $this->color['blue'] = $this->color(117, 130, 148);
+ $this->color['grey'] = $this->color(192, 192, 192);
+ $this->color['darkgrey'] = $this->color(124, 124, 124);
}
/**
@@ -279,9 +281,9 @@ function addGeoObjectIncrease(&$geoObject, $color='black', $radii=array(0=>2, 5=
* @return void
* @see addGeoObject()
*/
- function addGeoObjects(&$geoObjects,$color='black') {
+ function addGeoObjects(&$geoObjects,$color='black',$radius=0) {
foreach($geoObjects AS $geoObject) {
- $this->addGeoObject($geoObject,$color);
+ $this->addGeoObject($geoObject,$color,$radius);
}
}
View
@@ -1,93 +1,97 @@
-<?php
-
-/**
- * the e00 class generates maps based on arc-info files
- * it uses the map class for the image handling
- *
- * http://jan.kneschke.de/projects/
- */
-class e00 extends map {
- /**
- * draws a datafile into the image
- *
- * @param $img image-handler
- * @param $fn filename of the datafile
- * @param $col color used for drawing
- */
-
- function draw($fn, $col) {
- if (($f = fopen($fn, "r")) == false) return false;
-
- $num_records = 0;
- $ln = 0;
-
- while(0 || $line = fgets($f, 1024)) {
- $ln ++;
-
- # a node definition
- if ($num_records == 0 &&
- preg_match("#^\s+([0-9]+)\s+([-0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)#", $line, $a)) {
- $num_records = $a[7];
-
- $pl['x'] = -1;
- $pl['y'] = -1;
-
- # 2 coordinates
- } else if ($num_records &&
- preg_match("#^ *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) {
-
- # print $a[0]."<br />";
-
- if ($pl['x'] != -1 &&
- $pl['y'] != -1
- ) {
-
- $this->draw_clipped($pl['x'], $pl['y'],
- $a[1], $a[2],
- $col);
- }
-
- $num_records--;
-
- $this->draw_clipped($a[1], $a[2],
- $a[3], $a[4],
- $col);
-
- $pl["x"] = $a[3];
- $pl["y"] = $a[4];
-
- $num_records--;
-
- # 1 coordinate
- } else if ($num_records &&
- preg_match("#^ *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) {
-
- if ($pl['x'] != -1 &&
- $pl['y'] != -1
- ) {
-
- $this->draw_clipped($pl['x'], $pl['y'],
- $a[1], $a[2],
- $col);
-
- $pl["x"] = $a[1];
- $pl["y"] = $a[2];
- }
-
- $num_records--;
-
-
- # done
- } else if ($ln > 2) {
- # print "died at: ".$ln."<br />";
- break;
- } else {
- # print $line."<br />";
- }
- }
-
- fclose($f);
- }
-}
-
+<?php
+
+/**
+ * the e00 class generates maps based on arc-info files
+ * it uses the map class for the image handling
+ *
+ * http://jan.kneschke.de/projects/
+ */
+class e00 extends map {
+ /**
+ * draws a datafile into the image
+ *
+ * @param $img image-handler
+ * @param $fn filename of the datafile
+ * @param $col color used for drawing
+ */
+
+ function __construct($x=false,$y=false){
+ parent::__construct($x,$y);
+ }
+
+ function draw($fn, $col) {
+ if (($f = fopen($fn, "r")) == false) return false;
+
+ $num_records = 0;
+ $ln = 0;
+
+ while(0 || $line = fgets($f, 1024)) {
+ $ln ++;
+
+ # a node definition
+ if ($num_records == 0 &&
+ preg_match("#^\s+([0-9]+)\s+([-0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)#", $line, $a)) {
+ $num_records = $a[7];
+
+ $pl['x'] = -1;
+ $pl['y'] = -1;
+
+ # 2 coordinates
+ } else if ($num_records &&
+ preg_match("#^ *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) {
+
+ # print $a[0]."<br />";
+
+ if ($pl['x'] != -1 &&
+ $pl['y'] != -1
+ ) {
+
+ $this->draw_clipped($pl['x'], $pl['y'],
+ $a[1], $a[2],
+ $col);
+ }
+
+ $num_records--;
+
+ $this->draw_clipped($a[1], $a[2],
+ $a[3], $a[4],
+ $col);
+
+ $pl["x"] = $a[3];
+ $pl["y"] = $a[4];
+
+ $num_records--;
+
+ # 1 coordinate
+ } else if ($num_records &&
+ preg_match("#^ *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2}) *([-+]?[0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) {
+
+ if ($pl['x'] != -1 &&
+ $pl['y'] != -1
+ ) {
+
+ $this->draw_clipped($pl['x'], $pl['y'],
+ $a[1], $a[2],
+ $col);
+
+ $pl["x"] = $a[1];
+ $pl["y"] = $a[2];
+ }
+
+ $num_records--;
+
+
+ # done
+ } else if ($ln > 2) {
+ # print "died at: ".$ln."<br />";
+ break;
+ } else {
+ # print $line."<br />";
+ }
+ }
+
+ fclose($f);
+ }
+}
+
?>
Oops, something went wrong.

0 comments on commit 05b7423

Please sign in to comment.