Beispiel #1
0
 def test_classes_geofield_pt(self):
     """
     Test the geofield optional parameter for a point-based geographic model.
     """
     try:
         generator.as_equal_interval(Hydrant.objects.filter(pressure=1), 'number', 5)
         self.fail('Geometry field is not default, and should throw an exception.')
     except FieldDoesNotExist, e:
         pass
Beispiel #2
0
 def test_classes_geofield_ln(self):
     """
     Test the geofield optional parameter for a line-based geographic model.
     """
     try:
         generator.as_equal_interval(Pipeline.objects.filter(material='ceramic'), 'diameter', 5)
         self.fail('Geometry field is not default, and should throw an exception.')
     except FieldDoesNotExist, e:
         pass
Beispiel #3
0
 def test_classes_geofield_poly(self):
     """
     Test the geofield optional parameter for a polygon-based geographic model.
     """
     try:
         generator.as_equal_interval(Reservoir.objects.filter(name__startswith='City'), 'volume', 5)
         self.fail('Geometry field is not default, and should throw an exception.')
     except FieldDoesNotExist, e:
         pass
Beispiel #4
0
    def test_ei_classes_poly(self):
        """
        Test the equal interval classifier for a polygon-based geographic model.
        """
        sld = generator.as_equal_interval(Reservoir.objects.filter(name__startswith='City'), 'volume', 5, geofield='coastline')

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

        sld = generator.as_equal_interval(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 = ['5008000.0', '10006000.0', '15004000.0', '20002000.0', '25000000.0']

        for i,n in enumerate(literals):
            self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
Beispiel #5
0
    def test_ei_classes_ln(self):
        """
        Test the equal interval classifier for a line-based geographic model.
        """
        sld = generator.as_equal_interval(Pipeline.objects.filter(material='ceramic'), 'diameter', 5, geofield='path')

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

        sld = generator.as_equal_interval(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.8', '19.6', '29.4', '39.2', '49.0']

        for i,n in enumerate(literals):
            self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
Beispiel #6
0
    def test_ei_classes_pt(self):
        """
        Test the equal interval classifier for a point-based geographic model.
        """
        sld = generator.as_equal_interval(Hydrant.objects.filter(pressure=1), 'number', 5, geofield='location')

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

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

        # class literal nodes:
        literals = sld._node.xpath('//ogc:PropertyIsLessThanOrEqualTo/ogc:Literal',namespaces=sld._nsmap)
        expected = ['480.2', '960.4', '1440.6', '1920.8', '2401.0']

        for i,n in enumerate(literals):
            self.assertEqual(n.text, expected[i], 'Class %d is not correct.' % i)
Beispiel #7
0
        self.assertEqual(len(sld._node.xpath('//sld:PointSymbolizer', namespaces=sld._nsmap)), 5)
        self.assertEqual(len(sld._node.xpath('//sld:LineSymbolizer', namespaces=sld._nsmap)), 0)
        self.assertEqual(len(sld._node.xpath('//sld:PolygonSymbolizer', namespaces=sld._nsmap)), 0)

    def test_classes_geofield_ln(self):
        """
        Test the geofield optional parameter for a line-based geographic model.
        """
        try:
            generator.as_equal_interval(Pipeline.objects.filter(material='ceramic'), 'diameter', 5)
            self.fail('Geometry field is not default, and should throw an exception.')
        except FieldDoesNotExist, e:
            pass

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

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

        self.assertEqual(len(sld._node.xpath('//sld:PointSymbolizer', namespaces=sld._nsmap)), 0)
        self.assertEqual(len(sld._node.xpath('//sld:LineSymbolizer', namespaces=sld._nsmap)), 5)
        self.assertEqual(len(sld._node.xpath('//sld:PolygonSymbolizer', namespaces=sld._nsmap)), 0)

    def test_classes_geofield_poly(self):
        """
        Test the geofield optional parameter for a polygon-based geographic model.
        """
        try:
            generator.as_equal_interval(Reservoir.objects.filter(name__startswith='City'), 'volume', 5)
            self.fail('Geometry field is not default, and should throw an exception.')
        except FieldDoesNotExist, e: