Пример #1
0
        static void addAtomsToRoute(Route route, AtomGenerator generator, int count)
        {
            for (int i = 0; i < count; i++)
            {
                double scatterLength = 0.0000;
                double offset        = Util.rand.NextDouble();

                double firstLegDeltaX = route.routePoints[1].x - route.routePoints[0].x;
                double firstLegDeltaY = route.routePoints[1].y - route.routePoints[0].y;

                double length = Math.Sqrt(firstLegDeltaX * firstLegDeltaX + firstLegDeltaY * firstLegDeltaY);

                double scatterX = (scatterLength / length) * firstLegDeltaX;
                double scatterY = (scatterLength / length) * firstLegDeltaY;

                AtomObject atom = new AtomObject(route.name + i, 0, route.routePoints[0].x - scatterX * offset, route.routePoints[0].y - scatterY * offset);

                // generate new random number for start time - for now between 0:01 to 1:30
                int minutes = Util.rand.Next(2);
                int seconds = Util.rand.Next(1, 60);
                int speed   = Util.rand.Next(3, 11);

                String   secondsString = seconds >= 10 ? seconds.ToString() : "0" + seconds;
                Activity activity      = new Activity(100 + i, atom.guid, 1, 1, "00:0" + minutes + ":" + secondsString,
                                                      "00:00:01", speed, route.guid, route.routePoints[0].x, route.routePoints[0].y);
                generator.createAtom(atom);
                generator.createActivityToAtom(activity, atom);
                generator.addAtomToTreeObject(atom);
            }
        }
Пример #2
0
        static void addAtomsToRoute(Route route, AtomGenerator generator, int count)
        {
            for (int i = 0; i < count; i++)
            {
                double scatterLength = 0.0000;
                double offset = Util.rand.NextDouble();

                double firstLegDeltaX = route.routePoints[1].x - route.routePoints[0].x;
                double firstLegDeltaY = route.routePoints[1].y - route.routePoints[0].y;

                double length = Math.Sqrt(firstLegDeltaX * firstLegDeltaX + firstLegDeltaY * firstLegDeltaY);

                double scatterX = (scatterLength / length) * firstLegDeltaX;
                double scatterY = (scatterLength / length) * firstLegDeltaY;

                AtomObject atom = new AtomObject(route.name + i, 0, route.routePoints[0].x - scatterX*offset, route.routePoints[0].y - scatterY*offset);

                // generate new random number for start time - for now between 0:01 to 1:30
                int minutes = Util.rand.Next(2);
                int seconds = Util.rand.Next(1, 60);
                int speed = Util.rand.Next(3, 11);

                String secondsString = seconds >= 10 ? seconds.ToString() : "0" + seconds;
                Activity activity = new Activity(100 + i, atom.guid, 1, 1, "00:0" + minutes + ":" + secondsString,
                                                 "00:00:01", speed, route.guid, route.routePoints[0].x, route.routePoints[0].y);
                generator.createAtom(atom);
                generator.createActivityToAtom(activity, atom);
                generator.addAtomToTreeObject(atom);
            }
        }
Пример #3
0
 public void createAtom(AtomObject atom)
 {
     // save the object to the database
     String query = "INSERT INTO atomobjects(atom_guid, atom_name, countryid, pointx, pointy) VALUES (:guid, :name, :countryId, :x, :y)";
     NpgsqlCommand command = new NpgsqlCommand(query, connection);
     command.Parameters.Add(new NpgsqlParameter("guid", atom.guid));
     command.Parameters.Add(new NpgsqlParameter("name", atom.name));
     command.Parameters.Add(new NpgsqlParameter("countryId", atom.countryId));
     command.Parameters.Add(new NpgsqlParameter("x", atom.pointX));
     command.Parameters.Add(new NpgsqlParameter("y", atom.pointY));
     command.ExecuteNonQuery();
 }
Пример #4
0
        public void createAtom(AtomObject atom)
        {
            // save the object to the database
            String        query   = "INSERT INTO atomobjects(atom_guid, atom_name, countryid, pointx, pointy) VALUES (:guid, :name, :countryId, :x, :y)";
            NpgsqlCommand command = new NpgsqlCommand(query, connection);

            command.Parameters.Add(new NpgsqlParameter("guid", atom.guid));
            command.Parameters.Add(new NpgsqlParameter("name", atom.name));
            command.Parameters.Add(new NpgsqlParameter("countryId", atom.countryId));
            command.Parameters.Add(new NpgsqlParameter("x", atom.pointX));
            command.Parameters.Add(new NpgsqlParameter("y", atom.pointY));
            command.ExecuteNonQuery();
        }
