package cup;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class catchmap{
String[] data=new String[5000000];
int s,sx,datanumber,sxs,number;
String[] code=new String[20000];
String[][] geo=new String[5000][5000];
int[] x=new int[20000];
int[] y=new int[20000];
int[] number_g=new int[20000];
String maxg;
int number_code;
HashMap<String,Integer> map = new HashMap<String,Integer>();
void makedata(double lat,double lon){
readx("adm.txt");
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<code>")>-1)sx=sx+1;
if(data[s].indexOf("<code>")>-1)code[sx]=data[s];
}
number=sx;
for(s=1;s<number+1;s++){
code[s]=code[s].replace("<code>","");
code[s]=code[s].replace("</code>","");
}
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<geo>")>-1)sx=sx+1;
if(data[s].indexOf("<geo>")>-1)x[sx]=s;
}
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("</geo>")>-1)sx=sx+1;
if(data[s].indexOf("</geo>")>-1)y[sx]=s;
}
int tx;
for(s=1;s<number+1;s++){
tx=0;
for(sx=x[s]+1;sx<y[s];sx++){
tx=tx+1;
geo[s][tx]=data[sx];
}
number_g[s]=tx;
}
int h,sx;
sx=0;
for(s=1;s<number+1;s++){
h=0;
if(map.containsKey(code[s]))h=100;
if(h<50)sx=sx+1;
if(h<50)map.put(code[s], sx);
}
number_code=sx;
maxg=geo5(lat,lon);
}
void readx(String file){
String str;
BufferedReader br;
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
String geo5(double xs,double ys){
double x,y;
int x1,x2,x3,x4,x5;
int y1,y2,y3,y4,y5;
x=xs-100;
y=1.5*ys;
y1=(int)y;
x1=(int)x;
y=y-y1;
y=8*y;
x=x-x1;
x=8*x;
y2=(int)y;
x2=(int)x;
y=y-y2;
y=10*y;
x=x-x2;
x=10*x;
y3=(int)y;
x3=(int)x;
x=x-x3;
y=y-y3;
x=2*x;
y=2*y;
y4=(int)y;
x4=(int)x;
x=x-x4;
y=y-y4;
x=2*x;
y=2*y;
y5=(int)y;
x5=(int)x;
String str;
str=""+y1+""+x1+""+y2+""+x2+""+y3+""+x3+""+y4+""+x4+""+y5+""+x5;
return str;
}
}
最終更新:2015年10月09日 00:24