当前位置: 首页>>代码示例>>Java>>正文


Java Geometry类代码示例

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


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


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