Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

generate artificial non-events based on the real events data

PAN KEVINDec 12 2017 — edited Dec 13 2017

I want to generate artificial non-events based on the real events data

> events
  TIME_ LATITUDE LONGITUDE
1  2013-10-15 00:12:32   9.880  124.1167
2  2013-10-25 17:10:19   37.156  144.6611
3  2014-04-11 07:07:23   -6.586  155.0485
4  2014-04-12 20:14:39  -11.270  162.1481
5  2014-04-19 13:28:00   -6.755  155.0241
6  2014-11-15 02:31:41   1.893  126.5217
7  2015-02-27 13:45:05   -7.297  122.5348
8  2015-03-29 23:48:31   -4.729  152.5623
9  2015-05-05 01:44:06   -5.462  151.8751
10 2015-05-07 07:10:19   -7.218  154.5567
11 2015-05-30 11:23:02   27.839  140.4931
12 2015-07-18 02:27:33  -10.401  165.1409
13 2015-07-27 21:41:21   -2.629  138.5277

The artificial non-events must meet:

1. Date between 2013/10 and 2015/10, LATITUDE between -26.0 and 43.5 degrees, LONGITUDE between 118.0 and 175.0 degrees.
2. Date cannot set to the value plus or minus 30 days for each real events.
3. LATITUDE cannot set to the value plus or minus 5 degrees for each real events.
4. LONGITUDE cannot set set to the value plus or minus 5 degrees for each real events.

I can only think a hard way using three loops (Date: 2013/10/01:1:2015/10/01; LATITUDE: -26.0:0.1:43.5; LONGITUDE: 118.0:0.1:175.0) to implement it, but inefficient.

The sample artificial non-events may be like

TIME_ LATITUDE LONGITUDE
1  2014-10-15 00:12:32   19.8  130.0

So, can you give a efficient solution. Thanks

my table is

CREATE TABLE EVENTS

(

  TIME_      TIMESTAMP(6),

  LATITUDE   NUMBER(7,3),

  LONGITUDE  NUMBER(12,7)

)

SET DEFINE OFF;

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('15/10/2013 00:12:32.050000','DD/MM/YYYY HH24:MI:SS.FF'), 9.88, 124.1167);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('25/10/2013 17:10:19.710000','DD/MM/YYYY HH24:MI:SS.FF'), 37.156, 144.6611);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('11/04/2014 07:07:23.130000','DD/MM/YYYY HH24:MI:SS.FF'), -6.586, 155.0485);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('12/04/2014 20:14:39.300000','DD/MM/YYYY HH24:MI:SS.FF'), -11.27, 162.1481);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('19/04/2014 13:28:00.810000','DD/MM/YYYY HH24:MI:SS.FF'), -6.755, 155.0241);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('15/11/2014 02:31:41.720000','DD/MM/YYYY HH24:MI:SS.FF'), 1.893, 126.5217);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('27/02/2015 13:45:05.370000','DD/MM/YYYY HH24:MI:SS.FF'), -7.297, 122.5348);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('29/03/2015 23:48:31.010000','DD/MM/YYYY HH24:MI:SS.FF'), -4.729, 152.5623);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('05/05/2015 01:44:06.380000','DD/MM/YYYY HH24:MI:SS.FF'), -5.462, 151.8751);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('07/05/2015 07:10:19.590000','DD/MM/YYYY HH24:MI:SS.FF'), -7.218, 154.5567);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('30/05/2015 11:23:02.110000','DD/MM/YYYY HH24:MI:SS.FF'), 27.839, 140.4931);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('18/07/2015 02:27:33.820000','DD/MM/YYYY HH24:MI:SS.FF'), -10.401, 165.1409);

Insert into EVENTS

   (TIME_, LATITUDE, LONGITUDE)

Values

   (TO_TIMESTAMP('27/07/2015 21:41:21.710000','DD/MM/YYYY HH24:MI:SS.FF'), -2.629, 138.5277);

COMMIT;

This post has been answered by Paulzip on Dec 12 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2018
Added on Dec 12 2017
22 comments
526 views