| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- Lib::loadClass('RouteBase');
- Lib::loadClass('EpsgConversion');
- class Route_GeoreferencesManager extends RouteBase {
- protected $ACTION, $REFERER;
- const TABLE = "WMS_MAP_GEOREFERENCES";
- public function handleAuth() {
- if (!User::logged()) {
- User::authByRequest();
- }
- $this->REFERER = $_SERVER['HTTP_REFERER'];
- $this->ACTION = V::get('action', '', $_GET, '');
- }
- public function defaultAction() {
- SE_Layout::gora();
- SE_Layout::menu();
- ?>
- <div class="container" style="margin-top:20px">
- <legend>Zarządzanie punktami georeferencyjnymi</legend>
- <div class="form-group">
- <div class="col-sm-12">
- <a href="?_route=GeoreferencesManager&action=verifyPoints" class="btn-sm btn-primary">Zweryfikuj punkty</a>
- </div>
- </div>
- <?php
- switch ($this->ACTION) {
- case "verifyPoints":
- $this->verifyPoints();
- break;
- }
- ?>
- </div>
- <?php
- SE_Layout::dol();
- }
- public function reinstallAction() {
- $this->reinstall();
- die('OK');
- }
- public function reinstall() {
- }
- private function verifyPoints() {
- $points = DB::getPDO()->fetchall("select `ID`, `EPSG`, x(`the_geom`) as `gx`, y(`the_geom`) as `gy`, `x`, `y` from `" . self::TABLE . "`");
- $errors = [];
- foreach ($points as $point) {
- if ($point['x'] && $point['y']) {
- if ($point['gx'] && $point['gy']) {
- try {
- $test = epsgConversion::LatLonToPUWGWGS84($point['gx'], $point['gy']);
- } catch (Exception $e) {
- SE_Layout::alert('danger', $e->getMessage());
- }
- if ((abs($point['x'] - $test->x) > 1 ) || (abs($point['y'] - $test->y) > 1) || ($point['EPSG'] != $test->epsg)) {
- $error = "[{$point['ID']}] x = <span style='color:" . ((abs($point['x'] - $test->x) > 1) ? "red" : "green") .
- ";'>{$point['x']}</span> ({$test->x}), y = <span style='color:" . ((abs($point['y'] - $test->y) > 1) ? "red" : "green") .
- ";'>{$point['y']}</span> ({$test->y}), epsg = <span style='color:" . (($point['EPSG'] != $test->epsg) ? "red" : "green") .
- ";'>{$point['EPSG']}</span>" . (($point['EPSG'] != $test->epsg) ? " ({$test->epsg})" : "");
- $errors[] = $error;
- }
- }
- }
- }
- ?>
- <div class="form-group">
- <div class="col-sm-12"><br/>
- <?php
- //$errors = [];
- // if ($errors) echo "<pre>" . implode("<br/>", $errors) . "</pre>";
- if ($errors) {
- SE_Layout::alert('danger', "<pre>" . implode("<br/>", $errors) . "</pre>");
- ?>
- <div style="text-align:center;"><a href="?_route=GeoreferencesManager&action=repairPoints" class="btn btn-primary">Napraw wszystkie</a></div>
- <?php
- } else SE_Layout::alert('success', "Wszystko OK"); //echo "<span style='color:green;'>Wszystko OK</span>";
- ?>
- </div>
- </div>
- <?php
- }
- }
|