ФУНКЦИОНАЛЬНАЯ траектория (mp MPoint_V) RETURN SDO_GEOMETRY; - PullRequest
0 голосов
/ 06 февраля 2020

Я застрял на том, как реализовать функцию траектории, которая берет Moving_Point и возвращает SDO_GEOMETRY этого объекта (Moving_Point), представляющего его проекцию на 2D-пространство.

Я уже определил ADT Moving_Point следующим образом :

CREATE OR REPLACE TYPE upoint AS
object(Xs NUMBER,   Ys NUMBER, ts NUMBER,   Xe NUMBER,   Ye NUMBER,  te NUMBER);

# Xs, Ys and Xe, Ye represent  the  start  and  end  positions  for  the  segment  at  times ts, te respectively.

CREATE OR REPLACE TYPE UPOINT_V AS VARRAY(10000) OF upoint;

CREATE OR REPLACE TYPE MPOINT_V AS
object(units UPOINT_V);

Вот рабочая функция, которую я реализовал в MovingGraphPoint, которая возвращает Gline_V:

public static GLine_V trajectory (MGPoint_V mgp) {
        if (mgp == null)
                return null;
        try {
                int counter = 0;
                Section sects[] = new Section[mgp.getUnits().length()];
                SortedSet sortedMGPoint = UtilityFunctions.getSpatialOrderedMGPoint(mgp);
                BigDecimal s, e;
                Integer rid, side;

                Iterator it = sortedMGPoint.iterator();
                UGPoint ugp = (UGPoint) it.next();

                rid = ugp.getRid();
                side = ugp.getSide();
                s = ugp.getPos1();
                e = ugp.getPos2();
                if (! it.hasNext())
                        sects[counter++] = new Section(ugp.getRid(), ugp.getSide(), ugp.getPos1(), ugp.getPos2());
                else {
                        while (it.hasNext()) {
                                ugp = (UGPoint) it.next();

                                if (rid.equals(ugp.getRid()) && side.equals(ugp.getSide()) 
                                                && (s.compareTo(ugp.getPos1()) <= 0) && (e.compareTo(ugp.getPos1()) >= 0)) {
                                        if (e.compareTo(ugp.getPos2()) < 0)
                                                e = ugp.getPos2();
                                }
                                else {
                                        sects[counter++] = new Section(rid, side, s, e);
                                        rid = ugp.getRid();
                                        side = ugp.getSide();
                                        s = ugp.getPos1();
                                        e = ugp.getPos2();
                                }
                        }
                        sects[counter++] = new Section(rid, side, s, e);
                }

                Section finalSects[] = new Section[counter];
                for (int i=0; i<counter; i++)
                        finalSects[i] = sects[i];

                return new GLine_V(mgp.getUnits().getElement(0).getNid(), new Sections_V(finalSects));

        } catch (SQLException e) { e.printStackTrace(); }

        return null;
}

...