Changes between Initial Version and Version 1 of SWIGMapScriptNewLayer


Ignore:
Timestamp:
2019-04-12T16:57:31-03:00 (6 years ago)
Author:
Jeff McKenna
Comment:

initial

Legend:

Unmodified
Added
Removed
Modified
  • SWIGMapScriptNewLayer

    v1 v1  
     1{{{
     2#!php
     3<?php
     4
     5// define variables
     6define( "MAPFILE", "C:/ms4w/apps/phpmapscriptng-swig/sample.map" );
     7
     8// required SWIG include (contains constants for PHP7)
     9include("C:/ms4w/apps/phpmapscriptng-swig/include/mapscript.php");
     10
     11// open map
     12$oMap = new mapObj(MAPFILE);
     13
     14//force all errors to display
     15//  comment out the next 2 lines, useful on servers not displaying errors
     16ini_set('display_errors','On');
     17error_reporting(E_ALL);
     18
     19// set image size
     20$oMap->setsize(400, 300);
     21
     22// set image format
     23$oMap->selectoutputformat("png");
     24
     25// create new WMS layer
     26$oWMSLayer = new layerObj($oMap);
     27$oWMSLayer->__set("name", "cities");
     28$oWMSLayer->__set("type", MS_LAYER_RASTER);
     29$oWMSLayer->__set("status", MS_ON);
     30$oWMSLayer->setConnectionType(MS_WMS, NULL);
     31$oWMSLayer->__set("connection", "https://demo.gatewaygeomatics.com/cgi-bin/wms_gateway?");
     32$oWMSLayer->setMetaData("wms_name", "popplace");
     33$oWMSLayer->setMetaData("wms_srs", "EPSG:3978");
     34$oWMSLayer->setMetaData("wms_server_version", "1.1.1");
     35$oWMSLayer->setMetaData("wms_format", "image/png");
     36$oWMSLayer->SetProjection("init=EPSG:3978");
     37
     38// create new polygon layer
     39$oPolyLayer = new layerObj($oMap);
     40$oPolyLayer->__set("name", "prov_bound");
     41$oPolyLayer->__set("type", MS_LAYER_POLYGON);
     42$oPolyLayer->__set("status", MS_ON);
     43$oPolyLayer->__set("data", "province");
     44// create new class for poly layer
     45$oClass = new classObj($oPolyLayer);
     46$oClass->__set("name", "Province");
     47// create new style
     48$oStyle = new styleObj();
     49// create new color
     50$oColor = new colorObj(120,120,120);
     51$oStyle->__set("color", $oColor);
     52$oClass->insertStyle($oStyle);
     53$oPolyLayer->SetProjection("init=EPSG:3978");
     54// set opacity (actually creates a new COMPOSITE object)
     55$oPolyLayer->setOpacity(40);
     56
     57// draw map
     58$oImage = $oMap->draw();
     59
     60// save image file
     61$file = $oImage->save("C:/ms4w/apps/phpmapscriptng-swig/ttt.png",$oMap);
     62
     63// save mapfile to new file
     64$oMap->save("C:/ms4w/apps/phpmapscriptng-swig/output.map");
     65
     66// set header
     67header("Content-type: image/gif");
     68
     69// read image to output buffer
     70readfile("C:/ms4w/apps/phpmapscriptng-swig/ttt.png");
     71
     72?>
     73}}}