本文整理汇总了Java中javax.measure.Measure.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Measure.valueOf方法的具体用法?Java Measure.valueOf怎么用?Java Measure.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.measure.Measure
的用法示例。
在下文中一共展示了Measure.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: positionOf
import javax.measure.Measure; //导入方法依赖的package包/类
@Override
protected AbsolutePosition positionOf(UTM coordinates,
AbsolutePosition position) {
final LatLong latLong;
if (coordinates.latitudeZone() < 'C'
|| coordinates.latitudeZone() > 'X') {
latLong = upsToLatLong(coordinates, WGS84);
} else {
latLong = utmToLatLong(coordinates, WGS84);
}
position.latitudeWGS84 = Measure.valueOf(latLong
.latitudeValue(SI.RADIAN), SI.RADIAN);
position.longitudeWGS84 = Measure.valueOf(latLong
.longitudeValue(SI.RADIAN), SI.RADIAN);
return position;
}
示例2: main
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Starts the demo.
* @param args No args.
*/
public static void main(String[] args) {
final String string = "AgentWise";
final List<Point> points = measureString(string, 30, 30, 0);
final RandomGenerator rng = new MersenneTwister(123);
final Simulator sim = new Simulator(rng, Measure.valueOf(1000L,
SI.MILLI(SI.SECOND)));
sim.register(new PlaneRoadModel(new Point(0, 0), new Point(4500, 1200),
SI.METER, Measure.valueOf(1000d, NonSI.KILOMETERS_PER_HOUR)));
sim.configure();
for (final Point p : points) {
sim.register(new Vehicle(p, rng));
}
View.create(sim)
.with(new PlaneRoadModelRenderer(), new VehicleRenderer(),
new DemoPanel(string, rng)).show();
}
示例3: main
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* @param args
*/
@SuppressWarnings("unchecked")
public static void main(String[] args) {
@SuppressWarnings("rawtypes")
Measure length = Measure.valueOf(10, SI.METRE);
// LengthAmount length = new LengthAmount(10, SI.KILOGRAM);
// this won't work ;-)
System.out.println(length);
Unit<Length> lenUnit = length.getUnit();
System.out.println(lenUnit);
System.out.println(length.doubleValue(NonSI.FOOT));
// System.out.println(length.doubleValue(USCustomary.POUND));
// this won't work either.
// UnitConverter footConv = lenUnit.getConverterTo(NonSI.INCH);
System.out.print(((Measurable<Length>) length).doubleValue(NonSI.INCH));
System.out.println(" " + NonSI.FOOT);
Measurable<Mass> mass = Measure.valueOf(1000, SI.GRAM);
Measurable<Mass> mass2 = Measure.valueOf(1, SI.KILOGRAM);
System.out.println(mass.equals(mass2));
}
示例4: calculateDistance
import javax.measure.Measure; //导入方法依赖的package包/类
private void calculateDistance(
CoordinateReferenceSystem crs, Point[] points) {
if (crs == null) {
crs = default_crs;
}
double distance = 0.0;
try {
distance = JTS.orthodromicDistance(
points[0].getCoordinate(),
points[1].getCoordinate(), crs);
} catch (TransformException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Measure<Double, Length> dist = Measure.valueOf(
distance, SI.METER);
System.out.println(dist.doubleValue(SI.KILOMETER)
+ " Km");
System.out.println(dist.doubleValue(NonSI.MILE)
+ " miles");
}
示例5: positionOf
import javax.measure.Measure; //导入方法依赖的package包/类
@Override
protected AbsolutePosition positionOf(LatLong coordinates,
AbsolutePosition position) {
position.latitudeWGS84 = Measure.valueOf(coordinates._latitude,
DEGREE_ANGLE);
position.longitudeWGS84 = Measure.valueOf(coordinates._longitude,
DEGREE_ANGLE);
return position;
}
示例6: getSemimajorAxis
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Returns the semimajor or equatorial radius of this reference ellipsoid.
*
* @return The semimajor radius.
*/
public Measurable<Length> getSemimajorAxis() {
if (_semimajorAxis == null) {
_semimajorAxis = Measure.valueOf(a, SI.METRE);
}
return _semimajorAxis;
}
示例7: getsSemiminorAxis
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Returns the semiminor or polar radius of this reference ellipsoid.
*
* @return The semiminor radius.
*/
public Measurable<Length> getsSemiminorAxis() {
if (_semiminorAxis == null) {
_semiminorAxis = Measure.valueOf(b, SI.METRE);
}
return _semiminorAxis;
}
示例8: positionOf
import javax.measure.Measure; //导入方法依赖的package包/类
@Override
protected AbsolutePosition positionOf(XYZ coordinates,
AbsolutePosition position) {
final double x = coordinates._x;
final double y = coordinates._y;
final double z = coordinates._z;
final double longitude = Math.atan2(y, x);
final double latitude;
final double xy = Math.hypot(x, y);
// conventional result if xy == 0.0...
if (xy == 0.0) {
latitude = (z >= 0.0) ? Math.PI / 2.0 : -Math.PI / 2.0;
} else {
final double a = WGS84.getSemimajorAxis().doubleValue(METRE);
final double b = WGS84.getsSemiminorAxis().doubleValue(METRE);
final double ea2 = WGS84.getEccentricitySquared();
final double eb2 = WGS84.getSecondEccentricitySquared();
final double beta = Math.atan2(a * z, b * xy);
double numerator = z + b * eb2 * cube(Math.sin(beta));
double denominator = xy - a * ea2 * cube(Math.cos(beta));
latitude = Math.atan2(numerator, denominator);
}
final double height = xy / Math.cos(latitude)
- WGS84.verticalRadiusOfCurvature(latitude);
position.latitudeWGS84 = Measure.valueOf(latitude, RADIAN);
position.longitudeWGS84 = Measure.valueOf(longitude, RADIAN);
position.heightWGS84 = Measure.valueOf(height, METRE);
return position;
}
示例9: main
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* take two pairs of lat/long and return bearing and distance.
*
* @param args
*/
public static void main(String[] args) {
DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
if (args.length != 4) {
System.err.println("Need 4 numbers lat_1 lon_1 lat_2 lon_2");
return;
}
GeometryFactory geomFactory = new GeometryFactory();
Point[] points = new Point[2];
for (int i = 0, k = 0; i < 2; i++, k += 2) {
double x = Double.valueOf(args[k]);
double y = Double.valueOf(args[k + 1]);
if (CRS.getAxisOrder(crs).equals(AxisOrder.NORTH_EAST)) {
System.out.println("working with a lat/lon crs");
points[i] = geomFactory.createPoint(new Coordinate(x, y));
} else {
System.out.println("working with a lon/lat crs");
points[i] = geomFactory.createPoint(new Coordinate(y, x));
}
}
double distance = 0.0;
GeodeticCalculator calc = new GeodeticCalculator(crs);
calc.setStartingGeographicPoint(points[0].getX(), points[0].getY());
calc.setDestinationGeographicPoint(points[1].getX(), points[1].getY());
distance = calc.getOrthodromicDistance();
double bearing = calc.getAzimuth();
Measure<Double, Length> dist = Measure.valueOf(distance, SI.METER);
System.out.println(dist.doubleValue(SI.KILOMETER) + " Km");
System.out.println(dist.doubleValue(NonSI.MILE) + " miles");
System.out.println("Bearing " + bearing + " degrees");
}
示例10: run
import javax.measure.Measure; //导入方法依赖的package包/类
public static void run(boolean testing) throws IOException {
final MersenneTwister rand = new MersenneTwister(123);
final Simulator simulator = new Simulator(rand, Measure.valueOf(1000L,
SI.MILLI(SI.SECOND)));
final Graph<LengthData> graph = DotGraphSerializer
.getLengthGraphSerializer(new SelfCycleFilter()).read(
AgentCommunicationExample.class.getResourceAsStream(MAP_DIR));
// create models
final RoadModel roadModel = new GraphRoadModel(graph);
final CommunicationModel communicationModel = new CommunicationModel(rand,
false);
simulator.register(roadModel);
simulator.register(communicationModel);
simulator.configure();
// add agents
for (int i = 0; i < NUM_AGENTS; i++) {
final int radius = MIN_RADIUS + rand.nextInt(MAX_RADIUS - MIN_RADIUS);
final double speed = MIN_SPEED + (MAX_SPEED - MIN_SPEED)
* rand.nextDouble();
final double reliability = MIN_RELIABILITY
+ (rand.nextDouble() * (MAX_RELIABILITY - MIN_RELIABILITY));
final RandomWalkAgent agent = new RandomWalkAgent(speed, radius,
reliability);
simulator.register(agent);
}
// create GUI
final UiSchema schema = new UiSchema(false);
schema
.add(ExamplePackage.class, "/graphics/perspective/deliverypackage2.png");
final UiSchema schema2 = new UiSchema();
schema2.add(RandomWalkAgent.C_BLACK, new RGB(0, 0, 0));
schema2.add(RandomWalkAgent.C_YELLOW, new RGB(0xff, 0, 0));
schema2.add(RandomWalkAgent.C_GREEN, new RGB(0x0, 0x80, 0));
final View.Builder viewBuilder = View.create(simulator)
.with(new GraphRoadModelRenderer())
.with(new RoadUserRenderer(schema, false))
.with(new MessagingLayerRenderer(roadModel, schema2))
.setSpeedUp(4);
if (testing) {
viewBuilder.enableAutoPlay()
.enableAutoClose()
.setSpeedUp(64)
.stopSimulatorAtTime(60 * 60 * 1000);
}
viewBuilder.show();
}
示例11: run
import javax.measure.Measure; //导入方法依赖的package包/类
public static void run(boolean testing) {
// initialize a random generator which we use throughout this
// 'experiment'
final RandomGenerator rnd = new MersenneTwister(123);
// initialize a new Simulator instance
final Simulator sim = new Simulator(rnd, Measure.valueOf(1000L,
SI.MILLI(SI.SECOND)));
// register a PlaneRoadModel, a model which facilitates the moving of
// RoadUsers on a plane. The plane is bounded by two corner points:
// (0,0) and (10,10)
sim.register(new PlaneRoadModel(new Point(0, 0), new Point(10, 10),
SI.KILOMETER, Measure.valueOf(VEHICLE_SPEED, NonSI.KILOMETERS_PER_HOUR)));
// configure the simulator, once configured we can no longer change the
// configuration (i.e. add new models) but we can start adding objects
sim.configure();
// add a number of drivers on the road
final int numDrivers = 200;
for (int i = 0; i < numDrivers; i++) {
// when an object is registered in the simulator it gets
// automatically 'hooked up' with models that it's interested in. An
// object declares to be interested in an model by implementing an
// interface.
sim.register(new Driver(rnd));
}
// initialize the GUI. We use separate renderers for the road model and
// for the drivers. By default the road model is rendererd as a square
// (indicating its boundaries), and the drivers are rendererd as red
// dots.
final View.Builder viewBuilder = View.create(sim).with(
new PlaneRoadModelRenderer(), new RoadUserRenderer());
if (testing) {
viewBuilder.setSpeedUp(16)
.enableAutoClose()
.enableAutoPlay()
.stopSimulatorAtTime(10 * 60 * 1000);
}
viewBuilder.show();
// in case a GUI is not desired, the simulation can simply be run by
// calling the start method of the simulator.
}
示例12: getLastValue
import javax.measure.Measure; //导入方法依赖的package包/类
@Override
public DataPoint<Temperature> getLastValue() {
return new DataPoint<>(Measure.valueOf(getCelsius(), UNIT), Instant.now());
}
示例13: verticalRadiusOfCurvature
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Returns the <i>radius of curvature in the prime vertical</i>
* for this reference ellipsoid at the specified latitude.
*
* @param latitude The local latitude.
* @return The radius of curvature in the prime vertical.
*/
public Measurable<Length> verticalRadiusOfCurvature(final Measurable<Angle> latitude) {
return Measure.valueOf(verticalRadiusOfCurvature(latitude.doubleValue(SI.RADIAN)), SI.METRE);
}
示例14: meridionalRadiusOfCurvature
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Returns the <i>radius of curvature in the meridian<i>
* for this reference ellipsoid at the specified latitude.
*
* @param latitude The local latitude (in radians).
* @return The radius of curvature in the meridian (in meters).
*/
public Measurable<Length> meridionalRadiusOfCurvature(final Measurable<Angle> latitude) {
return Measure.valueOf(meridionalRadiusOfCurvature(latitude.doubleValue(SI.RADIAN)), SI.METRE);
}
示例15: meridionalArc
import javax.measure.Measure; //导入方法依赖的package包/类
/**
* Returns the meridional arc, the true meridional distance on the
* ellipsoid from the equator to the specified latitude.
*
* @param latitude The local latitude.
* @return The meridional arc.
*/
public Measurable<Length> meridionalArc(final Measurable<Angle> latitude) {
return Measure.valueOf(meridionalArc(latitude.doubleValue(SI.RADIAN)), SI.METRE);
}