ST_AsMARC21 — Returns geometry as a MARC21/XML record with a geographic datafield (034).
text
ST_AsMARC21
(
geometry
geom
,
text
format='hdddmmss'
)
;
This function returns a MARC21/XML record with Coded Cartographic Mathematical Data representing the bounding box of a given geometry.
The format
parameter allows to encode the coordinates in subfields $d
,$e
,$f
and $g
in all formats supported by the MARC21/XML standard. Valid formats are:
cardinal direction, degrees, minutes and seconds (default): hdddmmss
decimal degrees with cardinal direction: hddd.dddddd
decimal degrees without cardinal direction: ddd.dddddd
decimal minutes with cardinal direction: hdddmm.mmmm
decimal minutes without cardinal direction: dddmm.mmmm
decimal seconds with cardinal direction: hdddmmss.sss
The decimal sign may be also a comma, e.g. hdddmm,mmmm
.
The precision of decimal formats can be limited by the number of characters after the decimal sign, e.g. hdddmm.mm
for decimal minutes with a precision of two decimals.
This function ignores the Z and M dimensions.
LOC MARC21/XML versions supported:
Availability: 3.3.0
This function does not support non lon/lat geometries, as they are not supported by the MARC21/XML standard (Coded Cartographic Mathematical Data). |
The MARC21/XML Standard does not provide any means to annotate the spatial reference system for Coded Cartographic Mathematical Data, which means that this information will be lost after conversion to MARC21/XML. |
Converting a POINT
to MARC21/XML formatted as hdddmmss (default)
SELECT ST_AsMARC21('SRID=4326;POINT(-4.504289 54.253312)'::geometry); st_asmarc21 ------------------------------------------------- <record xmlns="http://www.loc.gov/MARC21/slim"> <datafield tag="034" ind1="1" ind2=" "> <subfield code="a">a</subfield> <subfield code="d">W0043015</subfield> <subfield code="e">W0043015</subfield> <subfield code="f">N0541512</subfield> <subfield code="g">N0541512</subfield> </datafield> </record>
Converting a POLYGON
to MARC21/XML formatted in decimal degrees
SELECT ST_AsMARC21('SRID=4326;POLYGON((-4.5792388916015625 54.18172660239091,-4.56756591796875 54.196993557130355,-4.546623229980469 54.18313300502024,-4.5792388916015625 54.18172660239091))'::geometry,'hddd.dddd'); <record xmlns="http://www.loc.gov/MARC21/slim"> <datafield tag="034" ind1="1" ind2=" "> <subfield code="a">a</subfield> <subfield code="d">W004.5792</subfield> <subfield code="e">W004.5466</subfield> <subfield code="f">N054.1970</subfield> <subfield code="g">N054.1817</subfield> </datafield> </record>
Converting a GEOMETRYCOLLECTION
to MARC21/XML formatted in decimal minutes. The geometries order in the MARC21/XML output correspond to their order in the collection.
SELECT ST_AsMARC21('SRID=4326;GEOMETRYCOLLECTION(POLYGON((13.1 52.65,13.516666666666667 52.65,13.516666666666667 52.38333333333333,13.1 52.38333333333333,13.1 52.65)),POINT(-4.5 54.25))'::geometry,'hdddmm.mmmm'); st_asmarc21 ------------------------------------------------- <record xmlns="http://www.loc.gov/MARC21/slim"> <datafield tag="034" ind1="1" ind2=" "> <subfield code="a">a</subfield> <subfield code="d">E01307.0000</subfield> <subfield code="e">E01331.0000</subfield> <subfield code="f">N05240.0000</subfield> <subfield code="g">N05224.0000</subfield> </datafield> <datafield tag="034" ind1="1" ind2=" "> <subfield code="a">a</subfield> <subfield code="d">W00430.0000</subfield> <subfield code="e">W00430.0000</subfield> <subfield code="f">N05415.0000</subfield> <subfield code="g">N05415.0000</subfield> </datafield> </record>