bool ogc_base_geod_crs :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_TBUF buf_hdr; OGC_TBUF buf_datum; OGC_TBUF buf_primem; OGC_TBUF buf_unit; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( !is_visible() ) return true; if ( (opts & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) kwd = old_kwd(); rc &= ogc_geod_datum :: to_wkt(_datum, buf_datum, opts, OGC_TBUF_MAX); rc &= ogc_primem :: to_wkt(_primem, buf_primem, opts, OGC_TBUF_MAX); rc &= ogc_unit :: to_wkt(_unit, buf_unit, opts, OGC_TBUF_MAX); ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); sprintf(buf_hdr, "%s%s\"%s\"", kwd, opn, buf_name); OGC_CPY_TO_BUF( buf_hdr ); OGC_ADD_TO_BUF( buf_datum ); OGC_ADD_TO_BUF( buf_primem ); OGC_ADD_TO_BUF( buf_unit ); OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
/*------------------------------------------------------------------------ * object to WKT */ bool ogc_method :: to_wkt_projection( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_TBUF buf_hdr; OGC_TBUF buf_id; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( (opts & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) kwd = alt_kwd(); ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); sprintf(buf_hdr, "%s%s\"%s\"", kwd, opn, buf_name); OGC_CPY_TO_BUF( buf_hdr ); if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 ) { for (int i = 0; i < id_count(); i++) { rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_id ); if ( (opts & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) break; } } OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_meridian :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_TBUF buf_angunit; OGC_TBUF buf_hdr; OGC_NBUF buf_value; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( !is_visible() ) return true; if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) return true; ogc_string :: dtoa(_value, buf_value); rc &= ogc_angunit :: to_wkt(_angunit, buf_angunit, opts, OGC_TBUF_MAX); sprintf(buf_hdr, "%s%s%s", kwd, opn, buf_value); OGC_CPY_TO_BUF( buf_hdr ); OGC_ADD_TO_BUF( buf_angunit ); OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_cs :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_TBUF buf_hdr; OGC_TBUF buf_id; OGC_NBUF buf_dimension; const char * cs_type; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) return true; cs_type = ogc_utils :: cs_type_to_kwd(_cs_type); ogc_string :: itoa(_dimension, buf_dimension); sprintf(buf_hdr, "%s%s\"%s\",%s", kwd, opn, cs_type, buf_dimension); OGC_CPY_TO_BUF( buf_hdr ); if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 ) { for (int i = 0; i < id_count(); i++) { rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_id ); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) break; } } OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_id :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_UTF8_TEXT buf_identifier; OGC_UTF8_TEXT buf_version; OGC_TBUF buf_hdr; OGC_TBUF buf_citation; OGC_TBUF buf_uri; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( !is_visible() ) return true; if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) { kwd = old_kwd(); /* old syntax requires an integer identifier > 0 */ if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) { if ( ! ogc_string::is_numeric(_identifier) ) return false; } } rc &= ogc_citation :: to_wkt(_citation, buf_citation, opts, OGC_TBUF_MAX); rc &= ogc_uri :: to_wkt(_uri, buf_uri, opts, OGC_TBUF_MAX); ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); ogc_string::escape_str(buf_identifier, _identifier, OGC_UTF8_TEXT_MAX); ogc_string::escape_str(buf_version, _version, OGC_UTF8_TEXT_MAX); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) { sprintf(buf_hdr, "%s%s\"%s\",%s", kwd, opn, buf_name, _identifier); } else { const char * q = (ogc_string::is_numeric(buf_identifier) ? "" : "\""); if ( *buf_version != 0 ) { sprintf(buf_hdr, "%s%s\"%s\",%s%s%s,\"%s\"", kwd, opn, buf_name, q, buf_identifier, q, buf_version); } else { sprintf(buf_hdr, "%s%s\"%s\",%s%s%s", kwd, opn, buf_name, q, buf_identifier, q); } } OGC_CPY_TO_BUF( buf_hdr ); OGC_ADD_TO_BUF( buf_citation ); OGC_ADD_TO_BUF( buf_uri ); OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_geog3d_crs :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_TBUF buf_hdr; OGC_TBUF buf_datum; OGC_TBUF buf_primem; OGC_TBUF buf_cs; OGC_TBUF buf_axis_1; OGC_TBUF buf_axis_2; OGC_TBUF buf_axis_3; OGC_TBUF buf_unit; OGC_TBUF buf_extent; OGC_TBUF buf_id; OGC_TBUF buf_remark; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( (opts & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) return true; rc &= ogc_geodetic_datum :: to_wkt(_datum, buf_datum, opts, OGC_TBUF_MAX); rc &= ogc_primem :: to_wkt(_primem, buf_primem, opts, OGC_TBUF_MAX); rc &= ogc_cs :: to_wkt(_cs, buf_cs, opts, OGC_TBUF_MAX); rc &= ogc_axis :: to_wkt(_axis_1, buf_axis_1, opts, OGC_TBUF_MAX); rc &= ogc_axis :: to_wkt(_axis_2, buf_axis_2, opts, OGC_TBUF_MAX); rc &= ogc_axis :: to_wkt(_axis_3, buf_axis_3, opts, OGC_TBUF_MAX); rc &= ogc_unit :: to_wkt(_unit, buf_unit, opts, OGC_TBUF_MAX); rc &= ogc_remark :: to_wkt(_remark, buf_remark, opts, OGC_TBUF_MAX); ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); sprintf(buf_hdr, "%s%s\"%s\"", kwd, opn, buf_name); OGC_CPY_TO_BUF( buf_hdr ); OGC_ADD_TO_BUF( buf_datum ); OGC_ADD_TO_BUF( buf_primem ); OGC_ADD_TO_BUF( buf_cs ); OGC_ADD_TO_BUF( buf_axis_1 ); OGC_ADD_TO_BUF( buf_axis_2 ); OGC_ADD_TO_BUF( buf_axis_3 ); OGC_ADD_TO_BUF( buf_unit ); if ( _extents != OGC_NULL && (options & OGC_WKT_OPT_OLD_SYNTAX) == 0 ) { for (int i = 0; i < extent_count(); i++) { rc &= ogc_extent :: to_wkt(extent(i), buf_extent, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_extent ); } } if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 ) { for (int i = 0; i < id_count(); i++) { rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_id ); } } OGC_ADD_TO_BUF( buf_remark ); OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_unit :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_TBUF buf_hdr; OGC_TBUF buf_id; OGC_NBUF buf_factor; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( !is_visible() ) return true; ogc_string :: dtoa(_factor, buf_factor); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) == 0 ) { switch (_unit_type) { case OGC_UNIT_TYPE_ANGLE: kwd = ogc_angunit ::obj_kwd(); break; case OGC_UNIT_TYPE_LENGTH: kwd = ogc_lenunit ::obj_kwd(); break; case OGC_UNIT_TYPE_PARAM: kwd = ogc_paramunit::obj_kwd(); break; case OGC_UNIT_TYPE_SCALE: kwd = ogc_scaleunit::obj_kwd(); break; case OGC_UNIT_TYPE_TIME: kwd = ogc_timeunit ::obj_kwd(); break; default: break; } } ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); sprintf(buf_hdr, "%s%s\"%s\",%s", kwd, opn, buf_name, buf_factor); OGC_CPY_TO_BUF( buf_hdr ); if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 ) { for (int i = 0; i < id_count(); i++) { rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_id ); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) break; } } OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }
bool ogc_ellipsoid :: to_wkt( char buffer[], int options, size_t buflen) const { OGC_UTF8_NAME buf_name; OGC_TBUF buf_hdr; OGC_TBUF buf_lenunit; OGC_TBUF buf_id; OGC_NBUF buf_sm_axis; OGC_NBUF buf_flattening; int opts = (options | OGC_WKT_OPT_INTERNAL); size_t len = 0; bool rc = true; const char * opn = "["; const char * cls = "]"; const char * kwd = obj_kwd(); if ( (options & OGC_WKT_OPT_PARENS) != 0 ) { opn = "("; cls = ")"; } if ( (opts & OGC_WKT_OPT_TOP_ID_ONLY) != 0 ) opts |= OGC_WKT_OPT_NO_IDS; if ( buffer == OGC_NULL ) return false; *buffer = 0; if ( !is_visible() ) return true; if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) kwd = alt_kwd(); double flattening = _flattening; if ( flattening != 0.0 ) flattening = (1.0 / flattening); ogc_string :: dtoa(_semi_major_axis, buf_sm_axis); ogc_string :: dtoa( flattening, buf_flattening); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) == 0 ) rc &= ogc_lenunit :: to_wkt(_lenunit, buf_lenunit, opts, OGC_TBUF_MAX); else *buf_lenunit = 0; ogc_string::escape_str(buf_name, _name, OGC_UTF8_NAME_MAX); sprintf(buf_hdr, "%s%s\"%s\",%s,%s", kwd, opn, buf_name, buf_sm_axis, buf_flattening); OGC_CPY_TO_BUF( buf_hdr ); OGC_ADD_TO_BUF( buf_lenunit ); if ( _ids != OGC_NULL && (options & OGC_WKT_OPT_NO_IDS) == 0 ) { for (int i = 0; i < id_count(); i++) { rc &= ogc_id :: to_wkt(id(i), buf_id, opts, OGC_TBUF_MAX); OGC_ADD_TO_BUF( buf_id ); if ( (options & OGC_WKT_OPT_OLD_SYNTAX) != 0 ) break; } } OGC_CPY_TO_BUF( cls ); if ( (options & OGC_WKT_OPT_INTERNAL) == 0 && (options & OGC_WKT_OPT_EXPAND) != 0 ) { rc &= ogc_utils :: expand_wkt(buffer, buffer, "", options, buflen); } return rc; }