Examples of OMPoly


Examples of com.bbn.openmap.omGraphics.OMPoly

        super(initialCapacity);
    }

    public static OMPoly convert(OMLine omLine) {
        if (omLine.getRenderType() == OMGraphic.RENDERTYPE_LATLON) {
            OMPoly poly = new OMPoly(omLine.getLL(), OMGraphic.DECIMAL_DEGREES, omLine.getLineType());
            poly.setAttributes(omLine.getAttributes());
            DrawingAttributes da = new DrawingAttributes();
            da.setFrom(omLine);
            da.setTo(poly);
            return poly;
        } else
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

        boolean pushback;
        StringTokenizer st = null;
        String tok = null;
        pushback = false;
        int idx;
        OMPoly omp = null;
        OMLine oml = null;
        MIFPoint ompoint = null;
        OMText omtext = null;
        boolean ismultiple = false;

        OMGraphicList aList = new OMGraphicList();

        // a vector of omgraphics for regions that allows adding and
        // deleting
        Vector omgs = new Vector();

        MAIN_LOOP: while (true) {

            if (!pushback) {
                // if it's null then there's no more
                if ((st = getTokens(br)) == null)
                    break MAIN_LOOP;

                tok = st.nextToken();
            } else {
                pushback = false; // pushback was true so make it
                // false so it doesn't happen twice
            }

            SWITCH: switch (action) {

            case PROCESS_HEADER:
                if (isSame(tok, DATA_WORD)) {
                    action = PROCESS_DATA;
                } else if (isSame(tok, VERSION_WORD)) {
                } else if (isSame(tok, DELIMITER_WORD)) {
                } else if (isSame(tok, COORDSYS_WORD)) {
                    // check the CoordSys header, OpenMap only
                    // directly
                    // supports LatLong type of coordsys
                    String coordSysLine = COORDSYS_WORD;
                    while (st.hasMoreElements()) {
                        coordSysLine += " " + st.nextElement();
                    }

                    String goodCoordSys = COORDSYS_WORD + " "
                            + LATLONG_COORDSYS_DEF;
                    if (goodCoordSys.length() < coordSysLine.length()) {
                        coordSysLine = coordSysLine.substring(0,
                                goodCoordSys.length());
                    } else {
                        goodCoordSys = goodCoordSys.substring(0,
                                coordSysLine.length());
                    }

                    // check that the CoordSys header matches the MIF
                    // specification for LatLong type
                    if (!isSame(coordSysLine, goodCoordSys)) {
                        Debug.error("MIFLoader file has coordinate system: "
                                + coordSysLine + ", requires " + goodCoordSys);
                        // raise error, as the coordsys header was
                        // invalid
                        throw new MIFException("File appears to contain objects with an incompatible coordinate system (Must be Lat/Lon).");
                    }

                }
                break SWITCH;

            case PROCESS_DATA:
                omgs.clear();
                if (isSame(tok, PLINE_WORD)) {
                    tok = st.nextToken();
                    if (isSame(tok, MULTIPLE_WORD)) {
                        multiple = Integer.parseInt(st.nextToken());
                        multicnt = 0;
                        action = PROCESS_MULTIPLE;
                        ismultiple = true;
                    } else {
                        number = Integer.parseInt(tok);
                        ptarray = new float[number + number];
                        count = 0;
                        action = PROCESS_PLINE;
                    }
                } else if (isSame(tok, REGION_WORD)) {
                    multiple = Integer.parseInt(st.nextToken());
                    multicnt = 0;
                    action = PROCESS_REGION_HEADER;
                } else if (isSame(tok, LINE_WORD)) {
                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());
                    float lon2 = Float.parseFloat(st.nextToken());
                    float lat2 = Float.parseFloat(st.nextToken());

                    oml = new OMLine(lat1, lon1, lat2, lon2, OMGraphicConstants.LINETYPE_STRAIGHT);

                    action = PROCESS_POST_LINE;
                } else if (isSame(tok, POINT_WORD)) // handle a MIF
                // POINT primitive
                {
                    // get the coordinates
                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());

                    // construct the OM graphic
                    ompoint = new MIFPoint(lat1, lon1, pointVisible);
                    st = getTokens(br);

                    // set the graphics attributes
                    this.processSymbolWord(st, ompoint);

                    // add to the graphic list for this layer
                    aList.add(ompoint);
                    action = PROCESS_DATA;
                } else if (isSame(tok, TEXT_WORD)) // handle a MIF
                // TEXT primitive
                {
                    String textString = "";

                    // if the actual text is not on the same line as
                    // the primitive declaration
                    if (st.countTokens() < 1) {
                        // get the next line
                        st = getTokens(br);
                    }
                    // build up the display text string,
                    while (st.hasMoreTokens()) {
                        textString += st.nextToken();
                    }

                    if (textString.length() >= 1) {
                        // remove any surrounding " characters
                        textString = textString.substring(1,
                                textString.length() - 1);
                    }
                    // get the next line, it contains the coordinates
                    st = getTokens(br);

                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());
                    /* float lon2 = */Float.parseFloat(st.nextToken());
                    /* float lat2 = */Float.parseFloat(st.nextToken());
                    // create the OMGraphic for the text object
                    omtext = new MIFText(lat1, lon1, textString, OMText.JUSTIFY_CENTER, textVisible);

                    // the next line contains the text attributes
                    st = getTokens(br);
                    // set the attributes agains the omgraphic
                    this.processFontWord(st, omtext);
                    // add to the layers graphic list
                    aList.add(omtext);

                    action = PROCESS_DATA;
                }
                break SWITCH;

            // We have a line, tok is the first coord and the next
            // token is the second
            case PROCESS_PLINE:
                idx = count + count;
                ptarray[idx + 1] = Float.parseFloat(tok);
                ptarray[idx] = Float.parseFloat(st.nextToken());
                count++;
                if (count == number) {
                    omp = new OMPoly(ptarray, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_STRAIGHT);

                    aList.add(omp);
                    if (!ismultiple) {
                        action = PROCESS_POST_PLINE;
                    } else {
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

            if (graphic instanceof OMGraphicList) {
                OMGraphicList sublist = (OMGraphicList) graphic;
                contentLength += sublist.size() * 2; // offsets?

                for (int j = 0; j < sublist.size(); j++) {
                    OMPoly poly = (OMPoly) sublist.getOMGraphicAt(j);
                    data = poly.getLatLonArray();

                    // each value equals 4 words
                    contentLength += data.length * 4;
                }
            } else {
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

     */
    protected int[] getPartOffsets(OMGraphicList sublist) {
        int pos = 0;
        int[] offsets = new int[sublist.size()];
        for (int j = 0; j < sublist.size(); j++) {
            OMPoly poly = (OMPoly) sublist.getOMGraphicAt(j);
            float[] data = poly.getLatLonArray();
            offsets[j] = pos / 2;
            pos += data.length;
        }
        return offsets;
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

     * @return The number of points for a given shape
     */
    protected int getPointsPerShape(OMGraphicList sublist) {
        int numPoints = 0;
        for (int i = 0; i < sublist.size(); i++) {
            OMPoly poly = (OMPoly) sublist.getOMGraphicAt(i);
            float[] data = poly.getLatLonArray();
            numPoints += data.length;
        }
        numPoints /= 2;
        return numPoints;
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

     * @return A two dimensional array containing shape offsets and content
     *         lengths
     */
    public int[][] writePolyGeometry(EsriGraphicList list) throws IOException {

        OMPoly poly;

        _leos.writeInt(9994); // Byte 0 File Code
        _leos.writeInt(0); // Byte 4 Unused
        _leos.writeInt(0); // Byte 8 Unused
        _leos.writeInt(0); // Byte 12 Unused
        _leos.writeInt(0); // Byte 16 Unused
        _leos.writeInt(0); // Byte 20 Unused

        int[][] indexData = createPolyIndex(list);
        int contentLength = 50;

        if (list.size() > 0) {
            contentLength = indexData[0][indexData[0].length - 1]
                    + indexData[1][indexData[0].length - 1];
        }

        _leos.writeInt(contentLength); // Byte 24 File Length
        _leos.writeLEInt(1000); // Byte 28 Version
        _leos.writeLEInt(list.getType()); // Byte 32 Shape Type

        // Writes bounding box.
        float[] extents = list.getExtents();
        writeExtents(extents);

        _leos.writeDouble(0.0); // Byte 68
        _leos.writeDouble(0.0); // Byte 76
        _leos.writeDouble(0.0); // Byte 84
        _leos.writeDouble(0.0); // Byte 92

        // Iterate through the list
        for (int i = 0; i < list.size(); i++) {

            OMGraphic graphic = list.getOMGraphicAt(i);

            // Record header
            _leos.writeInt(i + 1); // Record numbers start with 1
            _leos.writeInt(indexData[1][i]);

            // Beginning of Geometry data
            _leos.writeLEInt(list.getType()); // Little endian

            // More stuff needs to be written out for just the OMPoly
            // case...
            // Single part, etc.

            if (graphic instanceof EsriGraphicList) {

                // Assumes that the elements of the top level list are
                // EsriGraphicLists, too. This will probably be
                // changing.
                EsriGraphicList sublist = (EsriGraphicList) graphic;

                // Writes bounding box.
                extents = sublist.getExtents();
                writeExtents(extents);

                // Writes number of parts
                int numParts = sublist.size();
                _leos.writeLEInt(numParts);

                // Write number of points per shape
                int numPoints = getPointsPerShape(sublist);
                _leos.writeLEInt(numPoints);

                // Write the offsets to each part for a given shape
                int[] offsets = getPartOffsets(sublist);

                for (int j = 0; j < offsets.length; j++) {
                    _leos.writeLEInt(offsets[j]);
                }

                // Write the geometry for each part
                for (int j = 0; j < sublist.size(); j++) {
                    poly = (OMPoly) sublist.getOMGraphicAt(j);
                    float[] data = poly.getLatLonArray();
                    int n = 0;
                    while (n < data.length) {
                        Float lat = new Float(data[n++]);
                        Float lon = new Float(data[n++]);
                        _leos.writeLEDouble(Math.toDegrees(lon.doubleValue()));
                        _leos.writeLEDouble(Math.toDegrees(lat.doubleValue()));
                    }
                }
            } else {
                extents = ((EsriGraphic) graphic).getExtents();
                writeExtents(extents);

                // Writes number of parts for shape (1)
                _leos.writeLEInt(1);

                poly = (OMPoly) graphic;
                float[] data = poly.getLatLonArray();

                // Write number of points for shape
                _leos.writeLEInt(data.length / 2);

                // Write the offsets to this shape
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

     */
    protected int[] getPartOffsets(OMGraphicList sublist) {
        int pos = 0;
        int[] offsets = new int[sublist.size()];
        for (int j = 0; j < sublist.size(); j++) {
            OMPoly poly = (OMPoly) sublist.getOMGraphicAt(j);
            float[] data = poly.getLatLonArray();
            offsets[j] = pos / 2;
            pos += data.length;
        }
        return offsets;
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

     * @deprecated not used.
     */
    protected int getPointsPerShape(OMGraphicList sublist) {
        int numPoints = 0;
        for (int i = 0; i < sublist.size(); i++) {
            OMPoly poly = (OMPoly) sublist.getOMGraphicAt(i);
            float[] data = poly.getLatLonArray();
            numPoints += data.length;
        }
        numPoints /= 2;
        return numPoints;
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

                              DrawingAttributes drawingAttributes) {

        int nPolys = polygons.length;
        if (nPolys <= 0)
            return;
        OMPoly p = null;
        float[] pts;
        boolean ispolyg = isPolygon();
        /*
         * modifications in the next 4 lines marked with as: allow to
         * treat ESRIPolygonRecord with holes correctly (ESRIPolys
         * with counterclockwise order of vertices)
         */
        OMGraphicList sublist = null;

        if (nPolys > 1) {
            // Only want the OMAreaList if the shape type is for
            // polygons
            if (false && ispolyg) {
                // There's a problem here with OMPolys that wrap
                // around the earth, putting them in OMAreaLists makes
                // them draw lines through the map. Need to sort that
                // out before enabling this code by removing 'false'
                // in if statement.
                sublist = new OMAreaList();
                ((OMAreaList) sublist).setConnectParts(false);
            } else {
                sublist = new OMGraphicList();
            }

            if (drawingAttributes != null) {
                drawingAttributes.setTo(sublist);
            }

            sublist.setVague(true); // Treat list as one object.
            list.add(sublist);
            sublist.setAppObject(new Integer(getRecordNumber()));
        }

        for (int i = 0; i < nPolys; i++) {
            // these points are already in RADIAN lat,lon order!...
            pts = ((ESRIPoly.ESRIFloatPoly) polygons[i]).getRadians();
            p = new OMPoly(pts, OMGraphic.RADIANS, OMGraphic.LINETYPE_STRAIGHT);

            drawingAttributes.setTo(p);
            if (!ispolyg) {
                p.setIsPolygon(false);
            }

            if (sublist != null) {
                sublist.add(p);
            } else {
                // There should be only one.
                p.setAppObject(new Integer(getRecordNumber()));
                list.add(p);
            }
        }
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMPoly

            setShowCrossingPoints(false);
            float[] coords = new float[] { 33.4f, -77.2f, 34f, -79.5f, 35f,
                    -90f, 40f, -100f, 45f, -101f, 50f, -83.2f, 35f, -65.7f,
                    -34f, -70.5f, 33.4f, -77.2f };

            omg = new OMPoly(coords, OMPoly.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
            getDrawnIntersectorList().add(omg);
            startTime = System.currentTimeMillis();
            calculateIntersectionsWithDrawnList();
            endTime = System.currentTimeMillis();
            if (countThisIteration) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.