def test_jc_classes_ln(self): """ Test the Jenks Caspall classifier for a line-based geographic model. """ sld = generator.as_jenks_caspall(Pipeline.objects.filter(material='ceramic'), 'diameter', 5, geofield='path') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall(Pipeline.objects.filter(material='concrete'), 'diameter', 5, geofield='path') literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap) expected = ['9.0', '19.0', '29.0', '39.0', '49.0'] for i,n in enumerate(literals): self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
def test_jc_classes_poly(self): """ Test the Jenks Caspall classifier for a polygon-based geographic model. """ sld = generator.as_jenks_caspall(Reservoir.objects.filter(name__startswith='City'), 'volume', 5, geofield='coastline') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall(Reservoir.objects.filter(name__startswith='County'), 'volume', 5, geofield='coastline') literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap) expected = ['1690000.0', '5290000.0', '10240000.0', '16810000.0', '25000000.0'] for i,n in enumerate(literals): self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
def test_jc_classes_pt(self): """ Test the Jenks Caspall classifier for a point-based geographic model. """ sld = generator.as_jenks_caspall(Hydrant.objects.filter(pressure=1), 'number', 5, geofield='location') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall(Hydrant.objects.filter(pressure=2), 'number', 5, geofield='location') literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap) expected = ['169', '484', '961', '1600', '2401'] for i,n in enumerate(literals): self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)