本文整理汇总了Python中Map.Map.getPOIGroup方法的典型用法代码示例。如果您正苦于以下问题:Python Map.getPOIGroup方法的具体用法?Python Map.getPOIGroup怎么用?Python Map.getPOIGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map.Map
的用法示例。
在下文中一共展示了Map.getPOIGroup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAddCategory
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import getPOIGroup [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)
示例2: testSimple
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import getPOIGroup [as 别名]
def testSimple(self):
map = Map(MapDirectory(self.testdatadir), maptype=MapTypeImage)
map.open("a")
map.addPOIGroupAndLayer()
poigroup = map.getPOIGroup()
cat = POICategory("Aerials")
cat.addField("POI Name")
subcat = cat.addSubCategory(POISubCategory("NOSUB1000"))
expected = [cat]
poigroup.addCategory(cat)
# cat.addField
actual = poigroup.getCategories()
if actual != expected:
print "actual:", actual
print "expected:", expected
self.assertEqual(actual, expected)
# Close map and try it to open it again
map.close()
map = Map()
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
self.assertEqual(actual, expected, "categories were not read back correctly")
示例3: testCategories
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import getPOIGroup [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()
示例4: testAddPOI
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import getPOIGroup [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