Esempio n. 1
0
 def testRemoveFeature(self):
     repo = self.getClonedRepo()        
     repo.removefeatures(["parks/1"])
     f = Feature(repo, geogig.WORK_HEAD, "parks/1")
     self.assertFalse(f.exists())
     f = Feature(repo, geogig.STAGE_HEAD, "parks/1")
     self.assertFalse(f.exists()) 
Esempio n. 2
0
 def testBlame(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     blame = feature.blame()        
     self.assertEquals(8, len(blame))
     attrs = feature.attributes
     for k,v in blame.iteritems():
         self.assertTrue(v[0], attrs[k])
Esempio n. 3
0
 def testOsmImport(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile)
     feature = Feature(repo, geogig.WORK_HEAD, "way/31045880")
     self.assertTrue(feature.exists())
Esempio n. 4
0
 def testBlame(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     blame = feature.blame()
     self.assertEquals(8, len(blame))
     attrs = feature.attributes
     for k, v in blame.iteritems():
         self.assertTrue(v[0], attrs[k])
Esempio n. 5
0
 def testOsmImport(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile)
     feature = Feature(repo, geogig.WORK_HEAD, "way/31045880")
     self.assertTrue(feature.exists())
Esempio n. 6
0
 def testModifyFeature(self):
     repo = self.getClonedRepo()
     attrs = Feature(repo, geogig.HEAD, "parks/1").attributes
     attrs["area"] = 1234.5
     repo.insertfeature("parks/1", attrs)
     attrs = Feature(repo, geogig.WORK_HEAD, "parks/1").attributes
     self.assertEquals(1234.5, attrs["area"])
Esempio n. 7
0
 def testAddFeature(self):
     repo = self.getClonedRepo()
     attrs = Feature(repo, geogig.HEAD, "parks/1").attributes
     repo.insertfeature("parks/newfeature", attrs)
     newattrs = Feature(repo, geogig.WORK_HEAD,
                        "parks/newfeature").attributes
     self.assertAlmostEqual(attrs["area"], newattrs["area"], 5)
Esempio n. 8
0
 def testOsmImportWithMappingFile(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")
     mappingfile = os.path.join(os.path.dirname(__file__), "data", "osm", "mapping.json")
     repo.importosm(osmfile, False, mappingfile)     
     feature = Feature(repo, geogig.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Esempio n. 9
0
 def testOsmImportWithMappingFile(self):
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")
     mappingfile = os.path.join(os.path.dirname(__file__), "data", "osm", "mapping.json")
     repo.importosm(osmfile, False, mappingfile)     
     feature = Feature(repo, geogig.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Esempio n. 10
0
 def testDiff(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     featureB = Feature(self.repo, geogig.HEAD + "~1", "parks/5")
     diffs = feature.diff(featureB)
     self.assertTrue(2, len(diffs))
     areas = diffs["area"]
     self.assertEquals(15297.503295898438, areas[1])
     self.assertEquals(15246.59765625, areas[0])
     self.assertTrue("the_geom" in diffs)
Esempio n. 11
0
 def testDiff(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     featureB = Feature(self.repo, geogig.HEAD + "~1", "parks/5")
     diffs = feature.diff(featureB)        
     self.assertTrue(2, len(diffs))
     areas = diffs["area"]
     self.assertEquals(15297.503295898438, areas[1])
     self.assertEquals(15246.59765625, areas[0])
     self.assertTrue("the_geom" in diffs)
Esempio n. 12
0
 def testFeatureType(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     ftype = feature.featuretype()
     self.assertTrue("owner" in ftype)
     self.assertTrue("agency" in ftype)
     self.assertTrue("name" in ftype)
     self.assertTrue("parktype" in ftype)
     self.assertTrue("area" in ftype)
     self.assertTrue("perimeter" in ftype)
     self.assertTrue("the_geom" in ftype)
     self.assertEquals("MULTIPOLYGON EPSG:4326", ftype['the_geom'])
Esempio n. 13
0
 def testFeatureType(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     ftype = feature.featuretype()
     self.assertTrue("owner" in ftype)
     self.assertTrue("agency" in ftype)
     self.assertTrue("name" in ftype)
     self.assertTrue("parktype" in ftype)
     self.assertTrue("area" in ftype)
     self.assertTrue("perimeter" in ftype)  
     self.assertTrue("the_geom" in ftype) 
     self.assertEquals("MULTIPOLYGON EPSG:4326", ftype['the_geom'])
Esempio n. 14
0
 def testOsmImportWithMapping(self):
     mapping = OSMMapping()
     rule = OSMMappingRule("onewaystreets")
     rule.addfilter("oneway", "yes")
     rule.addfield("lit", "lit", geogig.TYPE_STRING)
     rule.addfield("geom", "the_geom", geogig.TYPE_LINESTRING)
     mapping.addrule(rule)
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile, False, mapping)     
     feature = Feature(repo, geogig.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Esempio n. 15
0
 def testOsmImportWithMapping(self):
     mapping = OSMMapping()
     rule = OSMMappingRule("onewaystreets")
     rule.addfilter("oneway", "yes")
     rule.addfield("lit", "lit", geogig.TYPE_STRING)
     rule.addfield("geom", "the_geom", geogig.TYPE_LINESTRING)
     mapping.addrule(rule)
     repoPath =  self.getTempRepoPath()         
     repo = Repository(repoPath, init = True)
     osmfile = os.path.join(os.path.dirname(__file__), "data", "osm", "ways.xml")        
     repo.importosm(osmfile, False, mapping)     
     feature = Feature(repo, geogig.WORK_HEAD, "onewaystreets/31045880")
     self.assertTrue(feature.exists())
Esempio n. 16
0
 def testNoGeom(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     allattrs = feature.attributes
     attrs = feature.attributesnogeom
     self.assertEquals(len(allattrs), len(attrs) + 1)
     self.assertTrue("owner" in attrs)
     self.assertTrue("agency" in attrs)
     self.assertTrue("name" in attrs)
     self.assertTrue("parktype" in attrs)
     self.assertTrue("area" in attrs)
     self.assertTrue("perimeter" in attrs)
     self.assertFalse("the_geom" in attrs)
Esempio n. 17
0
 def testRemoveFeature(self):
     repo = self.getClonedRepo()        
     repo.removefeatures(["parks/1"])
     f = Feature(repo, geogig.WORK_HEAD, "parks/1")
     self.assertFalse(f.exists())
     f = Feature(repo, geogig.STAGE_HEAD, "parks/1")
     self.assertFalse(f.exists()) 
Esempio n. 18
0
 def testAttributes(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/1")
     data = feature.attributes
     self.assertEquals(8, len(data))
     self.assertEquals("Public", data["usage"])
     self.assertTrue("owner" in data)
     self.assertTrue("agency" in data)
     self.assertTrue("name" in data)
     self.assertTrue("parktype" in data)
     self.assertTrue("area" in data)
     self.assertTrue("perimeter" in data)
     self.assertTrue("the_geom" in data)
     self.assertTrue(isinstance(data["the_geom"], Geometry))
Esempio n. 19
0
 def testGeomFieldName(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     name = feature.geomfieldname
     self.assertEquals("the_geom", name)
Esempio n. 20
0
 def testExists(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/1")
     self.assertTrue(feature.exists())
     feature = Feature(self.repo, geogig.HEAD, "wrong/path")
     self.assertFalse(feature.exists())
Esempio n. 21
0
 def testExists(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/1")                    
     self.assertTrue(feature.exists())
     feature = Feature(self.repo, geogig.HEAD, "wrong/path")                    
     self.assertFalse(feature.exists())
Esempio n. 22
0
 def testGeom(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     geom = feature.geom
     self.assertTrue(isinstance(geom, Geometry))
Esempio n. 23
0
     repo = self.getClonedRepo()
     try:
         repo.merge("conflicted")
         self.fail()
     except GeoGigConflictException, e:
         pass
     conflicts = repo.conflicts()        
     self.assertEquals(1, len(conflicts))
     path = conflicts.keys()[0]
     self.assertTrue("parks/5", path)
     features = conflicts[path]
     origFeature = features[0]
     repo.solveconflict(path, origFeature.attributes)
     conflicts = repo.conflicts()        
     self.assertEquals(0, len(conflicts))
     feature = Feature(repo, geogig.WORK_HEAD, "parks/5")
     self.assertAlmostEqual(feature.attributes["area"], origFeature.attributes["area"], 5)
     
 def testSolveConflictOurs(self):
     repo = self.getClonedRepo()
     try:
         repo.merge("conflicted")
         self.fail()
     except GeoGigConflictException, e:
         pass
     conflicts = repo.conflicts()        
     self.assertEquals(1, len(conflicts))
     path = conflicts.keys()[0]
     self.assertTrue("parks/5", path)
     features = conflicts[path]
     oursFeature = features[1]