Tabnine Logo
DefaultConversion
Code IndexAdd Tabnine to your IDE (free)

How to use
DefaultConversion
in
org.apache.sis.referencing.operation

Best Java code snippets using org.apache.sis.referencing.operation.DefaultConversion (Showing top 20 results out of 315)

origin: apache/sis

  conversion = new DefaultConversion(properties, method, null, parameters);
} catch (IllegalArgumentException exception) {
  throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
origin: org.apache.sis.core/sis-referencing

/**
 * Returns the source CRS, which must be geographic or {@code null}.
 */
@Override
public final GeographicCRS getSourceCRS() {
  return (GeographicCRS) super.getSourceCRS();
}
origin: org.apache.sis.core/sis-referencing

  /**
   * Returns the target CRS, which must be projected or {@code null}.
   */
  @Override
  public final ProjectedCRS getTargetCRS() {
    return (ProjectedCRS) super.getTargetCRS();
  }
}
origin: org.apache.sis.core/sis-referencing

/**
 * Creates the conversion instance to associate with this {@code AbstractDerivedCRS}.
 *
 * <p><b>WARNING:</b> this method is invoked at construction time and will invoke indirectly
 * (through {@link DefaultConversion}) the {@link #getCoordinateSystem()} method on {@code this}.
 * Consequently this method shall be invoked only after the construction of this {@code AbstractDerivedCRS}
 * instance is advanced enough for allowing the {@code getCoordinateSystem()} method to execute.
 * Subclasses may consider to make the {@code getCoordinateSystem()} method final for better guarantees.</p>
 */
private C createConversionFromBase(final Map<String,?> properties, final SingleCRS baseCRS, final Conversion conversion) {
  MathTransformFactory factory = null;
  if (properties != null) {
    factory = (MathTransformFactory) properties.get(ReferencingServices.MT_FACTORY);
  }
  if (factory == null) {
    factory = DefaultFactories.forBuildin(MathTransformFactory.class);
  }
  try {
    return DefaultConversion.castOrCopy(conversion).specialize(getConversionType(), baseCRS, this, factory);
  } catch (FactoryException e) {
    throw new IllegalArgumentException(Errors.getResources(properties).getString(
        Errors.Keys.IllegalArgumentValue_2, "conversion", conversion.getName()), e);
  }
}
origin: apache/sis

