Simple GIS

GISプログラムの練習

地図

package map8;


import tool.*;

public class ren{

    String data=new String[50000];
    String article=new String[50000];
     String name=new String[50000];
     String pos=new String[50000];
     int s,sx,datanumber,posnumber;
    String str;
    String str1,str2;
    int number;
int x=new int[600];
int y=new int[600];
double lat=new double[500];
double lon=new double[500];
int lx=new int[600];
int ly=new int[600];

int p1;
String strx;


void makedata(){

    
    str1="<AdmArea";
    str2="";
    
    readfile sub=new readfile();
    sub.makedata("nagoya.xml","SJIS");
data=sub.data;
datanumber=sub.datanumber;
    
sx=0;
for(s=1;s<datanumber+1;s++){    
str=data[s];
if(str.indexOf(str1)>-1)sx=sx+1;
if(str.indexOf(str1)>-1)x[sx]=s;
}
number=sx;

sx=0;
for(s=1;s<datanumber+1;s++){    
str=data[s];
if(str.indexOf(str2)>-1)sx=sx+1;
if(str.indexOf(str2)>-1)y[sx]=s;
}


System.out.println(number);

for(s=1;s<number+1;s++){    
str="";
for(sx=x[s]+1;sx<y[s];sx++){
str=str+data[sx];
}
article[s]=str;
}

catchword sub2=new catchword();
str=sub2.makedata(article[9],"name");
name[s]=str;
str=article[9];
check(str);

for(s=1;s<posnumber+1;s++){
str=pos[s];
p1=str.indexOf(" ");
strx=str.substring(0,p1);
lat[s]=Double.parseDouble(strx);
strx=str.substring(p1+1,str.length());
lon[s]=Double.parseDouble(strx);
}

double maxx,minx,maxy,miny;
maxx=0;
maxy=0;
miny=999;
minx=999;
for(s=1;s<posnumber+1;s++){
if(lat[s]>maxx)maxx=lat[s];
if(lon[s]>maxy)maxy=lon[s];
if(lat[s]<minx)minx=lat[s];
if(lon[s]<miny)miny=lon[s];
}

for(s=1;s<posnumber+1;s++){
lx[s]=(int)(500*(lat[s]-minx)/(maxx-minx));    
ly[s]=(int)(500*(lon[s]-miny)/(maxy-miny)); 
}







}

void check(String str){
int p1,sx,pnumber;
int px=new int[500];
int py=new int[500];
sx=0;
p1=str.indexOf("");    
if(p1>-1)sx=sx+1;    
if(p1>-1)px[sx]=p1;    
while(p1>-1){
p1=str.indexOf("",p1+1);    
if(p1>-1)sx=sx+1;    
if(p1>-1)px[sx]=p1;       
}
pnumber=sx;
for(sx=1;sx<pnumber+1;sx++){
py[sx]=str.indexOf("",px[sx]);
}
for(sx=1;sx<pnumber+1;sx++){
p1=str.indexOf(">",px[sx]);
pos[sx]=str.substring(p1+1,py[sx]);    
}
posnumber=pnumber;

}
}