gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-22 19:33:05 26 4
gpt4 key购买 nike

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

WKTFormat.<init>介绍

[英]Creates a format for the given locale and timezone. The given locale will be used for InternationalString localization; this is not the locale for number format.
[中]为给定的语言环境和时区创建格式。给定的语言环境将用于国际字符串本地化;这不是数字格式的区域设置。

代码示例

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

/**
 * Creates a new {@link DefaultCoordinateOperationFactory} to use for testing purpose.
 * The same factory will be used for all tests in this class.
 *
 * @throws ParseException if an error occurred while preparing the WKT parser.
 */
@BeforeClass
public static void createFactory() throws ParseException {
  factory = new DefaultCoordinateOperationFactory();
  parser  = new WKTFormat(null, null);
  parser.addFragment("NTF",
      "Datum[“Nouvelle Triangulation Française (Paris)”,\n" +
      "  Ellipsoid[“Clarke 1880 (IGN)”, 6378249.2, 293.4660212936269]]");
}

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

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
public void testConsistencyOfWKT1() throws ParseException {
  format = new WKTFormat(null, null);
  format.setConvention(Convention.WKT1);
  parser = format;
  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

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

/**
 * Tests integration in {@link WKTFormat#parse(CharSequence, ParsePosition)}.
 * This method tests only a simple WKT because it is not the purpose of this
 * method to test the parser itself. We only want to tests its integration in
 * the {@link WKTFormat} class.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
public void testParse() throws ParseException {
  format = new WKTFormat(null, null);
  final VerticalCRS crs = (VerticalCRS) format.parseObject(
      "VERT_CS[“Gravity-related height”,\n" +
      "  VERT_DATUM[“Mean Sea Level”, 2005],\n" +
      "  UNIT[“metre”, 1],\n" +
      "  AXIS[“Gravity-related height”, UP]]");
  GeodeticObjectParserTest.assertNameAndIdentifierEqual("Gravity-related height", 0, crs);
  GeodeticObjectParserTest.assertNameAndIdentifierEqual("Mean Sea Level", 0, crs.getDatum());
}

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

public static void createFactory() throws ParseException {
  factory = new DefaultCoordinateOperationFactory();
  parser  = new WKTFormat(null, null);

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

public static void createFactory() throws ParseException {
  factory = new DefaultCoordinateOperationFactory();
  parser  = new WKTFormat(null, null);
  parser.addFragment("NTF",
      "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +

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

public void testCoordinateReferenceSystems() throws FactoryException {
  assumeTrue(RUN_EXTENSIVE_TESTS);
  final WKTFormat v1  = new WKTFormat(null, null);
  final WKTFormat v1c = new WKTFormat(null, null);
  final WKTFormat v2  = new WKTFormat(null, null);
  final WKTFormat v2s = new WKTFormat(null, null);
  v1 .setConvention(Convention.WKT1);
  v1c.setConvention(Convention.WKT1_COMMON_UNITS);

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

/**
 * Parses the given Well Known Text (version 1) into a math transform.
 */
@Override
public synchronized MathTransform createFromWKT(final String wkt) throws FactoryException {
  ArgumentChecks.ensureNonEmpty("wkt", wkt);
  if (parser == null) {
    parser = new WKTFormat(null, null);
    parser.setFactory(CRSAuthorityFactory.class, this);
    parser.setFactory(MathTransformFactory.class, this);
    parser.setFactory(CoordinateOperationFactory.class, this);
  }
  try {
    return (MathTransform) parser.parseObject(wkt);
  } catch (ParseException | ClassCastException e) {
    throw new FactoryException(e);
  }
}

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

@Test
  public void testFromWKT() throws ParseException, TransformException {
    final WKTFormat parser = new WKTFormat(null, null);
    final MathTransform mt = (MathTransform) parser.parseObject("Param_MT[\"Ellipsoid_To_Geoid\"]");
    DirectPosition pos = new GeneralDirectPosition(new double[] {45, 45, 1000});
    pos = mt.transform(pos, pos);
    assertEquals(  45.000, pos.getOrdinate(0), 0.001);
    assertEquals(  45.000, pos.getOrdinate(1), 0.001);
    assertEquals(1001.515, pos.getOrdinate(2), 0.001);
  }
}

代码示例来源: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 pm = new DefaultPrimeMeridian(Collections.singletonMap(
    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();

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

final Symbols symbols = new Symbols(Symbols.SQUARE_BRACKETS);
symbols.setPairedQuotes("“”");
parser = format = new WKTFormat(null, null);
format.setSymbols(symbols);
final DefaultProjectedCRS crs = (DefaultProjectedCRS) parser.parseObject(

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