当前位置: 首页>>代码示例>>Python>>正文


Python Map.open方法代码示例

本文整理汇总了Python中Map.Map.open方法的典型用法代码示例。如果您正苦于以下问题:Python Map.open方法的具体用法?Python Map.open怎么用?Python Map.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map.Map的用法示例。


在下文中一共展示了Map.open方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testPolylineSerialize

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
    def testPolylineSerialize(self):
        map = Map()
        map.open(os.path.join(self.testdatadir, "00map.ini"))

        streets = map.getLayerByName("00_Streets")
        streets.open("r")

        cell = streets.getCell(1)

        street = cell.getCellElements()[0]

        expected = getCellElementRawData(streets, 1, 0)


        actual = street.serialize(cell)

        if actual != expected:
            print "Expected:", dump(expected)
            print "Actual:  ", dump(actual)

        outstreet = CellElementPolyline(streets)
        outstreet.deSerialize(cell, actual)

        self.assertEqual(street,outstreet)
        self.assertEqual(len(actual), len(expected))
        self.assertEqual(actual, expected)
开发者ID:codingforfun,项目名称:pymagellan,代码行数:28,代码来源:cell.py

示例2: testSimple

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
    def testSimple(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("r")

        poigroup = map.getPOIGroup()
        poigroup.open("r")

        f = poigroup.getFeatureByIndex(0)
        aux = f.getAuxAsDict(poigroup)
        print f, aux
开发者ID:codingforfun,项目名称:pymagellan,代码行数:12,代码来源:test_poi.py

示例3: testCategories

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
    def testCategories(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("a")

        poigroup = map.getPOIGroup()

        poigroup.open("a")

        catman = poigroup.getCategoryManager()

        print catman.getCategories()

        poigroup.close()
开发者ID:codingforfun,项目名称:pymagellan,代码行数:15,代码来源:test_poi.py

示例4: testAddCategory

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
    def testAddCategory(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("a")
        poigroup = map.getPOIGroup()
        poilayer = map.getPOILayers()[0]
        #        poilayer.open('a')
        poigroup.open("a")
        map.close()
        map.writeImage("test.imi")

        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("a")

        poigroup = map.getPOIGroup()

        poigroup.open("a")

        cat = POICategory("Aerials")
        cat.addField("POI Name")
        subcat = cat.addSubCategory(POISubCategory("NOSUB1000"))

        expected = deepcopy(poigroup.getCategories()) + [cat]

        poigroup.addCategory(cat)

        #        cat.addField

        actual = poigroup.getCategories()

        if actual != expected:
            print "actual:", actual
            print "expected:", expected

        self.assertEqual(actual, expected)

        map.close()

        map = createMap(self.testdatadir)
        map.open()

        poigroup = map.getPOIGroup()

        poigroup.open("r")

        catman = poigroup.getCategoryManager()

        print catman.getCategories()

        self.assertTrue("Aerials" in [cat.getName() for cat in catman.getCategories()])

        actual = poigroup.getCategories()

        if actual != expected:
            print "actual:", actual
            print "expected:", expected

        #        expected.sort(lambda x,y: cmp(x.name.upper(), y.name.upper()))

        self.assertEqual(actual, expected)
开发者ID:codingforfun,项目名称:pymagellan,代码行数:61,代码来源:test_poi.py

示例5: MainWindow

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
class MainWindow(QMainWindow):

	CONFIG_FILE = "config/config.txt"
	
	def __init__(self, parent=None):
		QMainWindow.__init__(self, parent)
		
		self.setWindowTitle(u"Éditeur de cartes")
		self.setWindowIcon(QIcon("icons/application.png"))
		
		# actions
		exit = QAction(QIcon("icons/application-exit.png"), "Quitter", self)
		exit.setShortcut('Ctrl+Q')
		exit.setStatusTip("Quitter l'application")
		# sans confirmation
		self.connect(exit, SIGNAL('triggered()'), qApp, SLOT('quit()'))

		doc_new = QAction(QIcon("icons/document-new.png"), "Nouveau", self)
		doc_new.setShortcut("Ctrl+N")
		doc_new.setStatusTip(u"Créer une nouvelle carte")
		self.connect(doc_new, SIGNAL("triggered()"), self.create_map)
		
		doc_open = QAction(QIcon("icons/document-open.png"), "Ouvrir", self)
		doc_open.setShortcut("Ctrl+O")
		doc_open.setStatusTip("Ouvrir une carte existante")
		self.connect(doc_open, SIGNAL("triggered()"), self.ask_open_map)
		
		doc_save = QAction(QIcon("icons/document-save.png"), "Enregistrer", self)
		doc_save.setShortcut("Ctrl+S")
		doc_save.setStatusTip("Enregistrer la carte")
		self.connect(doc_save, SIGNAL('triggered()'), self.save)
		
		doc_save_as = QAction(QIcon("icons/document-save-as.png"), "Enregistrer sous ...", self)
		doc_save_as.setShortcut("Ctrl+Shift+S")
		doc_save_as.setStatusTip(u"Enregistrer la carte actuelle sous un nom différent")
		self.connect(doc_save_as, SIGNAL("triggered()"), self.save_as)
		
		about_qt = QAction(QIcon("icons/information.png"), u"À propos de Qt", self)
		self.connect(about_qt, SIGNAL("triggered()"), qApp, SLOT("aboutQt()"))
		
		# MENUBAR ##############################################################
		
		# MENU Fichier
		
		menubar = self.menuBar()
		file = menubar.addMenu('&Fichier')
		file.addAction(doc_new)
		file.addAction(doc_open)
		file.addAction(doc_save)
		file.addAction(doc_save_as)
		file.addSeparator()
		file.addAction(exit)
		
		# MENU Édition
		
		# paint
		paint = QAction(QIcon("icons/paint.png"), "Peindre avec la tile courante", self)
		paint.setStatusTip("Remplir toute la zone avec la tile courante")
		self.connect(paint, SIGNAL("triggered()"), self.paint_all)
		# undo tile
		act_undo = QAction(QIcon("icons/edit-undo.png"), "Annuler tile", self)
		act_undo.setShortcut("U")
		act_undo.setStatusTip(u"Annuler le dernier placement de tile")
		self.connect(act_undo, SIGNAL("triggered()"), self.undo)
		# add line
		act_add_line = QAction(QIcon("icons/edit-add-line.png"), "Ajouter une ligne", self)
		act_add_line.setStatusTip("Ajouter une ligne de zones dans la carte")
		self.connect(act_add_line, SIGNAL("triggered()"), self.add_line)
		# add column
		act_add_col = QAction(QIcon("icons/edit-add-col.png"), "Ajouter une colonne", self)
		act_add_col.setStatusTip("Ajouter une colonne de zones dans la carte")
		self.connect(act_add_col, SIGNAL("triggered()"), self.add_column)
		# remove line
		act_rem_line = QAction(QIcon("icons/edit-remove-line.png"), "Supprimer une ligne", self)
		act_rem_line.setStatusTip("Supprimer une ligne de zones de le carte")
		# remove column
		act_rem_col = QAction(QIcon("icons/edit-remove-col.png"), "Supprimer une colonne", self)
		act_rem_col.setStatusTip("Supprimer une colonne de zones de le carte")
		# delete entity
		act_del_entity = QAction(QIcon("icons/entity-remove.png"), u"Supprimer une entité", self)
		act_del_entity.setStatusTip(u"Supprimer n'importe quelle entité de la zone courante")
		act_del_entity.setShortcut("S")
		self.connect(act_del_entity, SIGNAL("triggered()"), self.delete_entity)
		# move entity
		act_move_entity = QAction(QIcon("icons/entity-move.png"), u"Déplacer une entité", self)
		act_move_entity.setStatusTip(u"Déplacer n'importe quelle entité de la zone courante")
		act_move_entity.setShortcut("D")
		self.connect(act_move_entity, SIGNAL("triggered()"), self.move_entity)
		
		edit = menubar.addMenu(u"&Édition")
		edit.addAction(act_undo)
		edit.addAction(paint)
		
		edit.addSeparator()
		edit.addAction(act_add_line)
		edit.addAction(act_add_col)
		#edit.addAction(act_rem_line)
		#edit.addAction(act_rem_col)
		
		edit.addSeparator()
#.........这里部分代码省略.........
开发者ID:charafsalmi,项目名称:ppd-paris-descartes,代码行数:103,代码来源:Editor.py

示例6: Map

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
        searchgroup.addFeature(feature)

        ogrfeature = ogrlayer.GetNextFeature()

        i+=1
        if i>2000:
            break

filename = 'shape/romania/roads.shp'

ds = ogr.Open(filename)

layer = ds.GetLayerByIndex(0)

map = Map(MapDirectory(), maptype=MapTypeImage)
map.open("w")

extent = layer.GetExtent()
map.bbox = ((extent[0], extent[2]), (extent[1], extent[3]))

## Add streets layer
streets = Layer(map, name="00_Streets", filename="00str", layertype=LayerTypePolyline)
streets.open(mode='w')
streetstyle = DetailMapLayerStyle()
streetstyle.style = 'US_STREET_LINE'
map.addLayer(streets, layerstyle = streetstyle)
map.getGroupByName('00_Roads').addLayer(streets)

importLayer(map, streets, map.getGroupByName('00_Roads'), layer, nameattribute='LABEL')

map.close()
开发者ID:codingforfun,项目名称:pymagellan,代码行数:33,代码来源:importogr.py

示例7: testAddPOI

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import open [as 别名]
    def testAddPOI(self):
        map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
        map.open("a")

        poigroup = map.getPOIGroup()
        poilayer = map.getPOILayers()[0]
        poigroup.open("a")

        print "nlevels", poilayer.nlevels

        catman = poigroup.getCategoryManager()
        cat = catman.getCategory(1)
        subcat = cat.getSubCategory(1)

        # Save number of pois in category 1
        cat1count = cat.getPOICount()
        self.assertEqual(cat1count, 5)

        wkt = "POINT (16.185 58.5912)"
        poi = CellElementPOI(poilayer, categoryid=1, subcategoryid=1, wkt=wkt)
        poi.discretizeGeometry(poilayer.getCell(1))
        feature = FeaturePOI(poilayer.addCellElement(poi), ["Apmacken", "", "", "", "", ""], 1, 1)

        expected = Set([f for f in poigroup.getFeatures()]) | Set([feature])

        poigroup.addFeature(feature)

        actual = Set([f for f in poigroup.getFeatures()])

        self.assertEqual(actual, expected, "feature not present in poi group in memory")

        map.close()

        # Verify that the category statistics are updated
        self.assertEqual(cat.getPOICount(), cat1count + 1)

        map = Map()
        map.open(os.path.join(self.testdatadir, "00map.ini"))

        poigroup = map.getPOIGroup()

        poigroup.open()

        actual = Set([f for f in poigroup.getFeatures()])

        self.assertEqual(len(actual), len(expected))

        if actual != expected:
            print "actual:", actual
            print "expected:", expected

        #        expected.sort(lambda x,y: cmp(x.name.upper(), y.name.upper()))

        self.assertEqual(actual, expected, "feature was not added correctly after read back")

        self.assertTrue(
            areSorted([(f.getCategoryId(), f.getSubCategoryId()) for f in poigroup.getFeatures()]),
            "Feature are not sorted",
        )

        # Verify that the category statistics are updated
        cat = poigroup.getCategory(1)
        print poigroup.getCategories()
        subcat = cat.getSubCategory(1)
        self.assertEqual(cat.getPOICount(), cat1count + 1)

        f = poigroup.getFeatureByIndex(0)
        aux = f.getAuxAsDict(poigroup)
        print f, aux
开发者ID:codingforfun,项目名称:pymagellan,代码行数:71,代码来源:test_poi.py


注:本文中的Map.Map.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。