public void testDefiningConversion() throws FactoryException {
  final DefaultConversion reference = createLongitudeRotation(true);
  final DefaultConversion definingConversion = new DefaultConversion(
      IdentifiedObjects.getProperties(reference),
      reference.getMethod(),
      reference.getMathTransform(),
      reference.getParameterValues());
  assertNull("sourceCRS", definingConversion.getSourceCRS());
  assertNull("targetCRS", definingConversion.getTargetCRS());
  assertFalse(definingConversion.equals(reference));
  assertFalse(reference.equals(definingConversion));
  final DefaultConversion completed = definingConversion.specialize(
      DefaultConversion.class,    // In normal use, this would be 'Conversion.class'.
      changeCS(reference.getSourceCRS(), HardCodedCS.GEODETIC_φλ),
      reference.getTargetCRS(),
      DefaultFactories.forBuildin(MathTransformFactory.class));
origin: apache/sis

public void testConversionUnmarshalling() throws JAXBException {
  final DefaultConversion c = unmarshalFile(DefaultConversion.class, "Conversion.xml");
  assertEquals("name", "World Mercator", c.getName().getCode());
  assertEquals("identifier", "3395", getSingleton(c.getIdentifiers()).getCode());
  assertEquals("scope", "Very small scale mapping.", String.valueOf(c.getScope()));
  assertNull  ("operationVersion", c.getOperationVersion());
  final GeographicBoundingBox e = (GeographicBoundingBox) getSingleton(c.getDomainOfValidity().getGeographicElements());
  assertEquals("eastBoundLongitude", +180, e.getEastBoundLongitude(), STRICT);
  assertEquals("westBoundLongitude", -180, e.getWestBoundLongitude(), STRICT);
  assertNull("sourceCRS",        c.getSourceCRS());
  assertNull("targetCRS",        c.getTargetCRS());
  assertNull("interpolationCRS", c.getInterpolationCRS());
  assertNull("mathTransform",    c.getMathTransform());
  final OperationMethod method = c.getMethod();
  assertNotNull("method", method);
  verifyMethod(method);
  final ParameterValueGroup parameters = c.getParameterValues();
  assertNotNull("parameters", parameters);
  final Iterator<GeneralParameterValue> it = parameters.values().iterator();
origin: apache/sis

/**
 * Asserts that at least some of the properties of the given {@code op} instance have the expected values
 * for an instance created by {@link #createLongitudeRotation(GeographicCRS, GeographicCRS, TemporalCRS)}.
 */
@SuppressWarnings("SuspiciousToArrayCall")
private static void verifyProperties(final DefaultConversion op, final boolean swapSourceAxes) {
  assertEquals("name",       "Paris to Greenwich", op.getName().getCode());
  assertEquals("sourceCRS",  "NTF (Paris)",        op.getSourceCRS().getName().getCode());
  assertEquals("targetCRS",  "Back to Greenwich",  op.getTargetCRS().getName().getCode());
  assertEquals("method",     "Longitude rotation", op.getMethod().getName().getCode());
  assertEquals("parameters", "Longitude rotation", op.getParameterDescriptors().getName().getCode());
  final ParameterValueGroup parameters = op.getParameterValues();
  final ParameterValue<?>[] values = parameters.values().toArray(new ParameterValue<?>[1]);
  assertEquals("parameters",    "Longitude rotation", parameters.getDescriptor().getName().getCode());
  assertEquals("parameters[0]", "Longitude offset",    values[0].getDescriptor().getName().getCode());
  assertEquals("parameters[0]", OFFSET, values[0].doubleValue(), STRICT);
  assertEquals(1, values.length);
  final Matrix3 expected = new Matrix3();
  expected.m02 = OFFSET;
  if (swapSourceAxes) {
    expected.m00 = expected.m11 = 0;
    expected.m01 = expected.m10 = 1;
  }
  assertMatrixEquals("Longitude rotation of a two-dimensional CRS", expected,
      MathTransforms.getMatrix(op.getMathTransform()), STRICT);
}
origin: apache/sis

    0, 1, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1), MathTransforms.getMatrix(op.getMathTransform()), STRICT);
assertSame(op, op.specialize(Conversion.class, op.getSourceCRS(), op.getTargetCRS(), factory));
op = op.specialize(DefaultConversion.class, op.getSourceCRS(),
    changeCS(op.getTargetCRS(), HardCodedCS.GEODETIC_φλ), factory);
assertMatrixEquals("Longitude rotation of a two-dimensional CRS", Matrices.create(3, 4, new double[] {
    0, 1, 0, 0,
    1, 0, 0, OFFSET,
    0, 0, 0, 1}), MathTransforms.getMatrix(op.getMathTransform()), STRICT);
origin: apache/sis

/**
 * Creates a dummy derived CRS defined by a longitude rotation from Paris to Greenwich prime meridian,
 * and swapping the axis order. The result is equivalent to {@link HardCodedCRS#WGS84_φλ},
 * which of course makes the returned {@code DerivedCRS} totally useless.
 * Its purpose is only to perform easy tests.
 */
private static DefaultDerivedCRS createLongitudeRotation() {
  final DefaultConversion conversion = DefaultConversionTest.createLongitudeRotation(false);
  return new DefaultDerivedCRS(Collections.singletonMap(DefaultDerivedCRS.NAME_KEY, conversion.getTargetCRS().getName()),
      (SingleCRS) conversion.getSourceCRS(), conversion, HardCodedCS.GEODETIC_φλ);
}
origin: org.apache.sis.core/sis-referencing

/**
 * Invoked by JAXB at unmarshalling time for storing the result temporarily.
 *
 * @param  conversion  the unmarshalled element.
 */
public void setElement(final DefaultConversion conversion) {
  metadata = conversion;
  Context.setWrapper(Context.current(), this);
  if (conversion.getMethod() == null) incomplete("method");
}
origin: apache/sis

