def test_jcf_classes_ln(self): """ Test the Jenks Caspall Forced classifier for a line-based geographic model. """ sld = generator.as_jenks_caspall_forced(Pipeline.objects.filter(material='ceramic'), 'diameter', 5, geofield='path') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall_forced(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_jcf_classes_poly(self): """ Test the Jenks Caspall Forced classifier for a polygon-based geographic model. """ sld = generator.as_jenks_caspall_forced(Reservoir.objects.filter(name__startswith='City'), 'volume', 5, geofield='coastline') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall_forced(Reservoir.objects.filter(name__startswith='County'), 'volume', 5, geofield='coastline') literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap) expected = ['3240000.0', '7840000.0', '12960000.0', '18490000.0', '25000000.0'] for i,n in enumerate(literals): self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
def test_jcf_classes_pt(self): """ Test the Jenks Caspall Forced classifier for a point-based geographic model. """ sld = generator.as_jenks_caspall_forced(Hydrant.objects.filter(pressure=1), 'number', 5, geofield='location') self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5) sld = generator.as_jenks_caspall_forced(Hydrant.objects.filter(pressure=2), 'number', 5, geofield='location') literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap) expected = ['289', '729', '1225', '1764', '2401'] for i,n in enumerate(literals): self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)