Search in sources :

Example 11 with Length

use of javax.measure.quantity.Length in project uom-se by unitsofmeasurement.

the class NumberQuantityTest method testEqualityAtomic.

@Test
public void testEqualityAtomic() throws Exception {
    Quantity<Length> value = Quantities.getQuantity(new AtomicInteger(10), Units.METRE);
    Quantity<Length> anotherValue = Quantities.getQuantity(new AtomicLong(10), Units.METRE);
    assertEquals(value, anotherValue);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Length(javax.measure.quantity.Length) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Example 12 with Length

use of javax.measure.quantity.Length in project uom-se by unitsofmeasurement.

the class DoubleQuantityTest method testEqualityFirstDouble.

@Test
public void testEqualityFirstDouble() throws Exception {
    Quantity<Length> value = Quantities.getQuantity(new Double(10), Units.METRE);
    Quantity<Length> anotherValue = Quantities.getQuantity(new Long(10), Units.METRE);
    assertEquals(value, anotherValue);
}
Also used : Length(javax.measure.quantity.Length) AtomicLong(java.util.concurrent.atomic.AtomicLong) Test(org.junit.Test)

Example 13 with Length

use of javax.measure.quantity.Length in project indriya by unitsofmeasurement.

the class NumberQuantityTest method testEqualityAtomic.

@Test
public void testEqualityAtomic() throws Exception {
    Quantity<Length> value = Quantities.getQuantity(new AtomicInteger(10), Units.METRE);
    Quantity<Length> anotherValue = Quantities.getQuantity(new AtomicLong(10), Units.METRE);
    assertEquals(value, anotherValue);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Length(javax.measure.quantity.Length) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.jupiter.api.Test)

Example 14 with Length

use of javax.measure.quantity.Length in project sis by apache.

the class FranceGeocentricInterpolationTest method testGridAsFloats.

/**
 * Tests a small grid file with interpolations in geocentric coordinates as {@code float} values.
 *
 * <p>This method is part of a chain.
 * The next method is {@link #testGridAsShorts(DatumShiftGridFile)}.</p>
 *
 * @return the loaded grid with values as {@code float}.
 * @throws URISyntaxException if the URL to the test file can not be converted to a path.
 * @throws IOException if an error occurred while loading the grid.
 * @throws FactoryException if an error occurred while computing the grid.
 * @throws TransformException if an error occurred while computing the envelope.
 */
@TestStep
private static DatumShiftGridFile<Angle, Length> testGridAsFloats() throws URISyntaxException, IOException, FactoryException, TransformException {
    final Path file = getResource(TEST_FILE);
    final DatumShiftGridFile.Float<Angle, Length> grid;
    try (BufferedReader in = Files.newBufferedReader(file)) {
        grid = FranceGeocentricInterpolation.load(in, file);
    }
    assertEquals("cellPrecision", 0.005, grid.getCellPrecision(), STRICT);
    assertEquals("getCellMean", 168.2587, grid.getCellMean(0), 0.0001);
    assertEquals("getCellMean", 58.7163, grid.getCellMean(1), 0.0001);
    assertEquals("getCellMean", -320.1801, grid.getCellMean(2), 0.0001);
    verifyGrid(grid);
    return grid;
}
Also used : Path(java.nio.file.Path) Angle(javax.measure.quantity.Angle) Length(javax.measure.quantity.Length) BufferedReader(java.io.BufferedReader) TestStep(org.apache.sis.test.TestStep)

Example 15 with Length

use of javax.measure.quantity.Length in project com.revolsys.open by revolsys.

the class ShapeMarker method render.

@Override
public void render(final Viewport2D viewport, final Graphics2D graphics, final MarkerStyle style, final double modelX, final double modelY, double orientation) {
    final AffineTransform savedTransform = graphics.getTransform();
    try {
        final Quantity<Length> markerWidth = style.getMarkerWidth();
        final double mapWidth = Viewport2D.toDisplayValue(viewport, markerWidth);
        final Quantity<Length> markerHeight = style.getMarkerHeight();
        final double mapHeight = Viewport2D.toDisplayValue(viewport, markerHeight);
        final String orientationType = style.getMarkerOrientationType();
        if ("none".equals(orientationType)) {
            orientation = 0;
        }
        translateMarker(viewport, graphics, style, modelX, modelY, mapWidth, mapHeight, orientation);
        final AffineTransform shapeTransform = AffineTransform.getScaleInstance(mapWidth, mapHeight);
        final Shape newShape = new GeneralPath(this.getShape()).createTransformedShape(shapeTransform);
        if (style.setMarkerFillStyle(viewport, graphics)) {
            graphics.fill(newShape);
        }
        if (style.setMarkerLineStyle(viewport, graphics)) {
            graphics.draw(newShape);
        }
    } finally {
        graphics.setTransform(savedTransform);
    }
}
Also used : Shape(java.awt.Shape) GeneralPath(java.awt.geom.GeneralPath) Length(javax.measure.quantity.Length) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

Length (javax.measure.quantity.Length)44 Angle (javax.measure.quantity.Angle)7 Test (org.junit.Test)7 Color (java.awt.Color)5 Unit (javax.measure.Unit)5 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)4 AffineTransform (java.awt.geom.AffineTransform)4 ArrayList (java.util.ArrayList)4 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 LineString (com.revolsys.geometry.model.LineString)3 Point (com.revolsys.geometry.model.Point)3 Shape (java.awt.Shape)3 Rectangle2D (java.awt.geom.Rectangle2D)3 Path (java.nio.file.Path)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Quantity (javax.measure.Quantity)3 CloseableAffineTransform (com.revolsys.awt.CloseableAffineTransform)2 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)2 ChainedCoordinatesOperation (com.revolsys.geometry.cs.projection.ChainedCoordinatesOperation)2