• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Geometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.geolatte.geom.Geometry的典型用法代码示例。如果您正苦于以下问题:Java Geometry类的具体用法?Java Geometry怎么用?Java Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Geometry类属于org.geolatte.geom包,在下文中一共展示了Geometry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: facilityModule

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Bean
public Module facilityModule() {
    return new SimpleModule("geometryModule") {{
        final JsonMapper jsonMapper = new JsonMapper();

        addSerializer(Geometry.class, new GeojsonSerializer<>(jsonMapper));
        addDeserializer(Geometry.class, new GeojsonDeserializer<>(jsonMapper, Geometry.class));

        addSerializer(Polygon.class, new GeojsonSerializer<>(jsonMapper));
        addDeserializer(Polygon.class, new GeojsonDeserializer<>(jsonMapper, Polygon.class));

        addSerializer(Point.class, new GeojsonSerializer<>(jsonMapper));
        addDeserializer(Point.class, new GeojsonDeserializer<>(jsonMapper, Point.class));

        addSerializer(Feature.class, new GeojsonSerializer<>(jsonMapper));
        addSerializer(Phone.class, new PhoneSerializer());

        addSerializer(Time.class, new ToStringSerializer());
    }};
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:21,代码来源:Application.java


示例2: convertObjectValueToDataValue

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
public Object convertObjectValueToDataValue( final Object objectValue, final Session session )
{
  if( null == objectValue )
  {
    return null;
  }
  final Geometry geometry = (Geometry) objectValue;
  final String wkt = Wkt.newEncoder( Dialect.POSTGIS_EWKT_1 ).encode( geometry );
  try
  {
    return new PGgeometry( wkt );
  }
  catch ( final SQLException se )
  {
    throw new IllegalStateException( "Failed converting geometry", se );
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:19,代码来源:PostgisConverter.java


示例3: convertDataValueToObjectValue

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
public Geometry convertDataValueToObjectValue( final Object dataValue, final Session session )
{
  if( null == dataValue )
  {
    return null;
  }
  if ( dataValue instanceof PGgeometry )
  {
    final org.postgis.Geometry geometry = ( (PGgeometry) dataValue ).getGeometry();
    return Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ).decode( geometry.toString() );
  }
  else if ( dataValue instanceof String )
  {
    /*
    In some circumstances the data will come back in WKB format (i.e. When using the Driver directly)
    and sometimes it will be returned in WKT format (i.e. In GlassFish when using the DataSource) and
    it is unclear what is causing the variance so support both scenarios.
    */
    final String wk = (String) dataValue;
    final char ch = wk.charAt( 0 );
    if( '0' == ch )
    {
      //Guess that it is in WKB format
      return Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 ).decode( ByteBuffer.from( wk ) );
    }
    else
    {
      //Assume a WKT format
      return Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ).decode( wk );
    }
  }
  else
  {
    throw new IllegalStateException( "Unable to convert data value:" + dataValue );
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:38,代码来源:PostgisConverter.java


示例4: GjGeometry

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@SuppressWarnings( "ConstantConditions" )
public GjGeometry( @Nonnull final Geometry geometry,
                   @Nullable final CrsId crsId,
                   @Nullable final Envelope bbox,
                   @Nullable final JsonObject additionalProperties )
{
  super( crsId, bbox, additionalProperties );
  if ( null == geometry )
  {
    throw new IllegalArgumentException( "geometry is null" );
  }
  if ( geometry.getClass() == GeometryCollection.class )
  {
    throw new IllegalArgumentException( "geometry is a GeometryCollection" );
  }
  _geometry = geometry;
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:18,代码来源:GjGeometry.java


示例5: main

import org.geolatte.geom.Geometry; //导入依赖的package包/类
public static void main( final String[] args )
{
  final CrsId crsId = CrsRegistry.getCrsIdForEPSG( 3111 );
  final Envelope bbox = new Envelope( 0, 0, 2, 2, crsId );
  final JsonObject additionalProperties =
    Json.createObjectBuilder().
      add( "foo", false ).
      build();
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final GjGeometry e = new GjGeometry( geometry, crsId, bbox, additionalProperties );
  final ArrayList<GjGeometry> geometries = new ArrayList<GjGeometry>();
  geometries.add( e );
  final GjElement element =
    new GjGeometryCollection( geometries, crsId, bbox, additionalProperties );
  measureWritePerformance( element, 1000, 10000, 10000 );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:17,代码来源:Benchmark.java


示例6: emitPolygonGeometry

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void emitPolygonGeometry()
{
  final Geometry geometry = fromWkT( "POLYGON ( ( 100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0 ) ( 100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2 ) )" );
  final GjElement e = new GjGeometry( geometry, null, null, null );

  final JsonStructure result = writeAndRead( e );

  final String expectedJson = "{ \"type\": \"Polygon\",\n" +
                              "  \"coordinates\": [\n" +
                              "    [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],\n" +
                              "    [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]\n" +
                              "    ]\n" +
                              " }";
  final JsonObject expected = (JsonObject) parse( expectedJson );
  assertEquals( result, expected );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:18,代码来源:GeoJsonWriterTest.java


示例7: emitMultiLineStringGeometry

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void emitMultiLineStringGeometry()
{
  final Geometry geometry = fromWkT( "MULTILINESTRING ( ( 100.0 0.0, 101.0 1.0 ) ( 102.0 2.0, 103.0 3.0 ) )" );
  final GjElement e = new GjGeometry( geometry, null, null, null );

  final JsonStructure result = writeAndRead( e );


  final String expectedJson = "{ \"type\": \"MultiLineString\",\n" +
                              "  \"coordinates\": [\n" +
                              "      [ [100.0, 0.0], [101.0, 1.0] ],\n" +
                              "      [ [102.0, 2.0], [103.0, 3.0] ]\n" +
                              "    ]\n" +
                              "  }";
  final JsonObject expected = (JsonObject) parse( expectedJson );
  assertEquals( result, expected );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:19,代码来源:GeoJsonWriterTest.java


示例8: emitGeometryWithAdditionalAttributes

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void emitGeometryWithAdditionalAttributes()
{
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final JsonObject additionalProperties =
    Json.createObjectBuilder().
      add( "Foo", false ).
      add( "Bar", JsonValue.NULL ).
      build();
  final GjElement e = new GjGeometry( geometry, null, null, additionalProperties );

  final JsonStructure result = writeAndRead( e );

  final String expectedJson = "{\"type\":\"Point\",\"Foo\":false,\"Bar\":null,\"coordinates\":[1.0,1.0]}";
  final JsonObject expected = (JsonObject) parse( expectedJson );
  assertEquals( result, expected );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:18,代码来源:GeoJsonWriterTest.java


示例9: emitFeatureWithAdditionalProperties

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void emitFeatureWithAdditionalProperties()
{
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final GjGeometry g = new GjGeometry( geometry, null, null, null );
  final JsonObject additionalProperties =
    Json.createObjectBuilder().
      add( "Foo", false ).
      add( "Bar", JsonValue.NULL ).
      build();
  final GjElement e = new GjFeature( null, g, null, null, additionalProperties );

  final JsonStructure result = writeAndRead( e );

  final String expectedJson =
    "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[1.0,1.0]},\"properties\":{\"Foo\":false,\"Bar\":null}}";
  final JsonObject expected = (JsonObject) parse( expectedJson );
  assertEquals( result, expected );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:20,代码来源:GeoJsonWriterTest.java


示例10: getNullableResult

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
public Geometry getNullableResult(ResultSet rs, String columnName) throws SQLException {
	String value = rs.getString(columnName);
	if(!StringUtils.isEmpty(value)){
		return Wkt.fromWkt(value);
	}
	return null;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:9,代码来源:GeometryTypeHandler.java


示例11: convertToEntityAttribute

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
@SuppressWarnings( "unchecked" )
public T convertToEntityAttribute( final Object dbData )
{
  if ( null == dbData )
  {
    return null;
  }
  else if ( dbData instanceof PGgeometry )
  {
    final org.postgis.Geometry geometry = ( (PGgeometry) dbData ).getGeometry();
    return (T) Wkt.newDecoder( Dialect.POSTGIS_EWKT_1 ).decode( geometry.toString() );
  }
  else if ( dbData instanceof String )
  {
    /*
    In some circumstances the data will come back in WKB format (i.e. When using the Driver directly)
    and sometimes it will be returned in WKT format (i.e. In GlassFish when using the DataSource) and
    it is unclear what is causing the variance so support both scenarios.
    */
    final String wk = (String) dbData;
    final char ch = wk.charAt( 0 );
    if ( '0' == ch )
    {
      //Guess that it is in WKB format
      return (T) Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 ).decode( ByteBuffer.from( wk ) );
    }
    else
    {
      //Assume a WKT format
      return (T) Wkt.newDecoder( Dialect.POSTGIS_EWKT_1 ).decode( wk );
    }
  }
  else
  {
    throw new IllegalStateException();
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-jpa,代码行数:39,代码来源:PostgisConverter.java


示例12: doTests

import org.geolatte.geom.Geometry; //导入依赖的package包/类
private void doTests( final boolean postgres )
  throws Exception
{
  testType( postgres,
            postgres ? PgGeometryEntity.class : MsGeometryEntity.class,
            Geometry.class,
            "POINT ( 1 1 )" );
  testType( postgres,
            postgres ? PgGeometryCollectionEntity.class : MsGeometryCollectionEntity.class,
            GeometryCollection.class,
            "GEOMETRYCOLLECTION ( POINT ( 1 1 ) , POINT ( 1 1 ))" );
  testType( postgres,
            postgres ? PgPointEntity.class : MsPointEntity.class,
            Point.class,
            "POINT ( 1 1 )" );
  testType( postgres,
            postgres ? PgMultiPointEntity.class : MsMultiPointEntity.class,
            MultiPoint.class,
            "MULTIPOINT ( (100.0 0.0) , (101.0 1.0) )" );
  testType( postgres,
            postgres ? PgLineStringEntity.class : MsLineStringEntity.class,
            LineString.class,
            "LINESTRING ( 1 1, 2 1 )" );
  testType( postgres,
            postgres ? PgMultiLineStringEntity.class : MsMultiLineStringEntity.class,
            MultiLineString.class,
            "MULTILINESTRING ( ( 100.0 0.0, 101.0 1.0 ), ( 102.0 2.0, 103.0 3.0 ) )" );
  testType( postgres,
            postgres ? PgPolygonEntity.class : MsPolygonEntity.class,
            Polygon.class,
            "POLYGON((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 0.0))" );
  testType( postgres,
            postgres ? PgMultiPolygonEntity.class : MsMultiPolygonEntity.class,
            MultiPolygon.class,
            "MULTIPOLYGON(((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 0.0)))" );
}
 
开发者ID:realityforge,项目名称:geolatte-geom-jpa,代码行数:37,代码来源:AbstractConverterTest.java


示例13: getRegion

import org.geolatte.geom.Geometry; //导入依赖的package包/类
private Region getRegion(Geometry location) {
    for (Region r : regions) {
        if (r.area.intersects(location)) {
            return r;
        }
    };
    return Region.UNKNOWN_REGION;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:9,代码来源:ReportContext.java


示例14: isValid

import org.geolatte.geom.Geometry; //导入依赖的package包/类
public boolean isValid(Geometry geometry) {
        if (geometry == null) {
        return true;
    }
    PointCollection points = geometry.getPoints();
    for (int i = 0; i < points.size(); i++) {
        if (isNotBetween(19, points.getX(i), 32) || isNotBetween(59.5, points.getY(i), 70.5)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:13,代码来源:CoordinatesValidator.java


示例15: convertObjectValueToDataValue

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
public Object convertObjectValueToDataValue( final Object objectValue, final Session session )
{
  if ( null == objectValue )
  {
    return null;
  }
  else
  {
    return Encoders.encode( (Geometry) objectValue );
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:13,代码来源:SqlServerConverter.java


示例16: convertDataValueToObjectValue

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Override
public Geometry convertDataValueToObjectValue( final Object dataValue, final Session session )
{
  if ( null == dataValue )
  {
    return null;
  }
  else
  {
    Throwable cause = null;
    if ( dataValue instanceof Blob )
    {
      try
      {
        final Blob blob = (Blob) dataValue;
        return Decoders.decode( blob.getBytes( 1, (int) blob.length() ) );
      }
      catch ( final SQLException sqle )
      {
        cause = sqle;
      }
    }
    else if ( dataValue instanceof byte[] )
    {
      return Decoders.decode( (byte[]) dataValue );
    }
    throw new IllegalStateException( "Unable to convert data value:" + dataValue, cause );
  }
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:30,代码来源:SqlServerConverter.java


示例17: doTests

import org.geolatte.geom.Geometry; //导入依赖的package包/类
private void doTests( final boolean postgres )
  throws Exception
{
  testType( postgres,
            TestGeometryEntity.class,
            Geometry.class,
            "POINT ( 1 1 )" );
  testType( postgres,
            TestGeometryCollectionEntity.class,
            GeometryCollection.class,
            "GEOMETRYCOLLECTION ( POINT ( 1 1 ) , POINT ( 1 1 ))" );
  testType( postgres,
            TestPointEntity.class,
            Point.class,
            "POINT ( 1 1 )" );
  testType( postgres,
            TestMultiPointEntity.class,
            MultiPoint.class,
            "MULTIPOINT ( (100.0 0.0) , (101.0 1.0) )" );
  testType( postgres,
            TestLineStringEntity.class,
            LineString.class,
            "LINESTRING ( 1 1, 2 1 )" );
  testType( postgres,
            TestMultiLineStringEntity.class,
            MultiLineString.class,
            "MULTILINESTRING ( ( 100.0 0.0, 101.0 1.0 ), ( 102.0 2.0, 103.0 3.0 ) )" );
  testType( postgres,
            TestPolygonEntity.class,
            Polygon.class,
            "POLYGON((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 0.0))" );
  testType( postgres,
            TestMultiPolygonEntity.class,
            MultiPolygon.class,
            "MULTIPOLYGON(((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 0.0)))" );
}
 
开发者ID:realityforge,项目名称:geolatte-geom-eclipselink,代码行数:37,代码来源:AbstractGeolatteExtensionTest.java


示例18: basicInteraction

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void basicInteraction()
  throws Exception
{
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final CrsId crsId = CrsRegistry.getCrsIdForEPSG( 1234 );
  final Envelope bbox = new Envelope( 0, 0, 2, 2, crsId );
  final JsonObject additionalProperties =
    Json.createObjectBuilder().
      add( "foo", false ).
      build();
  final GjGeometry e = new GjGeometry( geometry, crsId, bbox, additionalProperties );
  assertEquals( e.getGeometry(), geometry );
  assertEquals( e.getBBox(), bbox );
  assertEquals( e.getCrsId(), crsId );
  assertEquals( e.getAdditionalProperties(), additionalProperties );
  assertPropertyAllowed( e, "X" );
  assertPropertyNotAllowed( e, "crs" );
  assertPropertyNotAllowed( e, "bbox" );
  assertPropertyNotAllowed( e, "type" );
  final JsonStructure actual = Json.createReader( new StringReader( e.toString() ) ).read();

  final String expectedJson =
    "{\"type\":\"Point\",\"bbox\":[0.0,0.0,2.0,2.0],\"foo\":false,\"coordinates\":[1.0,1.0]}";
  final JsonStructure expected = Json.createReader( new StringReader( expectedJson ) ).read();
  assertEquals( actual, expected );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:28,代码来源:GjElementTest.java


示例19: nullMetadata

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void nullMetadata()
  throws Exception
{
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final GjGeometry e = new GjGeometry( geometry, null, null, null );
  assertEquals( e.getGeometry(), geometry );
  assertNull( e.getBBox() );
  assertNull( e.getCrsId() );
  assertEquals( e.getAdditionalProperties().size(), 0 );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:12,代码来源:GjElementTest.java


示例20: basic

import org.geolatte.geom.Geometry; //导入依赖的package包/类
@Test
public void basic()
  throws Exception
{
  final Geometry geometry = fromWkT( "POINT (1 1)" );
  final GjGeometry e = new GjGeometry( geometry, null, null, null );
  assertEquals( e.getGeometry(), geometry );
  assertPropertyAllowed( e, "X" );
  assertPropertyNotAllowed( e, "coordinates" );
}
 
开发者ID:realityforge,项目名称:jeo,代码行数:11,代码来源:GjGeometryTest.java



注:本文中的org.geolatte.geom.Geometry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OnMarkerEvaluator类代码示例发布时间:2022-05-22
下一篇:
Java Image类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap