Ejemplo n.º 1
0
    def test_create_mapcalc_map(self, grass_i):
        xml = "<mapcalc>if(isnull(nz_DEM),x(),nz_DEM)</mapcalc>"
        map_node = string_as_xml_node(xml)
        self.gmap = GrassMap(xml_node = map_node)
        self.assertEqual(self.gmap.xml_map_type, "mapcalc")
        self.assertEqual(self.gmap.refresh, False)
        del self.gmap

        xml = "<mapcalc refresh=\"true\">if(isnull(nz_DEM),x(),nz_DEM)</mapcalc>"
        map_node = string_as_xml_node(xml)
        self.gmap = GrassMap(xml_node=map_node)
        self.assertEqual(self.gmap.xml_map_type, "mapcalc")
        self.assertEqual(self.gmap.refresh, True)
Ejemplo n.º 2
0
 def test_normalise_map_colors(self):
     maps = []
     for i in range(0,5):
         xml = "<value>%d</value>" % (i * 10)
         map_node = string_as_xml_node(xml)
         maps.append(GrassMap(xml_node = map_node).get_map_filename())
     the_range = self.g.normalise_map_colors(maps)
     self.assertEqual(the_range, (0.0, 40.0))
Ejemplo n.º 3
0
 def test_create_name_map(self, get_g):
     xml = "<map>nz_DEM</map>"
     map_node = string_as_xml_node(xml)
     self.gmap = GrassMap(xml_node = map_node)
     self.assertEqual(self.gmap.value, "nz_DEM")
     self.assertEqual(self.gmap.filename, "nz_DEM")
     self.assertEqual(self.gmap.xml_map_type, "name")
     self.assertEqual(self.gmap.get_map_filename(), "nz_DEM")
Ejemplo n.º 4
0
 def test_normalise_map_colors(self):
     maps = []
     for i in range(0, 5):
         xml = "<value>%d</value>" % (i * 10)
         map_node = string_as_xml_node(xml)
         maps.append(GrassMap(xml_node=map_node).get_map_filename())
     the_range = self.g.normalise_map_colors(maps)
     self.assertEqual(the_range, (0.0, 40.0))
Ejemplo n.º 5
0
 def test_create_sites_map_w_comment(self,get_g):
     xml = """<sites>
       <!--<s x="1" y="0" count="100"/>-->
       <s x="2" y="0"/>
       <s x="3" y="0"/>
       <s x="4" y="0"/>
       <s x="5" y="0"/>
       <s x="0" y="-5"/>
     </sites>"""
     map_node = string_as_xml_node(xml)
     self.gmap = GrassMap(xml_node = map_node)
     self.assertEqual(len(self.gmap.value), 5)
Ejemplo n.º 6
0
    def test_mapcalc_cleanup(self, get_g):
        xml = "<mapcalc refresh=\"true\">if(isnull(nz_DEM),x(),nz_DEM)</mapcalc>"
        map_node = string_as_xml_node(xml)
        self.gmap = GrassMap(xml_node=map_node)

        get_g.return_value.init_map.return_value = ("test","a_map_type")
        get_g.return_value.get_mapset.return_value = "a_mapset"

        a = self.gmap.get_map_filename()
        b = self.gmap.get_map_filename()
        self.assertEqual(get_g.return_value.init_map.call_count,2)
        self.assertEqual(get_g.return_value.destruct_map.call_count,1)
        self.assertEqual(self.gmap.ready, True)
        self.assertEqual(self.gmap.mapset, "a_mapset")
        self.gmap.clean_up()
        self.assertEqual(get_g.return_value.destruct_map.call_count,2)
Ejemplo n.º 7
0
    def test_create_sites_map(self,get_g):
        xml = """<sites>
          <s x="1" y="0" count="100"/>
          <s x="2" y="0"/>
          <s x="3" y="0"/>
          <s x="4" y="0"/>
          <s x="5" y="0"/>
          <s x="0" y="-5"/>
        </sites>"""
        map_node = string_as_xml_node(xml)
        self.gmap = GrassMap(xml_node = map_node)
        self.assertEqual(len(self.gmap.value), 6)

        get_g.return_value.init_map.return_value = ("test","a_map_type")
        get_g.return_value.get_mapset.return_value = "a_mapset"
        a = self.gmap.get_map_filename()
        b = self.gmap.get_map_filename()
        self.assertEqual(get_g.return_value.init_map.call_count,1)
        self.assertEqual(self.gmap.ready, True)
        self.assertEqual(self.gmap.mapset, "a_mapset")
Ejemplo n.º 8
0
 def test_create_value_map(self, get_g):
     xml = "<value>1</value>"
     map_node = string_as_xml_node(xml)
     self.gmap = GrassMap(xml_node = map_node)
     self.assertEqual(self.gmap.value, "1")
     self.assertEqual(self.gmap.xml_map_type, "value")
Ejemplo n.º 9
0
    def test_init_map(self):
        xml = "<mapcalc refresh=\"true\">x()</mapcalc>"
        map_node = string_as_xml_node(xml)
        self.gmap = GrassMap(xml_node=map_node)

        grass.get_g().init_map(self.gmap)