Ejemplo n.º 1
0
 def setUp(self):
     MapTestCase.setUp(self)
     with open(HOME_IMAGE, 'rb') as fh:
         s = BytesIO(fh.read())
     symb_img = mapscript.imageObj(s)
     self.h_symbol = mapscript.symbolObj('house')
     self.h_symbol.type = mapscript.MS_SYMBOL_PIXMAP
     self.h_symbol.setImage(symb_img)
     with open(XMARKS_IMAGE, 'rb') as fh:
         s = BytesIO(fh.read())
     symb_img = mapscript.imageObj(s)
     self.x_symbol = mapscript.symbolObj('xmarks')
     self.x_symbol.type = mapscript.MS_SYMBOL_PIXMAP
     self.x_symbol.setImage(symb_img)
Ejemplo n.º 2
0
 def xtestConstructorFilenameDriver(self):
     """imageObj with a filename and a driver works"""
     imgobj = mapscript.imageObj(test_image)
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
     imgobj.save('testConstructorFilenameDriver.png')
Ejemplo n.º 3
0
 def xtestConstructorFilenameDriver(self):
     """imageObj with a filename and a driver works"""
     imgobj = mapscript.imageObj(test_image)
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
     imgobj.save('testConstructorFilenameDriver.png')
Ejemplo n.º 4
0
 def xtestConstructorStream(self):
     """imageObj with a file stream works"""
     f = open(test_image, 'rb')
     imgobj = mapscript.imageObj(f)
     f.close()
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
Ejemplo n.º 5
0
 def xtestConstructorUrlStream(self):
     """imageObj with a URL stream works"""
     url = urllib.urlopen('http://mapserver.org/_static/banner.png')
     imgobj = mapscript.imageObj(url, 'AGG/JPEG')
     assert imgobj.thisown == 1
     assert imgobj.height == 68
     assert imgobj.width == 439
     imgobj.save('testConstructorUrlStream.jpg')
Ejemplo n.º 6
0
 def xtestConstructorStream(self):
     """imageObj with a file stream works"""
     f = open(test_image, 'rb')
     imgobj = mapscript.imageObj(f)
     f.close()
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
Ejemplo n.º 7
0
 def xtestConstructorUrlStream(self):
     """imageObj with a URL stream works"""
     url = urllib.urlopen('http://mapserver.org/_static/banner.png')
     imgobj = mapscript.imageObj(url, 'AGG/JPEG')
     assert imgobj.thisown == 1
     assert imgobj.height == 68
     assert imgobj.width == 439
     imgobj.save('testConstructorUrlStream.jpg')
Ejemplo n.º 8
0
 def testConstructorWithFormat(self):
     """imageObj with an optional driver works"""
     driver = 'AGG/PNG'
     format = mapscript.outputFormatObj(driver)
     imgobj = mapscript.imageObj(10, 10, format)
     assert imgobj.thisown == 1
     assert imgobj.format.driver == driver
     assert imgobj.height == 10
     assert imgobj.width == 10
Ejemplo n.º 9
0
 def xtestConstructorBytesIO(self):
     """imageObj with a BytesIO works"""
     with open(test_image, 'rb') as f:
         data = f.read()
     s = BytesIO(data)
     imgobj = mapscript.imageObj(s)
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
Ejemplo n.º 10
0
 def testConstructorWithFormat(self):
     """imageObj with an optional driver works"""
     driver = 'AGG/PNG'
     format = mapscript.outputFormatObj(driver)
     imgobj = mapscript.imageObj(10, 10, format)
     assert imgobj.thisown == 1
     assert imgobj.format.driver == driver
     assert imgobj.height == 10
     assert imgobj.width == 10
Ejemplo n.º 11
0
 def xtestConstructorBytesIO(self):
     """imageObj with a BytesIO works"""
     with open(test_image, 'rb') as f:
         data = f.read()
     s = BytesIO(data)
     imgobj = mapscript.imageObj(s)
     assert imgobj.thisown == 1
     assert imgobj.height == 200
     assert imgobj.width == 200
Ejemplo n.º 12
0
	def addPlaneSymbol(self,position):
		"""Adds the plane symbol at the indicated position"""
		pt = mapscript.pointObj()
		pt.x = position[0] #lat
		pt.y = position[1] #lon
		
		# project our point into the mapObj's projection 
		#ddproj = mapscript.projectionObj('proj=latlong,ellps=WGS84')
		#http://www.mass.gov/mgis/dd-over.htm
		ddproj = mapscript.projectionObj('proj=lcc,ellps=GRS80')
		
		origproj = mapscript.projectionObj(self.map.getProjection())
		pt.project(ddproj,origproj)
		
		# create the symbol using the image 
		planeSymbol = mapscript.symbolObj('from_img') 
		planeSymbol.type = mapscript.MS_SYMBOL_PIXMAP 
		planeImg = mapscript.imageObj('images/map-plane-small.png','GD/PNG')
		#TODO: need to rotate plane to current heading
		planeSymbol.setImage(planeImg) 
		symbol_index = self.map.symbolset.appendSymbol(planeSymbol) 

		# create a shapeObj out of our location point so we can 
		# add it to the map. 
		self.routeLine = mapscript.lineObj()
		self.routeLine.add(pt)
		routeShape=mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
		routeShape.add(self.routeLine) 
		routeShape.setBounds() 

		# create our inline layer that holds our location point 
		self.planeLayer = mapscript.layerObj(None)
		self.planeLayer.addFeature(routeShape) 
		self.planeLayer.setProjection(self.map.getProjection()) 
		self.planeLayer.name = "plane" 
		self.planeLayer.type = mapscript.MS_LAYER_POINT 
		self.planeLayer.connectiontype=mapscript.MS_INLINE 
		self.planeLayer.status = mapscript.MS_ON 
		self.planeLayer.transparency = mapscript.MS_GD_ALPHA 
		
		# add the image symbol we defined above to the inline layer. 
		planeClass = mapscript.classObj(None)
		planeClass.name='plane' 
		style = mapscript.styleObj(None)
		style.symbol = self.map.symbolset.index('from_img') 
		planeClass.insertStyle(style) 
		self.planeLayer.insertClass(planeClass)
		self.map.insertLayer(self.planeLayer)
		if debug: print "added plane layer, layerorder=",self.map.getLayerOrder()
Ejemplo n.º 13
0
 def testConstructor(self):
     """imageObj constructor works"""
     imgobj = mapscript.imageObj(10, 10)
     assert imgobj.thisown == 1
     assert imgobj.height == 10
     assert imgobj.width == 10
Ejemplo n.º 14
0
# %%
fields = []
for idx in range(0, qry_layer.numitems):
    fields.append(qry_layer.getItem(idx))

print(fields)
props = zip(fields, values)  # join fields to values
print(props)

# %% [markdown]
# We can also create a map showing the query results: 
# *Note the imageObj is broken for Python MapScript 7.0, but is fixed in 7.2*

# %%
# create a new 400 by 400 empty image
query_image = mapscript.imageObj(400, 400)
# draw the query into the image and save it to file
qry_layer.drawQuery(qry_layer.map, query_image)
output_file = r"layer_query.png"
query_image.save(output_file)
Image(filename=output_file)

# %% [markdown]
# If we want to zoom in on the results we can set the map extent to a buffered area
# around the results: 

# %%
bbox = result_shp.bounds
print(bbox.minx, bbox.miny, bbox.maxx, bbox.maxy)
buffer = 2000
Ejemplo n.º 15
0
 def testConstructor(self):
     """imageObj constructor works"""
     imgobj = mapscript.imageObj(10, 10)
     assert imgobj.thisown == 1
     assert imgobj.height == 10
     assert imgobj.width == 10