/**
         * Constructs a VPF Database from a path to the Database Header table. This initializes the Database Header Table
         * and the Library Attribute Table.
         *
         * @param filePath the path to the Database Header Table.
         *
         * @return a new Database from the specified Database Header Table path.
         *
         * @throws ArgumentException if the file path is null or empty.
         */
        public static VPFDatabase fromFile(String filePath)
        {
            if (WWUtil.isEmpty(filePath))
            {
                String message = Logging.getMessage("nullValue.FilePathIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            File file = new File(filePath);

            if (!file.exists())
            {
                String message = Logging.getMessage("generic.FileNotFound", filePath);
                Logging.logger().severe(message);
                throw new WWRuntimeException(message);
            }

            // Database tables.
            VPFBufferedRecordData dht = VPFUtils.readTable(file);

            if (dht == null)
            {
                String message = Logging.getMessage("VPF.DatabaseHeaderTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFBufferedRecordData lat = VPFUtils.readTable(
                new File(file.getParent(), VPFConstants.LIBRARY_ATTRIBUTE_TABLE));

            if (lat == null)
            {
                String message = Logging.getMessage("VPF.LibraryAttributeTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFDatabase database = new VPFDatabase(file.getParent());

            database.setDatabaseHeaderTable(dht);
            database.setLibraryAttributeTable(lat);

            // Database metadata attributes.
            VPFRecord record = dht.getRecord(1);

            if (record != null)
            {
                VPFUtils.checkAndSetValue(record, "database_name", AVKey.DISPLAY_NAME, database);
                VPFUtils.checkAndSetValue(record, "database_desc", AVKey.DESCRIPTION, database);
            }

            // Database Libraries.
            Collection <VPFLibrary> col = createLibraries(database, lat);

            if (col != null)
            {
                database.setLibraries(col);
            }

            return(database);
        }
Beispiel #2
0
        public static UTMCoord fromLatLon(Angle latitude, Angle longitude, string datum)
        {
            if (latitude == null || longitude == null)
            {
                string message = Logging.getMessage("nullValue.LatitudeOrLongitudeIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            UTMCoordConverter converter;

            if (!WWUtil.isEmpty(datum) && datum.Equals("NAD27"))
            {
                converter = new UTMCoordConverter(UTMCoordConverter.CLARKE_A, UTMCoordConverter.CLARKE_F);
                LatLon llNAD27 = UTMCoordConverter.convertWGS84ToNAD27(latitude, longitude);
                latitude  = llNAD27.getLatitude();
                longitude = llNAD27.getLongitude();
            }
            else
            {
                converter = new UTMCoordConverter(UTMCoordConverter.WGS84_A, UTMCoordConverter.WGS84_F);
            }

            long err = converter.convertGeodeticToUTM(latitude.radians, longitude.radians);

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                string message = Logging.getMessage("Coord.UTMConversionError");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(new UTMCoord(latitude, longitude, converter.getZone(), converter.getHemisphere(),
                                converter.getEasting(), converter.getNorthing(), Angle.fromRadians(converter.getCentralMeridian())));
        }
Beispiel #3
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            if (!(source is java.io.File) && !(source is java.net.URL))
            {
                return(false);
            }

            // If the data source doesn't already have all the necessary metadata, then we determine whether or not
            // the missing metadata can be read.
            String error = this.validateMetadata(source, parameters);

            if (!WWUtil.isEmpty(error))
            {
                if (!WorldFile.hasWorldFiles(source))
                {
                    Logging.logger().fine(error);
                    return(false);
                }
            }

            if (null != parameters)
            {
                if (!params.hasKey(AVKey.PIXEL_FORMAT))
                {
                    parameters.setValue(AVKey.PIXEL_FORMAT, AVKey.ELEVATION);
                }
            }

            return(true);
        }
Beispiel #4
0
            protected URLBuilder(String version, AVList parameters)
            {
                Double d = (Double)parameters.getValue(AVKey.MISSING_DATA_SIGNAL);

                this.layerNames  = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames  = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat = parameters.getStringValue(AVKey.IMAGE_FORMAT);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0) // version 1.3.0 or greater
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
        private void loadConfigProperties(Document doc)
        {
            try
            {
                XPath xpath = WWXML.makeXPath();

                NodeList nodes = (NodeList)xpath.evaluate("/WorldWindConfiguration/Property", doc, XPathConstants.NODESET);
                if (nodes == null || nodes.getLength() == 0)
                {
                    return;
                }

                for (int i = 0; i < nodes.getLength(); i++)
                {
                    Node   node  = nodes.item(i);
                    String prop  = xpath.evaluate("@name", node);
                    String value = xpath.evaluate("@value", node);
                    if (WWUtil.isEmpty(prop))// || WWUtil.isEmpty(value))
                    {
                        continue;
                    }

                    this.properties.setProperty(prop, value);
                }
            }
            catch (XPathExpressionException e)
            {
                Logging.logger(DEFAULT_LOGGER_NAME).log(Level.WARNING, "XML.ParserConfigurationException");
            }
        }
        /** {@inheritDoc} */
        public void preRender(ColladaTraversalContext tc, DrawContext dc)
        {
            List <ColladaRenderable> children = this.getChildren();

            if (WWUtil.isEmpty(children))
            {
                return;
            }

            Matrix matrix = this.getMatrix();

            try
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.pushMatrix();
                    tc.multiplyMatrix(matrix);
                }

                foreach (ColladaRenderable node in children)
                {
                    node.preRender(tc, dc);
                }
            }
            finally
            {
                if (matrix != null && matrix != Matrix.IDENTITY)
                {
                    tc.popMatrix();
                }
            }
        }
            public URLBuilder(AVList parameters)
            {
                this.layerNames      = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames      = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat     = parameters.getStringValue(AVKey.IMAGE_FORMAT);
                this.backgroundColor = parameters.getStringValue(AVKey.WMS_BACKGROUND_COLOR);
                String version = parameters.getStringValue(AVKey.WMS_VERSION);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0)
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
        /**
         * Create a surface polygon from a KML GroundOverlay.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the {@link SharpEarth.ogc.kml.KMLGroundOverlay} to render as a polygon.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLSurfacePolygonImpl(KMLTraversalContext tc, KMLGroundOverlay overlay)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = overlay;

            // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad
            Position.PositionList corners = overlay.getPositions();
            this.setOuterBoundary(corners.list);

            // Check to see if a rotation is provided. The rotation will be applied when the image is rendered, because
            // how the rotation is performed depends on the globe.
            KMLLatLonBox box = overlay.getLatLonBox();

            if (box != null && box.getRotation() != null)
            {
                this.mustApplyRotation = true;
            }

            if (overlay.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, overlay.getName());
            }

            if (overlay.getDescription() != null)
            {
                this.setValue(AVKey.BALLOON_TEXT, overlay.getDescription());
            }

            if (overlay.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, overlay.getSnippetText());
            }

            String colorStr = overlay.getColor();

            if (!WWUtil.isEmpty(colorStr))
            {
                Color color = WWUtil.decodeColorABGR(colorStr);

                ShapeAttributes attributes = new BasicShapeAttributes();
                attributes.setDrawInterior(true);
                attributes.setInteriorMaterial(new Material(color));
                this.setAttributes(attributes);
            }
        }
        protected void createRasterServer(AVList parameters)
        {
            if (params == null)
            {
                String reason = Logging.getMessage("nullValue.ParamsIsNull");
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            if (this.getDataFileStore() == null)
            {
                String reason = Logging.getMessage("nullValue.FileStoreIsNull");
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String datasetName = parameters.getStringValue(AVKey.DATASET_NAME);

            if (WWUtil.isEmpty(datasetName))
            {
                String reason = Logging.getMessage("generic.MissingRequiredParameter", AVKey.DATASET_NAME);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String dataCacheName = parameters.getStringValue(AVKey.DATA_CACHE_NAME);

            if (WWUtil.isEmpty(dataCacheName))
            {
                String reason = Logging.getMessage("generic.MissingRequiredParameter", AVKey.DATA_CACHE_NAME);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String rasterServerConfigFilename = dataCacheName + File.separator + datasetName + ".RasterServer.xml";

            final URL rasterServerFileURL = this.getDataFileStore().findFile(rasterServerConfigFilename, false);

            if (WWUtil.isEmpty(rasterServerFileURL))
            {
                String reason = Logging.getMessage("Configuration.ConfigNotFound", rasterServerConfigFilename);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            final AVList rasterServerParams = parameters.copy();

            rasterServerParams.setValue(AVKey.FILE_STORE, this.getDataFileStore());

            RetrieverFactory retrieverFactory = new RetrieverFactory()
            {
                final protected RasterServer rasterServer = new BasicRasterServer(rasterServerFileURL, rasterServerParams);
Beispiel #10
0
        public String getName()
        {
            if (this.hasNetworkLinkControl() && !WWUtil.isEmpty(this.getRoot().getNetworkLinkControl().getLinkName()))
            {
                return(this.getRoot().getNetworkLinkControl().getLinkName());
            }

            return(super.getName());
        }
Beispiel #11
0
        public Object getSnippet()
        {
            if (this.hasNetworkLinkControl() && !WWUtil.isEmpty(this.getRoot().getNetworkLinkControl().getLinkSnippet()))
            {
                return(this.getRoot().getNetworkLinkControl().getLinkSnippet());
            }

            return(super.getSnippet());
        }
Beispiel #12
0
        /**
         * Create an screen image.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the <i>Overlay</i> element containing.
         *
         * @throws NullPointerException     if the traversal context is null.
         * @throws ArgumentException if the parent overlay or the traversal context is null.
         */
        public KMLSurfaceImageImpl(KMLTraversalContext tc, KMLGroundOverlay overlay)
        {
            this.parent = overlay;

            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad
            KMLLatLonBox box = overlay.getLatLonBox();

            if (box != null)
            {
                Sector sector = KMLUtil.createSectorFromLatLonBox(box);
                this.initializeGeometry(sector);

                // Check to see if a rotation is provided. The rotation will be applied when the image is rendered, because
                // how the rotation is performed depends on the globe.
                Double rotation = box.getRotation();
                if (rotation != null)
                {
                    this.mustApplyRotation = true;
                }
            }
            else
            {
                GXLatLongQuad latLonQuad = overlay.getLatLonQuad();
                if (latLonQuad != null && latLonQuad.getCoordinates() != null)
                {
                    this.initializeGeometry(latLonQuad.getCoordinates().list);
                }
            }

            // Apply opacity to the surface image
            String colorStr = overlay.getColor();

            if (!WWUtil.isEmpty(colorStr))
            {
                Color color = WWUtil.decodeColorABGR(colorStr);
                int   alpha = color.getAlpha();

                this.setOpacity((double)alpha / 255);
            }

            this.setPickEnabled(false);
        }
Beispiel #13
0
        /**
         * Resolves a <i>styleUrl</i> to a style selector, which is either a style or style map.
         * <p/>
         * If the url refers to a remote resource and the resource has not been retrieved and cached locally, this method
         * returns null and initiates a retrieval.
         *
         * @return the style or style map referred to by the style URL.
         */
        public KMLAbstractStyleSelector resolveStyleUrl()
        {
            if (WWUtil.isEmpty(this.getCharacters()))
            {
                return(null);
            }

            Object o = this.getRoot().resolveReference(this.getCharacters());

            return(o is KMLAbstractStyleSelector ? (KMLAbstractStyleSelector)o : null);
        }
 private void insertConfigDoc(String configLocation)
 {
     if (!WWUtil.isEmpty(configLocation))
     {
         Document doc = WWXML.openDocument(configLocation);
         if (doc != null)
         {
             this.configDocs.add(0, doc);
             this.loadConfigProperties(doc);
         }
     }
 }
Beispiel #15
0
        /**
         * Indicates the number of tokens that the accessor can read. For example, if the accessor reads floats, then this
         * method returns the number of floats that the accessor can read.
         *
         * @return Number of tokens that the accessor can read.
         */
        public int size()
        {
            int count = 0;

            foreach (ColladaParam param in this.params)
            {
                if (!WWUtil.isEmpty(param.getName()))
                {
                    count += 1;
                }
            }
            return(count * this.getCount());
        }
        /**
         * Attempts to load the specified filename from the local file system as a dynamic library. The filename argument
         * must be a complete path name.
         *
         * @param pathToLibrary - the file to load
         *
         * @return TRUE if the file is loadable library
         */
        protected bool canLoad(String pathToLibrary)
        {
            try
            {
                System.load(pathToLibrary);

                return(true);
            }
            catch (Throwable t)
            {
                Logging.logger().finest(WWUtil.extractExceptionReason(t));
            }
            return(false);
        }
Beispiel #17
0
        /**
         * Create shapes to render this node.
         *
         * @return List shapes. The list may be empty, but will never be null.
         */
        protected List <ColladaMeshShape> createShapes()
        {
            if (WWUtil.isEmpty(this.geometries))
            {
                return(Collections.emptyList());
            }

            List <ColladaMeshShape> shapes = new ArrayList <ColladaMeshShape>();

            foreach (ColladaInstanceGeometry geometry in this.geometries)
            {
                this.createShapesForGeometry(geometry, shapes);
            }
            return(shapes);
        }
                public Retriever createRetriever(AVList tileParams, RetrievalPostProcessor postProcessor)
                {
                    LocalRasterServerRetriever retriever =
                        new LocalRasterServerRetriever(tileParams, this.rasterServer, postProcessor);

                    // copy only values that do not exist in destination AVList
                    // from rasterServerParams (source) to retriever (destination)

                    String[] keysToCopy = new String[] {
                        AVKey.DATASET_NAME, AVKey.DISPLAY_NAME, AVKey.FILE_STORE, AVKey.IMAGE_FORMAT, AVKey.FORMAT_SUFFIX
                    };

                    WWUtil.copyValues(rasterServerParams, retriever, keysToCopy, false);

                    return(retriever);
                }
        /**
         * Static method to create an object from a factory, a configuration source, and an optional configuration parameter
         * list.
         *
         * @param factoryKey   the key identifying the factory in {@link Configuration}.
         * @param configSource the configuration source. May be any of the types listed for {@link
         *                     #createFromConfigSource(object, SharpEarth.avlist.AVList)}
         * @param parameters       key-value parameters to override or supplement the information provided in the specified
         *                     configuration source. May be null.
         *
         * @return a new instance of the requested object.
         *
         * @throws ArgumentException if the factory key is null, or if the configuration source is null or an empty
         *                                  string.
         */
        public static object create(string factoryKey, object configSource, AVList parameters)
        {
            if (factoryKey == null)
            {
                string message = Logging.getMessage("generic.FactoryKeyIsNull");
                throw new ArgumentException(message);
            }

            if (WWUtil.isEmpty(configSource))
            {
                string message = Logging.getMessage("generic.ConfigurationSourceIsInvalid", configSource);
                throw new ArgumentException(message);
            }

            Factory factory = (Factory)WorldWind.createConfigurationComponent(factoryKey);

            return(factory.createFromConfigSource(configSource, parameters));
        }
 protected bool isHidden(String path)
 {
     if (!WWUtil.isEmpty(path))
     {
         String[] folders = path.split(Pattern.quote(File.separator));
         if (!WWUtil.isEmpty(folders))
         {
             foreach (String folder in folders)
             {
                 if (!WWUtil.isEmpty(folder) && folder.startsWith("."))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
        /**
         * Returns a two-element array containing this raster's extreme scalar values, ignoring any values marked as
         * missing-data. This returns null if this raster contains no values, or if it contains only values marked as
         * missing-data.
         *
         * @return a two-element array containing this raster's extreme values, or null if none exist. Entry 0 contains the
         *         minimum value; entry 1 contains the maximum value.
         */
        public double[] getExtremes()
        {
            // Create local variables to store the raster's dimensions and missing data signal to eliminate any overhead in
            // the loops below.
            int    width             = this.getWidth();
            int    height            = this.getHeight();
            double missingDataSignal = this.getTransparentValue();

            // Allocate a buffer to hold one row of scalar values.
            double[] buffer = new double[width];

            // Allocate a buffer to hold the extreme values.
            double[] extremes = null;

            for (int j = 0; j < height; j++)
            {
                this.get(0, j, width, buffer, 0); // Get the row starting at (0, j).

                for (int i = 0; i < width; i++)
                {
                    if (buffer[i] == missingDataSignal) // Ignore values marked as missing-data.
                    {
                        continue;
                    }

                    if (extremes == null)
                    {
                        extremes = WWUtil.defaultMinMix();
                    }

                    if (extremes[0] > buffer[i])
                    {
                        extremes[0] = buffer[i];
                    }
                    if (extremes[1] < buffer[i])
                    {
                        extremes[1] = buffer[i];
                    }
                }
            }

            // Extremes is null if this raster is empty, or contains only values marked as missing-data.
            return(extremes);
        }
                public Retriever createRetriever(AVList tileParams, RetrievalPostProcessor postProcessor)
                {
                    LocalRasterServerRetriever retriever =
                        new LocalRasterServerRetriever(tileParams, rasterServer, postProcessor);

                    // copy only values that do not exist in destination AVList
                    // from rasterServerParams (source) to retriever (destination)
                    String[] keysToCopy = new String[] {
                        AVKey.DATASET_NAME, AVKey.DISPLAY_NAME,
                        AVKey.FILE_STORE, AVKey.BYTE_ORDER,
                        AVKey.IMAGE_FORMAT, AVKey.DATA_TYPE, AVKey.FORMAT_SUFFIX,
                        AVKey.MISSING_DATA_SIGNAL, AVKey.MISSING_DATA_REPLACEMENT,
                        AVKey.ELEVATION_MIN, AVKey.ELEVATION_MAX,
                    };

                    WWUtil.copyValues(rasterServerParams, retriever, keysToCopy, false);

                    return(retriever);
                }
Beispiel #23
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            if (WWUtil.isEmpty(source))
            {
                return(false);
            }

            if (null == parameters)
            {
                File file = WWIO.getFileForLocalAddress(source);
                if (null == file)
                {
                    return(false);
                }

                return(GDALUtils.canOpen(file));
            }

            bool           canOpen = false;
            GDALDataRaster raster  = null;

            try
            {
                raster = new GDALDataRaster(source, true); // read data raster quietly
                parameters.setValues(raster.getMetadata());
                canOpen = true;
            }
            catch (Throwable t)
            {
                // we purposely ignore any exception here, this should be a very quiet mode
                canOpen = false;
            }
            finally
            {
                if (null != raster)
                {
                    raster.dispose();
                    raster = null;
                }
            }

            return(canOpen);
        }
Beispiel #24
0
        protected void determineActiveAttributes()
        {
            super.determineActiveAttributes();

            if (this.mustRefreshIcon())
            {
                String path = this.getActiveAttributes().getImageAddress();

                if (!WWUtil.isEmpty(path))
                {
                    // Evict the resource from the file store if there is a cached resource older than the icon update
                    // time. This prevents fetching a stale resource out of the cache when the Icon is updated.
                    bool highlighted = this.isHighlighted();
                    this.parent.getRoot().evictIfExpired(path,
                                                         highlighted ? this.highlightIconRetrievalTime : this.iconRetrievalTime);
                    this.textures.remove(path);
                }
            }
        }
Beispiel #25
0
        public static ShapeAttributes assembleInteriorAttributes(ShapeAttributes attrs, KMLPolyStyle style)
        {
            // Assign the attributes defined in the KML Feature element.

            if (style.getColor() != null)
            {
                Color color = WWUtil.decodeColorABGR(style.getColor());

                attrs.setInteriorMaterial(new Material(color));
                attrs.setInteriorOpacity((double)color.getAlpha() / 255);
            }

            if (style.getColorMode() != null && "random".Equals(style.getColorMode()))
            {
                attrs.setInteriorMaterial(new Material(WWUtil.makeRandomColor(attrs.getOutlineMaterial().getDiffuse())));
            }

            return(attrs);
        }
        /**
         * Creates an object from a general configuration source. The source can be one of the following: <ul> <li>{@link
         * java.net.URL}</li> <li>{@link java.io.File}</li> <li>{@link java.io.InputStream}</li> <li>{@link Element}</li>
         * <li>{@link SharpEarth.ogc.OGCCapabilities}</li>
         * <li>{@link SharpEarth.ogc.wcs.wcs100.WCS100Capabilities}</li>
         * <li>{@link string} holding a file name, a name of a resource on the classpath, or a string representation of a
         * URL</li></ul>
         * <p/>
         *
         * @param configSource the configuration source. See above for supported types.
         * @param parameters       key-value parameters to override or supplement the information provided in the specified
         *                     configuration source. May be null.
         *
         * @return the new object.
         *
         * @throws ArgumentException if the configuration source is null or an empty string.
         * @throws WWUnrecognizedException  if the source type is unrecognized.
         * @throws WWRuntimeException       if object creation fails. The exception indicating the source of the failure is
         *                                  included as the {@link Exception#initCause(Throwable)}.
         */
        public object createFromConfigSource(object configSource, AVList parameters)
        {
            if (WWUtil.isEmpty(configSource))
            {
                string message = Logging.getMessage("generic.ConfigurationSourceIsInvalid", configSource);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            object o = null;

            try
            {
                if (configSource is Element)
                {
                    o = this.doCreateFromElement((Element)configSource, parameters);
                }
                else if (configSource is OGCCapabilities)
                {
                    o = this.doCreateFromCapabilities((OGCCapabilities)configSource, parameters);
                }
                else if (configSource is WCS100Capabilities)
                {
                    o = this.doCreateFromCapabilities((WCS100Capabilities)configSource, parameters);
                }
                else
                {
                    Document doc = WWXML.openDocument(configSource);
                    if (doc != null)
                    {
                        o = this.doCreateFromElement(doc.getDocumentElement(), parameters);
                    }
                }
            }
            catch (Exception e)
            {
                string msg = Logging.getMessage("generic.CreationFromConfigurationFileFailed", configSource);
                throw new WWRuntimeException(msg, e);
            }

            return(o);
        }
Beispiel #27
0
        protected PointPlacemarkAttributes assembleLabelAttributes(PointPlacemarkAttributes attrs, KMLLabelStyle style)
        {
            // Assign the attributes defined in the KML Feature element.

            if (style.getScale() != null)
            {
                attrs.setLabelScale(style.getScale());
            }

            if (style.getColor() != null)
            {
                attrs.setLabelColor(style.getColor());
            }

            if (style.getColorMode() != null && "random".Equals(style.getColorMode()))
            {
                attrs.setLabelMaterial(new Material(WWUtil.makeRandomColor(attrs.getLabelColor())));
            }

            return(attrs);
        }
Beispiel #28
0
        public static ShapeAttributes assembleLineAttributes(ShapeAttributes attrs, KMLLineStyle style)
        {
            // Assign the attributes defined in the KML Feature element.

            if (style.getWidth() != null)
            {
                attrs.setOutlineWidth(style.getWidth());
            }

            if (style.getColor() != null)
            {
                attrs.setOutlineMaterial(new Material(WWUtil.decodeColorABGR(style.getColor())));
            }

            if (style.getColorMode() != null && "random".Equals(style.getColorMode()))
            {
                attrs.setOutlineMaterial(new Material(WWUtil.makeRandomColor(attrs.getOutlineMaterial().getDiffuse())));
            }

            return(attrs);
        }
Beispiel #29
0
        /**
         * Build the resource map from the KML Model's <i>ResourceMap</i> element.
         *
         * @param model Model from which to create the resource map.
         *
         * @return Map that relates relative paths in the COLLADA document to paths relative to the KML document.
         */
        protected Map <String, String> createResourceMap(KMLModel model)
        {
            Map <String, String> map = new HashMap <String, String>();

            KMLResourceMap resourceMap = model.getResourceMap();

            if (resourceMap == null)
            {
                return(Collections.emptyMap());
            }

            foreach (KMLAlias alias in resourceMap.getAliases())
            {
                if (alias != null && !WWUtil.isEmpty(alias.getSourceRef()) && !WWUtil.isEmpty(alias.getTargetHref()))
                {
                    map.put(alias.getSourceRef(), alias.getTargetHref());
                }
            }

            return(map.size() > 0 ? map : Collections.< String, String > emptyMap());
        }
Beispiel #30
0
        /**
         * Create shapes for a geometry.
         *
         * @param geomInstance Geometry for which to create shapes.
         * @param shapes       List to collect the new shapes.
         */
        protected void createShapesForGeometry(ColladaInstanceGeometry geomInstance, List <ColladaMeshShape> shapes)
        {
            ColladaGeometry geometry = geomInstance.get();

            if (geometry == null)
            {
                return;
            }

            ColladaMesh mesh = geometry.getMesh();

            if (mesh == null)
            {
                return;
            }

            ColladaBindMaterial bindMaterial = geomInstance.getBindMaterial();
            ColladaRoot         root         = this.getRoot();

            List <ColladaTriangles> triangles = mesh.getTriangles();

            if (!WWUtil.isEmpty(triangles))
            {
                ColladaMeshShape newShape = ColladaMeshShape.createTriangleMesh(triangles, bindMaterial);
                newShape.setDelegateOwner(root);

                shapes.add(newShape);
            }

            List <ColladaLines> lines = mesh.getLines();

            if (!WWUtil.isEmpty(lines))
            {
                ColladaMeshShape newShape = ColladaMeshShape.createLineMesh(lines, bindMaterial);
                newShape.setDelegateOwner(root);

                shapes.add(newShape);
            }
        }