Skip to content
Snippets Groups Projects
Commit f3fbaa2a authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Force use of factory to create simple tiles.

parent 06627a09
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ package org.orekit.rugged.core.dem;
import org.orekit.rugged.api.RuggedException;
/** Simple implementation of a {@link Tile}.
* @see SimpleTileFactory
* @author Luc Maisonobe
*/
public class SimpleTile extends AbstractTile {
......@@ -31,7 +32,7 @@ public class SimpleTile extends AbstractTile {
* Creates an empty tile.
* </p>
*/
public SimpleTile() {
SimpleTile() {
}
/** {@inheritDoc} */
......
/* Copyright 2013-2014 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.rugged.core.dem;
import org.orekit.rugged.core.dem.TileFactory;
/** Simple implementation of a {@link TileFactory} for {@link SimpleTile}.
* @author Luc Maisonobe
*/
public class SimpleTileFactory implements TileFactory<SimpleTile> {
/** {@inheritDoc} */
@Override
public SimpleTile createTile() {
return new SimpleTile();
}
}
......@@ -17,19 +17,22 @@
package orekit.rugged.core.dem;
import org.orekit.rugged.core.dem.SimpleTile;
import org.orekit.rugged.core.dem.SimpleTileFactory;
import org.orekit.rugged.core.dem.TileFactory;
public class CountingFactory implements TileFactory<SimpleTile> {
private int count;
private TileFactory<SimpleTile> rawFactory;
public CountingFactory() {
count = 0;
rawFactory = new SimpleTileFactory();
}
public SimpleTile createTile() {
++count;
return new SimpleTile();
return rawFactory.createTile();
}
public int getCount() {
......
......@@ -21,13 +21,14 @@ import org.junit.Test;
import org.orekit.rugged.api.RuggedException;
import org.orekit.rugged.api.RuggedMessages;
import org.orekit.rugged.core.dem.SimpleTile;
import org.orekit.rugged.core.dem.SimpleTileFactory;
import org.orekit.rugged.core.dem.Tile;
public class SimpleTileTest {
@Test
public void testEmpty() {
SimpleTile tile = new SimpleTile();
SimpleTile tile = new SimpleTileFactory().createTile();
Assert.assertEquals(0, tile.getMinimumLatitude(), 1.0e-10);
Assert.assertEquals(0, tile.getMinimumLongitude(), 1.0e-10);
Assert.assertEquals(0, tile.getLatitudeStep(), 1.0e-10);
......@@ -39,7 +40,7 @@ public class SimpleTileTest {
@Test
public void testUpdate() throws RuggedException {
SimpleTile tile = new SimpleTile();
SimpleTile tile = new SimpleTileFactory().createTile();
tile.setGeometry(1.0, 2.0, 0.1, 0.2, 100, 200);
for (int i = 0; i < tile.getLatitudeRows(); ++i) {
for (int j = 0; j < tile.getLongitudeColumns(); ++j) {
......@@ -71,7 +72,7 @@ public class SimpleTileTest {
@Test
public void testOutOfBounds() throws RuggedException {
SimpleTile tile = new SimpleTile();
SimpleTile tile = new SimpleTileFactory().createTile();
tile.setGeometry(1.0, 2.0, 0.1, 0.2, 100, 200);
tile.setElevation(50, 100, 1000.0);
checkOutOfBound( -1, 100, tile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment