|
@@ -78,7 +78,7 @@ discard block |
|
|
block discarded – undo |
|
78
|
78
|
// Try simple direct match before doing anything more complex! |
|
79
|
79
|
$candidatePaths = $this->buildDirectTransformationPathsToCRS($source, $target); |
|
80
|
80
|
|
|
81
|
|
- usort($candidatePaths, static function (array $a, array $b) { |
|
|
81
|
+ usort($candidatePaths, static function(array $a, array $b) { |
|
82
|
82
|
return count($a['path']) <=> count($b['path']) ?: $a['accuracy'] <=> $b['accuracy']; |
|
83
|
83
|
}); |
|
84
|
84
|
|
|
@@ -91,7 +91,7 @@ discard block |
|
|
block discarded – undo |
|
91
|
91
|
// Otherwise, recursively calculate permutations of intermediate CRSs |
|
92
|
92
|
$candidatePaths = $this->buildIndirectTransformationPathsToCRS($source, $target); |
|
93
|
93
|
|
|
94
|
|
- usort($candidatePaths, static function (array $a, array $b) { |
|
|
94
|
+ usort($candidatePaths, static function(array $a, array $b) { |
|
95
|
95
|
return count($a['path']) <=> count($b['path']) ?: $a['accuracy'] <=> $b['accuracy']; |
|
96
|
96
|
}); |
|
97
|
97
|
|
|
@@ -163,7 +163,7 @@ discard block |
|
|
block discarded – undo |
|
163
|
163
|
*/ |
|
164
|
164
|
protected function buildDirectTransformationPathsToCRS(CoordinateReferenceSystem $source, CoordinateReferenceSystem $target): array |
|
165
|
165
|
{ |
|
166
|
|
- $cacheKey = $source->getSRID() . '|' . $target->getSRID(); |
|
|
166
|
+ $cacheKey = $source->getSRID().'|'.$target->getSRID(); |
|
167
|
167
|
if (!isset(self::$directTransformationPathCache[$cacheKey])) { |
|
168
|
168
|
$simplePaths = [[$source->getSRID(), $target->getSRID()]]; |
|
169
|
169
|
|
|
@@ -192,7 +192,7 @@ discard block |
|
|
block discarded – undo |
|
192
|
192
|
return []; |
|
193
|
193
|
} |
|
194
|
194
|
|
|
195
|
|
- $cacheKey = $sourceSRID . '|' . $targetSRID; |
|
|
195
|
+ $cacheKey = $sourceSRID.'|'.$targetSRID; |
|
196
|
196
|
if (!isset(self::$indirectTransformationPathCache[$cacheKey])) { |
|
197
|
197
|
$visited = []; |
|
198
|
198
|
foreach (CoordinateReferenceSystem::getSupportedSRIDs() as $crs => $name) { |
|
@@ -219,7 +219,7 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
} |
|
220
|
220
|
|
|
221
|
221
|
// Filter out any incomplete chains didn't make it to the target |
|
222
|
|
- $simplePaths = array_filter($simplePaths, static function (array $simplePath) use ($targetSRID) { |
|
|
222
|
+ $simplePaths = array_filter($simplePaths, static function(array $simplePath) use ($targetSRID) { |
|
223
|
223
|
return end($simplePath) === $targetSRID; |
|
224
|
224
|
}); |
|
225
|
225
|
|
|
@@ -247,7 +247,7 @@ discard block |
|
|
block discarded – undo |
|
247
|
247
|
do { |
|
248
|
248
|
$to = array_shift($simplePath); |
|
249
|
249
|
$wipTransformationsInPath = []; |
|
250
|
|
- foreach (static::$transformationsByCRSPair[$from . '|' . $to] ?? [] as $transformation) { |
|
|
250
|
+ foreach (static::$transformationsByCRSPair[$from.'|'.$to] ?? [] as $transformation) { |
|
251
|
251
|
foreach ($transformationsToMakePath as $transformationToMakePath) { |
|
252
|
252
|
$wipTransformationsInPath[] = array_merge($transformationToMakePath, [$transformation]); |
|
253
|
253
|
} |
|
@@ -327,13 +327,13 @@ discard block |
|
|
block discarded – undo |
|
327
|
327
|
{ |
|
328
|
328
|
if (!static::$transformationsByCRSPair) { |
|
329
|
329
|
foreach (CRSTransformations::getSupportedTransformations() as $key => $transformation) { |
|
330
|
|
- if (!isset(static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key])) { |
|
331
|
|
- static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key] = $transformation; |
|
332
|
|
- static::$transformationsByCRSPair[$transformation['source_crs'] . '|' . $transformation['target_crs']][$key]['in_reverse'] = false; |
|
|
330
|
+ if (!isset(static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key])) { |
|
|
331
|
+ static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key] = $transformation; |
|
|
332
|
+ static::$transformationsByCRSPair[$transformation['source_crs'].'|'.$transformation['target_crs']][$key]['in_reverse'] = false; |
|
333
|
333
|
} |
|
334
|
|
- if ($transformation['reversible'] && !isset(static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key])) { |
|
335
|
|
- static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key] = $transformation; |
|
336
|
|
- static::$transformationsByCRSPair[$transformation['target_crs'] . '|' . $transformation['source_crs']][$key]['in_reverse'] = true; |
|
|
334
|
+ if ($transformation['reversible'] && !isset(static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key])) { |
|
|
335
|
+ static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key] = $transformation; |
|
|
336
|
+ static::$transformationsByCRSPair[$transformation['target_crs'].'|'.$transformation['source_crs']][$key]['in_reverse'] = true; |
|
337
|
337
|
} |
|
338
|
338
|
} |
|
339
|
339
|
} |