def get_layer_points_wfs(self, layer, bbox, max_features): # Get points in bbox by creating/dispatching an WFS GetFeature # internally. This is a nice abstraction from various source types like # PostGIS, Shape etc. wfs_req = mapscript.OWSRequest() wfs_req.setParameter("SERVICE", "WFS") wfs_req.setParameter("VERSION", "1.1.0") wfs_req.setParameter("REQUEST", "GetFeature") wfs_req.setParameter("TYPENAME", layer) wfs_req.setParameter("BBOX", bbox) wfs_req.setParameter("VERSION", "1.1.0") # wfs_req.setParameter( 'SRSNAME', "EPSG:4326") ????? # TODO: reproject response points mapscript.msIO_installStdoutToBuffer() self.map.OWSDispatch(wfs_req) # print 'bbox=' + wms_req.getValueByName('BBOX') mapscript.msIO_stripStdoutBufferContentType() content = mapscript.msIO_getStdoutBufferString() # Parse WFS result into array of Point (slooow, TODO optimize) parser = WFSParser(mapscript.msGetVersionInt() >= 50600, max_features) return parser.parse(content)
### System imports, Standard Libraries import os import sys import zlib import math import struct import base64 ### Custom Imports, these need to be installed. import mapscript as ms assert ms.msGetVersionInt() >= 50200 #require 5.2.0 or above assert 'OUTPUT=PNG' in ms.msGetVersion() #require PNG support assert 'INPUT=SHAPEFILE' in ms.msGetVersion() #require PNG support ### Local imports. included from common import SPHEREMERC_GROUND_SIZE,MAPFILE WGS = ms.projectionObj('init=epsg:4326') #GMERC = ms.projectionObj('init=epsg:900913') GMERC = ms.projectionObj('init=epsg:3857') ID_OFFSET = 2 # 0==background,1==borders class Tiler: def __init__(self,mapobj): if issubclass(type(mapobj),basestring): mapobj = ms.mapObj(mapobj) self.map = mapobj def getScales(self): #print "Zoom: " scales = [] for i in range(20):
def debug(self, msg=None): print("Content-type: text/plain\n\n") print(mapscript.msGetVersion()) print("version int=" + str(mapscript.msGetVersionInt())) if msg: print(msg)