javax.measure.unit.SI Java Examples
The following examples show how to use
javax.measure.unit.SI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapTools.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Compute the size of one metre in latitude/longitude relative to a reference point. @param lat The latitude of the reference point. @param lon The longitude of the reference point. @return The size of one metre at the reference point. */ public static double sizeOf1Metre(double lat, double lon) { UTM centre = UTM.latLongToUtm(LatLong.valueOf(lat, lon, NonSI.DEGREE_ANGLE), ReferenceEllipsoid.WGS84); UTM offset = UTM.valueOf(centre.longitudeZone(), centre.latitudeZone(), centre.eastingValue(SI.METRE), centre.northingValue(SI.METRE) + 1, SI.METRE); LatLong result = UTM.utmToLatLong(offset, ReferenceEllipsoid.WGS84); return Math.abs(result.latitudeValue(NonSI.DEGREE_ANGLE) - lat); }
Example #2
Source File: ProjectionFactory.java From gama with GNU General Public License v3.0 | 5 votes |
void computeTargetCRS(final IScope scope, final CoordinateReferenceSystem crs, final double longitude, final double latitude) { // If we already know in which CRS we project the data in GAMA, no need to recompute it. This information is // normally wiped when an experiment is disposed if (targetCRS != null) { return; } try { if (!GamaPreferences.External.LIB_TARGETED.getValue()) { targetCRS = computeDefaultCRS(scope, GamaPreferences.External.LIB_TARGET_CRS.getValue(), true); } else { if (crs != null && crs instanceof DefaultProjectedCRS) { // Temporary fix of issue 766... a better solution final CartesianCS ccs = ((DefaultProjectedCRS) crs).getCoordinateSystem(); final Unit<?> unitX = ccs.getAxis(0).getUnit(); if (unitX != null && !unitX.equals(SI.METER)) { unitConverter = unitX.getConverterTo(SI.METER); } targetCRS = crs; } else { final int index = (int) (0.5 + (longitude + 186.0) / 6); final boolean north = latitude > 0; final String newCode = EPSGPrefix + (32600 + index + (north ? 0 : 100)); targetCRS = getCRS(scope, newCode); } } } catch (final GamaRuntimeException e) { e.addContext( "The cause could be that you try to re-project already projected data (see Gama > Preferences... > External for turning the option to true)"); throw e; } }