/**
 * Ensures that {@link DefaultConversion#specialize DefaultConversion.specialize(…)} verifies the datum.
 *
 * @throws FactoryException if an error occurred while creating the conversion.
 */
@Test
public void testDatumCheck() throws FactoryException {
  final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
  final DefaultConversion op = createLongitudeRotation(true);
  try {
    op.specialize(Conversion.class, HardCodedCRS.WGS84, HardCodedCRS.NTF_NORMALIZED_AXES, factory);
    fail("Should not have accepted to change the geodetic datum.");
  } catch (IllegalArgumentException e) {
    final String message = e.getMessage();
    assertTrue(message, message.contains("sourceCRS"));
    assertTrue(message, message.contains("Nouvelle Triangulation Française"));
  }
  try {
    op.specialize(Conversion.class, HardCodedCRS.NTF_NORMALIZED_AXES, HardCodedCRS.WGS84, factory);
    fail("Should not have accepted to change the geodetic datum.");
  } catch (IllegalArgumentException e) {
    final String message = e.getMessage();
    assertTrue(message, message.contains("targetCRS"));
    assertTrue(message, message.contains("Nouvelle Triangulation Française"));
  }
}
origin: org.apache.sis.core/sis-referencing

/**
 * Invoked by JAXB at marshalling time for getting the actual element to write
 * inside the {@code <gml:Conversion>} XML element.
 * This is the value or a copy of the value given in argument to the {@code wrap} method.
 *
 * @return the element to be marshalled.
 */
@XmlElement(name = "Conversion")
public DefaultConversion getElement() {
  return DefaultConversion.castOrCopy(metadata);
}
origin: org.apache.sis.core/sis-referencing

if (transform != null) {
  this.transform = transform;
  checkDimensions(method, 0, transform, properties);
} else if (parameters == null) {
  throw new IllegalArgumentException(Resources.forProperties(properties)
  this.parameters = Parameters.unmodifiable(parameters);
checkDimensions(properties);
origin: apache/sis

    0, 1, 0, OFFSET,
    0, 0, 1, 0,
    0, 0, 0, 1), MathTransforms.getMatrix(op.getMathTransform()), STRICT);
op = op.specialize(
    DefaultConversion.class,    // In normal use, this would be 'Conversion.class'.
    op.getSourceCRS(),          // Keep the same source CRS.
    changeCS(op.getTargetCRS(), HardCodedCS.GEODETIC_φλ),   // Swap axis order.
    DefaultFactories.forBuildin(MathTransformFactory.class));
    0, 0, 1, 0,
    0, 1, 0, OFFSET,
    0, 0, 0, 1), MathTransforms.getMatrix(op.getMathTransform()), STRICT);
origin: apache/sis

/**
 * Creates the conversion instance to associate with this {@code AbstractDerivedCRS}.
 *
 * <p><b>WARNING:</b> this method is invoked at construction time and will invoke indirectly
 * (through {@link DefaultConversion}) the {@link #getCoordinateSystem()} method on {@code this}.
 * Consequently this method shall be invoked only after the construction of this {@code AbstractDerivedCRS}
 * instance is advanced enough for allowing the {@code getCoordinateSystem()} method to execute.
 * Subclasses may consider to make the {@code getCoordinateSystem()} method final for better guarantees.</p>
 */
private C createConversionFromBase(final Map<String,?> properties, final SingleCRS baseCRS, final Conversion conversion) {
  MathTransformFactory factory = null;
  if (properties != null) {
    factory = (MathTransformFactory) properties.get(ReferencingServices.MT_FACTORY);
  }
  if (factory == null) {
    factory = DefaultFactories.forBuildin(MathTransformFactory.class);
  }
  try {
    return DefaultConversion.castOrCopy(conversion).specialize(getConversionType(), baseCRS, this, factory);
  } catch (FactoryException e) {
    throw new IllegalArgumentException(Errors.getResources(properties).getString(
        Errors.Keys.IllegalArgumentValue_2, "conversion", conversion.getName()), e);
  }
}
origin: apache/sis

