Ejemplo n.º 1
0
    def test_nb_classes_poly(self):
        """
        Test the Natural Breaks classifier for a polygon-based geographic model.
        """
        sld = generator.as_natural_breaks(Reservoir.objects.filter(name__startswith='City'), 'volume', 5, geofield='coastline')

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

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

        # Cannot test the values, as the Natural Breaks documentation indicates
        # that the consistency of breaks on multiple runs of the same data may
        # not be consistent with the default number of solutions generated. 
        # Even with an extremely high initial solution value (10,000), these
        # classes are still non-deterministic with the sample test data.
        self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5)
Ejemplo n.º 2
0
    def test_nb_classes_ln(self):
        """
        Test the Natural Breaks classifier for a line-based geographic model.
        """
        sld = generator.as_natural_breaks(Pipeline.objects.filter(material='ceramic'), 'diameter', 5, geofield='path')

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

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

        # Cannot test the values, as the Natural Breaks documentation indicates
        # that the consistency of breaks on multiple runs of the same data may
        # not be consistent with the default number of solutions generated. 
        # Even with an extremely high initial solution value (10,000), these
        # classes are still non-deterministic with the sample test data.
        self.assertEqual(len(sld.NamedLayer.UserStyle.FeatureTypeStyle.Rules), 5)