Esempio n. 1
0
def test_vertical_crs():
    vc = VerticalCRS(
        name="NAVD88 height",
        datum="North American Vertical Datum 1988",
        geoid_model="GEOID12B",
    )
    assert vc.name == "NAVD88 height"
    assert vc.type_name == "Vertical CRS"
    assert vc.coordinate_system == VerticalCS()
    assert vc.to_json_dict()["geoid_model"]["name"] == "GEOID12B"
Esempio n. 2
0
def test_compund_crs():
    vertcrs = VerticalCRS(
        name="NAVD88 height",
        datum="North American Vertical Datum 1988",
        vertical_cs=VerticalCS(),
        geoid_model="GEOID12B",
    )
    projcrs = ProjectedCRS(
        name="NAD83 / Pennsylvania South",
        conversion=LambertConformalConic2SPConversion(
            latitude_false_origin=39.3333333333333,
            longitude_false_origin=-77.75,
            latitude_first_parallel=40.9666666666667,
            latitude_second_parallel=39.9333333333333,
            easting_false_origin=600000,
            northing_false_origin=0,
        ),
        geodetic_crs=GeographicCRS(datum="North American Datum 1983"),
        cartesian_cs=Cartesian2DCS(),
    )
    compcrs = CompoundCRS(
        name="NAD83 / Pennsylvania South + NAVD88 height", components=[projcrs, vertcrs]
    )
    assert compcrs.name == "NAD83 / Pennsylvania South + NAVD88 height"
    assert compcrs.type_name == "Compound CRS"
    assert compcrs.sub_crs_list[0].type_name == "Projected CRS"
    assert compcrs.sub_crs_list[1].type_name == "Vertical CRS"
Esempio n. 3
0
def test_vertical_crs__chance_cs_axis(axis):
    vc = VerticalCRS(
        name="NAVD88 height",
        datum="North American Vertical Datum 1988",
        vertical_cs=VerticalCS(axis=axis),
    )
    assert vc.name == "NAVD88 height"
    assert vc.type_name == "Vertical CRS"
    assert vc.coordinate_system == VerticalCS(axis=axis)
Esempio n. 4
0
def build_valid_vert_crs(crs: pyproj_VerticalCRS, regions: [str],
                         datum_data: object) -> (pyproj_VerticalCRS, str, str):
    """
    Add the regions and pipeline to the remarks section of the wkt for the
    provided pyproj VerticalCRS object.

    Parameters
    ----------
    crs : pyproj.crs.VerticalCRS
        The vertical crs object to add the pipeline and region into.
    regions : [str]
        The regions to add into the crs remarks.
    vdatum_version_string
        version of vdatum, used in the geoid/region lookup

    Returns
    -------
    result (pyproj.crs.VerticalCRS, str)
        First value is the vertical crs object with the remarks updated to add the region and
        pipeline.  The second value is the vyperdatum.pipeline datum identifier. The third
        value is the pipeline string.

    """
    datum = guess_vertical_datum_from_string(crs.name)
    pipeline = None
    new_crs = VerticalPipelineCRS(datum_data=datum_data)
    new_crs.from_wkt(crs.to_wkt())
    if datum:
        for region in regions:
            if datum == 'ellipse':
                new_pipeline = '[]'
            else:
                geoid_name = datum_data.get_geoid_name(region)
                new_pipeline = get_regional_pipeline('ellipse', datum, region,
                                                     geoid_name)
            if new_pipeline:
                new_crs.add_pipeline(new_pipeline, region)
        pipeline = new_crs.pipeline_string
        if datum == 'geoid':
            geoids = [
                gd for gd in geoid_possibilities if pipeline.find(gd) != -1
            ]
            if len(geoids) > 1:
                raise NotImplementedError(
                    f'Found multiple geoids in the pipeline string, only one geoid per pipeline supported at this time: {geoids}'
                )
            elif len(geoids) == 0:
                raise ValueError(
                    f'No geoid found in given pipeline string: {pipeline}')
            newdatum = geoids[0]
            new_crs.datum_name = newdatum
        valid_vert_crs = CRS.from_wkt(new_crs.to_wkt())
    else:
        valid_vert_crs = None
    return valid_vert_crs, datum, pipeline
Esempio n. 5
0
def test_vertical_crs__from_methods():
    assert_maker_inheritance_valid(VerticalCRS.from_epsg(5703), VerticalCRS)
    assert_maker_inheritance_valid(VerticalCRS.from_string("EPSG:5703"),
                                   VerticalCRS)
    with pytest.raises(CRSError, match="Invalid type"):
        VerticalCRS.from_proj4("+proj=latlon")
    assert_maker_inheritance_valid(
        VerticalCRS.from_user_input(VerticalCRS.from_string("EPSG:5703")),
        VerticalCRS)
    assert_maker_inheritance_valid(VerticalCRS.from_json(CRS(5703).to_json()),
                                   VerticalCRS)
    assert_maker_inheritance_valid(
        VerticalCRS.from_json_dict(CRS(5703).to_json_dict()), VerticalCRS)