|
@@ -77,7 +77,7 @@ discard block |
|
|
block discarded – undo |
|
77
|
77
|
// Try simple direct match before doing anything more complex! |
|
78
|
78
|
$candidatePaths = $this->buildDirectTransformationPathsToCRS($source, $target); |
|
79
|
79
|
|
|
80
|
|
- usort($candidatePaths, static function (array $a, array $b) { |
|
|
80
|
+ usort($candidatePaths, static function(array $a, array $b) { |
|
81
|
81
|
return count($a['path']) <=> count($b['path']) ?: $a['accuracy'] <=> $b['accuracy']; |
|
82
|
82
|
}); |
|
83
|
83
|
|
|
@@ -90,7 +90,7 @@ discard block |
|
|
block discarded – undo |
|
90
|
90
|
// Otherwise, recursively calculate permutations of intermediate CRSs |
|
91
|
91
|
$candidatePaths = $this->buildIndirectTransformationPathsToCRS($source, $target); |
|
92
|
92
|
|
|
93
|
|
- usort($candidatePaths, static function (array $a, array $b) { |
|
|
93
|
+ usort($candidatePaths, static function(array $a, array $b) { |
|
94
|
94
|
return count($a['path']) <=> count($b['path']) ?: $a['accuracy'] <=> $b['accuracy']; |
|
95
|
95
|
}); |
|
96
|
96
|
|
|
@@ -162,7 +162,7 @@ discard block |
|
|
block discarded – undo |
|
162
|
162
|
*/ |
|
163
|
163
|
protected function buildDirectTransformationPathsToCRS(CoordinateReferenceSystem $source, CoordinateReferenceSystem $target): array |
|
164
|
164
|
{ |
|
165
|
|
- $cacheKey = $source->getSRID() . '|' . $target->getSRID(); |
|
|
165
|
+ $cacheKey = $source->getSRID().'|'.$target->getSRID(); |
|
166
|
166
|
if (!isset(self::$directTransformationPathCache[$cacheKey])) { |
|
167
|
167
|
$simplePaths = [[$source->getSRID(), $target->getSRID()]]; |
|
168
|
168
|
|
|
@@ -185,7 +185,7 @@ discard block |
|
|
block discarded – undo |
|
185
|
185
|
*/ |
|
186
|
186
|
protected function buildIndirectTransformationPathsToCRS(CoordinateReferenceSystem $source, CoordinateReferenceSystem $target): array |
|
187
|
187
|
{ |
|
188
|
|
- $cacheKey = $source->getSRID() . '|' . $target->getSRID(); |
|
|
188
|
+ $cacheKey = $source->getSRID().'|'.$target->getSRID(); |
|
189
|
189
|
if (!isset(self::$indirectTransformationPathCache[$cacheKey])) { |
|
190
|
190
|
$simplePaths = []; |
|
191
|
191
|
$visited = []; |
|
@@ -239,7 +239,7 @@ discard block |
|
|
block discarded – undo |
|
239
|
239
|
do { |
|
240
|
240
|
$to = array_shift($simplePath); |
|
241
|
241
|
$wipTransformationsInPath = []; |
|
242
|
|
- foreach (static::$transformationsByCRSPair[$from . '|' . $to] ?? [] as $transformation) { |
|
|
242
|
+ foreach (static::$transformationsByCRSPair[$from.'|'.$to] ?? [] as $transformation) { |
|
243
|
243
|
foreach ($transformationsToMakePath as $transformationToMakePath) { |
|
244
|
244
|
$wipTransformationsInPath[] = array_merge($transformationToMakePath, [$transformation]); |
|
245
|
245
|
} |
|
@@ -319,13 +319,13 @@ discard block |
|
|
block discarded – undo |
|
319
|
319
|
{ |
|
320
|
320
|
if (!static::$transformationsByCRSPair) { |
|
321
|
321
|
foreach (CRSTransformations::getSupportedTransformations() as $key => $transformation) { |
|
322
|
|
- if (!isset(static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key])) { |
|
323
|
|
- static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key] = $transformation; |
|
324
|
|
- static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key]['in_reverse'] = false; |
|
|
322
|
+ if (!isset(static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key])) { |
|
|
323
|
+ static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key] = $transformation; |
|
|
324
|
+ static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key]['in_reverse'] = false; |
|
325
|
325
|
} |
|
326
|
|
- if ($transformation['reversible'] && !isset(static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key])) { |
|
327
|
|
- static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key] = $transformation; |
|
328
|
|
- static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key]['in_reverse'] = true; |
|
|
326
|
+ if ($transformation['reversible'] && !isset(static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key])) { |
|
|
327
|
+ static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key] = $transformation; |
|
|
328
|
+ static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key]['in_reverse'] = true; |
|
329
|
329
|
} |
|
330
|
330
|
} |
|
331
|
331
|
} |