[Mapbender-commits] r9134 - in trunk/mapbender/http/extensions: . mapserver
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Dec 16 11:31:34 PST 2014
Author: armin11
Date: 2014-12-16 11:31:34 -0800 (Tue, 16 Dec 2014)
New Revision: 9134
Added:
trunk/mapbender/http/extensions/mapserver/
trunk/mapbender/http/extensions/mapserver/class_mapserver_layer.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_label.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_style.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_metadata.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_map.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_map_legend.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_map_metadata.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_map_outputformat.php
trunk/mapbender/http/extensions/mapserver/class_mapserver_map_web.php
Log:
New classes to allow the creation of mapserver mapfiles
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_layer.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_layer.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_layer.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,99 @@
+<?php
+class MapserverLayer
+{
+ public $name;
+ public $group;
+ public $type;
+ public $connection;
+ public $connectiontype;
+ public $data;
+ public $processing;
+ public $status;
+ public $labelitem;
+ public $minscaledenom;
+ public $maxscaledenom;
+ public $labelmaxscaledenom;
+ public $metadata;
+ public $printElements = array( "name",
+ "group",
+ "type",
+ "connection",
+ "connectiontype",
+ "data",
+ "processing",
+ "status",
+ "labelitem",
+ "minscaledenom",
+ "maxscaledenom",
+ "labelmaxscaledenom"
+ );
+
+ private $classes = array();
+
+ public function addClass($obj, $key = null) {
+ if ($key == null) {
+ $this->classes[] = $obj;
+ }
+ else {
+ if (isset($this->classes[$key])) {
+ throw new KeyHasUseException("Key $key already in use.");
+ }
+ else {
+ $this->classes[$key] = $obj;
+ }
+ }
+ }
+
+ public function deleteClass($key) {
+ if (isset($this->classes[$key])) {
+ unset($this->classes[$key]);
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function getClass($key) {
+ if (isset($this->classes[$key])) {
+ return $this->classes[$key];
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function keys() {
+ return array_keys($this->classes);
+ }
+
+ public function keyExists($key) {
+ return isset($this->classes[$key]);
+ }
+
+ public function printText() {
+ $printLayer = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printLayer = true;
+ break;
+ }
+ }
+ if ($printLayer == true) {
+ $text = "LAYER\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ if ($this->metadata != null) {
+ $text .= $this->metadata->printText();
+ }
+ foreach ($this->classes as $class) {
+ $text .= $class->printText();
+ }
+ $text .= "END\n";
+ return $text;
+ }
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,121 @@
+<?php
+class MapserverLayerClass
+{
+ public $name;
+ public $group;
+ public $groupname;
+ public $printElements = array( "name",
+ "group",
+ "groupname"
+ );
+
+ private $styles = array();
+ private $labels = array();
+
+ public function addStyle($obj, $key = null) {
+ if ($key == null) {
+ $this->styles[] = $obj;
+ }
+ else {
+ if (isset($this->styles[$key])) {
+ throw new KeyHasUseException("Key $key already in use.");
+ }
+ else {
+ $this->styles[$key] = $obj;
+ }
+ }
+ }
+
+ public function deleteStyle($key) {
+ if (isset($this->styles[$key])) {
+ unset($this->styles[$key]);
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function getStyle($key) {
+ if (isset($this->styles[$key])) {
+ return $this->styles[$key];
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function styleKeys() {
+ return array_keys($this->styles);
+ }
+
+ public function styleKeyExists($key) {
+ return isset($this->styles[$key]);
+ }
+
+ public function addLabel($obj, $key = null) {
+ if ($key == null) {
+ $this->labels[] = $obj;
+ }
+ else {
+ if (isset($this->labels[$key])) {
+ throw new KeyHasUseException("Key $key already in use.");
+ }
+ else {
+ $this->labels[$key] = $obj;
+ }
+ }
+ }
+
+ public function deleteLabel($key) {
+ if (isset($this->labels[$key])) {
+ unset($this->labels[$key]);
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function getLabel($key) {
+ if (isset($this->labels[$key])) {
+ return $this->labels[$key];
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function labelKeys() {
+ return array_keys($this->labels);
+ }
+
+ public function labelKeyExists($key) {
+ return isset($this->labels[$key]);
+ }
+
+ public function printText() {
+ $printClass = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printClass = true;
+ }
+ }
+ if ($printClass == true) {
+ $text = "CLASS\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ foreach ($this->labels as $label) {
+ $text .= $label->printText();
+ }
+ foreach ($this->styles as $style) {
+ $text .= $style->printText();
+ }
+ $text .= "END\n";
+ return $text;
+ }
+ }
+
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_label.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_label.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_label.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,43 @@
+<?php
+class MapserverLayerClassLabel
+{
+ public $partials;
+ public $encoding;
+ public $type;
+ public $font;
+ public $size;
+ public $color;
+ public $outlinecolor;
+ public $position;
+ public $mindistance;
+ public $printElements = array( "partials",
+ "encoding",
+ "type",
+ "font",
+ "size",
+ "color",
+ "outlinecolor",
+ "mindistance"
+ );
+
+ public function printText() {
+ $printLabel = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printLabel = true;
+ break;
+ }
+ }
+ if ($printLabel == true) {
+ $text = "LABEL\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= "END\n";
+ }
+ return $text;
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_style.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_style.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_class_style.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,36 @@
+<?php
+class MapserverLayerClassStyle
+{
+ public $color;
+ public $symbol;
+ public $size;
+ public $outlinecolor;
+ public $width;
+ public $printElements = array( "color",
+ "symbol",
+ "size",
+ "outlinecolor",
+ "width"
+ );
+
+ public function printText() {
+ $printStyle = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printStyle = true;
+ break;
+ }
+ }
+ if ($printStyle == true) {
+ $text = "STYLE\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= "END\n";
+ }
+ return $text;
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_metadata.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_metadata.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_layer_metadata.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,35 @@
+<?php
+class MapserverLayerMetadata
+{
+ public $ows_title;
+ public $ows_srs;
+ public $ows_abstract;
+ public $ows_keywordlist;
+ public $ows_extent;
+ public $printElements = array( "ows_title",
+ "ows_srs",
+ "ows_abstract",
+ "ows_keywordlist",
+ "ows_extent"
+ );
+
+ public function printText() {
+ $printMetadata = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printMetadata = true;
+ }
+ }
+ if ($printMetadata == true) {
+ $text = "METADATA\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= "END\n";
+ }
+ return $text;
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_map.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_map.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_map.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,145 @@
+<?php
+class MapserverMap
+{
+ public $name;
+ public $size;
+ public $units;
+ public $symbolset;
+ public $fontset;
+ public $extent;
+ public $projection; //extra
+ public $imagecolor;
+ public $imagequality;
+
+ public $outputformat = array();
+
+ public $legend; //extra
+ public $web; //extra obj
+
+ public $metadata;
+ public $layers = array();
+ public $printElements = array( "name",
+ "size",
+ "units",
+ "symbolset",
+ "fontset",
+ "extent",
+ "imagecolor",
+ "imagequality"
+
+ );
+
+ public function addLayer($obj, $key = null) {
+ if ($key == null) {
+ $this->layers[] = $obj;
+ }
+ else {
+ if (isset($this->layers[$key])) {
+ throw new KeyHasUseException("Key $key already in use.");
+ }
+ else {
+ $this->layers[$key] = $obj;
+ }
+ }
+ }
+
+ public function deleteLayer($key) {
+ if (isset($this->layers[$key])) {
+ unset($this->layers[$key]);
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function getLayer($key) {
+ if (isset($this->layers[$key])) {
+ return $this->layers[$key];
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function layerKeys() {
+ return array_keys($this->layers);
+ }
+
+ public function layerKeyExists($key) {
+ return isset($this->layers[$key]);
+ }
+
+ public function addOutputFormat($obj, $key = null) {
+ if ($key == null) {
+ $this->outputformat[] = $obj;
+ }
+ else {
+ if (isset($this->outputformat[$key])) {
+ throw new KeyHasUseException("Key $key already in use.");
+ }
+ else {
+ $this->outputformat[$key] = $obj;
+ }
+ }
+ }
+
+ public function deleteOutputFormat($key) {
+ if (isset($this->outputformat[$key])) {
+ unset($this->outputformat[$key]);
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function getOutputFormat($key) {
+ if (isset($this->outputformat[$key])) {
+ return $this->outputformat[$key];
+ }
+ else {
+ throw new KeyInvalidException("Invalid key $key.");
+ }
+ }
+
+ public function outputFormatKeys() {
+ return array_keys($this->outputformat);
+ }
+
+ public function outputFormatKeyExists($key) {
+ return isset($this->outputformat[$key]);
+ }
+
+ public function printText() {
+ $printMap = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printMap = true;
+ break;
+ }
+ }
+ if ($printMap == true) {
+ $text = "MAP\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ foreach ($this->outputformat as $outputformat) {
+ $text .= $outputformat->printText();
+ }
+ if ($this->legend != null) {
+ $text .= $this->legend->printText();
+ }
+ if ($this->web != null) {
+ $text .= $this->web->printText();
+ }
+ foreach ($this->layers as $layer) {
+ $text .= $layer->printText();
+ }
+ $text .= "END\n";
+ return $text;
+ }
+ }
+
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_map_legend.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_map_legend.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_map_legend.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,35 @@
+<?php
+class MapserverMapLegend
+{
+ public $imagecolor;
+ public $status;
+ public $keysize;
+ public $label; //obj
+
+ public $printElements = array( "imagecolor",
+ "status",
+ "keysize"
+ );
+
+ public function printText() {
+ $printLegend = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printLegend = true;
+ }
+ }
+ if ($printLegend == true) {
+ $text = "LEGEND\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= $this->label->printText();
+ $text .= "END\n";
+ return $text;
+ }
+ }
+
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_map_metadata.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_map_metadata.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_map_metadata.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,69 @@
+<?php
+class MapserverMapMetadata
+{
+ public $ows_title;
+ public $ows_srs;
+ public $ows_abstract;
+ public $ows_keywordlist;
+ public $ows_extent;
+ public $ows_onlineresource;
+ public $ows_fees;
+ public $ows_accessconstraints;
+ public $ows_addresstype;
+ public $ows_address;
+ public $ows_city;
+ public $ows_stateorprovince;
+ public $ows_postcode;
+ public $ows_country;
+ public $ows_contactperson;
+ public $ows_contactorganization;
+ public $ows_contactposition;
+ public $ows_contactelectronicmailaddress;
+ public $wms_contactfacsimiletelephones;
+ public $wms_contactvoicetelephone;
+ public $wms_enable_request;
+ public $wms_encoding;
+
+ public $printElements = array( "ows_title",
+ "ows_srs",
+ "ows_abstract",
+ "ows_keywordlist",
+ "ows_extent",
+ "ows_onlineresource",
+ "ows_fees",
+ "ows_accessconstraints",
+ "ows_addresstype",
+ "ows_address",
+ "ows_city",
+ "ows_stateorprovince",
+ "ows_postcode",
+ "ows_country",
+ "ows_contactperson",
+ "ows_contactorganization",
+ "ows_contactposition",
+ "ows_contactelectronicmailaddress", "wms_contactfacsimiletelephones",
+ "wms_contactvoicetelephone",
+ "wms_enable_request",
+ "wms_encoding"
+ );
+
+ public function printText() {
+ $printMetadata = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printMetadata = true;
+ }
+ }
+ if ($printMetadata == true) {
+ $text = "METADATA\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= "END\n";
+ }
+ return $text;
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_map_outputformat.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_map_outputformat.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_map_outputformat.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,43 @@
+<?php
+class MapserverMapOutputFormat
+{
+ public $name;
+ public $driver;
+ public $imagetype;
+ public $mimetype;
+ public $imagemode;
+ public $extension;
+ public $formatoptions = array();
+
+ public $printElements = array( "name",
+ "driver",
+ "imagetype",
+ "mimetype",
+ "imagemode",
+ "extension"
+ );
+
+ public function printText() {
+ $printOutputFormat = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printOutputFormat = true;
+ break;
+ }
+ }
+ if ($printOutputFormat == true) {
+ $text = "OUTPUTFORMAT\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ foreach ($this->formatoptions as $formatoption) {
+ $text .= "FORMATOPTION"." ".$formatoption."\n";
+ }
+ $text .= "END\n";
+ return $text;
+ }
+ }
+}
+?>
Added: trunk/mapbender/http/extensions/mapserver/class_mapserver_map_web.php
===================================================================
--- trunk/mapbender/http/extensions/mapserver/class_mapserver_map_web.php (rev 0)
+++ trunk/mapbender/http/extensions/mapserver/class_mapserver_map_web.php 2014-12-16 19:31:34 UTC (rev 9134)
@@ -0,0 +1,33 @@
+<?php
+class MapserverMapWeb
+{
+ public $imagepath;
+ public $imageurl;
+ public $metadata; //obj
+
+ public $printElements = array( "imagepath",
+ "imageurl"
+ );
+
+ public function printText() {
+ $printWeb = false;
+ foreach($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $printWeb = true;
+ }
+ }
+ if ($printWeb == true) {
+ $text = "WEB\n";
+ foreach ($this->printElements as $element) {
+ if ($this->{$element} != null) {
+ $text .= strtoupper($element)." ".$this->{$element}."\n";
+ }
+ }
+ $text .= $this->metadata->printText();
+ $text .= "END\n";
+ return $text;
+ }
+ }
+
+}
+?>
More information about the Mapbender_commits
mailing list