gpt4 book ai didi

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

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

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

WKTFormat.setConvention介绍

[英]Sets the convention for parsing and formatting WKT elements.
[中]设置解析和格式化WKT元素的约定。

代码示例

代码示例来源: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

/**
 * 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

final WKTFormat f = new WKTFormat(locale, timezone);
if (convention != null) {
  f.setConvention(convention);

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

/**
 * Tests consistency between the parser and the formatter when using the WKT 1 format.
 * This test parses a WKT, formats it then parses again. We should obtain the same result.
 *
 * @throws ParseException if a parsing failed.
 */
@Test
@DependsOnMethod("testConsistencyOfWKT1")
public void testConsistencyOfWKT1_WithCommonUnits() throws ParseException {
  format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT1_COMMON_UNITS);
  parser = new WKTFormat(null, null);
  parser.setConvention(Convention.WKT1);
  testConsistency();
  testConsistencyWithDenormalizedBaseCRS();
}

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

/**
 * Tests consistency between the parser and the formatter when using the WKT 2 format.
 * This test parses a WKT, formats it then parses again. We should obtain the same result.
 *
 * @throws ParseException if a parsing failed.
 */
@Test
@DependsOnMethod("testConsistencyOfWKT1")
public void testConsistencyOfWKT2() throws ParseException {
  format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT2);
  parser = format;
  testConsistency();
}

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

/**
 * Tests consistency between the parser and the formatter when using the WKT 2 simplified format.
 * This test parses a WKT, formats it then parses again. We should obtain the same result.
 *
 * @throws ParseException if a parsing failed.
 */
@Test
@DependsOnMethod("testConsistencyOfWKT2")
public void testConsistencyOfWKT2_Simplified() throws ParseException {
  format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT2_SIMPLIFIED);
  parser = format;
  testConsistency();
}

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

/**
 * Tests consistency between the parser and the formatter when using the WKT 1 format.
 * This test parses a WKT, formats it then parses again. We should obtain the same result.
 *
 * @throws ParseException if a parsing failed.
 */
@Test
public void testConsistencyOfWKT1() throws ParseException {
  format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT1);
  parser = format;
  testConsistency();
  testConsistencyWithDenormalizedBaseCRS();
}

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

/**
 * Specialization of {@link #testCoordinateReferenceSystems()} for specific cases that were known to fail.
 * This is used for debugging purposes only; not included in normal test execution because it is redundant
 * with {@link #testCoordinateReferenceSystems()}.
 *
 * @throws FactoryException if the coordinate reference system can not be created.
 *
 * @see <a href="https://issues.apache.org/jira/browse/SIS-433">SIS-433</a>
 * @see <a href="https://issues.apache.org/jira/browse/SIS-434">SIS-434</a>
 */
public void debug() throws FactoryException {
  final String code = "EPSG::29871";
  final CoordinateReferenceSystem crs = CRS.forCode(code);
  final WKTFormat format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT2);
  lookup(parseAndFormat(format, code, crs), crs);
}

代码示例来源: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

final WKTFormat v2  = new WKTFormat(null, null);
final WKTFormat v2s = new WKTFormat(null, null);
v1 .setConvention(Convention.WKT1);
v1c.setConvention(Convention.WKT1_COMMON_UNITS);
v2 .setConvention(Convention.WKT2);
v2s.setConvention(Convention.WKT2_SIMPLIFIED);
for (final String code : CRS.getAuthorityFactory(null).getAuthorityCodes(CoordinateReferenceSystem.class)) {
  if (!EXCLUDES.contains(code) && !code.startsWith("Proj4:")) {

代码示例来源: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

format.setConvention(Convention.WKT1);
assertMultilinesEquals(
  "PROJCS[“OSGB 1936 / British National Grid”,\n" +
format.setConvention(Convention.WKT1_COMMON_UNITS);
assertMultilinesEquals(
  "PROJCS[“OSGB 1936 / British National Grid”,\n" +

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