Simple GIS

GISプログラムの練習

catcgdata

package face7;

import tool.*;

public class catchdata {

    String urlx;
String data=new String[5000];
int s,datanumber,pointnumber;
int sx;

String point=new String[500];
String id=new String[500];
int px=new int[500];
int py=new int[500];
double p=new double[500];
String str,bou,right,left;
int p1,p2;
 
int x,y,w,h;
int rx,ry,lx,ly;

int nnumber;
  int nx=new int[500];
int ny=new int[500];  
    
int fnumber;
  int fx=new int[500];
int fy=new int[500];  
    
int mnumber;
  int mx=new int[500];
int my=new int[500];  

int brnumber;
  int brx=new int[500];
int bry=new int[500];  


int blnumber;
  int blx=new int[500];
int bly=new int[500];  

int ernumber;
  int erx=new int[500];
int ery=new int[500];  


int elnumber;
  int elx=new int[500];
int ely=new int[500]; 

int plnumber;
  int plx=new int[500];
int ply=new int[500];

int prnumber;
  int prx=new int[500];
int pry=new int[500];  


void makedata(String pic){

    urlx=" http://detectface.com/api/detect?url="+pic+"&m=2";
    
    
    getdata sub=new getdata();
    sub.makedata(urlx,"UTF-8");
    data=sub.data;
    datanumber=sub.datanumber;
    
    sx=0;
    for(s=1;s<datanumber+1;s++){
    str=data[s];
    if(str.indexOf("<point")>-1)sx=sx+1;
     if(str.indexOf("<point")>-1)point[sx]=data[s];
    }
    
    pointnumber=sx;
    
    for(s=1;s<pointnumber+1;s++){
     str=point[s];   
    p1=str.indexOf("id=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    id[s]=str.substring(p1+1,p2);
    }
    
    
    
    for(s=1;s<pointnumber+1;s++){
     str=point[s];   
    p1=str.indexOf("x=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    px[s]=Integer.parseInt(str);
    }
    
    for(s=1;s<pointnumber+1;s++){
     str=point[s];   
    p1=str.indexOf("y=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    py[s]=Integer.parseInt(str);
    }
    
    for(s=1;s<pointnumber+1;s++){
    str=point[s];   
    p1=str.indexOf("s=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    p[s]=Double.parseDouble(str);
    }

    
     bou="";
     right="";
     left="";
    for(s=1;s<datanumber+1;s++){
    str=data[s];
    if(str.indexOf("<bounds")>-1)bou=data[s];
    if(str.indexOf("<right")>-1)right=data[s];
    if(str.indexOf("<left")>-1)left=data[s];
    }
    
    
    str=bou;   
    p1=str.indexOf("x=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    x=Integer.parseInt(str);
     
    str=bou;   
    p1=str.indexOf("y=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    y=Integer.parseInt(str);
    
    str=bou;   
    p1=str.indexOf("width=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    w=Integer.parseInt(str);
     
    str=bou;   
    p1=str.indexOf("height=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    h=Integer.parseInt(str);
    
    str=right;   
    p1=str.indexOf("x=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    rx=Integer.parseInt(str);
     
    str=right;   
    p1=str.indexOf("y=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    ry=Integer.parseInt(str);
    
     str=left;   
    p1=str.indexOf("x=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    lx=Integer.parseInt(str);
     
    str=left;   
    p1=str.indexOf("y=");
    p1=str.indexOf("'",p1);
    p2=str.indexOf("'",p1+1);
    str=str.substring(p1+1,p2);
    ly=Integer.parseInt(str);
 
    int c1,n;
    String strx;
    c1=0;
    
    for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("N")>-1)c1=c1+1;
    if(str.indexOf("N")>-1)strx=str.replace("N","");
     if(str.indexOf("N")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("N")>-1)nx[n]=px[s];
       if(str.indexOf("N")>-1)ny[n]=py[s];
    }
    
    nnumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("F")>-1)c1=c1+1;
    if(str.indexOf("F")>-1)strx=str.replace("F","");
     if(str.indexOf("F")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("F")>-1)fx[n]=px[s];
       if(str.indexOf("F")>-1)fy[n]=py[s];
    System.out.println(str);
     }
    
    fnumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("M")>-1)c1=c1+1;
    if(str.indexOf("M")>-1)strx=str.replace("M","");
     if(str.indexOf("M")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("M")>-1)mx[n]=px[s];
       if(str.indexOf("M")>-1)my[n]=py[s];
    System.out.println(str);
     }
    
    mnumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("BR")>-1)c1=c1+1;
    if(str.indexOf("BR")>-1)strx=str.replace("BR","");
     if(str.indexOf("BR")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("BR")>-1)brx[n]=px[s];
       if(str.indexOf("BR")>-1)bry[n]=py[s];
    System.out.println(str);
     }
    
    brnumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("BL")>-1)c1=c1+1;
    if(str.indexOf("BL")>-1)strx=str.replace("BL","");
     if(str.indexOf("BL")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("BL")>-1)blx[n]=px[s];
       if(str.indexOf("BL")>-1)bly[n]=py[s];
    System.out.println(str);
     }
    
    blnumber=c1;
    
     c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("ER")>-1)c1=c1+1;
    if(str.indexOf("ER")>-1)strx=str.replace("ER","");
     if(str.indexOf("ER")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("ER")>-1)erx[n]=px[s];
       if(str.indexOf("ER")>-1)ery[n]=py[s];
    System.out.println(str);
     }
    
    ernumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("EL")>-1)c1=c1+1;
    if(str.indexOf("EL")>-1)strx=str.replace("EL","");
     if(str.indexOf("EL")>-1)n=Integer.parseInt(strx);
      if(str.indexOf("EL")>-1)elx[n]=px[s];
       if(str.indexOf("EL")>-1)ely[n]=py[s];
    System.out.println(str);
     }
    
    elnumber=c1;
    
    c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("PL")>-1)c1=c1+1;
      if(str.indexOf("PL")>-1)plx[c1]=px[s];
       if(str.indexOf("PL")>-1)ply[c1]=py[s];
    System.out.println(str);
     }
    
    plnumber=c1;
    
     c1=0;
     for(s=1;s<pointnumber+1;s++){
    str=id[s];
    strx="";
    n=0;
    if(str.indexOf("PR")>-1)c1=c1+1;
      if(str.indexOf("PR")>-1)prx[c1]=px[s];
       if(str.indexOf("PR")>-1)pry[c1]=py[s];
    System.out.println(str);
     }
    
    prnumber=c1;
    
    
    
}
}