本文整理汇总了Java中javax.measure.Measure类的典型用法代码示例。如果您正苦于以下问题:Java Measure类的具体用法?Java Measure怎么用?Java Measure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Measure类属于javax.measure包,在下文中一共展示了Measure类的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: fillTable
import javax.measure.Measure; //导入依赖的package包/类
@Override
protected void fillTable(ExperimentGroup experimentGroup, int counter, List<TableRow> tableRows) {
for (ExperimentGroupRun run : experimentGroup.getReports()) {
for (int i = 0; i < run.getMeasurement().size(); i++) {
Measurement measurement = run.getMeasurement().get(i);
for(int j=0; j<measurement.getMeasurementRanges().size(); j++){
RawMeasurements rawMeasurements = measurement.getMeasurementRanges().get(j).getRawMeasurements();
if (rawMeasurements != null && !rawMeasurements.getDataSeries().isEmpty()){
final IDataSource edp2Source = new Edp2DataTupleDataSource(rawMeasurements);
Iterator<IMeasureProvider> iter = edp2Source.getDataStream().iterator();
while (iter.hasNext()) {
List<Measure<?,?>> measures = iter.next().asList();
for(int m=0; m<measures.size(); m++){
Measure<?,?> measure = measures.get(m);
if(m == 1){
TableRow result = new TableRow("System capacity");
result.value = Double.parseDouble(measure.getValue().toString());
tableRows.add(result);
}
}
}
edp2Source.getDataStream().close();
}
}
}
}
}
示例10: fillTable
import javax.measure.Measure; //导入依赖的package包/类
@Override
protected void fillTable(ExperimentGroup experimentGroup, int counter, List<TableRow> tableRows) {
for (ExperimentGroupRun run : experimentGroup.getReports()) {
for (int i = 0; i < run.getMeasurement().size(); i++) {
Measurement measurement = run.getMeasurement().get(i);
for(int j=0; j<measurement.getMeasurementRanges().size(); j++){
RawMeasurements rawMeasurements = measurement.getMeasurementRanges().get(j).getRawMeasurements();
if (rawMeasurements != null && !rawMeasurements.getDataSeries().isEmpty()){
final IDataSource edp2Source = new Edp2DataTupleDataSource(rawMeasurements);
Iterator<IMeasureProvider> iter = edp2Source.getDataStream().iterator();
while (iter.hasNext()) {
List<Measure<?,?>> measures = iter.next().asList();
for(int m=0; m<measures.size(); m++){
Measure<?,?> measure = measures.get(m);
if(m == 1){
TableRow result = new TableRow("System scalability");
result.value = Double.parseDouble(measure.getValue().toString());
tableRows.add(result);
}
}
}
edp2Source.getDataStream().close();
}
}
}
}
}
示例11: 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");
}
示例12: onStateChanged
import javax.measure.Measure; //导入依赖的package包/类
@Override
public void onStateChanged(ActivityState previous, ActivityState current, Locale locale, InteractionSession session) throws Exception {
super.onStateChanged(previous, current, locale, session);
if (ActivityState.PENDING == previous && ActivityState.ACTIVE == current) {
final List<UtterancePattern> localizedExpressions = expressions.stream()
.filter(it -> null == it.getInLanguage() || locale.equals(Locale.forLanguageTag(it.getInLanguage())))
.collect(Collectors.toList());
Preconditions.checkState(!localizedExpressions.isEmpty(),
"Cannot get %s expression for affirmation '%s' from %s expressions: %s",
locale.toLanguageTag(), getPath(), expressions.size(), expressions);
final UtterancePattern expression = localizedExpressions.get(RandomUtils.nextInt(0, localizedExpressions.size()));
// interpolate with in-slots
final String pattern = expression.getPattern();
StringBuffer sb = new StringBuffer();
final Pattern SLOT_PLACEHOLDER = Pattern.compile("\\{([a-z0-9_]+)\\}", Pattern.CASE_INSENSITIVE);
final Matcher matcher = SLOT_PLACEHOLDER.matcher(pattern);
while (matcher.find()) {
matcher.appendReplacement(sb, "");
final String slotId = matcher.group(1);
final Object slotValue = getInSlot(slotId).getLast();
log.debug("in-slot {}.{} = {}", getPath(), slotId, slotValue);
final String ssmlValue;
if (slotValue instanceof Measure) {
final MeasureFormat measureFormat = MeasureFormat.getInstance(NumberFormat.getNumberInstance(locale), UnitFormat.getInstance(locale));
ssmlValue = measureFormat.format(slotValue);
} else if (slotValue instanceof LocalDate) {
ssmlValue = DateTimeFormat.longDate().withLocale(locale).print((LocalDate) slotValue);
} else if (slotValue instanceof LocalTime) {
ssmlValue = DateTimeFormat.shortTime().withLocale(locale).print((LocalTime) slotValue);
} else if (slotValue instanceof DateTime) {
ssmlValue = DateTimeFormat.longDateTime().withLocale(locale).print((DateTime) slotValue);
} else {
ssmlValue = String.valueOf(slotValue);
}
sb.append(ssmlValue);
}
matcher.appendTail(sb);
final String result = sb.toString();
log.info("'{}' requesting CommunicateAction: {}", getPath(), result);
final CommunicateAction communicateAction = new CommunicateAction(locale, result, null);
communicateAction.setUsedForSynthesis(true);
getPendingCommunicateActions().add(communicateAction);
session.complete(this, locale);
}
}
示例13: convertNewtonToDyne
import javax.measure.Measure; //导入依赖的package包/类
public static double convertNewtonToDyne(double value) {
UnitConverter converter = NEWTON.getConverterTo(DYNE);
double out = converter.convert(Measure.valueOf(value, NEWTON).doubleValue(NEWTON));
return out;
}
示例14: convertNewtonToPoundForce
import javax.measure.Measure; //导入依赖的package包/类
public static double convertNewtonToPoundForce(double value) {
UnitConverter converter = NEWTON.getConverterTo(POUND_FORCE);
double out = converter.convert(Measure.valueOf(value, NEWTON).doubleValue(NEWTON));
return out;
}
示例15: convertNewtonToKilogramForce
import javax.measure.Measure; //导入依赖的package包/类
public static double convertNewtonToKilogramForce(double value) {
UnitConverter converter = NEWTON.getConverterTo(KILOGRAM_FORCE);
double out = converter.convert(Measure.valueOf(value, NEWTON).doubleValue(NEWTON));
return out;
}