アットウィキロゴ

google mapc

package map2;
 
public class pro {
 
double lat,lon,latx,lonx;
int cx,cy,dy,dx;
 
int h=500;
int w=500;
double delta;
 
int[][] memor=new int[h][w]; 
int[][] memog=new int[h][w]; 
int[][] memob=new int[h][w];  
 
int px,py,px1,py1;
int x1,y1;
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
 pro(){  
 
lat=36;
lon=139;
 
 
map sub=new map();
sub.makedata(lat,lon,lat,lon);
cx=sub.px;
cy=sub.py;
memor=sub.memor;
memog=sub.memog;
memob=sub.memob;
 
 
map sub2=new map();
sub2.makedata(lat,lon,lat+1,lon);
px=sub2.px;
py=sub2.py;
 
dy=py-cy;
 
 
map sub3=new map();
sub3.makedata(lat,lon,lat,lon+1);
px=sub3.px;
py=sub3.py;
 
dx=px-cx;
 
latx=36.59;
lonx=136.6;
 
x1=(int)(cx+dx*(lonx-lon));
y1=(int)(cy+dy*(latx-lat));
 
graph sub7=new graph();
sub7.memor=memor;
sub7.memog=memog;
sub7.memob=memob;
sub7.x1=x1;
sub7.y1=y1;
sub7.makedata("x.jpg");
 
 
 
 
 
 
 
 
 
 
 
  }
 
}
 
 
 
 
package map2;
 
 
public class map {
 
     String urlx,urlxs;
    double lat,lon,delta;
 
    int px,py;
 
    int h=500;
    int w=500;
 
int[][] memor=new int[h][w]; 
int[][] memog=new int[h][w]; 
int[][] memob=new int[h][w];  
 
 int[][] memors=new int[h][w]; 
int[][] memogs=new int[h][w]; 
int[][] memobs=new int[h][w];  
 
void makedata(double lat,double lon,double latx,double lonx){
 
 
urlx=makeurl(lat,lon);
 
urlxs=makemarker(lat,lon,latx,lonx); 
 
catchimg sub=new catchimg();
sub.makedata(urlx);
memor=sub.memor;
memog=sub.memog;
memob=sub.memob;
 
catchimg sub3=new catchimg();
sub3.makedata(urlxs);
memors=sub3.memor;
memogs=sub3.memog;
memobs=sub3.memob;
 
 
search();
 
 
}
 
void search(){
 
    int sx,mx,nx;
    int r1,g1,b1,r2,b2,g2;
    int m1;
    int subnumber;
    int[] subx=new int[500];
    int[] suby=new int[500];
 
 sx=0;
for(mx=0;mx<h;mx++){
for(nx=0;nx<w;nx++){
r1=memor[mx][nx];
g1=memog[mx][nx];
b1=memob[mx][nx];   
r2=memors[mx][nx];
g2=memogs[mx][nx];
b2=memobs[mx][nx];   
m1=(r1-r2)*(r1-r2)+(g1-g2)*(g1-g2)+(b1-b2)*(b1-b2);
if(m1>500)sx=sx+1;
if(m1>500)subx[sx]=nx;
if(m1>500)suby[sx]=mx;
}
}
 
subnumber=sx;
 
 
 
int s,maxy,maxx;
maxy=0;
maxx=0;
for(s=1;s<subnumber+1;s++){
if(suby[s]>maxy)maxx=subx[s];
if(suby[s]>maxy)maxy=suby[s];
}
 
px=maxx;
py=maxy;
 
}
 
 
 
 
String makeurl(double lat,double lon){
 String urlx;
 urlx="http://maps.google.com/maps/api/staticmap?center="+lat+","+lon+"&zoom=5&size=500x500&sensor=false";
 
    return urlx;   
}
 
String makemarker(double lat,double lon,double latx,double lonx){
 String urlx;
 urlx="http://maps.google.com/maps/api/staticmap?center="+lat+","+lon+"&zoom=5&size=500x500&sensor=false";
 urlx=urlx+"&markers="+latx+","+lonx; 
    return urlx;   
}
 
}
 
 
 
package map2;
 
import java.awt.*; 
import java.awt.Color;   
import java.awt.image.*;   
import java.awt.image.BufferedImage;   
import java.io.*;   
import javax.imageio.ImageIO;   
 
class graph{
 
    int h=500;
    int w=500;
int p1;
int s,sx;
String a1,a2;
 int[][] memor=new int[h][w]; 
int[][] memog=new int[h][w]; 
int[][] memob=new int[h][w];  
int mx,nx;
 
int w1,h1;
int x1,y1; 
 
void makedata(String file){
 
w1=500;
h1=500;    
BufferedImage off = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_BGR);   
Graphics offsc = off.getGraphics(); 
offsc.setColor(Color.white); 
offsc.fillRect(0,0,w1,h1); 
offsc.setColor(Color.black); 
 
 
 
 
for(mx=0;mx<h;mx++){
for(nx=0;nx<w;nx++){
offsc.setColor(new Color(memor[mx][nx],memog[mx][nx],memob[mx][nx])); 
offsc.drawRect(nx,mx,1,1);
}
}
 
offsc.setColor(new Color(255, 0, 0, 100));
offsc.fillRect(x1,y1,10,10);
 
offsc.dispose(); 
 
try { 
ImageIO.write(off, "jpeg", new File(file)); 
} catch (IOException exception) { exception.printStackTrace(); }     
}   
}
 
 
 
 
package map2;
 
import java.awt.*; 
import java.awt.image.*; 
import java.net.URL;
import java.net.MalformedURLException;
 
public class catchimg {
 
PixelGrabber pg; 
Color col; 
Image img;
int red,green,blue; 
 
int mx,nx,m,n; 
int ex,ey; 
String s1,s2,s3,s4; 
URL urlx;
int w=500;
int h=500;
int[] pix=new int[w*h]; 
int[][] memor=new int[h][w]; 
int[][] memog=new int[h][w]; 
int[][] memob=new int[h][w];  
 
    void makedata(String pic){
 
 
 
        try{
urlx = new URL(pic);
    }catch(MalformedURLException e){e.printStackTrace();}
 
catchimg(urlx);  
 
} 
 
void catchimg(URL s){ 
 
img = Toolkit.getDefaultToolkit().getImage(s); 
pg = new PixelGrabber(img,0,0,w,h,pix,0,w); 
 
try{pg.grabPixels();}catch(InterruptedException ie){} 
m=0; 
n=0; 
for(int i=0;i<w*h;i++){ 
int p = pix[i]; 
col=new Color(pix[i]); 
red=col.getRed(); 
green=col.getGreen(); 
blue=col.getBlue(); 
memor[m][n]=red; 
memog[m][n]=green; 
memob[m][n]=blue; 
n=n+1; 
if (n==w)m=m+1; 
if (n==w)n=0; 
} 
 
 
 
} 
 
 
 
 
 
}
 
最終更新:2013年12月31日 23:07