forked from ProfessionalWiki/Maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc7e67a
commit 574093d
Showing
6 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Maps; | ||
|
||
use Maps\Elements\ImageOverlay; | ||
use Maps\Elements\WmsOverlay; | ||
use ValueParsers\GeoCoordinateParser; | ||
use ValueParsers\ParseException; | ||
use ValueParsers\StringValueParser; | ||
|
||
/** | ||
* @since 3.1 | ||
* | ||
* @licence GNU GPL v2+ | ||
* @author Jeroen De Dauw < [email protected] > | ||
*/ | ||
class ImageOverlayParser extends StringValueParser { | ||
|
||
/** | ||
* @since 3.1 | ||
* | ||
* @param string $value | ||
* | ||
* @return WmsOverlay | ||
* @throws ParseException | ||
*/ | ||
protected function stringParse( $value ) { | ||
$parameters = explode( '~', $value ); | ||
$imageParameters = explode( ':', $parameters[0], 3 ); | ||
|
||
if ( count( $imageParameters ) === 3 ) { | ||
$boundsNorthEast = $this->stringToLatLongValue( $imageParameters[0] ); | ||
$boundsSouthWest = $this->stringToLatLongValue( $imageParameters[1] ); | ||
$imageUrl = \MapsMapper::getFileUrl( $imageParameters[2] ); | ||
|
||
return new ImageOverlay( $boundsNorthEast, $boundsSouthWest, $imageUrl ); | ||
} | ||
|
||
throw new ParseException( 'Need 3 parameters for an image overlay' ); | ||
} | ||
|
||
private function stringToLatLongValue( $location ) { | ||
$parser = new GeoCoordinateParser( new \ValueParsers\ParserOptions() ); | ||
return $parser->parse( $location ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters