示例#1
0
    def buffer_layer(self,
                     layer_name,
                     distance,
                     segments=1,
                     cap_style=1,
                     join_style=1,
                     mitre_limit=1.0,
                     result_layer_name=None):
        layer = self.has_layer(layer_name, True)
        if layer is None:
            raise LayerNotFoundException("Layer not found")

        buffer_result = Computing.buffer(layer, distance, segments, cap_style,
                                         join_style, mitre_limit)
        if result_layer_name is None:
            layer.data = buffer_result
            self.update_vector_layer(layer_name, layer.data)
        else:
            if self.has_layer(result_layer_name):
                self.window.page().runJavaScript(
                    GEOJSON_LAYER_ADD_DATA_SCRIPT %
                    (result_layer_name, str(buffer_result)))
            else:
                self.add_vector_layer(result_layer_name,
                                      "",
                                      data=buffer_result)
示例#2
0
 def remove_layer(self, layer_name):
     layer = self.has_layer(layer_name, True)
     if layer is None:
         raise LayerNotFoundException("Layer not found")
     self.layers.remove(layer)
     self.window.page().runJavaScript(REMOVE_LAYER_SCRIPT %
                                      (layer_name, layer_name))
示例#3
0
 def update_vector_layer(self, layer_name, data):
     if not self.has_layer(layer_name):
         raise LayerNotFoundException("Layer not found")
     self.window.page().runJavaScript(REMOVE_LAYER_SCRIPT %
                                      (layer_name, layer_name))
     self.window.page().runJavaScript(GEOJSON_LAYER_CREATION_SCRIPT %
                                      (layer_name, layer_name))
     self.window.page().runJavaScript(GEOJSON_LAYER_ADD_DATA_SCRIPT %
                                      (layer_name, str(data)))
示例#4
0
 def set_visible(self, layer_name, is_visible):
     layer = self.has_layer(layer_name, True)
     if layer is None:
         raise LayerNotFoundException("Layer not found")
     layer.is_visible = is_visible
     if layer.is_visible:
         self.window.page().runJavaScript(SHOW_LAYER_SCRIPT %
                                          (layer_name, layer_name))
     else:
         self.window.page().runJavaScript(HIDE_LAYER_SCRIPT %
                                          (layer_name, layer_name))
示例#5
0
    def intersect_layers(self, first_layer_name, second_layer_name,
                         result_layer_name):
        first_layer = self.has_layer(first_layer_name, True)
        second_layer = self.has_layer(second_layer_name, True)
        if first_layer is None or second_layer is None:
            raise LayerNotFoundException("Layer not found")

        intersection_result = Computing.intersection(first_layer, second_layer)

        if self.has_layer(result_layer_name):
            self.window.page().runJavaScript(
                GEOJSON_LAYER_ADD_DATA_SCRIPT %
                (result_layer_name, str(intersection_result)))
        else:
            self.add_vector_layer(result_layer_name,
                                  "",
                                  data=intersection_result)
示例#6
0
 def bring_to_front(self, layer_name):
     layer = self.has_layer(layer_name, True)
     if layer is None:
         raise LayerNotFoundException("Layer not found")
     self.window.page().runJavaScript(BRING_TO_FRONT_SCRIPT % layer_name)