Package com.bbn.openmap.proj

Examples of com.bbn.openmap.proj.Projection


     *
     */
    protected OMRaster buildRaster() {
        // initialize the return
        OMRaster ret = null;
        Projection projection = getProjection();
        // work with the slopeMap
        if (slopeMap != null) {
           
            // compute our deltas
            int pixelColumns = projection.getWidth();
            int pixelRows = projection.getHeight();

            // create int array to hold colors
            int[] colors = new int[pixelColumns * pixelRows];

            // compute scalers for lat/lon indicies
            float yPixPerDataPt = (float) bufferHeight / 180F;
            float xPixPerDataPt = (float) bufferWidth / 360F;

            // starting and ending indices
            int sx = 0, sy = 0, ex = pixelColumns, ey = pixelRows;

            // handle CADRG
            if (projection instanceof CADRG) {

                                // get corners
                LatLonPoint ul = projection.getUpperLeft();
                LatLonPoint lr = projection.getLowerRight();

                                // set start/end indicies
                Point ulp = projection.forward(ul);
                Point lrp = projection.forward(lr);
                sx = (int) ulp.getX();
                ex = (int) lrp.getX();
                sy = (int) ulp.getY();
                ey = (int) lrp.getY();

            }

            // get the center lat/lon (used by the HACK, see above in
            // method description)
            LatLonPoint center = projection.getCenter();
            LatLonPoint llp = new LatLonPoint();

            // build array
            float lat;
            float lon;
            int lat_idx;
            int lon_idx;
            float latWt;
            float lonWt;

            // offset
            int ofs;
            int ofsRight;
            int ofsDown;
            int ofsDownRight;

            for (int y = sy; y < ey; y++) {


                                // process each column
                for (int x = sx; x < ex; x++) {

                    // inverse project x,y to lon,lat
                    projection.inverse(x, y, llp);

                    // get point values
                    lat = llp.getLatitude();
                    lon = llp.getLongitude();

View Full Code Here


     * @param newPoints populated with points on the route.
     * @param segments populated with Segments.
     */
    protected void populatePointsAndSegments(Route bestRoute, List newPoints,
                                             List segments) {
        Projection proj = getProjection();

        Intersection origin = bestRoute.getOriginIntersection();
        // Intersection dest = bestRoute.getDestinationIntersection();

        if (logger.isLoggable(Level.INFO))
            logger.info("adding " + bestRoute.roads.length + " new roads.");

        Road road = null;

        Intersection from = origin, to = null;

        Set loopSet = new HashSet();
        if (doLoopCheck)
            loopSet.add(origin);
        Set ptSet = new HashSet();
        for (int i = 0; i < bestRoute.roads.length; i++) {
            road = bestRoute.roads[i];

            if (!from.equals(road.getFirstIntersection())
                    && !from.equals(road.getSecondIntersection())) {
                logger.severe("huh? " + from
                        + " is not an intersection on road " + road);
            }

            Point pt = createPoint(proj.forward(from.getLocation()));

            if (doLoopCheck) {
                if (ptSet.contains(pt)) {
                    logger.warning("pt set has duplicate at " + pt);
                }
                ptSet.add(pt);
            }

            newPoints.add(pt);
            to = road.getOtherIntersection(from);
            if (doLoopCheck) {
                if (loopSet.contains(to)) {
                    logger.warning("road has a cycle at " + to);
                }
                loopSet.add(to);
            }

            // check to see if we need to reverse the order of the
            // road points,
            // which may not be ordered the same as the previous road

            boolean reverse = from.equals(road.getSecondIntersection());
            Segment path = getPathSegment(proj, road, reverse);

            if (logger.isLoggable(Level.INFO))
                logger.info("created path " + path);

            segments.add(path);

            from = to;
        }

        Point pt = createPoint(proj.forward(to.getLocation()));
        if (ptSet.contains(pt)) {
            logger.warning("pt set has duplicate at " + pt);
        }

        newPoints.add(pt);
View Full Code Here

            Debug.message("link", getName()
                    + "|BufferedLinkLayer.prepare(): aborted.");
            return null;
        }

        Projection projection = getProjection();

        if (projection == null) {
            System.err.println("Link Layer needs to be added to the MapBean before it can get graphics!");
            return new LinkOMGraphicList();
        }
View Full Code Here

    public boolean mousePressed(MouseEvent e) {
        return false;
    }

    public boolean mouseReleased(MouseEvent e) {
        Projection projection = getProjection();
        LatLonPoint ll = projection.inverse(e.getX(), e.getY());
        location = new DTEDLocation(e.getX(), e.getY());
        location.setElevation(cache.getElevation(ll.getLatitude(),
                ll.getLongitude()));
        location.generate(projection);
        repaint();
View Full Code Here

     */
    public void projectionChanged(ProjectionEvent ev) {
        // Lets the ScaleFilterLayer remember the projection, just in case.
        setProjection(ev);

        Projection proj = ev.getProjection();
        // get the appropriate layer and invoke projectionChanged
        Layer layer = configureAppropriateLayer(proj.getScale());

        fireStatusUpdate(LayerStatusEvent.START_WORKING);
        layer.projectionChanged(ev);
    }
View Full Code Here

        // Need to grab a copy of the old projection in case
        // saveGraphicsForRedraw is true and the projection changes,
        // so we can test to see if the zone and scale have changed,
        // testing for reuse of current frames.
        Projection oldProj = getProjection();
        Projection newProj = setProjection(e);

        if (newProj == null) {
            // Projection didn't change, nothing to do, already have
            // good graphics and just need to paint...
            repaint();
View Full Code Here

        if (this.cache == null) {
            Debug.message("rpf", getName() + "|RpfLayer: Creating cache!");
            this.cache = new RpfCacheManager(frameProvider, viewAttributes, subframeCacheSize, auxSubframeCacheSize);
        }

        Projection projection = getProjection();

        if (coverage != null && coverage.isInUse()) {
            coverage.prepare(frameProvider,
                    projection,
                    viewAttributes.chartSeries);
        }

        // Check to make sure the projection is CADRG
        if (!(projection instanceof EqualArc)
                && (viewAttributes.showMaps || viewAttributes.showInfo)) {
            fireRequestInfoLine("RpfLayer requires an Equal Arc projection (CADRG/LLXY) for images or attributes!");
            return null;
        }

        Debug.message("basic", getName() + "|RpfLayer.prepare(): doing it");

        // Setting the OMGraphicsList for this layer. Remember, the
        // OMGraphicList is made up of OMGraphics, which are generated
        // (projected) when the graphics are added to the list. So,
        // after this call, the list is ready for painting.

        // call getRectangle();
        if (Debug.debugging("rpf")) {
            Debug.output(getName() + "|RpfLayer.prepare(): "
                    + "calling getRectangle " + " with projection: "
                    + projection + " ul = " + projection.getUpperLeft()
                    + " lr = " + projection.getLowerRight());
        }

        if (frameProvider.needViewAttributeUpdates()) {
            frameProvider.setViewAttributes(viewAttributes);
        }

        Projection cadrgProj = projection;
        if (!(projection instanceof CADRG)) {
            cadrgProj = new CADRG(projection.getCenter(), projection.getScale(), projection.getWidth(), projection.getHeight());

            Point ulp = cadrgProj.forward(projection.getUpperLeft());
            Point lrp = cadrgProj.forward(projection.getLowerRight());

            int w = (int) Math.abs(lrp.getX() - ulp.getX());
            int h = (int) Math.abs(lrp.getY() - ulp.getY());

            // float cadrgScale =
View Full Code Here

            }
            return null;
        }

        Vector omGraphicList = new Vector();
        Projection projection = getProjection();
        if (projection == null) {
            if (Debug.debugging("location")) {
                Debug.output(getName()
                        + "|LocationLayer.prepare(): null projection, layer not ready.");
            }
            return omGraphicList;
        }

        if (Debug.debugging("location")) {
            Debug.output(getName() + "|LocationLayer.prepare(): doing it");
        }

        if (useDeclutterMatrix && declutterMatrix != null) {
            declutterMatrix.setWidth(projection.getWidth());
            declutterMatrix.setHeight(projection.getHeight());
            declutterMatrix.create();
        }

        // Setting the OMGraphicsList for this layer. Remember, the
        // Vector is made up of OMGraphics, which are generated
        // (projected) when the graphics are added to the list. So,
        // after this call, the list is ready for painting.

        // call getRectangle();
        if (Debug.debugging("location")) {
            Debug.output(getName() + "|LocationLayer.prepare(): "
                    + "calling prepare with projection: " + projection
                    + " ul = " + projection.getUpperLeft() + " lr = "
                    + projection.getLowerRight());
        }

        LatLonPoint ul = projection.getUpperLeft();
        LatLonPoint lr = projection.getLowerRight();

        if (Debug.debugging("location")) {
            float delta = lr.getLongitude() - ul.getLongitude();
            Debug.output(getName() + "|LocationLayer.prepare(): " + " ul.lon ="
                    + ul.getLongitude() + " lr.lon = " + lr.getLongitude()
View Full Code Here

        repaint();
    }

    public OMGraphic getPointIntersectionImage(OMGraphic omg) {
        Shape s = omg.getShape();
        Projection p = getProjection();
        if (s != null && p != null && omg instanceof OMPoly) {
            Rectangle r = s.getBounds();

            double x = r.getX();
            double y = r.getY();
            double h = r.getHeight();
            double w = r.getWidth();
            float[] rawll = ((OMPoly) omg).getLatLonArray();
            LatLonPoint llHolder = new LatLonPoint();
            Geo g = new Geo(0, 0);
            int[] pix = new int[(int) (h * w)];

            for (double j = 0; j < h; j++) {
                for (double i = 0; i < w; i++) {

                    boolean inShape = s.contains(i + x, j + y);
                    p.inverse((int) (i + x), (int) (j + y), llHolder);

                    g.initialize(llHolder.getLatitude(), llHolder.getLongitude());
                    boolean inGeo = Intersection.isPointInPolygon(g,
                            rawll,
                            false);
View Full Code Here

    public void setCreatePointCheck(boolean createPointCheck) {
        this.createPointCheck = createPointCheck;
    }
   
    public void runGeoTests(int numIterations, int numToSkipAtStart) {
        Projection proj = new Mercator(new LatLonPoint(35f, -90f), 100000000, 800, 800);

        double[] results = new double[7];

        for (int i = 0; i < numIterations; i++) {

            boolean countThisIteration = (i >= numToSkipAtStart);

            long startTime = System.currentTimeMillis();
            setProjection(proj.makeClone());
            calculateIntersectionsWithDrawnList();
            long endTime = System.currentTimeMillis();
            if (countThisIteration) {
                results[0] += endTime - startTime;
            }
View Full Code Here

TOP

Related Classes of com.bbn.openmap.proj.Projection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.