当前位置: 首页>>代码示例>>Java>>正文


Java SI.METER属性代码示例

本文整理汇总了Java中javax.measure.unit.SI.METER属性的典型用法代码示例。如果您正苦于以下问题:Java SI.METER属性的具体用法?Java SI.METER怎么用?Java SI.METER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.measure.unit.SI的用法示例。


在下文中一共展示了SI.METER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLocationInterp2D

public void testLocationInterp2D()
{
  final LocationDocumentBuilder loc1b =
      new LocationDocumentBuilder("loc1", null, SI.MILLI(SI.SECOND), SI.METER);
  final IGeoCalculator builder = loc1b.getCalculator();
  loc1b.add(1000, builder.createPoint(2, 3));
  loc1b.add(2000, builder.createPoint(3, 4));

  final LocationDocument loc1 = loc1b.toDocument();

  Point2D geo1 = loc1.locationAt(1500);
  assertEquals("correct value", 2.5, geo1.getX());
  assertEquals("correct value", 3.5, geo1.getY());

  geo1 = loc1.locationAt(1700);
  assertEquals("correct value", 2.7, geo1.getX());
  assertEquals("correct value", 3.7, geo1.getY());
}
 
开发者ID:debrief,项目名称:limpet,代码行数:18,代码来源:TestGeotoolsGeometry.java

示例2: testStoreWrongNumberType

