gpt4 book ai didi

org.apache.sis.io.wkt.WKTFormat.format()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 20:11:05 24 4
gpt4 key购买 nike

本文整理了Java中org.apache.sis.io.wkt.WKTFormat.format()方法的一些代码示例,展示了WKTFormat.format()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WKTFormat.format()方法的具体详情如下:
包路径:org.apache.sis.io.wkt.WKTFormat
类名称:WKTFormat
方法名:format

WKTFormat.format介绍

[英]Formats the specified object as a Well Know Text. The formatter accepts at least the following types: FormattableObject, IdentifiedObject, org.opengis.referencing.operation.MathTransform, org.opengis.metadata.extent.GeographicBoundingBox, org.opengis.metadata.extent.VerticalExtent, org.opengis.metadata.extent.TemporalExtentand Unit.
[中]将指定的对象格式化为众所周知的文本。格式化程序至少接受以下类型:FormattableObject、IdentifiedObject、org。opengis。参考。活动MathTransform,org。opengis。元数据。程度组织的GeographicBoundingBox。opengis。元数据。程度VerticalExtent,org。opengis。元数据。程度时间单位和单位。

代码示例

代码示例来源:origin: Geomatys/geotoolkit

/**
 * Formats the given CRS as a string.
 *
 * @throws ContentFormatException if the given CRS is not formattable as a WKT.
 */
private static String format(final CoordinateReferenceSystem crs) throws ContentFormatException {
  final WKTFormat format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT1);
  format.setIndentation(WKTFormat.SINGLE_LINE);
  final String wkt = format.format(crs);
  final Warnings warning = format.getWarnings();
  if (warning != null) {
    throw new ContentFormatException(warning.toString());
  }
  return wkt;
}

代码示例来源:origin: apache/sis

/**
 * Implementation of {@link #testConsistency()} for a single WKT.
 *
 * @throws ParseException if the parsing failed.
 */
private void testConsistency(final String wkt) throws ParseException {
  final Object expected = parser.parseObject(wkt);
  final String reformat = format.format(expected);
  final Object reparsed = format.parseObject(reformat);
  assertEqualsIgnoreMetadata(expected, reparsed);
}

代码示例来源:origin: apache/sis

/**
 * Asserts that the WKT of the given object according the given convention is equal to the given regular expression.
 * This method is like {@link #assertWktEquals(String, Object)}, but the use of regular expression allows some
 * tolerance for example on numerical parameter values that may be subject to a limited form of rounding errors.
 *
 * @param convention  the WKT convention to use.
 * @param expected    the expected regular expression, or {@code null} if {@code object} is expected to be null.
 * @param object      the object to format in <cite>Well Known Text</cite> format, or {@code null}.
 *
 * @since 0.6
 */
public static void assertWktEqualsRegex(final Convention convention, final String expected, final Object object) {
  if (expected == null) {
    assertNull(object);
  } else {
    assertNotNull(object);
    final String wkt;
    synchronized (WKT_FORMAT) {
      WKT_FORMAT.setConvention(convention);
      wkt = WKT_FORMAT.format(object);
    }
    if (!wkt.matches(expected.replace("\n", System.lineSeparator()))) {
      fail("WKT does not match the expected regular expression. The WKT that we got is:\n" + wkt);
    }
  }
}

代码示例来源:origin: apache/sis

f.setColors(Colors.DEFAULT);
f.format(object, out);
out.println();
break;

代码示例来源:origin: apache/sis

/**
 * Asserts that the WKT of the given object according the given convention is equal to the expected one.
 * This method expected the {@code “…”} quotation marks instead of {@code "…"} for easier readability of
 * {@link String} constants in Java code.
 *
 * @param convention  the WKT convention to use.
 * @param expected    the expected text, or {@code null} if {@code object} is expected to be null.
 * @param object      the object to format in <cite>Well Known Text</cite> format, or {@code null}.
 */
public static void assertWktEquals(final Convention convention, final String expected, final Object object) {
  if (expected == null) {
    assertNull(object);
  } else {
    assertNotNull(object);
    final String wkt;
    synchronized (WKT_FORMAT) {
      WKT_FORMAT.setConvention(convention);
      wkt = WKT_FORMAT.format(object);
    }
    assertMultilinesEquals((object instanceof IdentifiedObject) ?
        ((IdentifiedObject) object).getName().getCode() : object.getClass().getSimpleName(), expected, wkt);
  }
}

