getPoints() 공개 메소드

public getPoints ( ) : array
리턴 array
예제 #1
0
 /**
  * @param float $tolerance The maximum allowed deviation
  *
  * @return Polyline
  */
 public function simplify($tolerance)
 {
     $simplifiedLine = $this->douglasPeucker($this->polyline->getPoints(), $tolerance);
     $resultPolyline = new Polyline();
     foreach ($simplifiedLine as $point) {
         $resultPolyline->addPoint($point);
     }
     return $resultPolyline;
 }
예제 #2
0
 /**
  * Simplifies the given polyline
  *
  * 1. calculate the bearing angle between the first two points p1 and p2: b1
  * 2. calculate the bearing angle between the next two points p2 and p3: b2
  * 3. calculate the difference between b1 and b2: deltaB; if deltaB is
  *    smaller than the threshold angle, remove the middle point p2
  * 4. start again at (1.) as long as the polyline contains more points
  *
  * @param Polyline $polyline
  *
  * @return Polyline
  */
 public function simplify(Polyline $polyline)
 {
     $counterPoints = $polyline->getNumberOfPoints();
     if ($counterPoints < 3) {
         return clone $polyline;
     }
     $result = new Polyline();
     $bearingCalc = new BearingEllipsoidal();
     $points = $polyline->getPoints();
     $index = 0;
     // add the first point to the resulting polyline
     $result->addPoint($points[$index]);
     do {
         $index++;
         // preserve the last point of the original polyline
         if ($index === $counterPoints - 1) {
             $result->addPoint($points[$index]);
             break;
         }
         $bearing1 = $bearingCalc->calculateBearing($points[$index - 1], $points[$index]);
         $bearing2 = $bearingCalc->calculateBearing($points[$index], $points[$index + 1]);
         $bearingDifference = min(fmod($bearing1 - $bearing2 + 360, 360), fmod($bearing2 - $bearing1 + 360, 360));
         if ($bearingDifference > $this->bearingAngle) {
             $result->addPoint($points[$index]);
         }
     } while ($index < $counterPoints);
     return $result;
 }
예제 #3
0
파일: GeoJSON.php 프로젝트: mjaschen/phpgeo
 /**
  * @param \Location\Polyline $polyline
  *
  * @return string
  */
 public function format(Polyline $polyline)
 {
     $points = [];
     foreach ($polyline->getPoints() as $point) {
         $points[] = [$point->getLng(), $point->getLat()];
     }
     return json_encode(['type' => 'LineString', 'coordinates' => $points]);
 }
예제 #4
0
파일: GeoJSON.php 프로젝트: martinsv/phpgeo
 /**
  * @param \Location\Polyline $polyline
  *
  * @return string
  */
 public function format(Polyline $polyline)
 {
     $points = array();
     foreach ($polyline->getPoints() as $point) {
         $points[] = array($point->getLng(), $point->getLat());
     }
     return json_encode(array('type' => 'LineString', 'coordinates' => $points));
 }
예제 #5
0
 public function testCreatePolyline()
 {
     $this->assertCount(4, $this->polyline->getPoints());
 }