jbelien / mapfile-php-library
PHP Library to read/write MapServer mapfiles
Fund package maintenance!
jbelien
Installs: 3 297
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 4
Open Issues: 6
Requires
- php: ^7.4 || ^8.0
- doctrine/collections: ^1.5
Requires (Dev)
- phpunit/phpunit: ^7.3 || ^8.0 || ^9.0
- squizlabs/php_codesniffer: ^3.3
- dev-master / 2.x-dev
- v2.0.8-beta
- v2.0.7-beta
- v2.0.6-beta
- v2.0.5-beta
- v2.0.4-beta
- v2.0.3-beta
- v2.0.2-beta
- v2.0.1-beta
- 2.0.0
- v2.0.0-beta
- 1.x-dev
- v1.3.2
- v1.3.1
- v1.3.0
- dev-dependabot/composer/phpstan/phpstan-1.10.50
- dev-dependabot/composer/squizlabs/php_codesniffer-3.8.0
- dev-dependabot/composer/phpunit/phpunit-9.6.15
- dev-dependabot/composer/phpstan/phpstan-strict-rules-1.5.2
This package is auto-updated.
Last update: 2024-11-30 15:51:13 UTC
README
PHP Library to read/write MapServer mapfiles.
This library is based on MapServer 7.2.0 documentation (last updated on 16 June 2017).
Installation
composer require jbelien/mapfile-php-library
Usage
Write MapFile (example)
$map = new \MapFile\Model\Map(); $map->name = 'my-mapfile'; $map->projection = 'EPSG:4326'; $map->scalebar = new \MapFile\Model\Scalebar(); $map->scalebar->units = 'kilometers'; $layer = new \MapFile\Model\Layer(); $layer->name = 'my-layer'; $layer->type = 'POLYGON'; $layer->status = 'ON'; $layer->data = 'my-shapefile'; $layer->projection = 'EPSG:4326'; $class = new \MapFile\Model\LayerClass(); $style = new \MapFile\Model\Style(); $style->color = [0, 0, 0]; $class->style->add($style); $label = new \MapFile\Model\Label(); $label->text = '[label]'; $label->color = [0, 0, 0]; $label->size = 12; $class->label->add($label); $layer->class->add($class); $map->layer->add($layer); (new \MapFile\Writer\Map($map))->save('my-mapfile.map');
Have a look at the source code to see all the available options.
Parse MapFile (example)
$map = (new \MapFile\Parser\Map())->parse('my-mapfile.map'); foreach ($map->layer as $layer) { echo $layer->name; }