diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhagedRugged.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhagedRugged.java new file mode 100644 index 0000000000000000000000000000000000000000..59bc991a615cdce6207883176c4936d0e8c607ce --- /dev/null +++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhagedRugged.java @@ -0,0 +1,48 @@ +/* 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.duvenhage; + +import org.orekit.rugged.api.TileUpdater; +import org.orekit.rugged.core.AbstractRugged; +import org.orekit.rugged.core.dem.TilesCache; + +/** Direct and inverse localization using Duvenhage's algorithm. + * <p> + * The algorithm is described in the 2009 paper: + * <a href="http://researchspace.csir.co.za/dspace/bitstream/10204/3041/1/Duvenhage_2009.pdf">Using + * An Implicit Min/Max KD-Tree for Doing Efficient Terrain Line of Sight Calculations</a>. + * </p> + * @author Luc Maisonobe + */ +public class DuvenhagedRugged extends AbstractRugged { + + /** Cache for DEM tiles. */ + private TilesCache<MinMaxTreeTile> cache; + + /** Simple constructor. + */ + public DuvenhagedRugged() { + } + + /** {@inheritDoc} */ + @Override + public void setUpTilesManagement(TileUpdater updater, int maxCachedTiles) { + cache = new TilesCache<MinMaxTreeTile>(new MinMaxTreeTileFactory(), + updater, maxCachedTiles); + } + +} diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java new file mode 100644 index 0000000000000000000000000000000000000000..21fc47617cd2a362b617330e5effedaf1b511437 --- /dev/null +++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTile.java @@ -0,0 +1,73 @@ +/* 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.duvenhage; + +import org.orekit.rugged.api.RuggedException; +import org.orekit.rugged.core.dem.AbstractTile; +import org.orekit.rugged.core.dem.Tile; + +/** Simple implementation of a {@link Tile} with a min/max kd tree. + * @see MinMaxTreeTileFactory + * @author Luc Maisonobe + */ +public class MinMaxTreeTile extends AbstractTile { + + /** Elevation array. */ + private double[] elevations; + + /** Simple constructor. + * <p> + * Creates an empty tile. + * </p> + */ + MinMaxTreeTile() { + } + + /** {@inheritDoc} */ + @Override + public void setGeometry(final double minLatitude, final double minLongitude, + final double latitudeStep, final double longitudeStep, + final int latitudeRows, final int longitudeColumns) { + super.setGeometry(minLatitude, minLongitude, latitudeStep, longitudeStep, + latitudeRows, longitudeColumns); + this.elevations = new double[latitudeRows * longitudeColumns]; + } + + /** {@inheritDoc} */ + @Override + public void tileUpdateCompleted() throws RuggedException { + // TODO: compute min/max tree + throw RuggedException.createInternalError(null); + } + + /** {@inheritDoc} */ + @Override + public void setElevation(final int latitudeIndex, final int longitudeIndex, + final double elevation) throws RuggedException { + checkIndices(latitudeIndex, longitudeIndex); + elevations[latitudeIndex * getLongitudeColumns() + longitudeIndex] = elevation; + } + + /** {@inheritDoc} */ + @Override + public double getElevationAtIndices(int latitudeIndex, int longitudeIndex) + throws RuggedException { + checkIndices(latitudeIndex, longitudeIndex); + return elevations[latitudeIndex * getLongitudeColumns() + longitudeIndex]; + } + +} diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileFactory.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..259d81acb9d4745222b501ed55ab2d1b9afb1c64 --- /dev/null +++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/MinMaxTreeTileFactory.java @@ -0,0 +1,32 @@ +/* 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.duvenhage; + +import org.orekit.rugged.core.dem.TileFactory; + +/** Simple implementation of a {@link TileFactory} for {@link MinMaxTreeTile}. + * @author Luc Maisonobe + */ +public class MinMaxTreeTileFactory implements TileFactory<MinMaxTreeTile> { + + /** {@inheritDoc} */ + @Override + public MinMaxTreeTile createTile() { + return new MinMaxTreeTile(); + } + +}