public void testStoreWrongNumberType()
{
  LocationDocumentBuilder ldb =
      new LocationDocumentBuilder("name", null, SI.METER);
  ldb.add(12, new Point2D.Double(12, 13));
  ldb.add(14, new Point2D.Double(15, 23));

  LocationDocument locDoc = ldb.toDocument();
  IDataset oData = locDoc.getDataset();
  assertTrue("we're expecting an object dataset",
      oData instanceof ObjectDataset);

  // ok, now check an error is thrown if we put it into a nubmer document
  NumberDocument nd = new NumberDocument(null, null, null);
  boolean thrown = false;
  try
  {
    nd.setDataset(oData);
  }
  catch (IllegalArgumentException ee)
  {
    thrown = true;
  }
  assertTrue("the expected exception got caught", thrown);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:25,代码来源:TestCollections.java

示例3: testStoreWrongLocationType

public void testStoreWrongLocationType()
{
  NumberDocumentBuilder ldb =
      new NumberDocumentBuilder("name", null, null, SI.METER);
  ldb.add(12, 213d);
  ldb.add(14, 413d);

  NumberDocument locDoc = ldb.toDocument();
  IDataset oData = locDoc.getDataset();
  assertTrue("we're expecting an object dataset",
      oData instanceof DoubleDataset);

  // ok, now check an error is thrown if we put it into a nubmer document
  LocationDocument nd = new LocationDocument(null, null);
  boolean thrown = false;
  try
  {
    nd.setDataset(oData);
  }
  catch (IllegalArgumentException ee)
  {
    thrown = true;
  }
  assertTrue("the expected exception got caught", thrown);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:25,代码来源:TestCollections.java

示例4: testStoreWrongStringType

public void testStoreWrongStringType()
{
  NumberDocumentBuilder ldb =
      new NumberDocumentBuilder("name", null, null, SI.METER);
  ldb.add(12, 213d);
  ldb.add(14, 413d);

  NumberDocument locDoc = ldb.toDocument();
  IDataset oData = locDoc.getDataset();
  assertTrue("we're expecting an object dataset",
      oData instanceof DoubleDataset);

  // ok, now check an error is thrown if we put it into a nubmer document
  StringDocument nd = new StringDocument(null, null);
  boolean thrown = false;
  try
  {
    nd.setDataset(oData);
  }
  catch (IllegalArgumentException ee)
  {
    thrown = true;
  }
  assertTrue("the expected exception got caught", thrown);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:25,代码来源:TestCollections.java

示例5: get

private Unit get(LengthUnit lengthUnit) {
    switch (lengthUnit) {
    case CENTIMETER:
        return SI.CENTIMETER;
    case MILLIMETER:
        return SI.MILLIMETER;
    case METER:
        return SI.METER;
    case INCH:
        return NonSI.INCH;
    default:
        return null;
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:14,代码来源:DefaultLengthConverter.java

示例6: testBearingBetweenTracks2D

@Test
public void testBearingBetweenTracks2D()
{
  StoreGroup store = new SampleData().getData(10);
  List<IStoreItem> selection = new ArrayList<IStoreItem>();

  LocationDocumentBuilder lda =
      new LocationDocumentBuilder("one", null, SampleData.MILLIS, SI.METER);
  LocationDocumentBuilder ldb =
      new LocationDocumentBuilder("one", null, SampleData.MILLIS, SI.METER);

  IGeoCalculator calc = lda.getCalculator();
  lda.add(1000, calc.createPoint(1, 1));
  lda.add(2000, calc.createPoint(1, 1));

  ldb.add(1000, calc.createPoint(2, 2));
  ldb.add(2000, calc.createPoint(0, 0));

  selection.add(lda.toDocument());
  selection.add(ldb.toDocument());

  List<ICommand> commands =
      new BearingBetweenTracksOperation().actionsFor(selection, store,
          context);
  ICommand oper = commands.get(0);
  oper.execute();
  NumberDocument output = (NumberDocument) oper.getOutputs().get(0);
  DoubleDataset ds = (DoubleDataset) output.getDataset();
  assertEquals("correct ang", 45d, ds.get(0), 0.0001);
  assertEquals("correct ang", 225d, ds.get(1), 0.0001);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:31,代码来源:TestOperations.java

示例7: testLocationCalc2D

public void testLocationCalc2D()
{
  final LocationDocumentBuilder loc1 =
      new LocationDocumentBuilder("loc1", null, SI.MILLI(SI.SECOND), SI.METER);
  final LocationDocumentBuilder loc2 =
      new LocationDocumentBuilder("loc2", null, SI.MILLI(SI.SECOND), SI.METER);

  final List<IStoreItem> selection = new ArrayList<IStoreItem>();
  selection.add(loc1.toDocument());

  final StoreGroup store = new StoreGroup("Results");

  // ok, try adding some data
  final IGeoCalculator builder = loc1.getCalculator();

  loc1.add(1000, builder.createPoint(4, 3));
  loc1.add(2000, builder.createPoint(3, 4));

  loc2.add(1000, builder.createPoint(5, 3));
  loc2.add(2000, builder.createPoint(3, 6));

  // put in the new documents
  selection.clear();
  selection.add(loc1.toDocument());
  selection.add(loc2.toDocument());

  List<ICommand> ops =
      new DistanceBetweenTracksOperation().actionsFor(selection, store,
          context);
  assertEquals("not empty collection", 1, ops.size());
  ICommand firstC = ops.get(0);
  // ok, execute it
  firstC.execute();

  NumberDocument output = (NumberDocument) firstC.getOutputs().get(0);
  DoubleDataset data = (DoubleDataset) output.getDataset();
  assertEquals(1d, data.get(0), 0.0001);
  assertEquals(2d, data.get(1), 0.0001);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:39,代码来源:TestGeotoolsGeometry.java

示例8: testRateOfChangeCalculation

public void testRateOfChangeCalculation()
{
  final StoreGroup group = new StoreGroup("data");
  final List<IStoreItem> selection = new ArrayList<IStoreItem>();

  final RateOfChangeOperation op = new RateOfChangeOperation();

  final NumberDocumentBuilder ndb =
      new NumberDocumentBuilder("number", SI.METER, null, SI.SECOND);
  ndb.add(1, 22d);
  ndb.add(2, 32d);
  ndb.add(3, 37d);
  ndb.add(4, 47d);
  selection.clear();
  final NumberDocument numberDoc = ndb.toDocument();
  selection.add(numberDoc);

  final List<ICommand> res = op.actionsFor(selection, group, context);
  assertEquals("non-empty for doc with contents", 1, res.size());

  res.get(0).execute();

  final NumberDocument output =
      (NumberDocument) res.get(0).getOutputs().get(0);
  assertNotNull("output produced", output);
  assertTrue("is indexed", output.isIndexed());
  assertTrue("is quantity", output.isQuantity());
  assertEquals("correct size", 3, output.size());
  assertEquals("correct index", SI.SECOND, output.getIndexUnits());

  assertEquals("correct rate", 10d, output.getValueAt(0), 0.001);
  assertEquals("correct rate", 5d, output.getValueAt(1), 0.001);
  assertEquals("correct rate", 10d, output.getValueAt(2), 0.001);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:34,代码来源:TestArithmeticCollections2.java

示例9: buffer

/**
 * Build a buffer around a geometry
 *
 * @param crs
 * @param geometry
 * @param distanceUnits
 * @param distance
 * @return
 * @throws TransformException
 */
public static final Pair<Geometry, Double> buffer(
		final CoordinateReferenceSystem crs,
		final Geometry geometry,
		final String distanceUnits,
		final double distance )
		throws TransformException {
	Unit<?> unit;
	try {
		unit = (Unit<?>) new UnitBinding().parse(
				null,
				distanceUnits);
	}
	catch (final Exception e) {
		unit = SI.METER;
		LOGGER.warn(
				"Cannot lookup unit of measure " + distanceUnits,
				e);
	}
	final double meterDistance = unit.getConverterTo(
			SI.METER).convert(
			distance);
	final double degrees = distanceToDegrees(
			crs,
			geometry,
			meterDistance);
	// buffer does not respect the CRS; it uses simple cartesian math.
	// nor does buffer handle dateline boundaries
	return Pair.of(
			adjustGeo(
					crs,
					geometry.buffer(degrees)),
			degrees);

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:44,代码来源:FeatureGeometryUtils.java

示例10: ammountToRoundedString

@SuppressWarnings("unchecked")
public static <T extends Quantity> String ammountToRoundedString(Amount<T> a) {
	if (a == null)
		return "Null";
	Unit<T> u = RocketScience.UnitPreference.preference.getPreferredUnit(a
			.getUnit());
	double d = a.doubleValue(u);

	DecimalFormat df;
	
	if (u == SI.MILLIMETER && d > 1000.0) {
		u = (Unit<T>) SI.METER;
		d = d / 1000.0;
	} else if (u == NonSI.INCH && d > 12.0) {
		u = (Unit<T>) NonSI.FOOT;
		d = d / 12.0;
	}

	if (Math.abs(d) < 10.0) {
		df = new DecimalFormat("#.##");
	} else if (Math.abs(d) < 100.0) {
		df = new DecimalFormat("#.#");
	} else {
		df = new DecimalFormat("#");
	}

	return df.format(d) + " " + u.toString();
}
 
开发者ID:bkuker,项目名称:motorsim,代码行数:28,代码来源:RocketScience.java

示例11: testLocationComplianceTest

@Test
public void testLocationComplianceTest()
{
  LocationDocumentBuilder lda1 =
      new LocationDocumentBuilder("relative", null, SECOND);
  LocationDocumentBuilder lda2 =
      new LocationDocumentBuilder("relative", null, SECOND);
  LocationDocumentBuilder ldb =
      new LocationDocumentBuilder("relative", null, SECOND, SI.METER);

  IGeoCalculator calcA = lda1.getCalculator();
  IGeoCalculator calcB = ldb.getCalculator();

  lda1.add(1000, calcA.createPoint(2, 4));
  lda1.add(2000, calcA.createPoint(3, 5));

  lda2.add(1000, calcA.createPoint(1, 2));
  lda2.add(2000, calcA.createPoint(4, 1));

  ldb.add(1000, calcB.createPoint(2, 4));
  ldb.add(2000, calcB.createPoint(3, 5));

  final List<IStoreItem> selection = new ArrayList<IStoreItem>();
  selection.add(lda1.toDocument());
  selection.add(ldb.toDocument());
  final StoreGroup store = new StoreGroup("Results");

  List<ICommand> ops =
      new DistanceBetweenTracksOperation().actionsFor(selection, store,
          context);
  assertEquals("empty collection - wrong distance units", 0, ops.size());

  // try with wroking permutation
  selection.clear();
  selection.add(lda1.toDocument());
  selection.add(lda2.toDocument());

  ops =
      new DistanceBetweenTracksOperation().actionsFor(selection, store,
          context);
  assertEquals("received command", 1, ops.size());

}
 
开发者ID:debrief,项目名称:limpet,代码行数:43,代码来源:TestOperations.java

示例12: testFilterNotIndexed

@Test
public void testFilterNotIndexed()
{
  ArrayList<IStoreItem> selection = new ArrayList<IStoreItem>();
  MockContext context = new MockContext();
  StoreGroup store = new StoreGroup("data");

  NumberDocumentBuilder builder = new NumberDocumentBuilder("doc 1", SI.METER, null, null);
  builder.add(4d);
  builder.add(5d);
  builder.add(6d);
  builder.add(7d);
  builder.add(8d);
  builder.add(7d);
  builder.add(6d);
  
  NumberDocument doc = builder.toDocument();
  selection.add(doc);
  
  List<ICommand> oper = new MaxMinFilterOperation().actionsFor(selection, store, context);
  assertNotNull("operations present", oper);
  assertEquals("correct operations", 0, oper.size());
  
  // ok, give it a singleton
  NumberDocumentBuilder sBuilder = new NumberDocumentBuilder("singleton", SI.CELSIUS, null, null);
  sBuilder.add(6d);
  NumberDocument singleton = sBuilder.toDocument();
  
  selection.add(singleton);
  
  oper = new MaxMinFilterOperation().actionsFor(selection, store, context);
  assertNotNull("operations present", oper);
  assertEquals("correct operations", 2, oper.size());
      
  // ok, run it
  oper.get(0).execute();
  
  NumberDocument nd = (NumberDocument) oper.get(0).getOutputs().get(0);
  assertNotNull("have output", nd);
  assertEquals("correct length", 4, nd.size());
  assertEquals("correct units", SI.METER, nd.getUnits());
  
  // have a got at applying the minimum filter
  singleton.setValue(5d);
  
  assertNotNull("have output", nd);
  assertEquals("correct length", 2, nd.size());
  assertEquals("correct units", SI.METER, nd.getUnits());
  
  // check the name doesn't get reset
  final String new_name = "New_Name";
  nd.setName(new_name);

  // update the singleton, which will cause the dataset to be re-filtered
  singleton.setValue(6d);
  
  assertEquals("correct length", 4, nd.size());
  assertEquals("correct units", SI.METER, nd.getUnits());
  assertEquals("correct name", new_name, nd.getName());    
}
 
开发者ID:debrief,项目名称:limpet,代码行数:60,代码来源:TestFilter.java

示例13: testFilterIndexed

@Test
  public void testFilterIndexed()
  {
    ArrayList<IStoreItem> selection = new ArrayList<IStoreItem>();
    MockContext context = new MockContext();
    StoreGroup store = new StoreGroup("data");

    NumberDocumentBuilder builder = new NumberDocumentBuilder("doc 1", SI.METER, null, SI.SECOND);
    builder.add(10d, 4d);
    builder.add(20d, 5d);
    builder.add(30d, 6d);
    builder.add(40d, 7d);
    builder.add(50d, 8d);
    builder.add(60d, 7d);
    builder.add(70d, 6d);
    
    NumberDocument doc = builder.toDocument();
    selection.add(doc);
    
    List<ICommand> oper = new MaxMinFilterOperation().actionsFor(selection, store, context);
    assertNotNull("operations present", oper);
    assertEquals("correct operations", 0, oper.size());
    
    // ok, give it a singleton
    NumberDocumentBuilder sBuilder = new NumberDocumentBuilder("singleton", SI.CELSIUS, null, null);
    sBuilder.add(6d);
    NumberDocument singleton = sBuilder.toDocument();
    
    selection.add(singleton);
    
    oper = new MaxMinFilterOperation().actionsFor(selection, store, context);
    assertNotNull("operations present", oper);
    assertEquals("correct operations", 2, oper.size());
        
    // ok, run it
    oper.get(0).execute();
    
    NumberDocument nd = (NumberDocument) oper.get(0).getOutputs().get(0);
    assertNotNull("have output", nd);
    assertEquals("correct length", 4, nd.size());
    assertEquals("correct units", SI.METER, nd.getUnits());
    assertEquals("correct index units", SI.SECOND, nd.getIndexUnits());
    
    // have a got at applying the minimum filter
    singleton.setValue(5d);
    
    // ok, run it
  //  oper.get(1).execute();
    
//    nd = (NumberDocument) oper.get(0).getOutputs().get(0);
    assertNotNull("have output", nd);
    assertEquals("correct length", 2, nd.size());
    assertEquals("correct units", SI.METER, nd.getUnits());
    assertEquals("correct index units", SI.SECOND, nd.getIndexUnits());
    
    // check the name doesn't get reset
    final String new_name = "New_Name";
    nd.setName(new_name);

    // update the singleton, which will cause the dataset to be re-filtered
    singleton.setValue(6d);
    
    assertEquals("correct length", 4, nd.size());
    assertEquals("correct units", SI.METER, nd.getUnits());
    assertEquals("correct index units", SI.SECOND, nd.getIndexUnits());
    assertEquals("correct name", new_name, nd.getName());
    
  }
 
开发者ID:debrief,项目名称:limpet,代码行数:68,代码来源:TestFilter.java

示例14: testExtrapolateOnInterpolate

public void testExtrapolateOnInterpolate()
{
  CreateNewLookupDatafileOperation op =
      new CreateNewLookupDatafileOperation();
  StoreGroup store = new StoreGroup("data");
  List<IStoreItem> selection = new ArrayList<IStoreItem>();

  // start off with values all in range
  NumberDocumentBuilder ndb =
      new NumberDocumentBuilder("lookup", NonSI.DECIBEL, null, SI.METER);
  ndb.add(100d, 55d);
  ndb.add(200d, 50d);
  ndb.add(300d, 45d);
  ndb.add(400d, 40d);

  NumberDocument lookup = ndb.toDocument();
  NumberDocumentBuilder sbj =
      new NumberDocumentBuilder("subject", SI.METER, null, null);
  sbj.add(250d);
  NumberDocument subject = sbj.toDocument();

  selection.add(subject);
  selection.add(lookup);
  List<ICommand> ops = op.actionsFor(selection, store, context);
  assertNotNull("found some actions", ops);

  ops.get(0).execute();

  NumberDocument output = (NumberDocument) ops.get(0).getOutputs().get(0);
  assertEquals("correct interpolated value", 47.5, output.getValueAt(0), 0.1);

  // now create value out of range (to the left)
  selection.remove(subject);
  sbj.clear();
  sbj.add(50d);
  subject = sbj.toDocument();
  selection.add(subject);

  ops = op.actionsFor(selection, store, context);
  assertNotNull("found some actions", ops);

  ops.get(0).execute();

  output = (NumberDocument) ops.get(0).getOutputs().get(0);
  // TODO: we still need a fix to extrapolate the value if it's outside
  // the coverage of the lookup table. The current (default) behaviour
  // is to return the first/last value
  assertEquals("correct interpolated value", 55, output.getValueAt(0), 0.1);

  // now create value out of range (to the right)
  selection.remove(subject);
  sbj.clear();
  sbj.add(500d);
  subject = sbj.toDocument();
  selection.add(subject);

  ops = op.actionsFor(selection, store, context);
  assertNotNull("found some actions", ops);

  ops.get(0).execute();

  output = (NumberDocument) ops.get(0).getOutputs().get(0);
  // TODO: we still need a fix to extrapolate the value if it's outside
  // the coverage of the lookup table. The current (default) behaviour
  // is to return the first/last value
  assertEquals("correct interpolated value", 40, output.getValueAt(0), 0.1);

}
 
开发者ID:debrief,项目名称:limpet,代码行数:68,代码来源:TestCollections.java

示例15: testBinGeneration

public void testBinGeneration()
{
  // ok, create some real docs
  NumberDocumentBuilder len1 =
      new NumberDocumentBuilder("len_1", SI.METER, null,
          SI.SECOND);
  NumberDocumentBuilder len2 =
      new NumberDocumentBuilder("len_2", SI.METER, null,
          SI.SECOND);
  NumberDocumentBuilder len3 =
      new NumberDocumentBuilder("len_2", SI.METER, null,
          SI.SECOND);
  NumberDocumentBuilder other1 =
      new NumberDocumentBuilder("other1", SI.CELSIUS, null, SI.SECOND);

  // put some data into them
  for (int i = 0; i < 25; i++)
  {
    final double thisX = (double) (( i % 10) * (i % 3));
    len1.add(i * 1000, thisX);
    final double thisY = (double) (( i % 11) * (i % 5))/5d;
    len2.add(i * 1000, thisY);
    len3.add(i * 1000, (double) (( i % 11) * (i % 5))/50d);
    final double thisZ = 100 * Math.sin(i);
    other1.add(i * 1000, thisZ);      
  }
  
  GenerateGridCommand comm = new GenerateGridCommand(null, null, null, null, null, null, null, null);
  
  double[] bins1 = comm.binsFor(len1.toDocument());
  assertNotNull("bins generated", bins1);
  assertEquals("right length for array of size larger than cut-off", QuantityFrequencyBins.DEFAULT_NUM_BINS, bins1.length);
  
  double[] bins2 = comm.binsFor(len2.toDocument());
  assertNotNull("bins generated", bins2);
  assertEquals("right length for array smaller than cut-off (but larger than min)", 7, bins2.length);

  double[] bins3 = comm.binsFor(len3.toDocument());
  assertNotNull("bins generated", bins3);
  assertEquals("right length for tiny array", QuantityFrequencyBins.MIN_NUM_BINS, bins3.length);

  // ok, now try to grid the data
  GenerateGrid gen = new GenerateGrid();
  StoreGroup store = new StoreGroup("Store");
  List<IStoreItem> selection = new ArrayList<IStoreItem>();

  selection.clear();
  selection.add(len1.toDocument());
  selection.add(len2.toDocument());
  selection.add(other1.toDocument());

  List<ICommand> ops = gen.actionsFor(selection, store, context);
  assertEquals("Perm created", 2, ops.size());

  // ok, now execute it
  final GenerateGridCommand thisOp = (GenerateGridCommand) ops.get(0);
  thisOp.execute();

  assertEquals("output produced", 1, thisOp.getOutputs().size());
  Document<?> output = thisOp.getOutputs().get(0);
  assertNotNull("Output produced", output);    
}
 
开发者ID:debrief,项目名称:limpet,代码行数:62,代码来源:TestGrids.java


注:本文中的javax.measure.unit.SI.METER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。