Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • AboutDialog
  • ActivityIndicator
  • Button
  • CoordinatesDisplay
  • Copyright
  • FeatureInfo
  • GpsPosition
  • Layertree
  • Legend
  • Map
  • Overview
  • PrintClient
  • Ruler
  • ScaleBar
  • ScaleSelector
  • SearchRouter
  • SrsSelector
  • ZoomBar
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: 
  3: namespace Mapbender\CoreBundle\Element;
  4: 
  5: use Mapbender\CoreBundle\Component\Element;
  6: 
  7: /**
  8:  * Map element.
  9:  *
 10:  * @author Christian Wygoda
 11:  */
 12: class Map extends Element
 13: {
 14: 
 15:     /**
 16:      * @inheritdoc
 17:      */
 18:     static public function getClassTitle()
 19:     {
 20:         return "Map";
 21:     }
 22: 
 23:     /**
 24:      * @inheritdoc
 25:      */
 26:     static public function getClassDescription()
 27:     {
 28:         return "MapQuery/OpenLayers based map";
 29:     }
 30: 
 31:     /**
 32:      * @inheritdoc
 33:      */
 34:     static public function getClassTags()
 35:     {
 36:         return array('Map', 'MapQuery', 'OpenLayers');
 37:     }
 38: 
 39:     /**
 40:      * @inheritdoc
 41:      */
 42:     public static function getDefaultConfiguration()
 43:     {
 44:         return array(
 45:             'layerset' => null,
 46:             'dpi' => 72,
 47:             'srs' => 'EPSG:4326',
 48:             'otherSrs' => array("EPSG:31466","EPSG:31467"),
 49:             'units' => 'degrees',
 50:             'extents' => array(
 51:                 'max' => array(0, 40, 20, 60),
 52:                 'start' => array(5, 45, 15, 55)),
 53:             'maxResolution' => 'auto',
 54:             "scales" => array(25000000,10000000,5000000,1000000,500000),
 55:             'imgPath' => 'bundles/mapbendercore/mapquery/lib/openlayers/img');
 56:     }
 57: 
 58:     /**
 59:      * @inheritdoc
 60:      */
 61:     public function getWidgetName()
 62:     {
 63:         return 'mapbender.mbMap';
 64:     }
 65: 
 66:     /**
 67:      * @inheritdoc
 68:      */
 69:     public function getAssets()
 70:     {
 71:         return array(
 72:             'js' => array(
 73:                 'mapquery/lib/openlayers/OpenLayers.js',
 74:                 'mapquery/lib/jquery/jquery.tmpl.js',
 75:                 'mapquery/src/jquery.mapquery.core.js',
 76:                 'proj4js/proj4js-compressed.js',
 77:                 'mapbender.element.map.js'),
 78:             'css' => array());
 79:     }
 80: 
 81:     /**
 82:      * @inheritdoc
 83:      */
 84:     public function getConfiguration()
 85:     {
 86:         $configuration = parent::getConfiguration();
 87:         
 88:         if(isset($configuration["scales"]))
 89:         {
 90:             $scales = array();
 91:             if(is_string($configuration["scales"]))
 92:             { // from database
 93:                 $scales = preg_split("/\s?,\s?/", $configuration["scales"]);
 94:             } else if(is_array($configuration["scales"]))
 95:             { // from twig
 96:                 $scales = $configuration["scales"];
 97:             }
 98:             // sort scales high to low
 99:             $scales = array_map(
100:                     create_function('$value', 'return (int)$value;'), $scales);
101:             arsort($scales, SORT_NUMERIC);
102:             $configuration["scales"] = $scales;
103:         }
104:         
105:         $extra = array();
106: 
107:         // @TODO: Move into DataTransformer of MapAdminType
108:         $configuration = array_merge(array('extra' => $extra), $configuration);
109:         $allsrs = array();
110:         if(is_int(stripos($configuration["srs"], "|"))){
111:             $srsHlp = explode("|", $configuration["srs"]);
112:             $configuration["srs"] = $srsHlp[0];
113:             $allsrs[$srsHlp[0]] = $srsHlp[1];
114:         } else {
115:             $allsrs[$configuration["srs"]] = "";
116:         }
117:         
118:         if(isset($configuration["otherSrs"]))
119:         {
120:             if(is_array($configuration["otherSrs"]))
121:             {
122:                 $otherSrs = $configuration["otherSrs"];
123:             } else if(is_string($configuration["otherSrs"])
124:                     && strlen(trim($configuration["otherSrs"])) > 0)
125:             {
126:                 $otherSrs = preg_split("/\s?,\s?/",
127:                                                  $configuration["otherSrs"]);
128:             }
129:             foreach($otherSrs as $srs){
130:                 if(is_int(stripos($srs, "|"))){
131:                     $srsHlp = explode("|", $configuration["srs"]);
132:                     $allsrs[trim($srsHlp[0])] = trim($srsHlp[1]);
133:                 } else {
134:                     $allsrs[trim($srs)] = "";
135:                 }
136:             }
137:         }
138:         unset($configuration['otherSrs']);
139:         $em = $this->container->get("doctrine")->getEntityManager();
140:         $query = $em->createQuery("SELECT srs FROM MapbenderCoreBundle:SRS srs"
141:                         . " Where srs.name IN (:name)  ORDER BY srs.id ASC")
142:                 ->setParameter('name', array_keys($allsrs));
143:         $srses = $query->getResult();
144:         
145:         $ressrses = array();
146:         foreach($srses as $srsTemp)
147:         {
148:             $ressrses[$srsTemp->getName()] = array(
149:                 "name" => $srsTemp->getName(),
150:                 "title" => $allsrs[$srsTemp->getName()] !== "" ? $allsrs[$srsTemp->getName()] : $srsTemp->getTitle(),
151:                 "definition" => $srsTemp->getDefinition());
152:         }
153:         /* sort the ressrses */
154:         foreach($allsrs as $key => $value)
155:         {
156:             if(isset($ressrses[$key])){
157:                 $configuration["srsDefs"][] = $ressrses[$key];
158:             }
159:         }
160:         
161:         $srs_req = $this->container->get('request')->get('srs');
162:         if($srs_req)
163:         {
164:             if(!isset($ressrses[$srs]))
165:             {
166:                 throw new \RuntimeException('The srs: "' . $srs_req
167:                         . '" does not supported.');
168:             }
169:             $configuration = array_merge($configuration,
170:                                          array('targetsrs' => $srs_req));
171:             $poi = $this->container->get('request')->get('poi');
172:             if($poi)
173:             {
174:                 $extra['type'] = 'poi';
175:                 $point = split(',', $poi['point']);
176:                 $extra['data'] = array(
177:                     'x' => floatval($point[0]),
178:                     'y' => floatval($point[1]),
179:                     'label' => $poi['label'],
180:                     'scale' => $poi['scale']
181:                 );
182:             }
183: 
184:             $bbox = $this->container->get('request')->get('bbox');
185:             if(!$poi && $bbox)
186:             {
187:                 $bbox = explode(',', $bbox);
188:                 if(count($bbox) === 4)
189:                 {
190:                     $extra['type'] = 'bbox';
191:                     $extra['data'] = array(
192:                         floatval($bbox[0]),
193:                         floatval($bbox[1]),
194:                         floatval($bbox[2]),
195:                         floatval($bbox[3])
196:                     );
197:                 }
198:             }
199:         }
200:         
201:         if(!isset($configuration['scales']))
202:         {
203:             throw new \RuntimeException('The scales does not defined.');
204:         } else if(is_string($configuration['scales']))
205:         {
206:             $configuration['scales'] = preg_split(
207:                     "/\s?,\s?/", $configuration['scales']);
208:         }
209:         return $configuration;
210:     }
211: 
212:     /**
213:      * @inheritdoc
214:      */
215:     public function render()
216:     {
217:         return $this->container->get('templating')
218:                         ->render('MapbenderCoreBundle:Element:map.html.twig',
219:                                  array(
220:                             'id' => $this->getId()));
221:     }
222: 
223:     /**
224:      * @inheritdoc
225:      */
226:     public static function getType()
227:     {
228:         return 'Mapbender\CoreBundle\Element\Type\MapAdminType';
229:     }
230: 
231:     /**
232:      * @inheritdoc
233:      */
234:     public static function getFormTemplate()
235:     {
236:         return 'MapbenderManagerBundle:Element:map.html.twig';
237:     }
238: }
239: 
240: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0