Example #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()) 
Example #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])
Example #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())
Example #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])
Example #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())
Example #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"])
Example #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)
Example #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())
Example #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())
Example #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)
Example #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)
Example #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'])
Example #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'])
Example #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())
Example #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())
Example #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)
Example #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()) 
Example #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))
Example #19
0
 def testGeomFieldName(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     name = feature.geomfieldname
     self.assertEquals("the_geom", name)
Example #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())
Example #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())
Example #22
0
 def testGeom(self):
     feature = Feature(self.repo, geogig.HEAD, "parks/5")
     geom = feature.geom
     self.assertTrue(isinstance(geom, Geometry))
Example #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]