示例#1
0
def test_parse():
    assert crs_util.parse_name(TEST_WKT) == "WGS 84"
    assert crs_util.parse_authority(TEST_WKT) == ("EPSG", "4326")

    assert crs_util.parse_name(AXIS_LAST_WKT) == "WGS 84"
    assert crs_util.parse_authority(AXIS_LAST_WKT) == ("EPSG", "4326")

    # Strangely this doesn't entirely work using osgeo:
    spatial_ref = SpatialReference(TEST_WKT)
    assert spatial_ref.GetName() == "WGS 84"
    assert spatial_ref.GetAuthorityName(None) is None
    assert spatial_ref.GetAuthorityCode(None) is None
示例#2
0
    def generate_gpkg_spatial_ref_sys(cls, v2_obj):
        """Generate a gpkg_spatial_ref_sys meta item from a v2 dataset."""
        geom_columns = v2_obj.schema.geometry_columns
        if not geom_columns:
            return []

        crs_pathname = geom_columns[0].extra_type_info.get("geometryCRS")
        if not crs_pathname:
            return []
        wkt = v2_obj.get_crs_definition(crs_pathname)
        auth_name, auth_code = crs_util.parse_authority(wkt)
        if auth_code and auth_code.isdigit() and int(auth_code) > 0:
            srs_id = int(auth_code)
        else:
            srs_id = crs_util.get_identifier_int(wkt)
        return [{
            "srs_name": crs_util.parse_name(wkt),
            "definition": wkt,
            "organization": auth_name or "NONE",
            "srs_id": srs_id,
            "organization_coordsys_id": srs_id,
            "description": None,
        }]
示例#3
0
 def generate_mysql_spatial_ref_sys(cls, v2_obj):
     """
     Generates the contents of the spatial_referece_system table from the v2 object.
     The result is a list containing a dict per table row.
     Each dict has the format {column-name: value}.
     """
     result = []
     for crs_name, definition in v2_obj.crs_definitions().items():
         auth_name, auth_code = crs_util.parse_authority(definition)
         crs_id = crs_util.get_identifier_int(definition)
         result.append({
             "srs_id":
             crs_id,
             "name":
             crs_util.parse_name(definition),
             "definition":
             crs_util.mysql_compliant_wkt(definition),
             "organization":
             auth_name,
             "org_id":
             crs_id,
         })
     return result
示例#4
0
 def _is_builtin_crs(self, crs):
     auth_name, auth_code = crs_util.parse_authority(crs)
     return auth_name == "EPSG"
示例#5
0
 def _is_builtin_crs(self, crs):
     auth_name, auth_code = crs_util.parse_authority(crs)
     return auth_name in ("EPSG", "ESRI") or auth_code == "900913"  # GOOGLE