001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins.streetside;
003
004import java.awt.image.BufferedImage;
005import java.util.EnumSet;
006import java.util.HashMap;
007import java.util.Map;
008
009import org.openstreetmap.josm.data.coor.LatLon;
010import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils;
011import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
012
013import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils.CubemapFaces;
014
015/**
016 * @author renerr18
017 *
018 *
019 */
020public class StreetsideCubemap extends StreetsideAbstractImage implements Comparable<StreetsideAbstractImage>{
021
022        //private static Map<String,Map<String,BufferedImage>> face2TilesMap = new HashMap<String,Map<String,BufferedImage>>();
023
024        /**
025        * If two values for field cd differ by less than EPSILON both values are considered equal.
026        */
027        @SuppressWarnings("unused")
028        private static final float EPSILON = 1e-5f;
029
030        /**
031         * Main constructor of the class StreetsideCubemap
032         *
033         * @param quadId
034         *            The Streetside id of the base frontal image of the cubemap
035         *            in quternary
036         * @param latLon
037         *            The latitude and longitude where it is positioned.
038         * @param he
039         *            The direction of the images in degrees, meaning 0 north (camera
040         *            direction is not yet supported in the Streetside plugin).
041         */
042    @SuppressWarnings({ "unchecked", "rawtypes" })
043        public StreetsideCubemap(String quadId, LatLon latLon, double he) {
044                super(quadId, latLon, he);
045                /*face2TilesMap = new HashMap();
046
047                EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
048                        face2TilesMap.put(face.getValue(), new HashMap<String, BufferedImage>());
049                });*/
050
051        }
052
053        /**
054        * Returns a Map object containing a keyset of cubemap face numbers
055        *
056        * {@link CubemapFaces}
057        *
058        * for each cubeface number corresponding map if cubemap tile ids and buffered
059        * cubemap tile imagery is stored until assembly by the CubemapBuilder
060        * @see org.openstreetmap.josm.plugins.streetside.cubemap.CubemapBuilder
061        *
062        * @return the face2TilesMap
063        */
064        /*public Map<String, Map<String,BufferedImage>> getFace2TilesMap() {
065                return face2TilesMap;
066        }
067*/
068        /**
069         * Comparison method for the StreetsideCubemap object.
070         *
071         * @param image
072         *            - a StreetsideAbstract image object
073         *
074         *            StreetsideCubemaps are considered equal if they are associated
075         *            with the same image id - only one cubemap may be displayed at a
076         *            time. If the image selection changes, the cubemap changes.
077         *
078         * @return result of the hashcode comparison.
079         * @see org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage
080         */
081        @Override
082        public int compareTo(StreetsideAbstractImage image) {
083                if (image instanceof StreetsideImage) {
084                        return id.compareTo(((StreetsideImage) image).getId());
085                }
086                return hashCode() - image.hashCode();
087        }
088
089        /**
090         * HashCode StreetsideCubemap object.
091         *
092         * @return int hashCode
093         * @see org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage
094         */
095    @Override
096        public int hashCode() {
097                return id.hashCode();
098        }
099
100        /**
101         * stops ImageDisplay WalkAction (not currently supported by Streetside)
102         *
103         * @see org.openstreetmap.josm.plugins.streetside.actions.StreetsideWalkAction
104         */
105        @Override
106        public void stopMoving() {
107                super.stopMoving();
108        }
109
110        /**
111         * turns ImageDisplay WalkAction (not currently supported by Streetside)
112         *
113         * @param he - the direction the camera is facing (heading)
114         *
115         * @see org.openstreetmap.josm.plugins.streetside.actions.StreetsideWalkAction
116         */
117        @Override
118        public void turn(double he) {
119                super.turn(he);
120        }
121
122        /**
123         * @return the height of an assembled cubemap face for 16-tiled or 4-tiled imagery
124         *
125         * @see org.openstreetmap.josm.plugins.streetside.actions.StreetsideWalkAction
126         */
127        public int getHeight() {
128                return StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get().booleanValue()?1016:510;
129        }
130
131        /**
132         * resets the faces2TilesMap, emptying it for a new set of cubemap imagery
133         */
134        /*public void resetFaces2TileMap() {
135                face2TilesMap = new HashMap<>();
136
137                EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
138                        face2TilesMap.put(face.getValue(), new HashMap<String, BufferedImage>());
139                });
140        }*/
141}