예제 #1
0
    def test_grab_machine_coordinates(self, mck_paths):
        """
        Retrieve machine coordinates for Point, LineString and Polygon format.
        """
        mck_paths.COORDINATES = self.coords_path

        coords_b = coordinates.component_coordinates("machine-B")
        coords_c = coordinates.component_coordinates("machine-C")
        coords_d = coordinates.component_coordinates("machine-D")
        self.assertEqual(coords_b, {
            "type": "Point",
            "coordinates": [-78.254, 40.45712]
        })
        self.assertEqual(
            coords_c, {
                "type":
                "LineString",
                "coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0],
                                [105.0, 1.0]]
            })
        self.assertEqual(
            coords_d, {
                "type":
                "Polygon",
                "coordinates": [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
                                 [100.0, 1.0], [100.0, 0.0]]]
            })
예제 #2
0
 def test_none_name(self, mck_paths):
     """
     Check that a None value input is ignored.
     """
     mck_paths.COORDINATES = self.coords_path
     coords = coordinates.component_coordinates(None)
     self.assertIsNone(coords)
예제 #3
0
 def test_unknown_name(self, mck_paths):
     """
     Check that a name that does not exist is ignored.
     """
     mck_paths.COORDINATES = self.coords_path
     coords = coordinates.component_coordinates("machine-G")
     self.assertIsNone(coords)
예제 #4
0
 def _add_coordinates(graph, node):
     """
     Adds coordinates to the node within the graph. As the graph is passed
     by reference the calling method gets back the graph with the
     coordinates added.
     :param graph: The graph containing the node.
     :param node: THe id of the node.
     """
     coords = coordinates.component_coordinates(node)
     graph.node[node]["attributes"]["geo"] = coords