private static ICRS getEncodedCrs( final String[] tokens ) { if ( tokens.length % 2 == 1 ) { return getCRSRef( tokens[tokens.length - 1] ); } return null; } }
/** * Returns a {@link CRSRef} instance which is not resolved. * * @param uri * the uri of the resource which is used to resolve the reference * @return an unresolved {@link CRSRef} instance */ public static CRSRef getCRSRef( String uri ) { return getCRSRef( uri, false ); }
public static ICRS getAxisAwareCrs( final String epsgCode ) { final String identifierWithCorrectOrder = "urn:ogc:def:crs:epsg::" + epsgCode; return CRSManager.getCRSRef( identifierWithCorrectOrder ); }
/** * @return the defined crs or null if no crs was defined. */ public ICRS getCRS() { String s = options.get( CRS ); if ( s == null || "".equals( s.trim() ) ) { return null; } return CRSManager.getCRSRef( s ); }
/** * @param crs * should be a list of whitespace separated identifiers, may be null */ public static List<ICRS> fromJaxb( String crs ) { ArrayList<ICRS> list = new ArrayList<ICRS>(); if ( crs == null ) { return list; } for ( String c : crs.split( "\\s" ) ) { if ( !c.isEmpty() ) { list.add( CRSManager.getCRSRef( c ) ); } } return list; }
protected static Envelope parseBBox200( String bboxStr ) { String[] coordList = bboxStr.split( "," ); // NOTE: Contradiction between spec and CITE tests (for omitted crsUri) // - WFS 1.1.0 spec, 14.3.3: coordinates should be in WGS84 // - CITE tests, wfs:wfs-1.1.0-Basic-GetFeature-tc8.1: If no CRS reference is provided, a service-defined // default value must be assumed. ICRS bboxCrs = null; if ( coordList.length % 2 == 1 ) { bboxCrs = CRSManager.getCRSRef( coordList[coordList.length - 1] ); } return createEnvelope( bboxStr, bboxCrs ); } }
/** * @param crs * @return the auto crs as defined in WMS 1.1.1 spec Annex E */ public static ICRS getCRS111( String crs ) { if ( crs.startsWith( "AUTO:" ) ) { String[] cs = crs.split( ":" )[1].split( "," ); int id = Integer.parseInt( cs[0] ); // this is not supported // int units = Integer.parseInt( cs[1] ); double lon0 = Double.parseDouble( cs[2] ); double lat0 = Double.parseDouble( cs[3] ); return Utils.getAutoCRS( id, lon0, lat0 ); } return CRSManager.getCRSRef( crs, true ); }
private static ICRS getAuto42005( double lon0 ) { double central_meridian = lon0; String wkt = "PROJCS[\"WGS 84 / Auto Mollweide\","; wkt += " GEOGCS[\"WGS 84\","; wkt += " DATUM[\"WGS_1984\","; wkt += " SPHEROID[\"WGS_1984\", 6378137, 298.257223563]],"; wkt += " PRIMEM[\"Greenwich\", 0],"; wkt += " UNIT[\"Decimal_Degree\", 0.0174532925199433]],"; wkt += " PROJECTION[\"Mollweide\"],"; wkt += " PARAMETER[\"Central_Meridian\", " + central_meridian + "],"; wkt += " UNIT[\"Meter\", 1]]"; LOG.debug( "Generated wkt: {}", wkt ); try { return CRSManager.getCRSRef( WKTParser.parse( wkt ) ); } catch ( IOException e ) { LOG.debug( "Unknown error", e ); } return null; }
private ICRS determineActiveCRS( XMLStreamReaderWrapper xmlStream, ICRS defaultCRS ) { ICRS activeCRS = defaultCRS; String srsName = xmlStream.getAttributeValue( null, "srsName" ); if ( !( srsName == null || srsName.length() == 0 ) ) { if ( defaultCRS == null || !srsName.equals( defaultCRS.getAlias() ) ) { activeCRS = CRSManager.getCRSRef( srsName ); } } return activeCRS; }
private Envelope readEnvelope( ByteBuffer bb ) { Envelope result = null; if ( ( bb.position() + ( 6 * ( AllocatedHeapMemory.DOUBLE_SIZE ) ) ) < bb.capacity() ) { double[] min = new double[] { bb.getDouble(), bb.getDouble(), bb.getDouble() }; double[] max = new double[] { bb.getDouble(), bb.getDouble(), bb.getDouble() }; String crs = ObjectSerializer.readString( bb ); result = new GeometryFactory().createEnvelope( min, max, CRSManager.getCRSRef( crs ) ); } return result; }
private void initQueryCRS( List<String> queryCRSLists ) { // try { for ( String queryCRS : queryCRSLists ) { String[] querySrs = StringUtils.split( queryCRS, " ", REMOVE_EMPTY_FIELDS | REMOVE_DOUBLE_FIELDS ); for ( String srs : querySrs ) { LOG.debug( "Query CRS: " + srs ); ICRS crs = CRSManager.getCRSRef( srs ); this.queryCRS.add( crs ); } } // } catch ( UnknownCRSException e ) { // String msg = "Invalid QuerySRS parameter: " + e.getMessage(); // throw new ControllerInitException( msg ); // } if ( queryCRS.isEmpty() ) { LOG.info( "No query CRS defined, defaulting to EPSG:4326." ); queryCRS.add( CRSUtils.EPSG_4326 ); } defaultQueryCRS = this.queryCRS.get( 0 ); }
/** * Returns the {@link MappedAppSchema} derived from configuration / tables. * * @return mapped application schema, never <code>null</code> */ public MappedAppSchema getMappedSchema() { FeatureType[] fts = ftNameToFt.values().toArray( new FeatureType[ftNameToFt.size()] ); FeatureTypeMapping[] ftMappings = ftNameToMapping.values().toArray( new FeatureTypeMapping[ftNameToMapping.size()] ); Map<FeatureType, FeatureType> ftToSuperFt = null; Map<String, String> prefixToNs = null; GMLSchemaInfoSet xsModel = null; // TODO GeometryStorageParams geometryParams = new GeometryStorageParams( CRSManager.getCRSRef( "EPSG:4326" ), dialect.getUndefinedSrid(), CoordinateDimension.DIM_2 ); return new MappedAppSchema( fts, ftToSuperFt, prefixToNs, xsModel, ftMappings, null, null, geometryParams, deleteCascadingByDB, null, null, null ); }
/** * Returns the {@link MappedAppSchema} derived from configuration / tables. * * @return mapped application schema, never <code>null</code> */ @Override public MappedAppSchema getMappedSchema() { FeatureType[] fts = ftNameToFt.values().toArray( new FeatureType[ftNameToFt.size()] ); FeatureTypeMapping[] ftMappings = ftNameToMapping.values().toArray( new FeatureTypeMapping[ftNameToMapping.size()] ); Map<FeatureType, FeatureType> ftToSuperFt = null; Map<String, String> prefixToNs = null; GMLSchemaInfoSet xsModel = null; // TODO GeometryStorageParams geometryParams = new GeometryStorageParams( CRSManager.getCRSRef( "EPSG:4326" ), dialect.getUndefinedSrid(), CoordinateDimension.DIM_2 ); return new MappedAppSchema( fts, ftToSuperFt, prefixToNs, xsModel, ftMappings, null, null, geometryParams, deleteCascadingByDB, null, null, null ); }
@Override public void setValue( double[] lower, double[] upper, String crsName ) { setValue( geomFac.createEnvelope( lower, upper, CRSManager.getCRSRef( crsName ) ) ); }
public static void paintLegendText( int origin, LegendOptions opts, String text, TextRenderer textRenderer ) { TextStyling textStyling = new TextStyling(); textStyling.font = new org.deegree.style.styling.components.Font(); textStyling.font.fontFamily.add( 0, "Arial" ); textStyling.font.fontSize = opts.textSize; textStyling.anchorPointX = 0; textStyling.anchorPointY = 0.5; textStyling.uom = Metre; if ( text != null && text.length() > 0 ) { textRenderer.render( textStyling, text, geofac.createPoint( null, opts.baseWidth + opts.spacing * 2, origin - opts.baseHeight / 2 - opts.spacing, CRSManager.getCRSRef( "CRS:1" ) ) ); } }
private static RasterTreeBuilder initRTB( CommandLine line ) throws ParseException { RasterIOOptions options = RasterOptionsParser.parseRasterIOOptions( line ); String t_srs = line.getOptionValue( OPT_T_SRS ); ICRS tSRS = null; if ( t_srs == null ) { tSRS = options.getCRS(); } else { tSRS = CRSManager.getCRSRef( t_srs ); } File outDir = new File( line.getOptionValue( OPT_RASTER_OUT_LOC ) ); InterpolationType interpolationType = getInterpolationType( line.getOptionValue( OPT_INTERPOLATION ) ); int maxTileSize = getIntOption( line, OPT_TILE_SIZE, DEFAULT_TILE_SIZE ); return new RasterTreeBuilder( options, tSRS, outDir, maxTileSize, interpolationType ); }
private boolean axisFlipped( ICRS crs ) { if ( crs.getAlias().startsWith( "EPSG:" ) ) { crs = CRSManager.getCRSRef( "urn:ogc:def:crs:EPSG::" + crs.getAlias().substring( 5 ) ); } return wmsVersion.equals( VERSION_111 ) || crs.getAxis()[0].getOrientation() == Axis.AO_EAST; }
@Override public BatchedMTStore build() { BatchedMTStore bs = null; try { CRSManager.getCRSRef( config.getCrs() ); URL dir = metadata.getLocation().resolveToUrl( config.getDirectory() ); int maxDirectMem = config.getMaxDirectMemory().intValue(); bs = new BatchedMTFileStore( dir, maxDirectMem, metadata ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to build batched MT store: " + e.getLocalizedMessage(), e ); } return bs; }
private Envelope parseEnvelope() throws OWSException { // get the values from a spatial subset OMElement envelope = parseEnvelopeElement(); String srsName = parseSRSName( envelope, "EPSG:4326" ); List<OMElement> posElems = getElements( envelope, new XPath( "gml:pos", wcsNSContext ) ); if ( posElems.size() != 2 ) { throw new OWSException( "invalid envelope, need two gml:pos", OWSException.INVALID_PARAMETER_VALUE, "spatialSubset" ); } double[] min = parseNums( "gml:pos", posElems.get( 0 ) ); double[] max = parseNums( "gml:pos", posElems.get( 1 ) ); ICRS crs = CRSManager.getCRSRef( srsName ); GeometryFactory geomFactory = new GeometryFactory(); return geomFactory.createEnvelope( min, max, crs ); }
/** * * @param bboxEl * @return */ public Envelope parseWGS84BoundingBox( OMElement bboxEl ) { // <element name="LowerCorner" type="ows:PositionType2D"> double[] lowerCorner = parseDoubleList( getRequiredElement( bboxEl, new XPath( "ows:LowerCorner", nsContext ) ) ); // <element name="UpperCorner" type="ows:PositionType2D"> double[] upperCorner = parseDoubleList( getRequiredElement( bboxEl, new XPath( "ows:UpperCorner", nsContext ) ) ); // <attribute name="crs" type="anyURI" use="optional" fixed="urn:ogc:def:crs:OGC:2:84"> // TODO String crsName = "EPSG:4326"; CRSRef crsRef = CRSManager.getCRSRef( crsName ); // "dimensions" attribute (optional) // int dimensions = getNodeAsInt( boundingBoxDataElement, new XPath( "@dimensions", nsContext ), -1 ); return geomFac.createEnvelope( lowerCorner, upperCorner, crsRef ); }