This commit is contained in:
1 parent
13a60c8cc4
commit
518e74dfb8
3 files changed
+92
-85
No files matched your search
+9
-3
@@ -160,15 +160,21 @@ class GeoJson extends Geo {
|
||||
}
|
||||
|
||||
public function getCenter() {
|
||||
$asCoords = [];
|
||||
$iLatMin = 90;
|
||||
$iLatMax = -90;
|
||||
$iLngMin = 180;
|
||||
$iLngMax = -180;
|
||||
$asMainTracks = array_filter($this->asTracks, function ($astrack) {return $astrack['properties']['type'] == 'main';});
|
||||
foreach($asMainTracks as $asMainTrack) {
|
||||
foreach($asMainTrack['geometry']['coordinates'] as $aiCoords) {
|
||||
$asCoords[] = $aiCoords;
|
||||
if($aiCoords[1] > $iLatMax) $iLatMax = $aiCoords[1];
|
||||
if($aiCoords[1] < $iLatMin) $iLatMin = $aiCoords[1];
|
||||
if($aiCoords[0] > $iLngMax) $iLngMax = $aiCoords[0];
|
||||
if($aiCoords[0] < $iLngMin) $iLngMin = $aiCoords[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $asCoords[(int) floor(count($asCoords) / 2)];
|
||||
return ['latitude' => ($iLatMin + $iLatMax)/2, 'longitude' => ($iLngMin + $iLngMax)/2];
|
||||
}
|
||||
|
||||
private function parseOptions($sComment) {
|
||||
|
||||
+4
-3
@@ -139,9 +139,10 @@ class Project extends PhpObject {
|
||||
//Update geoJSON
|
||||
if(Converter::hasGpxFile($sCodeName) && (!Converter::isGeoJsonValid($sCodeName) || !$asProject['latitude'] && !$asProject['longitude'])) {
|
||||
$aiCenter = Converter::convertToGeoJson($sCodeName)['center'];
|
||||
$this->oDb->updateRow(self::PROJ_TABLE, $asProject['id'], ['latitude' => $aiCenter[1], 'longitude' => $aiCenter[0]]);
|
||||
$asProject['latitude'] = $aiCenter[1];
|
||||
$asProject['longitude'] = $aiCenter[0];
|
||||
$asProject['longitude'] = $aiCenter['longitude'];
|
||||
$asProject['latitude'] = $aiCenter['latitude'];
|
||||
|
||||
$this->oDb->updateRow(self::PROJ_TABLE, $asProject['id'], ['latitude' => $asProject['latitude'], 'longitude' => $asProject['longitude']]);
|
||||
}
|
||||
|
||||
switch($asProject['mode']) {
|
||||
|
||||
Reference in new issue
Block a user