コード例 #1
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>Point</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPoint} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLModelPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

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

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

            this.model  = (KMLModel)geom;
            this.parent = placemark;

            this.resourceMap = this.createResourceMap(this.model);
        }
コード例 #2
0
ファイル: KMLUtil.cs プロジェクト: zhj149/WorldWindJava.NET
        /**
         * Get all of the positions that make up a {@link KMLAbstractGeometry}. If the geometry contains other geometries,
         * this method collects all the points from all of the geometries.
         *
         * @param globe     Globe to use to determine altitude above terrain.
         * @param geometry  Geometry to collect positions from.
         * @param positions Placemark positions will be added to this list.
         */
        public static void getPositions(Globe globe, KMLAbstractGeometry geometry, java.util.List <Position> positions)
        {
            if (geometry is KMLPoint)
            {
                KMLPoint kmlPoint = (KMLPoint)geometry;
                Position pos      = kmlPoint.getCoordinates();

                if (pos != null)
                {
                    positions.add(computeAltitude(globe, pos, kmlPoint.getAltitudeMode()));
                }
            }
            else if (geometry is KMLModel)
            {
                KMLModel    model    = (KMLModel)geometry;
                KMLLocation location = model.getLocation();
                if (location != null)
                {
                    Position pos = location.getPosition();
                    if (pos != null)
                    {
                        positions.add(computeAltitude(globe, pos, model.getAltitudeMode()));
                    }
                }
            }
            else if (geometry is KMLLineString) // Also handles KMLLinearRing, since KMLLineString is a subclass of KMLLinearRing
            {
                KMLLineString         lineString   = (KMLLineString)geometry;
                Position.PositionList positionList = lineString.getCoordinates();
                if (positionList != null)
                {
                    positions.addAll(computeAltitude(globe, positionList.list, lineString.getAltitudeMode()));
                }
            }
            else if (geometry is KMLPolygon)
            {
                KMLLinearRing ring = ((KMLPolygon)geometry).getOuterBoundary();
                // Recurse and let the LineString/LinearRing code handle the boundary positions
                getPositions(globe, ring, positions);
            }
            else if (geometry is KMLMultiGeometry)
            {
                java.util.List <KMLAbstractGeometry> geoms = ((KMLMultiGeometry)geometry).getGeometries();
                foreach (KMLAbstractGeometry g in geoms)
                {
                    // Recurse, adding positions for the sub-geometry
                    getPositions(globe, g, positions);
                }
            }
        }
コード例 #3
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());
        }