Exemple #1
0
    def test_fj_classes_ln(self):
        """
        Test the Fisher Jenks classifier for a line-based geographic model.
        """
        sld = generator.as_fisher_jenks(Pipeline.objects.filter(material='ceramic'), 'diameter', 5, geofield='path')

        self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5)

        sld = generator.as_fisher_jenks(Pipeline.objects.filter(material='concrete'), 'diameter', 5, geofield='path')

        # class literal nodes:
        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)
Exemple #2
0
    def test_fj_classes_poly(self):
        """
        Test the Fisher Jenks classifier for a polygon-based geographic model.
        """
        sld = generator.as_fisher_jenks(Reservoir.objects.filter(name__startswith='City'), 'volume', 5, geofield='coastline')

        self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5)

        sld = generator.as_fisher_jenks(Reservoir.objects.filter(name__startswith='County'), 'volume', 5, geofield='coastline')

        # class literal nodes:
        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)
Exemple #3
0
    def test_fj_classes_pt(self):
        """
        Test the Fisher Jenks classifier for a point-based geographic model.
        """
        sld = generator.as_fisher_jenks(Hydrant.objects.filter(pressure=1), 'number', 5, geofield='location')

        self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5)

        sld = generator.as_fisher_jenks(Hydrant.objects.filter(pressure=2), 'number', 5, geofield='location')

        # class literal nodes:
        literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap)
        expected = ['324', '784', '1296', '1849', '2401.0']

        for i,n in enumerate(literals):
            self.assertEqual(n.text, expected[i], 'Class %d is not correct. Expected "%s" / Actual "%s"' % (i, expected[i], n.text,))