-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new Lizmap\Project\Qgis\Layer\RasterLayer* classes
- Loading branch information
Showing
10 changed files
with
1,019 additions
and
26 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
89 changes: 89 additions & 0 deletions
89
lizmap/modules/lizmap/lib/Project/Qgis/Layer/RasterLayer.php
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,89 @@ | ||
<?php | ||
/** | ||
* QGIS Raster layer. | ||
* | ||
* @author 3liz | ||
* @copyright 2023 3liz | ||
* | ||
* @see http://3liz.com | ||
* | ||
* @license Mozilla Public License : http://www.mozilla.org/MPL/ | ||
*/ | ||
|
||
namespace Lizmap\Project\Qgis\Layer; | ||
|
||
use Lizmap\Project\Qgis; | ||
|
||
/** | ||
* QGIS Raster layer. | ||
* | ||
* @property string $id | ||
* @property bool $embedded | ||
* @property string $type | ||
* @property string $layername | ||
* @property Qgis\SpatialRefSys $srs | ||
* @property string $datasource | ||
* @property string $provider | ||
* @property MapLayerStyleManager $styleManager | ||
* @property null|string $shortname | ||
* @property null|string $title | ||
* @property null|string $abstract | ||
* @property null|array<string> $keywordList | ||
* @property RasterLayerPipe $pipe | ||
* @property MapLayerStyleManager $styleManager | ||
*/ | ||
class RasterLayer extends Qgis\BaseQgisObject | ||
{ | ||
/** @var array<string> The instance properties */ | ||
protected $properties = array( | ||
'id', | ||
'embedded', | ||
'type', | ||
'layername', | ||
'srs', | ||
'datasource', | ||
'provider', | ||
'styleManager', | ||
'shortname', | ||
'title', | ||
'abstract', | ||
'keywordList', | ||
'pipe', | ||
); | ||
|
||
/** @var array<string> The not null properties */ | ||
protected $mandatoryProperties = array( | ||
'id', | ||
'embedded', | ||
'type', | ||
'layername', | ||
'srs', | ||
'datasource', | ||
'provider', | ||
'styleManager', | ||
'pipe', | ||
); | ||
|
||
/** | ||
* Get map layer as key array. | ||
* | ||
* @return array | ||
*/ | ||
public function toKeyArray() | ||
{ | ||
return array( | ||
'type' => $this->type, | ||
'id' => $this->id, | ||
'name' => $this->layername, | ||
'shortname' => $this->shortname !== null ? $this->shortname : '', | ||
'title' => $this->title !== null ? $this->title : $this->layername, | ||
'abstract' => $this->abstract !== null ? $this->abstract : '', | ||
'proj4' => $this->srs->proj4, | ||
'srid' => $this->srs->srid, | ||
'authid' => $this->srs->authid, | ||
'datasource' => $this->datasource, | ||
'provider' => $this->provider, | ||
'keywords' => $this->keywordList !== null ? $this->keywordList : array(), | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
lizmap/modules/lizmap/lib/Project/Qgis/Layer/RasterLayerHueSaturation.php
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,71 @@ | ||
<?php | ||
/** | ||
* QGIS Raster layer hue saturation. | ||
* | ||
* @author 3liz | ||
* @copyright 2023 3liz | ||
* | ||
* @see http://3liz.com | ||
* | ||
* @license Mozilla Public License : http://www.mozilla.org/MPL/ | ||
*/ | ||
|
||
namespace Lizmap\Project\Qgis\Layer; | ||
|
||
use Lizmap\Project; | ||
|
||
/** | ||
* QGIS Raster layer hue saturation. | ||
* | ||
* @property int $saturation | ||
* @property int $grayscaleMode | ||
* @property bool $invertColors | ||
* @property bool $colorizeOn | ||
* @property int $colorizeRed | ||
* @property int $colorizeGreen | ||
* @property int $colorizeBlue | ||
* @property int $colorizeStrength | ||
*/ | ||
class RasterLayerHueSaturation extends Project\Qgis\BaseQgisXmlObject | ||
{ | ||
/** @var array<string> The instance properties */ | ||
protected $properties = array( | ||
'saturation', | ||
'grayscaleMode', | ||
'invertColors', | ||
'colorizeOn', | ||
'colorizeRed', | ||
'colorizeGreen', | ||
'colorizeBlue', | ||
'colorizeStrength', | ||
); | ||
|
||
/** @var array<string> The not null properties */ | ||
protected $mandatoryProperties = array( | ||
'saturation', | ||
'grayscaleMode', | ||
'invertColors', | ||
'colorizeOn', | ||
'colorizeRed', | ||
'colorizeGreen', | ||
'colorizeBlue', | ||
'colorizeStrength', | ||
); | ||
|
||
/** @var string The XML element local name */ | ||
protected static $qgisLocalName = 'huesaturation'; | ||
|
||
protected static function getAttributes($oXmlReader) | ||
{ | ||
return array( | ||
'saturation' => (int) $oXmlReader->getAttribute('saturation'), | ||
'grayscaleMode' => (int) $oXmlReader->getAttribute('grayscaleMode'), | ||
'invertColors' => filter_var($oXmlReader->getAttribute('invertColors'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), | ||
'colorizeOn' => filter_var($oXmlReader->getAttribute('colorizeOn'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), | ||
'colorizeRed' => (int) $oXmlReader->getAttribute('colorizeRed'), | ||
'colorizeGreen' => (int) $oXmlReader->getAttribute('colorizeGreen'), | ||
'colorizeBlue' => (int) $oXmlReader->getAttribute('colorizeBlue'), | ||
'colorizeStrength' => (int) $oXmlReader->getAttribute('colorizeStrength'), | ||
); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
lizmap/modules/lizmap/lib/Project/Qgis/Layer/RasterLayerPipe.php
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,68 @@ | ||
<?php | ||
/** | ||
* QGIS Raster layer pipe. | ||
* | ||
* @author 3liz | ||
* @copyright 2023 3liz | ||
* | ||
* @see http://3liz.com | ||
* | ||
* @license Mozilla Public License : http://www.mozilla.org/MPL/ | ||
*/ | ||
|
||
namespace Lizmap\Project\Qgis\Layer; | ||
|
||
use Lizmap\Project; | ||
|
||
/** | ||
* QGIS Raster layer pipe. | ||
* | ||
* @property RasterLayerRasterRenderer $renderer | ||
* @property RasterLayerHueSaturation $hueSaturation | ||
*/ | ||
class RasterLayerPipe extends Project\Qgis\BaseQgisXmlObject | ||
{ | ||
/** @var array<string> The instance properties */ | ||
protected $properties = array( | ||
'renderer', | ||
'hueSaturation', | ||
); | ||
|
||
/** @var array<string> The not null properties */ | ||
protected $mandatoryProperties = array( | ||
'renderer', | ||
'hueSaturation', | ||
); | ||
|
||
/** @var string The XML element local name */ | ||
protected static $qgisLocalName = 'pipe'; | ||
|
||
/** @var array<string> The XML element parsed children */ | ||
protected static $children = array( | ||
'rasterrenderer', | ||
'huesaturation', | ||
); | ||
|
||
protected static $childParsers = array(); | ||
|
||
protected static function buildInstance($data) | ||
{ | ||
if (array_key_exists('rasterrenderer', $data)) { | ||
$data['renderer'] = $data['rasterrenderer']; | ||
unset($data['rasterrenderer']); | ||
} | ||
|
||
if (array_key_exists('huesaturation', $data)) { | ||
$data['hueSaturation'] = $data['huesaturation']; | ||
unset($data['huesaturation']); | ||
} | ||
|
||
return new RasterLayerPipe($data); | ||
} | ||
} | ||
RasterLayerPipe::registerChildParser('rasterrenderer', function ($oXmlReader) { | ||
return RasterLayerRasterRenderer::fromXmlReader($oXmlReader); | ||
}); | ||
RasterLayerPipe::registerChildParser('huesaturation', function ($oXmlReader) { | ||
return RasterLayerHueSaturation::fromXmlReader($oXmlReader); | ||
}); |
47 changes: 47 additions & 0 deletions
47
lizmap/modules/lizmap/lib/Project/Qgis/Layer/RasterLayerRasterRenderer.php
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 | ||
/** | ||
* QGIS Raster layer raster renderer. | ||
* | ||
* @author 3liz | ||
* @copyright 2023 3liz | ||
* | ||
* @see http://3liz.com | ||
* | ||
* @license Mozilla Public License : http://www.mozilla.org/MPL/ | ||
*/ | ||
|
||
namespace Lizmap\Project\Qgis\Layer; | ||
|
||
use Lizmap\Project; | ||
|
||
/** | ||
* QGIS Raster layer raster renderer. | ||
* | ||
* @property string $type | ||
* @property float $opacity | ||
*/ | ||
class RasterLayerRasterRenderer extends Project\Qgis\BaseQgisXmlObject | ||
{ | ||
/** @var array<string> The instance properties */ | ||
protected $properties = array( | ||
'type', | ||
'opacity', | ||
); | ||
|
||
/** @var array<string> The not null properties */ | ||
protected $mandatoryProperties = array( | ||
'type', | ||
'opacity', | ||
); | ||
|
||
/** @var string The XML element local name */ | ||
protected static $qgisLocalName = 'rasterrenderer'; | ||
|
||
protected static function getAttributes($oXmlReader) | ||
{ | ||
return array( | ||
'type' => $oXmlReader->getAttribute('type'), | ||
'opacity' => (float) $oXmlReader->getAttribute('opacity'), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.