Home > database >  Novice for help: latitude and longitude is known, the query range condition
Novice for help: latitude and longitude is known, the query range condition

Time:09-23

Small white [first of all, programming and database, are slowly groping, master looked glad]
With oracle trajectory data processing, want to pass on a select statement record coordinates range around a certain point, the total display parameter out of range, the specific method is as follows: select * from table 1
Where 2 * 6371 * ASIN (SQRT (round (SIN ((34.223445 - LATITUDE) * a cosine (1)/360), 4) + COS (34.223445 * a cosine (1)/180) * COS (LATITUDE * a cosine (1)/180) * round (SIN ((113.011235 - LONGITUDE) * a cosine (1)/360), 4))) <0.5
Note: the table 1 to find the data form; I selected fixed point is 34.223445, 113.011235, LATITUDE and LONGITUDE LATITUDE and LONGITUDE values in the table, respectively, for the great god, why I can't run, do you have any questions, how should do? Thank you very much
[note additionally, LATITUDE and LONGITUDE fields in my table are VARCHAR2 () format, I have tried to use the to_number modify the data type is not successful, also tried through the function to query the records the same failure, great god teach beginners small white, procedure is as follows:
Insert into table 1 (number, X, Y) select number, to_number (X), to_number (Y) from the user. The table 2.
[note: this sentence try to convert the X and Y in table 2 to type number is inserted into the new table 1, the results after operation without any data;]
The CREATE OR REPLACE FUNCTION GetDistance (lat1 varchar2 (9),
Lng1 number,
Lat2 number,
Lng2 number) RETURN number is
Earth_padius number:=6378.137;
RadLat1 number:=rad (lat1);
RadLat2 number:=rad (lat2);
A number:=radLat1 - radLat2;
Number: b=rad (lng1) - rad (lng2);
S number:=0;
The begin
S:=2 *
Asin (Sqrt (power (sin (a/2), 2) +
Cos (radLat1) * cos (radLat2) * power (sin/2 (b), 2)));
S:=s * earth_padius;
S:=Round (s * 10000)/10;
return s;

end;
The update GPSA set short=short (Y, X, 34.223445, 108.948301);
[note: this section to create function is looking for someone else's code, want to call a function to the distance of each trajectory point and fixed point to new, in a list of short but when running shows that the function parameter or inconsistent type]

CodePudding user response:

Tests do not have what problem, may be due to part of the LATITUDE and LONGITUDE values have problem cause, there are currently no data analysis is not a reason
  • Related