代码示例来源:origin: apache/sis

/**
 * Prints the coordinate operation or math transform in Well Known Text format.
 * This information is printed only if the {@code --verbose} option was specified.
 */
private void printDetails() throws IOException {
  final boolean debug = options.containsKey(Option.DEBUG);
  final WKTFormat f = new WKTFormat(locale, timezone);
  if (colors) f.setColors(Colors.DEFAULT);
  f.setConvention(convention);
  CharSequence[] lines = CharSequences.splitOnEOL(f.format(debug ? operation.getMathTransform() : operation));
  for (int i=0; i<lines.length; i++) {
    if (i == 0) {
      printHeader(Vocabulary.Keys.Details);
    } else {
      printCommentLinePrefix();
      outHeader.nextColumn();
    }
    outHeader.append(lines[i]);
    outHeader.nextLine();
  }
  final Warnings warnings = f.getWarnings();
  if (warnings != null) {
    lines = CharSequences.splitOnEOL(warnings.toString());
    if (lines.length != 0) {                                            // Paranoiac check.
      printHeader(Vocabulary.Keys.Note);
      outHeader.append(lines[0]);
      outHeader.nextLine();
    }
  }
}

代码示例来源:origin: apache/sis

"  AXIS[“Easting”, EAST],\n" +
"  AXIS[“Northing”, NORTH]]",
format.format(crs));
"  AXIS[“Easting”, EAST],\n" +
"  AXIS[“Northing”, NORTH]]",
format.format(crs));
"  AXIS[“Easting”, EAST],\n" +
"  AXIS[“Northing”, NORTH]]",
format.format(crs));
"  AXIS[“Easting”, EAST],\n" +
"  AXIS[“Northing”, NORTH]]",
format.format(crs));

代码示例来源:origin: apache/sis

final String code, final CoordinateReferenceSystem crs)
String wkt = f.format(crs);
final Warnings warnings = f.getWarnings();
if (warnings != null && !warnings.getExceptions().isEmpty()) {
  return null;
final String again = f.format(parsed);
final CharSequence[] expectedLines = CharSequences.splitOnEOL(wkt);
final CharSequence[] actualLines   = CharSequences.splitOnEOL(again);

代码示例来源:origin: apache/sis

/**
   * Tests the usage of {@code WKTFormat} with WKT fragments.
   *
   * @throws ParseException if the parsing failed.
   */
  @Test
  public void testFragments() throws ParseException {
    format = new WKTFormat(null, null);
    format.addFragment("deg",    "UNIT[“degree”, 0.0174532925199433]");
    format.addFragment("Bessel", "SPHEROID[“Bessel 1841”, 6377397.155, 299.1528128, AUTHORITY[“EPSG”,“7004”]]");
    format.addFragment("Tokyo",  "DATUM[“Tokyo”, $Bessel]");
    format.addFragment("Lat",    "AXIS[“Lat”, NORTH, $deg]");
    format.addFragment("Lon",    "AXIS[“Long”, EAST, $deg]");
    final Object crs = format.parseObject("GEOGCS[“Tokyo”, $Tokyo, $Lat, $Lon]");
    final String wkt = format.format(crs);
    assertMultilinesEquals(
        "GEODCRS[\"Tokyo\",\n" +
        "  DATUM[\"Tokyo\",\n" +
        "    ELLIPSOID[\"Bessel 1841\", 6377397.155, 299.1528128, LENGTHUNIT[\"metre\", 1]]],\n" +
        "    PRIMEM[\"Greenwich\", 0.0, ANGLEUNIT[\"degree\", 0.017453292519943295]],\n" +
        "  CS[ellipsoidal, 2],\n" +
        "    AXIS[\"Latitude (B)\", north, ORDER[1]],\n" +
        "    AXIS[\"Longitude (L)\", east, ORDER[2]],\n" +
        "    ANGLEUNIT[\"degree\", 0.017453292519943295]]", wkt);
  }
}

代码示例来源:origin: apache/sis

DefaultPrimeMeridian.NAME_KEY, "Invalid “$name” here"), -10, Units.DEGREE);
format = new WKTFormat(null, null);
final String   wkt      = format.format(pm);
final Warnings warnings = format.getWarnings();
assertNotNull("warnings", warnings);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com