Пример #5
0
 public void addAtomToTreeObject(AtomObject atom)
 {
     String query = "INSERT INTO treeobject(identification, guid, parentguid, countryid, platformcategoryid, platformtype, formationtypeid)"
                  + " VALUES (:identification, :guid, :parentguid, :countryid, :platformcategoryid, :platformtype, :formationtypeid)";
     NpgsqlCommand command = new NpgsqlCommand(query, connection);
     command.Parameters.Add(new NpgsqlParameter("identification", atom.name));
     command.Parameters.Add(new NpgsqlParameter("guid", atom.guid));
     command.Parameters.Add(new NpgsqlParameter("parentguid", ""));
     command.Parameters.Add(new NpgsqlParameter("countryid", atom.countryId));
     command.Parameters.Add(new NpgsqlParameter("platformcategoryid", 1));
     command.Parameters.Add(new NpgsqlParameter("platformtype", ""));
     command.Parameters.Add(new NpgsqlParameter("formationtypeid", 1));
     command.ExecuteNonQuery();
 }
Пример #6
0
        public void addAtomToTreeObject(AtomObject atom)
        {
            String query = "INSERT INTO treeobject(identification, guid, parentguid, countryid, platformcategoryid, platformtype, formationtypeid)"
                           + " VALUES (:identification, :guid, :parentguid, :countryid, :platformcategoryid, :platformtype, :formationtypeid)";
            NpgsqlCommand command = new NpgsqlCommand(query, connection);

            command.Parameters.Add(new NpgsqlParameter("identification", atom.name));
            command.Parameters.Add(new NpgsqlParameter("guid", atom.guid));
            command.Parameters.Add(new NpgsqlParameter("parentguid", ""));
            command.Parameters.Add(new NpgsqlParameter("countryid", atom.countryId));
            command.Parameters.Add(new NpgsqlParameter("platformcategoryid", 1));
            command.Parameters.Add(new NpgsqlParameter("platformtype", ""));
            command.Parameters.Add(new NpgsqlParameter("formationtypeid", 1));
            command.ExecuteNonQuery();
        }
Пример #7
0
        public void createActivityToAtom(Activity activity, AtomObject atom)
        {
            // TODO - read from sequence

            String query = "INSERT INTO activites(activityid, atom_guid, activity_seqnumber, activitytype,"
                + " startactivityoffset, durationactivity, speed, route_guid, referencepointx, referencepointy)"
                + " VALUES (:id, :atomGuid, :activitySeq, :activityType, :startOffset, :duration, :speed, :routeGuid, :refX, :refY)";
            NpgsqlCommand command = new NpgsqlCommand(query, connection);
            command.Parameters.Add(new NpgsqlParameter("id", activity.activityId));
            command.Parameters.Add(new NpgsqlParameter("atomGuid", activity.atomGuid));
            command.Parameters.Add(new NpgsqlParameter("activitySeq", activity.activitySeqNumber));
            command.Parameters.Add(new NpgsqlParameter("activityType", activity.activityType));
            command.Parameters.Add(new NpgsqlParameter("startOffset", activity.startActivityOffset));
            command.Parameters.Add(new NpgsqlParameter("duration", activity.durationActivity));
            command.Parameters.Add(new NpgsqlParameter("speed", activity.speed));
            command.Parameters.Add(new NpgsqlParameter("routeGuid", activity.routeGuid));
            command.Parameters.Add(new NpgsqlParameter("refX", activity.refX));
            command.Parameters.Add(new NpgsqlParameter("refY", activity.refY));
            command.ExecuteNonQuery();

            // TODO - increment seuquence
        }
Пример #8
0
        public void createActivityToAtom(Activity activity, AtomObject atom)
        {
            // TODO - read from sequence

            String query = "INSERT INTO activites(activityid, atom_guid, activity_seqnumber, activitytype,"
                           + " startactivityoffset, durationactivity, speed, route_guid, referencepointx, referencepointy)"
                           + " VALUES (:id, :atomGuid, :activitySeq, :activityType, :startOffset, :duration, :speed, :routeGuid, :refX, :refY)";
            NpgsqlCommand command = new NpgsqlCommand(query, connection);

            command.Parameters.Add(new NpgsqlParameter("id", activity.activityId));
            command.Parameters.Add(new NpgsqlParameter("atomGuid", activity.atomGuid));
            command.Parameters.Add(new NpgsqlParameter("activitySeq", activity.activitySeqNumber));
            command.Parameters.Add(new NpgsqlParameter("activityType", activity.activityType));
            command.Parameters.Add(new NpgsqlParameter("startOffset", activity.startActivityOffset));
            command.Parameters.Add(new NpgsqlParameter("duration", activity.durationActivity));
            command.Parameters.Add(new NpgsqlParameter("speed", activity.speed));
            command.Parameters.Add(new NpgsqlParameter("routeGuid", activity.routeGuid));
            command.Parameters.Add(new NpgsqlParameter("refX", activity.refX));
            command.Parameters.Add(new NpgsqlParameter("refY", activity.refY));
            command.ExecuteNonQuery();

            // TODO - increment seuquence
        }