/**
 * Invoked by JAXB at unmarshalling time for storing the result temporarily.
 *
 * @param  conversion  the unmarshalled element.
 */
public void setElement(final DefaultConversion conversion) {
  metadata = conversion;
  Context.setWrapper(Context.current(), this);
  if (conversion.getMethod() == null) incomplete("method");
}
origin: apache/sis

/**
 * Invoked by JAXB at marshalling time for getting the actual element to write
 * inside the {@code <gml:Conversion>} XML element.
 * This is the value or a copy of the value given in argument to the {@code wrap} method.
 *
 * @return the element to be marshalled.
 */
@XmlElement(name = "Conversion")
public DefaultConversion getElement() {
  return DefaultConversion.castOrCopy(metadata);
}
origin: apache/sis

if (transform != null) {
  this.transform = transform;
  checkDimensions(method, 0, transform, properties);
} else if (parameters == null) {
  throw new IllegalArgumentException(Resources.forProperties(properties)
  this.parameters = Parameters.unmodifiable(parameters);
checkDimensions(properties);
origin: org.apache.sis.core/sis-referencing

  conversion = new DefaultConversion(properties, method, null, parameters);
} catch (IllegalArgumentException exception) {
  throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
origin: apache/sis

  /**
   * Returns the target CRS, which must be projected or {@code null}.
   */
  @Override
  public final ProjectedCRS getTargetCRS() {
    return (ProjectedCRS) super.getTargetCRS();
  }
}
org.apache.sis.referencing.operationDefaultConversion

Javadoc

A parameterized mathematical operation that converts coordinates to another CRS without any change of org.apache.sis.referencing.datum.AbstractDatum. The best-known example of a coordinate conversion is a map projection. The parameters describing coordinate conversions are defined rather than empirically derived.

This coordinate operation contains an DefaultOperationMethod, usually with associated org.apache.sis.parameter.DefaultParameterValueGroup. In the SIS implementation, the parameter values can be either inferred from the org.apache.sis.referencing.operation.transform.AbstractMathTransformor explicitly provided at construction time in a defining conversion (see below).

Defining conversions
OperationMethod instances are generally created for a pair of existing #getSourceCRS()and #getTargetCRS(). But Conversion instances without those information may exist temporarily while creating a org.apache.sis.referencing.crs.DefaultDerivedCRS or org.apache.sis.referencing.crs.DefaultProjectedCRS. Those defining conversions have no source and target CRS since those elements are provided by the derived or projected CRS themselves. This class provides a #DefaultConversion(Map,OperationMethod,MathTransform,ParameterValueGroup) for such defining conversions.

After the source and target CRS become known, we can invoke the #specialize method for DefaultMathTransformFactory#createParameterizedTransform, instantiate a new Conversion of a more specific type ( org.opengis.referencing.operation.ConicProjection, org.opengis.referencing.operation.CylindricalProjection or org.opengis.referencing.operation.PlanarProjection) if possible, and assign the source and target CRS to it.

Immutability and thread safety
This class is immutable and thus thread-safe if the property values (not necessarily the map itself) given to the constructor are also immutable. This means that unless otherwise noted in the javadoc, Conversion instances created using only SIS factories and static constants can be shared by many objects and passed between threads without synchronization.

Most used methods

  • <init>
    Constructs a new conversion with the same values than the specified one, together with the specified
  • getMethod
  • getSourceCRS
  • getTargetCRS
  • specialize
    Returns a specialization of this conversion with a more specific type, source and target CRS. This s
  • castOrCopy
    Returns a SIS coordinate operation implementation with the values of the given arbitrary implementat
  • checkDimensions
  • ensureCompatibleDatum
    Ensures that the actual CRS uses a datum which is equals, ignoring metadata, to the datum of the exp
  • equals
  • getDomainOfValidity
  • getIdentifiers
  • getInterpolationCRS
  • getIdentifiers,
  • getInterpolationCRS,
  • getMathTransform,
  • getName,
  • getOperationVersion,
  • getParameterDescriptors,
  • getParameterValues,
  • getScope,
  • swapAndScaleAxes

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Notification (javax.management)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now