예제 #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
        /**
         * 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
        /**
         * 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 KMLPoint} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLPointPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            super(((KMLPoint)geom).getCoordinates());

            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);
            }

            this.parent = placemark;

            KMLPoint point = (KMLPoint)geom;

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default

            if (point.isExtrude())
            {
                this.setLineEnabled(true);
            }

            String altMode = point.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("clampToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                }
                else if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            if (this.parent.getVisibility() != null)
            {
                this.setVisible(this.parent.getVisibility());
            }

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

            String description = placemark.getDescription();

            if (description != null)
            {
                this.setValue(AVKey.DESCRIPTION, description);
            }

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

            this.setValue(AVKey.CONTEXT, this.parent);
        }
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPolygon} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLSurfacePolygonImpl(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);
            }

            this.parent = placemark;

            KMLPolygon polygon = (KMLPolygon)geom;

            // KMLPolygon's use linear interpolation between corners by definition. Configure the World Wind SurfacePolygon
            // to use the appropriate path type for linear interpolation in geographic coordinates.
            this.setPathType(AVKey.LINEAR);

            // Note: SurfacePolygon implies altitude mode "clampToGround", therefore KMLSurfacePolygonImpl ignores the
            // KMLPolygon's altitude mode property.

            KMLLinearRing outerBoundary = polygon.getOuterBoundary();

            if (outerBoundary != null)
            {
                Position.PositionList coords = outerBoundary.getCoordinates();
                if (coords != null && coords.list != null)
                {
                    this.setOuterBoundary(outerBoundary.getCoordinates().list);
                }
            }

            Iterable <? extends KMLLinearRing> innerBoundaries = polygon.getInnerBoundaries();

            if (innerBoundaries != null)
            {
                foreach (KMLLinearRing ring in innerBoundaries)
                {
                    Position.PositionList coords = ring.getCoordinates();
                    if (coords != null && coords.list != null)
                    {
                        this.addInnerBoundary(ring.getCoordinates().list);
                    }
                }
            }

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

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

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

            this.setValue(AVKey.CONTEXT, this.parent);
        }
예제 #5
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPolygon} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLPolygonImpl(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);
            }

            this.parent = placemark;

            KMLPolygon polygon = (KMLPolygon)geom;

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default

            String altMode = polygon.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            KMLLinearRing outerBoundary = polygon.getOuterBoundary();

            if (outerBoundary != null)
            {
                Position.PositionList coords = outerBoundary.getCoordinates();
                if (coords != null && coords.list != null)
                {
                    this.setOuterBoundary(outerBoundary.getCoordinates().list);
                }
            }

            Iterable <? extends KMLLinearRing> innerBoundaries = polygon.getInnerBoundaries();

            if (innerBoundaries != null)
            {
                foreach (KMLLinearRing ring in innerBoundaries)
                {
                    Position.PositionList coords = ring.getCoordinates();
                    if (coords != null && coords.list != null)
                    {
                        this.addInnerBoundary(ring.getCoordinates().list);
                    }
                }
            }

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

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

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

            this.setValue(AVKey.CONTEXT, this.parent);
        }
예제 #6
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link KMLLineString} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLLineStringPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            super(((KMLLineString)geom).getCoordinates());

            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);
            }

            this.parent = placemark;

            KMLLineString lineString = (KMLLineString)geom;

            if (lineString.isExtrude())
            {
                this.setExtrude(true);
            }

            if (lineString.getTessellate() != null && lineString.getTessellate())
            {
                this.setFollowTerrain(true);
            }

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default
            String altMode = lineString.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("clampToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                }
                else if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            // If the path is clamped to the ground and terrain conforming, draw as a great circle. Otherwise draw
            // as linear segments.
            if (this.getAltitudeMode() == WorldWind.CLAMP_TO_GROUND && this.isFollowTerrain())
            {
                this.setPathType(AVKey.GREAT_CIRCLE);
            }
            else
            {
                this.setPathType(AVKey.LINEAR);
            }

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

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

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

            this.setValue(AVKey.CONTEXT, this.parent);
        }