| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.environment.surface.impl; |
| |
| import org.eclipse.apogy.common.images.AbstractEImage; |
| import org.eclipse.apogy.common.math.ApogyCommonMathFacade; |
| import org.eclipse.apogy.common.math.Matrix4x4; |
| import org.eclipse.apogy.core.environment.surface.ApogySurfaceEnvironmentFactory; |
| import org.eclipse.apogy.core.environment.surface.RectangularRegion; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| |
| public abstract class ImageMapLayerCustomImpl extends ImageMapLayerImpl { |
| |
| @Override |
| public double getResolution() { |
| this.resolution = -1; |
| if (getImage() != null) { |
| double hResolution = getWidth() / getImage().getWidth(); |
| double vResolution = getHeight() / getImage().getHeight(); |
| this.resolution = (hResolution + vResolution) / 2.0; |
| } |
| return this.resolution; |
| } |
| |
| public RectangularRegion getImageMapLayerRegion() { |
| RectangularRegion rectangularRegion = ApogySurfaceEnvironmentFactory.eINSTANCE.createRectangularRegion(); |
| rectangularRegion.setTransformation(ApogyCommonMathFacade.INSTANCE.createIdentityMatrix4x4()); |
| |
| if (getMap() != null && getMap().getTransformation() != null) { |
| Matrix4x4 copy = EcoreUtil.copy(getMap().getTransformation()); |
| rectangularRegion.setTransformation(copy); |
| } |
| |
| // Fills in the extent. |
| rectangularRegion.setXMin(0); |
| rectangularRegion.setXMax(getWidth()); |
| rectangularRegion.setYMin(0); |
| rectangularRegion.setYMax(getHeight()); |
| |
| return rectangularRegion; |
| } |
| |
| public AbstractEImage getRegionImage() { |
| return getImage(); |
| } |
| |
| public RectangularRegion getRegion() { |
| return getImageMapLayerRegion(); |
| } |
| |
| } // ImageMapLayerImpl |