|
|
@@ -637,7 +637,7 @@ class Route_ViewTableAjax extends RouteBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function getCsvTheGeomAjax() {
|
|
|
+ public function getCsvTheGeomAjax($minDistance = 10) {
|
|
|
Lib::loadClass('EpsgConversion');
|
|
|
$namespace = V::get('namespace', '', $_GET, 'word');
|
|
|
$acl = Core_AclHelper::getAclByNamespace($namespace);
|
|
|
@@ -652,15 +652,43 @@ class Route_ViewTableAjax extends RouteBase {
|
|
|
}
|
|
|
if (!preg_match('/^[[:alpha:]]+\((.*)\)$/', $result, $matches)) throw new Exception('Błąd danych georeferencyjnych');
|
|
|
$points = explode(',', $matches[1]);
|
|
|
- $csv = implode("\n", array_map(function ($point, $i) {
|
|
|
+
|
|
|
+ $calcDistance = function($x1, $y1, $x2, $y2) {
|
|
|
+ return sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
|
|
|
+ };
|
|
|
+
|
|
|
+ $lastX = null; $lastY = null;
|
|
|
+ $csv = implode("\n", array_map(function ($point, $i) use (&$lastX, &$lastY, $calcDistance, $minDistance) {
|
|
|
+ $return = '';
|
|
|
list($x, $y) = explode(" ", $point, 2);
|
|
|
$puwg2000 = EpsgConversion::Wgs84ToPuwg2000($x, $y);
|
|
|
+
|
|
|
+ if ($lastX !== null) {
|
|
|
+ if (($distance = $calcDistance($lastX, $lastY, $puwg2000->x, $puwg2000->y)) > $minDistance) {
|
|
|
+ $parts = ceil($distance / $minDistance);
|
|
|
+ $deltaX = ($puwg2000->x - $lastX) / $parts;
|
|
|
+ $deltaY = ($puwg2000->y - $lastY) / $parts;
|
|
|
+ for ($j = 1; $j < $parts; $j++) {
|
|
|
+ $partX = round($lastX + $j * $deltaX, 3);
|
|
|
+ $partY = round($lastY + $j * $deltaY, 3);
|
|
|
+ try {
|
|
|
+ $partZ = round(EpsgConversion::GetZByPuwg2000($partX, $partY), 3);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $partZ = 0;
|
|
|
+ }
|
|
|
+ $return .= ($i - 1) . ".{$j},{$partY},{$partX},{$partZ},Punkt posredni\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $lastX = $puwg2000->x; $lastY = $puwg2000->y;
|
|
|
+
|
|
|
try {
|
|
|
$z = EpsgConversion::GetZByWgs84($x, $y);
|
|
|
} catch (Exception $e) {
|
|
|
$z = 0;
|
|
|
}
|
|
|
- return $i++ . ',' . round($puwg2000->y, 3) . ',' . round($puwg2000->x, 3) . ',' . round($z, 3) . ',Punkt';
|
|
|
+ $return .= $i . ',' . round($puwg2000->y, 3) . ',' . round($puwg2000->x, 3) . ',' . round($z, 3) . ',Punkt';
|
|
|
+ return $return;
|
|
|
}, $points, range(1, count($points))));
|
|
|
Response::sendCsv($csv, "{$table}.{$id}");
|
|
|
}
|