/** * Returns a <code>CrsId</code> with the specified code and the * EPSG as authority. * * @param code the code for the <code>CrsId</code>. * @return a <code>CrsId</code> for the specified code,and EPSG as authority. */ public static CrsId valueOf(int code) { return valueOf(CrsId.DEFAULT_AUTHORITY, code); }
/** * Returns an instance having the specified authority and code. * * @param authority the authority that assigned the code * @param code the code for the <code>CoordinateReferenceSystem</code> * @return a <code>CrsId</code> for the specified authority and code. */ public static CrsId valueOf(String authority, int code) { if (isUnknownEPSG(authority, code)) return CrsId.UNDEFINED; return new CrsId(authority, code); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CrsIdentifiable that = (CrsIdentifiable) o; if (crsId != null ? !crsId.equals(that.crsId) : that.crsId != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; return true; }
/** * Creates an instance having the specified authority and code. * * <p>If authority EPSG and 0 or -1 is passed for the code parameter, a value equal to <code>CrsId.UNDEFINED</code> is returned. * * param base base CrsId * @return a <code>CrsId</code> for the specified authority and code. */ CrsExtendedId(CrsId base, Unit verticalUnit, Unit measureUnit) { super(base.getAuthority(), base.getCode()); this.verticalUnit = verticalUnit; this.measureUnit = measureUnit; }
/** * Creates an instance from a <code>String</code> of the form "[<authority>:]<code>". * * <p>If the "authority" prefix is missing, then the authority will be assumed to be EPSG.</p> * * @param srsString the string to parse into a <code>CrsId</code>. * @return * @throws IllegalArgumentException when the string can nog be parsed as */ static public CrsId parse(String srsString) { if (srsString == null || srsString.isEmpty()) throw new IllegalArgumentException("Require input of form '<authority>:<code>"); String[] tokens = srsString.split(":"); String authority; String codeStr = tokens[tokens.length - 1]; int code = toNumericIdentifier(codeStr); authority = DEFAULT_AUTHORITY; if (tokens.length == 2) { authority = tokens[0]; } else if( tokens.length == 7) { authority = tokens[4]; } return valueOf(authority, code); }
void setCoordinateReferenceSystem(CoordinateReferenceSystem<?> crs) { this.crs = crs; this.srid = crs.getCrsId().getCode(); }
@Override public int hashCode() { int result = crsId != null ? crsId.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); return result; } }
private CrsId decodeOptionalAuthority(int srid) { matchesElementSeparator(); if (currentToken != CrsWktVariant.AUTHORITY) { return new CrsId("EPSG", srid); } nextToken(); matchesOpenList(); String authority = decodeText(); matchesElementSeparator(); int value = decodeInt(); matchesCloseList(); return new CrsId(authority, value); }
private CrsId decodeOptionalAuthority() { return decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); }
@Override public int hashCode() { return Objects.hash(super.hashCode(), verticalUnit, measureUnit); } }
/** * Determine if the registry contains the {@code CoordinateReferenceSystem} identified by its SRID * * @param epsgCode the SRID to look up * @return true iff the registry has a corresponding {@code CoordinateReferenceSystem} */ public static boolean hasCoordinateReferenceSystemForEPSG(int epsgCode) { return crsMap.containsKey(CrsId.valueOf(epsgCode)); }
@Override public <P extends Position> String encode(Geometry<P> geometry) { String wkt = super.encode( geometry ); if ( wkt == null ) { return null; } if ( !wkt.startsWith( "SRID=" ) ) { StringBuilder sb = new StringBuilder( wkt.length() + 16 ); sb.append( "SRID=" ); // Write the SRID, the HANA default SRID is 0 if ( geometry.getSRID() == CrsId.UNDEFINED.getCode() ) { sb.append( 0 ); } else { sb.append( geometry.getSRID() ); } sb.append( ";" ); sb.append( wkt ); wkt = sb.toString(); } return wkt; }
@Override public int hashCode() { int result = crsId.hashCode(); result = 31 * result + (name != null ? name.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Projection that = (Projection) o; if (!crsId.equals(that.crsId)) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; return true; }
/** * Returns the {@code CrsId} for the specified EPSG Code. * * @param epsgCode the EPSG code * @return the <code>CrsId</code> corresponding to the specified EPSG code, or null if * no such system is registered. */ public static CrsId getCrsIdForEPSG(int epsgCode) { CrsId crsId = CrsId.valueOf(epsgCode); return crsMap.containsKey(crsId) ? crsId : null; }
/** * Returns the numeric identifier of the coordinate reference system of this <code>Geometry</code>. * <p/> * <p>A SRID is usually interpreted as meaning the EPSG-code for the coordinate reference system. In this * implementation, this is not enforced.</p> * * @return the numeric identifier of the coordinate reference system of this <code>Geometry</code>. */ public int getSRID() { return getCoordinateReferenceSystem().getCrsId().getCode(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; CrsExtendedId that = (CrsExtendedId) o; return Objects.equals(verticalUnit, that.verticalUnit) && Objects.equals(measureUnit, that.measureUnit); }
public static Geographic2DCoordinateReferenceSystem getGeographicCoordinateReferenceSystemForEPSG(int epsgCode) { CoordinateReferenceSystem<? extends Position> crs = crsMap.get(CrsId.valueOf(epsgCode)); if (crs == null) return null; if (crs.getPositionClass().equals(G2D.class)) { return (Geographic2DCoordinateReferenceSystem) crs; } throw new RuntimeException(String.format("EPSG code %d doesn't refer to geographic projection system", epsgCode)); }
private Projection decodeProjection() { matchesElementSeparator(); if (currentToken != CrsWktVariant.PROJECTION) { throw new WktDecodeException("Expected PROJECTION keyword, found " + currentToken.toString()); } String name = decodeName(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return new Projection(crsId, name); }
public static ProjectedCoordinateReferenceSystem getProjectedCoordinateReferenceSystemForEPSG(int epsgCode) { CoordinateReferenceSystem<? extends Position> crs = crsMap.get(CrsId.valueOf(epsgCode)); if (crs.getPositionClass().equals(C2D.class)) { return (ProjectedCoordinateReferenceSystem) crs; } throw new RuntimeException(String.format("EPSG code %d doesn't refer to geographic projection system", epsgCode)); }