Пример #1
0
 def _assert_len_map_feat_fields(self, map_feat, map_fields):
     self.assertEqual(map_feat.keys(), map_fields.keys())
     for geom_str in map_feat:
         self.assertEqual(
             len(map_feat[geom_str]), len(map_fields[geom_str]),
             "len mismatch: map_feat, map_fields" + "\n %s \n %s" %
             (len_of_struct(map_feat), len_of_struct(map_fields)))
Пример #2
0
    def assert_layer(self, layer, obj, map_fields):
        lst_vlayer = list(layer.iter_layer())
        map_vlayer = layer.map_vlayer

        len_fields = len_of_struct(map_fields)  # field cnt
        len_vlayer = len_of_struct(map_vlayer)  # feat cnt
        len_vlayer_fields = dict((geom_str, [len(x.fields()) for x in lst])
                                 for geom_str, lst in map_vlayer.items())

        # self._log_debug("feat layer", len_vlayer)
        # self._log_debug("fields layer", len_vlayer_fields)

        self.assertGreater(len(lst_vlayer), 0)

        cnt = layer.get_feat_cnt()
        self.assertEqual(cnt, len(obj["features"]), len_vlayer)

        name_vlayer_fields = dict((geom_str, [x.fields().names() for x in lst])
                                  for geom_str, lst in map_vlayer.items())

        name_map_fields = dict((geom_str, [x.names() for x in lst])
                               for geom_str, lst in map_fields.items())
        self.assertEqual(
            len_vlayer_fields, len_fields, "\n".join([
                "layer fields and map_fields mismatch",
                pprint.pformat(name_vlayer_fields, compact=True),
                pprint.pformat(name_map_fields, compact=True)
            ]))
        self.assertEqual(name_vlayer_fields, name_map_fields)
Пример #3
0
    def do_test_parse_xyzjson_map(self, obj, similarity_threshold=None):
        obj_feat = obj["features"]
        # map_fields=dict()
        if similarity_threshold is None:
            similarity_threshold = self.similarity_threshold
        map_feat, map_fields = parser.xyz_json_to_feature_map(
            obj, similarity_threshold=similarity_threshold)

        self._log_debug("len feat", len(obj_feat))
        self._log_debug("parsed feat", len_of_struct(map_feat))
        self._log_debug("parsed fields", len_of_struct(map_fields))

        self._assert_parsed_map(obj_feat, map_feat, map_fields)
        return map_feat, map_fields