Kamis, 22 Agustus 2019

Android TM Lib

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:screenOrientation="landscape">

    <org.opencv.android.JavaCameraView
        android:id="@+id/deteksi"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        opencv:camera_id="any"
        opencv:show_fps="true"

        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center|bottom"
        android:layout_margin="16dp"
        android:gravity="center"
        android:orientation="horizontal"
        android:weightSum="2"
        android:layout_marginTop="260dp">

        <Button
            android:id="@+id/btnCek"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="COMPARE"
            android:layout_gravity="center"/>
    </LinearLayout>

</RelativeLayout>




package com.example.fau.deteksidaun;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.DMatch;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Scalar;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.imgproc.Imgproc;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

public class Deteksi extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{


    String gab="";
    int jd=10;
    Button btnCek;
    String[]arObject;
    String[]arNama;

String hasilObject="";
    private static final String TAG = "OCVSample::Activity";
    private static final int REQUEST_PERMISSION = 100;
    private int w, h;
    private CameraBridgeViewBase mOpenCvCameraView;
    TextView tvName;
    Scalar RED = new Scalar(255, 0, 0);
    Scalar GREEN = new Scalar(0, 255, 0);
    FeatureDetector detector;
    DescriptorExtractor descriptor;
    DescriptorMatcher matcher;

    Mat descriptors2;
    MatOfKeyPoint keypoints2;

    MatOfKeyPoint [] key1;
    Mat desc1[],citra1[];

    static {
        if (!OpenCVLoader.initDebug())
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS: {
                    Log.i(TAG, "OpenCV loaded successfully");
                    // mOpenCvCameraView.enableView();
                    try {
                        initializeOpenCVDependencies();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                break;
                default: {
                    super.onManagerConnected(status);
                }
                break;
            }
        }
    };

    private void initializeOpenCVDependencies() throws IOException {
        mOpenCvCameraView.enableView();
        detector = FeatureDetector.create(FeatureDetector.ORB);
        descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

        Button btnCek=(Button)findViewById(R.id.btnCek);
        btnCek.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Deteksi.this, HasilKlasifikasi.class);
                i.putExtra("hasil ", hasilObject);
                startActivity(i);
            }});



        arObject=new String[jd];
arNama=new String[jd];
desc1=new Mat[jd];
citra1=new Mat[jd];
key1=new MatOfKeyPoint[jd];

        arObject[0]="obj1.jpg";
        arObject[1]="obj2.jpg";
        arObject[2]="obj3.jpg";

        arNama[0]="Object 1";
        arNama[1]="Object 2";
        arNama[2]="Object 3";

        AssetManager assetManager = getAssets();

        for(int k=0;k<jd;k++) {
            citra1[k] = new Mat();
            InputStream istr1 = assetManager.open(arObject[k]);//a.jpeg
            Bitmap bitmap1 = BitmapFactory.decodeStream(istr1);
            Utils.bitmapToMat(bitmap1, citra1[k] );
            Imgproc.cvtColor(citra1[k] , citra1[k] , Imgproc.COLOR_RGB2GRAY);


            citra1[k] .convertTo(citra1[k] , 0);
            desc1[k] = new Mat();
            key1[k] = new MatOfKeyPoint();
            detector.detect(citra1[k] , key1[k]);
            descriptor.compute(citra1[k] , key1[k], desc1[k]);
        }
        //============================================1
    }
    public Deteksi() {
        Log.i(TAG, "Instantiated new " + this.getClass());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "called onCreate");
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_deteksi);


        if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_PERMISSION);
        }
        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.deteksi);
        mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
        mOpenCvCameraView.setCvCameraViewListener(this);
    }


    @Override
    public void onPause() {
        super.onPause();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onResume() {
        super.onResume();
        if (!OpenCVLoader.initDebug()) {
            Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, Deteksi.this, mLoaderCallback);
        } else {
            Log.d(TAG, "OpenCV library found inside package. Using it!");
            mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }

        }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onCameraViewStarted(int width, int height) {
        w = width;
        h = height;
    }

    @Override
    public void onCameraViewStopped() {

    }

    public Mat recognize(Mat aInputFrame) {//aInputFrame=objek dari Kamera
        double nmin = 10000000;
        int indexKe=0;

        Imgproc.cvtColor(aInputFrame, aInputFrame, Imgproc.COLOR_RGB2GRAY);
        descriptors2 = new Mat();
        keypoints2 = new MatOfKeyPoint();
        detector.detect(aInputFrame, keypoints2);
        descriptor.compute(aInputFrame, keypoints2, descriptors2);


        MatOfDMatch matches = null;
        Double max_dist = 0.0;
        Double min_dist = 100.0;
        int JM = 0;

        matches = new MatOfDMatch();
        for(int k=0;k<jd;k++){
        if (citra1[k].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[k], descriptors2, matches);

                List<DMatch> matchesList1 = matches.toList();

                max_dist = 0.0;
                min_dist = 100.0;

                JM = matchesList1.size();
                for (int i = 0; i < JM; i++) {
                    Double dist = (double) matchesList1.get(i).distance;
                    if (dist < min_dist)
                        min_dist = dist;
                    if (dist > max_dist)
                        max_dist = dist;
                }
                Log.d("MAXMIN15", "@Object1=" + max_dist + "@" + min_dist + "@" + (1.2 * min_dist));
                if (min_dist < nmin) {
                    indexKe = k;
                    nmin = min_dist;
                }

            } catch (Exception ee) {
            }
        } else {
            return aInputFrame;
        }

    }//loop


        //=================================================================================3
        matches = new MatOfDMatch();
        if (citra1[indexKe].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[indexKe], descriptors2, matches);
            } catch (Exception ee) {
            }

        } else {
            return aInputFrame;
        }

        List<DMatch> matchesListOut = matches.toList();
        JM = matchesListOut.size();
        List<DMatch>  listBest=null;
        Mat imgBest=new Mat();
        MatOfKeyPoint keyBest=null;

            listBest=matchesListOut;
            imgBest=citra1[indexKe];
            keyBest=key1[indexKe];
        hasilObject=arNama[indexKe];

        //=================================================================================================LAST
        int mm=0;
        LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
        for (int i = 0; i < JM; i++) {
            if (listBest.get(i).distance <= (1.2 * min_dist)) {//1.5 * min_dist
                good_matches.addLast(listBest.get(i));
                mm++;
            }
        }
        gab=gab+String.valueOf(mm)+"#";
        Log.d("GAB","#"+gab+"+++++++++++++++++++++++++++++++++++++++++++++");

        MatOfDMatch goodMatches = new MatOfDMatch();
        goodMatches.fromList(good_matches);
        Mat outputImg = new Mat();


        MatOfByte drawnMatches = new MatOfByte();
        if (aInputFrame.empty() || aInputFrame.cols() < 1 || aInputFrame.rows() < 1) {
            return aInputFrame;
        }
        Features2d.drawMatches(imgBest, keyBest, aInputFrame, keypoints2, goodMatches, outputImg, GREEN, RED, drawnMatches, Features2d.NOT_DRAW_SINGLE_POINTS);
        Imgproc.resize(outputImg, outputImg, aInputFrame.size());


        return outputImg;
    }


        @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
        return recognize(inputFrame.rgba());
    }
}


+++++
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fau.apps">
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature   android:name="android.hardware.camera"  android:required="false" />
    <uses-feature  android:name="android.hardware.camera.autofocus"  android:required="false" />
    <uses-feature  android:name="android.hardware.camera.front" android:required="false" />
    <uses-feature   android:name="android.hardware.camera.front.autofocus"   android:required="false" />


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".HalamanUtama">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Deteksi" />
        <activity android:name=".HasilKlasifikasi"></activity>
    </application>

</manifest>


HTML Assets Post Data to Android




<html lang="en">
<head>
  <meta charset="utf-8">
  <title>HTML POST</title>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<form action="http://localhost/aplikasi/add.php?&ket=register via HTML" id="searchForm">
  <input type="text" name="nama_user" placeholder="Search...">
  <input type="submit" value="Search">
</form>
<div id="result"></div>

<script>


$( "#searchForm" ).submit(function( event ) {

  // Stop form from submitting normally
  event.preventDefault();

  // Get some values from elements on the page:
  var $form = $( this ),
    term = $form.find( "input[name='s']" ).val(),
    url = $form.attr( "action" );

  // Send the data using post post
  var posting = $.get( url, { s: term } );

  // Put the results in a div
  posting.done(function( data ) {
    var content = $( data ).find( "#content" );
    $( "#result" ).empty().append( content );
  alert( "success" );
  });
});
</script>

</body>
</html>

++++++++++++++++++++++++++++++++++++THE PHP

$nama_user=$_GET["nama_user"];
$ket=$_GET["ket"];

$sql="INSERT INTO `tb_user`
(`id_user`, `nama_user`,  `keterangan`) VALUES('', '$nama_user', '$ket')";

$simpan=process($conn,$sql);
echo"#content:sukses";
+++++++++++++++++++++++++++++++++++++



Selasa, 20 Agustus 2019

Aplikasi Mencari Kesamaan Objek












import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.DMatch;
import org.opencv.core.Mat;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.RotatedRect;
import org.opencv.core.Scalar;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.imgproc.Imgproc;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class UJI extends AppCompatActivity {
    int jumMM=0;
    int jumJM;


    String gab="";
    int jd=20;
    Button btnCek;
    String[]arID;

    String kategori,mypath,huruf;
    private static final String TAG = "OCVSample::Activity";
    private static final int REQUEST_PERMISSION = 100;
    TextView tvName;
    Scalar RED = new Scalar(255, 0, 0);
    Scalar GREEN = new Scalar(0, 255, 0);
    FeatureDetector detector;
    DescriptorExtractor descriptor;
    DescriptorMatcher matcher;

    Mat descriptors2;
    MatOfKeyPoint keypoints2;

    MatOfKeyPoint [] key1;
    Mat desc1[],citra1[];

    static {
        if (!OpenCVLoader.initDebug())
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS: {
                    Log.i(TAG, "OpenCV loaded successfully");
                    try {
                       // initializeOpenCVDependencies();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
            }
                break;
                default: {
                    super.onManagerConnected(status);
                }
                break;
            }
        }
    };

    private void initializeOpenCVDependencies() throws IOException {
     //   mOpenCvCameraView.enableView();
        detector = FeatureDetector.create(FeatureDetector.ORB);
        descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);




        mypath=arID[0];
        AssetManager assetManager = getAssets();
        Mat aInputFrame=new Mat();

        //Bitmap   bitmap1 = BitmapFactory.decodeFile(path);

        InputStream istr2 = null;//a.jpeg
        try {
            istr2 = assetManager.open(mypath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Bitmap bitmap2 = BitmapFactory.decodeStream(istr2);

        Utils.bitmapToMat(bitmap2, aInputFrame );//aInputFrame=citra1[k]
        Imgproc.cvtColor(aInputFrame , aInputFrame , Imgproc.COLOR_RGB2GRAY);


        aInputFrame.convertTo(aInputFrame , 0);
        descriptors2= new Mat();//descriptors2=desc1[k]
        keypoints2 = new MatOfKeyPoint();//keypoints2=   key1[k]
        detector.detect(aInputFrame ,keypoints2);
        descriptor.compute(aInputFrame , keypoints2, descriptors2);






        for(int k=0;k<jd;k++) {
            citra1[k] = new Mat();
            InputStream istr1 = assetManager.open(arID[k]);//a.jpeg
            Bitmap bitmap1 = BitmapFactory.decodeStream(istr1);
            Utils.bitmapToMat(bitmap1, citra1[k] );
            Imgproc.cvtColor(citra1[k] , citra1[k] , Imgproc.COLOR_RGB2GRAY);


            citra1[k] .convertTo(citra1[k] , 0);
            desc1[k] = new Mat();
            key1[k] = new MatOfKeyPoint();
            detector.detect(citra1[k] , key1[k]);
            descriptor.compute(citra1[k] , key1[k], desc1[k]);

            compareBitmaps(bitmap1, bitmap2);
            //compareMats(descriptors2, desc1[k]);
        }
        //============================================1


//        Log.d("path",kategori+"#"+huruf+"#"+mypath);
//        cekCompare(mypath);

    }


    public UJI() {
        Log.i(TAG, "Instantiated new " + this.getClass());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "called onCreate");
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//        setContentView(R.layout.activity_deteksi);

//        Intent io=this.getIntent();
//        kategori=io.getStringExtra("kategori");
//        mypath=io.getStringExtra("mypath");
//        huruf=io.getStringExtra("huruf");
        //btnCek.setText(mypath);
        huruf="A";

        if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_PERMISSION);
        }


        jd=3;
        arID=new String[jd];
        desc1=new Mat[jd];
        citra1=new Mat[jd];
        key1=new MatOfKeyPoint[jd];

        if(huruf.equalsIgnoreCase("A")) {
            arID[0] = "a1.png";
            arID[1] = "a2.png";
            arID[2] = "a3.png";
        }
        else  if(huruf.equalsIgnoreCase("I")) {
            arID[0] = "i1.png";
            arID[1] = "i2.png";
            arID[2] = "i3.png";
        }
        else  if(huruf.equalsIgnoreCase("U")) {
            arID[0] = "u1.png";
            arID[1] = "u2.png";
            arID[2] = "u3.png";
        }
        else  if(huruf.equalsIgnoreCase("E")) {
            arID[0] = "e1.png";
            arID[1] = "e2.png";
            arID[2] = "e3.png";
        }
        else  if(huruf.equalsIgnoreCase("KA")) {
            arID[0] = "ka1.png";
            arID[1] = "ka2.png";
            arID[2] = "ka3.png";
        }
        else  if(huruf.equalsIgnoreCase("KI")) {
            arID[0] = "ki1.png";
            arID[1] = "ki2.png";
            arID[2] = "ki3.png";
        }
        else  if(huruf.equalsIgnoreCase("KU")) {
            arID[0] = "ku1.png";
            arID[1] = "ku2.png";
            arID[2] = "ku3.png";
        }
        else  if(huruf.equalsIgnoreCase("KE")) {
            arID[0] = "ke1.png";
            arID[1] = "ke2.png";
            arID[2] = "ke3.png";
        }
        else  if(huruf.equalsIgnoreCase("KO")) {
            arID[0] = "ko1.png";
            arID[1] = "ko2.png";
            arID[2] = "ko3.png";
        }
        else  if(huruf.equalsIgnoreCase("SA")) {
            arID[0] = "sa1.png";
            arID[1] = "sa2.png";
            arID[2] = "sa3.png";
        }
        else  if(huruf.equalsIgnoreCase("SHI")) {
            arID[0] = "shi1.png";
            arID[1] = "shi2.png";
            arID[2] = "shi3.png";
        }
        else  if(huruf.equalsIgnoreCase("SU")) {
            arID[0] = "su1.png";
            arID[1] = "su2.png";
            arID[2] = "su3.png";
        }
        else  if(huruf.equalsIgnoreCase("SE")) {
            arID[0] = "se1.png";
            arID[1] = "se2.png";
            arID[2] = "se3.png";
        }
        else  if(huruf.equalsIgnoreCase("SO")) {
            arID[0] = "so1.png";
            arID[1] = "so2.png";
            arID[2] = "so3.png";
        }
        else  if(huruf.equalsIgnoreCase("TA")) {
            arID[0] = "ta1.png";
            arID[1] = "ta2.png";
            arID[2] = "ta3.png";
        }
        else  if(huruf.equalsIgnoreCase("CHI")) {
            arID[0] = "chi1.png";
            arID[1] = "chi2.png";
            arID[2] = "chi3.png";
        }
        else  if(huruf.equalsIgnoreCase("TSU")) {
            arID[0] = "tsu1.png";
            arID[1] = "tsu2.png";
            arID[2] = "tsu3.png";
        }
        else  if(huruf.equalsIgnoreCase("TE")) {
            arID[0] = "te1.png";
            arID[1] = "te2.png";
            arID[2] = "te3.png";
        }
        else  if(huruf.equalsIgnoreCase("TO")) {
            arID[0] = "to1.png";
            arID[1] = "to2.png";
            arID[2] = "to3.png";
        }
        else  if(huruf.equalsIgnoreCase("NA")) {
            arID[0] = "na1.png";
            arID[1] = "na2.png";
            arID[2] = "na3.png";
        }
        else  if(huruf.equalsIgnoreCase("NI")) {
            arID[0] = "ni1.png";
            arID[1] = "ni2.png";
            arID[2] = "ni3.png";
        }
        else  if(huruf.equalsIgnoreCase("NU")) {
            arID[0] = "nu1.png";
            arID[1] = "nu2.png";
            arID[2] = "nu3.png";
        }
        else  if(huruf.equalsIgnoreCase("NE")) {
            arID[0] = "ne1.png";
            arID[1] = "ne2.png";
            arID[2] = "ne3.png";
        }
        else  if(huruf.equalsIgnoreCase("NO")) {
            arID[0] = "no1.png";
            arID[1] = "no2.png";
            arID[2] = "no3.png";
        }
        else  if(huruf.equalsIgnoreCase("HA")) {
            arID[0] = "ha1.png";
            arID[1] = "ha2.png";
            arID[2] = "ha3.png";
        }
        else  if(huruf.equalsIgnoreCase("HI")) {
            arID[0] = "hi1.png";
            arID[1] = "hi2.png";
            arID[2] = "hi3.png";
        }
        else  if(huruf.equalsIgnoreCase("FU")) {
            arID[0] = "fu1.png";
            arID[1] = "fu2.png";
            arID[2] = "fu3.png";
        }
        else  if(huruf.equalsIgnoreCase("HE")) {
            arID[0] = "he1.png";
            arID[1] = "he2.png";
            arID[2] = "he3.png";
        }
        else  if(huruf.equalsIgnoreCase("HO")) {
            arID[0] = "ho1.png";
            arID[1] = "ho2.png";
            arID[2] = "ho3.png";
        }
        else  if(huruf.equalsIgnoreCase("MA")) {
            arID[0] = "ma1.png";
            arID[1] = "ma2.png";
            arID[2] = "ma3.png";
        }
        else  if(huruf.equalsIgnoreCase("MI")) {
            arID[0] = "mi1.png";
            arID[1] = "mi2.png";
            arID[2] = "mi3.png";
        }
        else  if(huruf.equalsIgnoreCase("MU")) {
            arID[0] = "mu1.png";
            arID[1] = "mu2.png";
            arID[2] = "mu3.png";
        }
        else  if(huruf.equalsIgnoreCase("ME")) {
            arID[0] = "me1.png";
            arID[1] = "me2.png";
            arID[2] = "me3.png";
        }
        else  if(huruf.equalsIgnoreCase("MO")) {
            arID[0] = "mo1.png";
            arID[1] = "mo2.png";
            arID[2] = "mo3.png";
        }
        else  if(huruf.equalsIgnoreCase("YA")) {
            arID[0] = "ya1.png";
            arID[1] = "ya2.png";
            arID[2] = "ya3.png";
        }
        else  if(huruf.equalsIgnoreCase("YU")) {
            arID[0] = "yu1.png";
            arID[1] = "yu2.png";
            arID[2] = "yu3.png";
        }
        else  if(huruf.equalsIgnoreCase("YO")) {
            arID[0] = "yo1.png";
            arID[1] = "yo2.png";
            arID[2] = "yo3.png";
        }
        else  if(huruf.equalsIgnoreCase("RA")) {
            arID[0] = "ra1.png";
            arID[1] = "ra2.png";
            arID[2] = "ra3.png";
        }
        else  if(huruf.equalsIgnoreCase("RI")) {
            arID[0] = "ri1.png";
            arID[1] = "ri2.png";
            arID[2] = "ri3.png";
        }
        else  if(huruf.equalsIgnoreCase("RU")) {
            arID[0] = "ru1.png";
            arID[1] = "ru2.png";
            arID[2] = "ru3.png";
        }
        else  if(huruf.equalsIgnoreCase("RO")) {
            arID[0] = "re1.png";
            arID[1] = "re2.png";
            arID[2] = "re3.png";
        }
        else  if(huruf.equalsIgnoreCase("RO")) {
            arID[0] = "ro1.png";
            arID[1] = "ro2.png";
            arID[2] = "ro3.png";
        }
        else  if(huruf.equalsIgnoreCase("WA")) {
            arID[0] = "wa1.png";
            arID[1] = "wa2.png";
            arID[2] = "wa3.png";
        }
        else  if(huruf.equalsIgnoreCase("WO")) {
            arID[0] = "wo1.png";
            arID[1] = "wo2.png";
            arID[2] = "wo3.png";
        }
        else  if(huruf.equalsIgnoreCase("N")) {
            arID[0] = "n1.png";
            arID[1] = "n2.png";
            arID[2] = "n3.png";
        }


        try {
            initializeOpenCVDependencies();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void cekCompare(String path) {//aInputFrame=objek dari Kamera
        Mat aInputFrame=new Mat();
        AssetManager assetManager = getAssets();

        //Bitmap   bitmap1 = BitmapFactory.decodeFile(path);

        InputStream istr1 = null;//a.jpeg
        try {
            istr1 = assetManager.open(path);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Bitmap bitmap1 = BitmapFactory.decodeStream(istr1);

        Utils.bitmapToMat(bitmap1, aInputFrame );//aInputFrame=citra1[k]
        Imgproc.cvtColor(aInputFrame , aInputFrame , Imgproc.COLOR_RGB2GRAY);

        //cekCompare2(aInputFrame);


//        String sgab="";
//        aInputFrame.convertTo(aInputFrame , 0);
//        descriptors2= new Mat();//descriptors2=desc1[k]
//        keypoints2 = new MatOfKeyPoint();//keypoints2=   key1[k]
//        detector.detect(aInputFrame ,keypoints2);
//        descriptor.compute(aInputFrame , keypoints2, descriptors2);
//
//
//
//
//        compareBitmaps(bmTemplate, bmLogo);

    }
//======================================


    public   void cekCompare2(Mat aInputFrame) {
        String sgab="";
        aInputFrame.convertTo(aInputFrame , 0);
        descriptors2= new Mat();//descriptors2=desc1[k]
        keypoints2 = new MatOfKeyPoint();//keypoints2=   key1[k]
        detector.detect(aInputFrame ,keypoints2);
        descriptor.compute(aInputFrame , keypoints2, descriptors2);






        double nmin = 10000000;
        int indexKe=0;

        MatOfDMatch matches = null;

        int JM = 0;
        Double max_dist = 0.0;
        Double min_dist = 100.0;

        matches = new MatOfDMatch();
        for(int k=0;k<jd;k++){

            matcher.match(desc1[k],descriptors2,matches);
            MatOfDMatch filtered = filterMatchesByDistance(matches);

            int total = (int) matches.size().height;
            int Match= (int) filtered.size().height;
            Log.d("HITUNG_MM",k+"."+arID[k]+"=Total Bit:" + total + " Match Bit:"+Match);

            if(JM<Match){JM=Match;indexKe=k;}


//                try {
//                    matcher.match(desc1[k], descriptors2, matches);
//                    List<DMatch> matchesList1 = matches.toList();
//
//                    JM = matchesList1.size();
//                    for (int i = 0; i < JM; i++) {
//                        Double dist = (double) matchesList1.get(i).distance;
//                        if (dist < min_dist)
//                            min_dist = dist;
//                        if (dist > max_dist)
//                            max_dist = dist;
//                    }
//
//                    if (min_dist < nmin) {
//                        indexKe = k;
//                        nmin = min_dist;
//                    }
//                    Log.d("MAXMIN", k+"." + max_dist + "@" + min_dist + "@" + (1.2 * min_dist)+"#"+indexKe);
//                } catch (Exception ee) {
//                }
//
//
//            matches = new MatOfDMatch();
//                try {
//                    matcher.match(desc1[k], descriptors2, matches);
//                } catch (Exception ee) {
//                }
//
//
//                    List<DMatch> matchesListOut = matches.toList();
//                    JM = matchesListOut.size();
//                    List<DMatch>  listBest=null;
//                    listBest=matchesListOut;
//
//            //=================================================================================================LAST
//                    int mm=0;
//                    LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
//                    for (int i = 0; i < JM; i++) {
//                        if (listBest.get(i).distance <= (1.2 * min_dist)) {//1.5 * min_dist
//                            good_matches.addLast(listBest.get(i));
//                            mm++;
//                        }
//                    }
//
//            if(jumMM<mm){
//                jumMM=mm;
//            }
//
//            if(jumJM<JM){
//                jumJM=JM;
//            }
//
//            Log.d("HITUNG_MM",k+"."+mm+"#"+jumMM+"#JM="+JM+"#"+jumJM);
//
//            sgab+="GB"+(k+1)+"."+mm+"#"+jumMM+"#JM="+JM+"#"+jumJM+"\n";

        }//loop
hasil(JM+"#"+indexKe);
    }




    public void hasil(String hs){
        new AlertDialog.Builder(this)
                .setTitle("Kategori:"+kategori+":"+huruf)
                .setMessage(hs)
                .setNeutralButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sumthin) {
                        finish();
                    }})
                .show();
    }


//    static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
//        List<DMatch> matches_original = matches.toList();
//        List<DMatch> matches_filtered = new ArrayList<DMatch>();
//
//        int DIST_LIMIT = 30;
//        // Check all the matches distance and if it passes add to list of filtered matches
//        Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
//        for (int i = 0; i < matches_original.size(); i++) {
//            DMatch d = matches_original.get(i);
//            if (Math.abs(d.distance) <= DIST_LIMIT) {
//                matches_filtered.add(d);
//            }
//        }
//        Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");
//
//        MatOfDMatch mat = new MatOfDMatch();
//        mat.fromList(matches_filtered);
//        return mat;
//    }



    //=======================
    private Bitmap findLogo(Bitmap sourceBitmap) {
        Bitmap roiBitmap = null;
        Mat sourceMat = new Mat(sourceBitmap.getWidth(), sourceBitmap.getHeight(), CvType.CV_8UC3);
        Utils.bitmapToMat(sourceBitmap, sourceMat);
        Mat roiTmp = sourceMat.clone();

        final Mat hsvMat = new Mat();
        sourceMat.copyTo(hsvMat);

        // convert mat to HSV format for Core.inRange()
        Imgproc.cvtColor(hsvMat, hsvMat, Imgproc.COLOR_RGB2HSV);

        Scalar lowerb = new Scalar(85, 50, 40);         // lower color border for BLUE
        Scalar upperb = new Scalar(135, 255, 255);      // upper color border for BLUE
        Core.inRange(hsvMat, lowerb, upperb, roiTmp);   // select only blue pixels

        // find contours
        List<MatOfPoint> contours = new ArrayList<>();
        List<Rect> squares = new ArrayList<>();
        Imgproc.findContours(roiTmp, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);

        // find appropriate bounding rectangles
        for (MatOfPoint contour : contours) {
            MatOfPoint2f areaPoints = new MatOfPoint2f(contour.toArray());
            RotatedRect boundingRect = Imgproc.minAreaRect(areaPoints);

            double rectangleArea = boundingRect.size.area();

            // test min ROI area in pixels
            if (rectangleArea > 400) {
                Point rotated_rect_points[] = new Point[4];
                boundingRect.points(rotated_rect_points);

                Rect rect = Imgproc.boundingRect(new MatOfPoint(rotated_rect_points));
                double aspectRatio = rect.width > rect.height ?
                        (double) rect.height / (double) rect.width : (double) rect.width / (double) rect.height;
                if (aspectRatio >= 0.9) {
                    squares.add(rect);
                }
            }
        }

        Mat logoMat = extractSquareMat(roiTmp, getBiggestSquare(squares));

        roiBitmap = Bitmap.createBitmap(logoMat.cols(), logoMat.rows(), Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(logoMat, roiBitmap);
        return roiBitmap;
    }
    public static Mat extractSquareMat(Mat sourceMat, Rect rect) {
        Mat squareMat = null;
        int padding = 50;

        if (rect != null) {
            Rect truncatedRect = new Rect((int) rect.tl().x + padding, (int) rect.tl().y + padding,
                    rect.width - 2 * padding, rect.height - 2 * padding);
            squareMat = new Mat(sourceMat, truncatedRect);
        }

        return squareMat ;
    }

    private void compareBitmaps(Bitmap bitmap1, Bitmap bitmap2) {
        Mat mat1 = new Mat(bitmap1.getWidth(), bitmap1.getHeight(), CvType.CV_8UC3);
        Utils.bitmapToMat(bitmap1, mat1);

        Mat mat2 = new Mat(bitmap2.getWidth(), bitmap2.getHeight(), CvType.CV_8UC3);
        Utils.bitmapToMat(bitmap2, mat2);
Log.d("OKDEH","90sukses");
        compareMats(mat1, mat2);
    }


    private void compareMats(Mat img1, Mat img2) {
        FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
        DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);
        DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

        Mat descriptors1 = new Mat();
        MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
        detector.detect(img1, keypoints1);
        extractor.compute(img1, keypoints1, descriptors1);

        //second image
        // Mat img2 = Imgcodecs.imread(path2);
        Mat descriptors2 = new Mat();
        MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
        detector.detect(img2, keypoints2);
        extractor.compute(img2, keypoints2, descriptors2);

        Log.d("OKDEH","91sukses");
        //matcher image descriptors
        MatOfDMatch matches = new MatOfDMatch();
        matcher.match(descriptors1,descriptors2,matches);

        // Filter matches by distance
        MatOfDMatch filtered = filterMatchesByDistance(matches);

        int total = (int) matches.size().height;
        int Match= (int) filtered.size().height;
        Log.d("LOGOKDEH", "total:" + total + " Match:" + Match);
    }

    static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
        List<DMatch> matches_original = matches.toList();
        List<DMatch> matches_filtered = new ArrayList<DMatch>();

        int DIST_LIMIT = 30;
        // Check all the matches distance and if it passes add to list of filtered matches
        Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
        for (int i = 0; i < matches_original.size(); i++) {
            DMatch d = matches_original.get(i);
            if (Math.abs(d.distance) <= DIST_LIMIT) {
                matches_filtered.add(d);
            }
        }
        Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");

        MatOfDMatch mat = new MatOfDMatch();
        mat.fromList(matches_filtered);
        return mat;
    }


    public static Rect getBiggestSquare(List<Rect> squares) {
        Rect biggestSquare = null;

        if (squares != null && squares.size() >= 1) {
            Rect square;
            double maxArea;
            int ixMaxArea = 0;

            square = squares.get(ixMaxArea);
            maxArea = square.area();

            for (int ix = 1; ix < squares.size(); ix++) {
                square = squares.get(ix);
                if (square.area() > maxArea) {
                    maxArea = square.area();
                    ixMaxArea = ix;
                }
            }

            biggestSquare = squares.get(ixMaxArea);
        }

        return biggestSquare;
    }

}

Senin, 19 Agustus 2019

API MAPBOX Alternatif Rute GMAPS




<?php

function get_coordinates($city, $street, $province)

{
    $address = urlencode($city.','.$street.','.$province);
    $url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=Poland";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($ch);
    curl_close($ch);
    $response_a = json_decode($response);
    $status = $response_a->status;

    if ( $status == 'ZERO_RESULTS' )
    {
        return FALSE;
    }
    else
    {
        $return = array('lat' => $response_a->results[0]->geometry->location->lat, 'long' => $response_a->results[0]->geometry->location->lng);
        return $return;
    }
}

function GetDrivingDistance($lat1, $lat2, $long1, $long2)
{
$lat1=-6.704319;
$long1=111.342051;
$lat2=-6.690439;
$long2=111.282741;
    $url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=".$lat1.",".$long1."&destinations=".$lat2.",".$long2."&mode=driving&language=pl-PL";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $response = curl_exec($ch);
    curl_close($ch);
    $response_a = json_decode($response, true);
    $dist = $response_a['rows'][0]['elements'][0]['distance']['text'];
    $time = $response_a['rows'][0]['elements'][0]['duration']['text'];

    return array('distance' => $dist, 'time' => $time);
}

$coordinates1 = get_coordinates('Tychy', 'Jana Pawła II', 'Śląskie');
$coordinates2 = get_coordinates('Lędziny', 'Lędzińska', 'Śląskie');
if ( !$coordinates1 || !$coordinates2 )
{
    echo 'Bad address.';
}
else
{
    $dist = GetDrivingDistance($coordinates1['lat'], $coordinates2['lat'], $coordinates1['long'], $coordinates2['long']);
    echo 'Distance: <b>'.$dist['distance'].'</b><br>Travel time duration: <b>'.$dist['time'].'</b>';
}




?>


Reff:
https://stackoverflow.com/questions/29003118/get-driving-distance-between-two-points-using-google-maps-api
https://stackoverflow.com/questions/29003118/get-driving-distance-between-two-points-using-google-maps-api


Jika ada kendala biasanya masalah API KEYNYA Google yang kita belum punyai....solusi gunakan
API MAPBOX :

https://api.mapbox.com/directions/v5/mapbox/driving/106.832425,-6.352754;106.832661,-6.351810.json?access_token=pk.eyJ1IjoiaXdhbmdyYWhhZGlhbiIsImEiOiJjanpjZ25oYTgwMTRrM25sbnliaXAzdjhtIn0.BV5T_OcmGoMek6pVaQc64Q&steps=true&geometries=geojson






ASTAR Implementation on Android

08-19 15:28:28.375: I/System.out(1999):         OPEN : [Wates]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : []
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Wates***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Nasional 1]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Nasional 1***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Nasional 2]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Nasional 2***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Nasional 3]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Nasional 3***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Magersari]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Magersari***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Diponegoro]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Diponegoro***
08-19 15:28:28.375: I/System.out(1999):         OPEN : []
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari, Jl. Diponegoro]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Dr. Wahidin, Jl. Diponegoro2]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari, Jl. Diponegoro]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Dr. Wahidin***
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Diponegoro2]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari, Jl. Diponegoro, Jl. Dr. Wahidin]
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Diponegoro2, Jl. KS Tubun, Jl. Airlangga, Jl. Dr. Wahidin2]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari, Jl. Diponegoro, Jl. Dr. Wahidin]
08-19 15:28:28.375: I/System.out(1999):    ***BEST NODE : Jl. Airlangga***
08-19 15:28:28.375: I/System.out(1999):         OPEN : [Jl. Diponegoro2, Jl. KS Tubun, Jl. Dr. Wahidin2]
08-19 15:28:28.375: I/System.out(1999):         CLOSED : [Wates, Jl. Nasional 1, Jl. Nasional 2, Jl. Nasional 3, Magersari, Jl. Diponegoro, Jl. Dr. Wahidin, Jl. Airlangga]
08-19 15:28:28.375: D/Info(1999): MRUTE: -> Wates -> Jl. Nasional 1 -> Jl. Nasional 2 -> Jl. Nasional 3 -> Magersari -> Jl. Diponegoro -> Jl. Dr. Wahidin -> Jl. Airlangga -> Pantai Dampo Awang Rembang
08-19 15:28:28.375: D/Info(1999): MRUTE:https://www.google.co.id/maps/dir/-6.704319,111.342051/-6.690439,111.282741/-6.694965,111.282782/-6.699873,111.312078/-6.700048,111.313894/-6.700715,111.324093/-6.70412,111.332566/-6.705046,111.335064/-6.70645,111.336425
08-19 15:28:28.375: D/Info(1999): MRUTE:6.85 KM






OK

package com.example.objekwisata;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class Detail_wisata extends Activity {

String kodenode1A,namanode1A,kodenode1B,namanode1B;
double jarak1A,jarak1B;

int jd=64;
String[]arKode;
double[]arLati;
double[]arLongi;
double[]arJarak;
String[]arNama;
     
String myLati="-6.660531";
String myLongi="111.467079";

String myPosisi="GPS";
     
String myLati2="-6.688898";
String myLongi2="111.282493";
String myPosisi2="Tujuan Objek Wisata";



TextView txt1,txt2,txt3;
String  kategori,alamat,deskripsi, jarak,gambar,nama_wisata,latitude,longitude;
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detail_wisata);

        Intent io = this.getIntent();
        kategori=io.getStringExtra("kategori");
        alamat=io.getStringExtra("alamat");
        deskripsi=io.getStringExtra("deskripsi");
     
        myLati2=io.getStringExtra("latitude");
        myLongi2=io.getStringExtra("longitude");
        myPosisi2=io.getStringExtra("nama_wisata");
     
        gambar=io.getStringExtra("gambar");
        jarak=io.getStringExtra("jarak");

        myLati=io.getStringExtra("myLati");
        myLongi=io.getStringExtra("myLongi");
        myPosisi=io.getStringExtra("myPosisi");
     
        nama_wisata=myPosisi2;
        latitude=myLati2;
        longitude=myLongi2;
     
        TextView txtNama=(TextView)findViewById(R.id.dnama_wisata);
        TextView txtkategori=(TextView)findViewById(R.id.dkategori);
        TextView txtAlamat=(TextView)findViewById(R.id.dalamat);
        TextView txtdeskripsi=(TextView)findViewById(R.id.ddeskripsi);
        TextView txtPosisi=(TextView)findViewById(R.id.dposisi);
        TextView txtJarak=(TextView)findViewById(R.id.djarak);txtJarak.setVisibility(View.GONE);
     
     
        txt1=(TextView)findViewById(R.id.dlintasan);
        txt2=(TextView)findViewById(R.id.djaraknya);
        txt3=(TextView)findViewById(R.id.dketerangan);
     
        ImageView myGambar=(ImageView)findViewById(R.id.myGambar);
        int gb=R.drawable.wstsejarah ;
        if(nama_wisata.equalsIgnoreCase("Pantai Dampo Awang Rembang")){gb=R.drawable.pantai_dampoawang;}
     
        else         if(nama_wisata.equalsIgnoreCase("Pantai Nyamplung")){gb=R.drawable.pantai_nyamplung;}
        else         if(nama_wisata.equalsIgnoreCase("Pantai Karang Jahe")){gb=R.drawable.karang_jahe;}
        else         if(nama_wisata.equalsIgnoreCase("Pantai Jatisari")){gb=R.drawable.pantai_jatisari;}
        else         if(nama_wisata.equalsIgnoreCase("Pantai Pasir Putih Wates")){gb=R.drawable.pasir_putih_wates;}
        else         if(nama_wisata.equalsIgnoreCase("Hutan Mangrove")){gb=R.drawable.hutan_mangrove;}
        else         if(nama_wisata.equalsIgnoreCase("Pantai Caruban")){gb=R.drawable.pantai_caruban;}
        else         if(nama_wisata.equalsIgnoreCase("Gunung Kajar")){gb=R.drawable.gunung_kajar;}
        else         if(nama_wisata.equalsIgnoreCase("Air Terjun Pasucen")){gb=R.drawable.air_terjun_pasucen;}
        else         if(nama_wisata.equalsIgnoreCase("Watu Congol")){gb=R.drawable.watu_congol;}
        else         if(nama_wisata.equalsIgnoreCase("Karangsari Park")){gb=R.drawable.karangsari_park;}
        else         if(nama_wisata.equalsIgnoreCase("De Kampoeng")){gb=R.drawable.de_kampoeng1;}
        else         if(nama_wisata.equalsIgnoreCase("Embung Lodan")){gb=R.drawable.embung_lodan;}
        else         if(nama_wisata.equalsIgnoreCase("Waduk Panohan")){gb=R.drawable.waduk_panohan;}
        else         if(nama_wisata.equalsIgnoreCase("Sumber Semen")){gb=R.drawable.sumber_semen;}
        else         if(nama_wisata.equalsIgnoreCase("Wana Wisata Kartini Mantingan")){gb=R.drawable.kartini_mantingan;}
        else         if(nama_wisata.equalsIgnoreCase("Museum RA Kartini")){gb=R.drawable.museum_ra_kartini;}
        else         if(nama_wisata.equalsIgnoreCase("Vihara Ratanavana Arama")){gb=R.drawable.vihara_ratanavana_arama;}
        else         if(nama_wisata.equalsIgnoreCase("Klenteng Cu An Kiong Lasem")){gb=R.drawable.klenteng_cu_an_kiong;}
        else         if(nama_wisata.equalsIgnoreCase("Klenteng Tjoe Hwie Kiong")){gb=R.drawable.klenteng_tjoe_hwie_kiong;}
        else         if(nama_wisata.equalsIgnoreCase("Petilasan Sunan Bonang Lasem")){gb=R.drawable.pasujudan_sunan_bonang;}
        else         if(nama_wisata.equalsIgnoreCase("Makam RA Kartini")){gb=R.drawable.makam_ra_kartini;}
        else         if(nama_wisata.equalsIgnoreCase("Kuliner Lontong Tuyuhan")){gb=R.drawable.kuliner_tuyuhan;}
        else         if(nama_wisata.equalsIgnoreCase("Sate Serepeh")){gb=R.drawable.sate_serepeh;}
        else if(nama_wisata.equalsIgnoreCase("Kelo Mrico")){gb=R.drawable.sayur_mrico;}
        else if(nama_wisata.equalsIgnoreCase("Sayur Mangut")){gb=R.drawable.sayur_mangut;}
        else if(nama_wisata.equalsIgnoreCase("Toko Kawista Dewa Burung")){gb=R.drawable.dewa_burung;}
        else if(nama_wisata.equalsIgnoreCase("Rumah Makan Praukuno")){gb=R.drawable.rm_praukuno;}
        else if(nama_wisata.equalsIgnoreCase("Rumah Makan Bu Joyo")){gb=R.drawable.rm_bu_joyo;}
        else if(nama_wisata.equalsIgnoreCase("Rumah Makan Hien")){gb=R.drawable.rm_hien;}
        else if(nama_wisata.equalsIgnoreCase("Rumah Makan Pondok Hijau")){gb=R.drawable.rm_pondok_hijau;}
        else if(nama_wisata.equalsIgnoreCase("Dokar")){gb=R.drawable.dokar;}
        else if(nama_wisata.equalsIgnoreCase("Tossa")){gb=R.drawable.tossa;}
        else if(nama_wisata.equalsIgnoreCase("Angkutan Umum")){gb=R.drawable.angkot_kuning;}
        else if(nama_wisata.equalsIgnoreCase("Terminal Rembang")){gb=R.drawable.terminal_rembang;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Pantura")){gb=R.drawable.hotel_pantura;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Antika")){gb=R.drawable.hotel_antika;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Kartini")){gb=R.drawable.hotel_kartini2;}
        else if(nama_wisata.equalsIgnoreCase("Hotel SPBU Gajah Mada")){gb=R.drawable.hotel_spbu_gajahmada;}
        else if(nama_wisata.equalsIgnoreCase("Fave Hotel")){gb=R.drawable.favehotel;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Larasati")){gb=R.drawable.hotel_larasati;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Kencana")){gb=R.drawable.hotel_kencana1;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Puri Indah")){gb=R.drawable.hotel_puri_indah;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Kencana")){gb=R.drawable.hotel_kencana1;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Rantina")){gb=R.drawable.hotel_rantina;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Sumber Agung")){gb=R.drawable.hotel_sumberagung;}
        else if(nama_wisata.equalsIgnoreCase("Hotel Surya Lasem")){gb=R.drawable.hotel_surya;}
        else if(nama_wisata.equalsIgnoreCase("PO Madu Kismo")){gb=R.drawable.bis_madukismo;}
        else if(nama_wisata.equalsIgnoreCase("PO Subur Jaya")){gb=R.drawable.bis_suburjaya;}
        else{ gb=R.drawable.ic_launcher;}
     
     

        myGambar.setImageResource(gb);
     
        txtNama.setText(nama_wisata);
        txtkategori.setText(kategori);
        txtAlamat.setText(alamat);
        txtdeskripsi.setText(deskripsi);
       // txtKoordinat.setText(latitude+","+longitude);
        txtPosisi.setText(myPosisi);
        txtJarak.setText(jarak+"km");
     
        txtJarak.setVisibility(View.GONE);

    Button  btnarah=(Button)findViewById(R.id.btnarah);
    btnarah.setOnClickListener(new View.OnClickListener() {
    public void onClick(View arg0) {
// String modeDirection = "driving";
// String url = "http://maps.google.com/maps?saddr="+myLati+","+myLongi+"&daddr="+latitude+","+longitude+"&directionsmode=" + modeDirection;
// Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
// intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
// startActivity(intent);

    String url=txt3.getText().toString();
    cetak(url);
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
    //intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    startActivity(intent);
   
        }});
     
 
//     Button   call=(Button)findViewById(R.id.btncall);
//        call.setOnClickListener(new View.OnClickListener() {
//        public void onClick(View arg0) {
//        String toDial="0902234567560";
//          startActivity(new Intent(Intent.ACTION_DIAL,Uri.parse(toDial)));
//    }});
     
 
 
 
 
    init();
        start();
        mulai();
     
    }
 
public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
         finish();
                return true;
        }
    return super.onKeyDown(keyCode, event);



void start(){
     
     
double mlati=Double.parseDouble(myLati);
double mlongi=Double.parseDouble(myLongi);

double mlati2=Double.parseDouble(myLati2);
double mlongi2=Double.parseDouble(myLongi2);


double jmaxA=1000000000;
int indexA=0;
for(int i=0;i<jd;i++){
    double r=0;
    try{
        r=getJarak(mlati,mlongi,arLati[i],arLongi[i]);
        arJarak[i]=r;
        if(r<jmaxA){
            jmaxA=r;
            indexA=i;
        }
    }
    catch(Exception ee){}
}

double jmaxB=1000000000;
int indexB=0;
for(int i=0;i<jd;i++){
    double r=0;
    try{
        r=getJarak(mlati2,mlongi2,arLati[i],arLongi[i]);
        arJarak[i]=r;
        if(r<jmaxB){
            jmaxB=r;
            indexB=i;
        }
    }
    catch(Exception ee){}
}


 kodenode1A=arKode[indexA];
 namanode1A=arNama[indexA];
 jarak1A=arJarak[indexA];

 kodenode1B=arKode[indexB];
 namanode1B=arNama[indexB];
 jarak1B=arJarak[indexB];
//==========================     

}             
     
 void mulai() {
        Node A = new Node("Wates",0);
        Node B = new Node("Jl. Nasional 1",0);
        Node C = new Node("Jl. Nasional 2",0);
        Node D = new Node("Jl. Nasional 3",0);
        Node E = new Node("Magersari",0);
        Node F = new Node("Jl. Diponegoro",0);
        Node G = new Node("Jl. Dr. Wahidin",0);
        Node H = new Node("Jl. KS Tubun",0);
        Node I = new Node("Jl. KS Tubun2",0);
        Node J = new Node("Jl. KS Tubun3",0);
        Node K = new Node("Jl. Diponegoro2",0);
        Node L = new Node("Jl. Airlangga",0);
        Node M = new Node("Jl. Yos Sudarso",0);
        Node N = new Node("Jl. Yos Sudarso2",0);
        Node O = new Node("Jl. MH Tamrin",0);
        Node P = new Node("Jl. Dr. Wahidin2",0);
        Node Q = new Node("Jl. Diponegoro3",0);
        Node R = new Node("Jl. Diponegoro4",0);
        Node S = new Node("Jl. RA Kartini",0);
        Node T = new Node("Jl. RA Kartini2",0);
        Node U = new Node("Jl. Pemuda",0);
        Node V = new Node("Jl. Slamet Riyadi",0);
        Node W = new Node("Jl. Slamet Riyadi2",0);
        Node X = new Node("Jl. Lingkar",0);
        Node Y = new Node("Jl. Landoh",0);
        Node Z = new Node("Jl. Landoh2",0);
        Node A1 = new Node("Seren",0);
        Node B1 = new Node("Jl. Blora",0);
        Node C1 = new Node("Panohan",0);
        Node D1 = new Node("Jl. Blora2",0);
        Node E1 = new Node("Jl. Blora3",0);
        Node F1 = new Node("Jl. Blora4",0);
        Node G1 = new Node("Pasucen",0);
        Node H1 = new Node("Kutoharjo",0);
        Node I1 = new Node("Kutoharjo2",0);
        Node J1 = new Node("Kutoharjo3",0);
        Node K1 = new Node("Kabongan",0);
        Node L1 = new Node("Pasarbanggi",0);
        Node M1 = new Node("Tritunggal",0);
        Node N1 = new Node("Tritunggal2",0);
        Node O1 = new Node("Punjulharjo",0);
        Node P1 = new Node("Punjulharjo2",0);
        Node Q1 = new Node("Karangpelem",0);
        Node R1 = new Node("Karangpelem2",0);
        Node S1 = new Node("Gedongmulyo",0);
        Node T1 = new Node("Karangturi",0);
        Node U1 = new Node("Karangturi2",0);
        Node V1 = new Node("Karangturi3",0);
        Node W1 = new Node("Jl. Provinsi",0);
        Node X1 = new Node("Jl. Provinsi2",0);
        Node Y1 = new Node("Jl. Japerejo",0);
        Node Z1 = new Node("Jl. Gunem",0);
        Node A2 = new Node("Jl. Pamotan",0);
        Node B2 = new Node("Sale",0);
        Node C2 = new Node("Sale2",0);
        Node D2 = new Node("Jl. Kragan",0);
        Node E2 = new Node("Bonang",0);
        Node F2 = new Node("Jatisari",0);
        Node G2 = new Node("Jl. Baidhowi",0);
        Node H2 = new Node("Jl. Baidhowi2",0);
        Node I2 = new Node("Kajar",0);
        Node J2 = new Node("Selopuro",0);
        Node K2 = new Node("Vihara",0);
     
     
        //JARAK SATUAN KM
        A.connect(new Edge(B,0.55));
        B.connect(new Edge(A,0.55));
     
        B.connect(new Edge(C,3.3));
        C.connect(new Edge(B,3.3));
     
        C.connect(new Edge(D,0.21));
        D.connect(new Edge(C,0.21));
     
        D.connect(new Edge(E,1.2));
        E.connect(new Edge(D,1.2));
     
        E.connect(new Edge(F,1));
        F.connect(new Edge(E,1));
     
        F.connect(new Edge(G,0.3));
        G.connect(new Edge(F,0.3));
        F.connect(new Edge(K,0.5));
        K.connect(new Edge(F,0.5));
     
        G.connect(new Edge(H,0.19));
        G.connect(new Edge(L,0.29));
        G.connect(new Edge(P,0.2));
        H.connect(new Edge(G,0.19));
        L.connect(new Edge(G,0.29));
        P.connect(new Edge(G,0.2));
     
        I.connect(new Edge(J,0.6));
        I.connect(new Edge(N,0.5));
        I.connect(new Edge(V,0.95));
        J.connect(new Edge(I,0.6));
        N.connect(new Edge(I,0.5));
        V.connect(new Edge(I,0.95));
     
        K.connect(new Edge(P,0.16));
        K.connect(new Edge(Q,0.24));
        P.connect(new Edge(K,0.16));
        Q.connect(new Edge(K,0.24));
     
        H.connect(new Edge(M,0.5));
        M.connect(new Edge(H,0.5));
     
     
     
        M.connect(new Edge(N,0.12));
        M.connect(new Edge(O,0.15));
        M.connect(new Edge(T,0.35));
        N.connect(new Edge(M,0.12));
        O.connect(new Edge(M,0.15));
        T.connect(new Edge(M,0.35));
     
        L.connect(new Edge(P,0.11));
        L.connect(new Edge(O,0.25));
        P.connect(new Edge(L,0.11));
        O.connect(new Edge(L,0.25));
     
        O.connect(new Edge(Q,0.35));
        Q.connect(new Edge(O,0.35));
             
        Q.connect(new Edge(R,0.3));
        R.connect(new Edge(Q,0.3));
     
        P.connect(new Edge(S,0.3));
        S.connect(new Edge(P,0.3));
     
        R.connect(new Edge(S,0.27));
        R.connect(new Edge(H1,0.7));
        S.connect(new Edge(R,0.27));
        H1.connect(new Edge(R,0.7));
     
        S.connect(new Edge(U,0.29));
        U.connect(new Edge(S,0.29));
     
        T.connect(new Edge(U,0.11));
        U.connect(new Edge(T,0.11));
     
        N.connect(new Edge(U,0.45));
        U.connect(new Edge(N,0.45));
     
        U.connect(new Edge(V,0.11));
        U.connect(new Edge(X,0.29));
        V.connect(new Edge(U,0.11));
        X.connect(new Edge(U,0.29));
             
        V.connect(new Edge(W,2.2));
        W.connect(new Edge(V,2.2));
     
        W.connect(new Edge(X,1));
        X.connect(new Edge(W,1));
     
        X.connect(new Edge(Y,5));
        Y.connect(new Edge(X,5));
     
        Y.connect(new Edge(Z,4.6));
        Y.connect(new Edge(B1,5.4));
        Z.connect(new Edge(Y,4.6));
        B1.connect(new Edge(Y,5.4));
     
        Z.connect(new Edge(A1,3.7));
        A1.connect(new Edge(Z,3.7));
     
        B1.connect(new Edge(C1,6.8));
        B1.connect(new Edge(D1,6.1));
        C1.connect(new Edge(B1,6.8));
        D1.connect(new Edge(B1,6.1));
     
        D1.connect(new Edge(E1,2.8));
        E1.connect(new Edge(D1,2.8));
     
        E1.connect(new Edge(F1,0.95));
        F1.connect(new Edge(E1,0.95));
     
        F1.connect(new Edge(G1,6.8));
        G1.connect(new Edge(F1,6.8));
     
        H1.connect(new Edge(I1,0.22));
        I1.connect(new Edge(H1,0.22));
     
        I1.connect(new Edge(J1,0.1));
        I1.connect(new Edge(K1,1.1));
        J1.connect(new Edge(I1,0.1));
        K1.connect(new Edge(I1,1.1));
     
        K1.connect(new Edge(L1,3.1));
        L1.connect(new Edge(K1,3.1));
     
        L1.connect(new Edge(M1,1.4));
        M1.connect(new Edge(L1,1.4));
     
        M1.connect(new Edge(N1,0.9));
        N1.connect(new Edge(M1,0.9));
     
        N1.connect(new Edge(O1,2));
        O1.connect(new Edge(N1,2));
     
        O1.connect(new Edge(P1,0.75));
        O1.connect(new Edge(Q1,2.1));
        O1.connect(new Edge(R1,1.8));
        P1.connect(new Edge(O1,0.75));
        Q1.connect(new Edge(O1,2.1));
        R1.connect(new Edge(O1,1.8));
     
        Q1.connect(new Edge(R1,2.1));
        Q1.connect(new Edge(S1,4.6));
        R1.connect(new Edge(Q1,2.1));
        S1.connect(new Edge(Q1,4.6));
     
        S1.connect(new Edge(T1,0.75));
        T1.connect(new Edge(S1,0.75));
     
        T1.connect(new Edge(U1,0.3));
        T1.connect(new Edge(V1,0.5));
        U1.connect(new Edge(T1,0.3));
        V1.connect(new Edge(T1,0.5));
     
        V1.connect(new Edge(W1,0.45));
        W1.connect(new Edge(V1,0.45));
     
        W1.connect(new Edge(X1,0.85));
        X1.connect(new Edge(W1,0.85));
     
        X1.connect(new Edge(Y1,1.6));
        X1.connect(new Edge(Z1,8.6));
        Y1.connect(new Edge(X1,1.6));
        Z1.connect(new Edge(X1,8.6));
     
        Y1.connect(new Edge(Z1,8));
        Z1.connect(new Edge(Y1,8));
     
        Z1.connect(new Edge(A2,7.8));
        A1.connect(new Edge(Z1,7.8));
     
        A2.connect(new Edge(B2,9.4));
        B2.connect(new Edge(A2,9.4));
     
        B2.connect(new Edge(C2,4.9));
        C2.connect(new Edge(B2,4.9));
     
        C2.connect(new Edge(D2,0.3));
        D2.connect(new Edge(C2,0.3));
     
        D2.connect(new Edge(E2,4.6));
        D2.connect(new Edge(G2,0.6));
        E2.connect(new Edge(D2,4.6));
        G2.connect(new Edge(D2,0.6));
     
        E2.connect(new Edge(F2,7.1));
        F2.connect(new Edge(E2,7.1));
     
        G2.connect(new Edge(H2,1.1));
        G2.connect(new Edge(K2,2.4));
        H2.connect(new Edge(G2,1.1));
        K2.connect(new Edge(G2,2.4));
     
        H2.connect(new Edge(I2,1.8));
        H2.connect(new Edge(J2,1));
        I2.connect(new Edge(H2,1.8));
        J2.connect(new Edge(H2,1));
     
     
     
        //=======================================================
     
              Node n1=A;
           if(kodenode1A.equals("Wates")){n1=A;}
           else if(kodenode1A.equals("Jl. Nasional 1")){n1=B;}
           else if(kodenode1A.equals("Jl. Nasional 2")){n1=C;}
           else if(kodenode1A.equals("Jl. Nasional 3")){n1=D;}
           else if(kodenode1A.equals("Margesari")){n1=E;}
           else if(kodenode1A.equals("Jl. Diponegoro")){n1=F;}
           else if(kodenode1A.equals("Jl. Dr. Wahidin")){n1=G;}
           else if(kodenode1A.equals("Jl. KS Tubun")){n1=H;}
           else if(kodenode1A.equals("Jl. KS Tubun2")){n1=I;}
           else if(kodenode1A.equals("Jl. KS Tubun3")){n1=J;}
           else if(kodenode1A.equals("Jl. Diponegoro2")){n1=K;}
           else if(kodenode1A.equals("Jl. Airlangga")){n1=L;}
           else if(kodenode1A.equals("Jl. Yos Sudarso")){n1=M;}
           else if(kodenode1A.equals("Jl. Yos Sudarso2")){n1=N;}
           else if(kodenode1A.equals("Jl. MH Tamrin")){n1=O;}
           else if(kodenode1A.equals("Jl. Dr. Wahidin2")){n1=P;}
           else if(kodenode1A.equals("Jl. Diponegoro3")){n1=Q;}
           else if(kodenode1A.equals("Jl. Diponegoro4")){n1=R;}
           else if(kodenode1A.equals("Jl. RA Kartini")){n1=S;}
           else if(kodenode1A.equals("Jl. RA Kartin2")){n1=T;}
           else if(kodenode1A.equals("Jl. Pemuda")){n1=U;}
           else if(kodenode1A.equals("Jl. Slamet Riyadi")){n1=V;}
           else if(kodenode1A.equals("Jl. Slamet Riyadi2")){n1=W;}
           else if(kodenode1A.equals("Jl. Lingkar")){n1=X;}
           else if(kodenode1A.equals("Jl. Landoh")){n1=Y;}
           else if(kodenode1A.equals("Jl. Landoh2")){n1=Z;}
           else if(kodenode1A.equals("Seren")){n1=A1;}
           else if(kodenode1A.equals("Jl. Blora")){n1=B1;}
           else if(kodenode1A.equals("Panohan")){n1=C1;}
           else if(kodenode1A.equals("Jl. Blora2")){n1=D1;}
           else if(kodenode1A.equals("Jl. Blora3")){n1=E1;}
           else if(kodenode1A.equals("Jl. Blora4")){n1=F1;}
           else if(kodenode1A.equals("Pasucen")){n1=G1;}
           else if(kodenode1A.equals("Kutoharjo")){n1=H1;}
           else if(kodenode1A.equals("Kutoharjo2")){n1=I1;}
           else if(kodenode1A.equals("Kutoharjo3")){n1=J1;}
           else if(kodenode1A.equals("Kabongan")){n1=K1;}
           else if(kodenode1A.equals("Pasarbanggi")){n1=L1;}
           else if(kodenode1A.equals("Tritunggal")){n1=M1;}
           else if(kodenode1A.equals("Tritunggal2")){n1=N1;}
           else if(kodenode1A.equals("Punjulharjo")){n1=O1;}
           else if(kodenode1A.equals("Punjulharjo2")){n1=P1;}
           else if(kodenode1A.equals("Karangpelem")){n1=Q1;}
           else if(kodenode1A.equals("Karangpelem2")){n1=R1;}
           else if(kodenode1A.equals("Gedongmulyo")){n1=S1;}
           else if(kodenode1A.equals("Karangturi")){n1=T1;}
           else if(kodenode1A.equals("Karangturi2")){n1=U1;}
           else if(kodenode1A.equals("Karangturi3")){n1=V1;}
           else if(kodenode1A.equals("Jl. Provinsi")){n1=W1;}
           else if(kodenode1A.equals("Jl. Provinsi2")){n1=X1;}
           else if(kodenode1A.equals("Jl. Japerejo")){n1=Y1;}
           else if(kodenode1A.equals("Jl. Gunem")){n1=Z1;}
           else if(kodenode1A.equals("Jl. Pamotan")){n1=A2;}
           else if(kodenode1A.equals("Sale")){n1=B2;}
           else if(kodenode1A.equals("Sale2")){n1=C2;}
           else if(kodenode1A.equals("Jl. Kragan")){n1=D2;}
           else if(kodenode1A.equals("Bonang")){n1=E2;}
           else if(kodenode1A.equals("Jatisari")){n1=F2;}
           else if(kodenode1A.equals("Jl. Baidhowi")){n1=G2;}
           else if(kodenode1A.equals("Jl. Baidhowi2")){n1=H2;}
           else if(kodenode1A.equals("Kajar")){n1=H2;}
           else if(kodenode1A.equals("Selopuro")){n1=J2;}
           else if(kodenode1A.equals("Vihara")){n1=K2;}
         
         
            Node n2=B;
           if(kodenode1B.equals("Wates")){n2=A;}
           else if(kodenode1B.equals("Jl. Nasional 1")){n2=B;}
           else if(kodenode1B.equals("Jl. Nasional 2")){n2=C;}
           else if(kodenode1B.equals("Jl. Nasional 3")){n2=D;}
           else if(kodenode1B.equals("Margesari")){n2=E;}
           else if(kodenode1B.equals("Jl. Diponegoro")){n2=F;}
           else if(kodenode1B.equals("Jl. Dr. Wahidin")){n2=G;}
           else if(kodenode1B.equals("Jl. KS Tubun")){n2=H;}
           else if(kodenode1B.equals("Jl. KS Tubun2")){n2=I;}
           else if(kodenode1B.equals("Jl. KS Tubun3")){n2=J;}
           else if(kodenode1B.equals("Jl. Diponegoro2")){n2=K;}
           else if(kodenode1B.equals("Jl. Airlangga")){n2=L;}
           else if(kodenode1B.equals("Jl. Yos Sudarso")){n2=M;}
           else if(kodenode1B.equals("Jl. Yos Sudarso2")){n2=N;}
           else if(kodenode1B.equals("Jl. MH Tamrin")){n2=O;}
           else if(kodenode1B.equals("Jl. Dr. Wahidin2")){n2=P;}
           else if(kodenode1B.equals("Jl. Diponegoro3")){n2=Q;}
           else if(kodenode1B.equals("Jl. Diponegoro4")){n2=R;}
           else if(kodenode1B.equals("Jl. RA Kartini")){n2=S;}
           else if(kodenode1B.equals("Jl. RA Kartin2")){n2=T;}
           else if(kodenode1B.equals("Jl. Pemuda")){n2=U;}
           else if(kodenode1B.equals("Jl. Slamet Riyadi")){n2=V;}
           else if(kodenode1B.equals("Jl. Slamet Riyadi2")){n2=W;}
           else if(kodenode1B.equals("Jl. Lingkar")){n2=X;}
           else if(kodenode1B.equals("Jl. Landoh")){n2=Y;}
           else if(kodenode1B.equals("Jl. Landoh2")){n2=Z;}
           else if(kodenode1B.equals("Seren")){n2=A1;}
           else if(kodenode1B.equals("Jl. Blora")){n2=B1;}
           else if(kodenode1B.equals("Panohan")){n2=C1;}
           else if(kodenode1B.equals("Jl. Blora2")){n2=D1;}
           else if(kodenode1B.equals("Jl. Blora3")){n2=E1;}
           else if(kodenode1B.equals("Jl. Blora4")){n2=F1;}
           else if(kodenode1B.equals("Pasucen")){n2=G1;}
           else if(kodenode1B.equals("Kutoharjo")){n2=H1;}
           else if(kodenode1B.equals("Kutoharjo2")){n2=I1;}
           else if(kodenode1B.equals("Kutoharjo3")){n2=J1;}
           else if(kodenode1B.equals("Kabongan")){n2=K1;}
           else if(kodenode1B.equals("Pasarbanggi")){n2=L1;}
           else if(kodenode1B.equals("Tritunggal")){n2=M1;}
           else if(kodenode1B.equals("Tritunggal2")){n2=N1;}
           else if(kodenode1B.equals("Punjulharjo")){n2=O1;}
           else if(kodenode1B.equals("Punjulharjo2")){n2=P1;}
           else if(kodenode1B.equals("Karangpelem")){n2=Q1;}
           else if(kodenode1B.equals("Karangpelem2")){n2=R1;}
           else if(kodenode1B.equals("Gedongmulyo")){n2=S1;}
           else if(kodenode1B.equals("Karangturi")){n2=T1;}
           else if(kodenode1B.equals("Karangturi2")){n2=U1;}
           else if(kodenode1B.equals("Karangturi3")){n2=V1;}
           else if(kodenode1B.equals("Jl. Provinsi")){n2=W1;}
           else if(kodenode1B.equals("Jl. Provinsi2")){n2=X1;}
           else if(kodenode1B.equals("Jl. Japerejo")){n2=Y1;}
           else if(kodenode1B.equals("Jl. Gunem")){n2=Z1;}
           else if(kodenode1B.equals("Jl. Pamotan")){n2=A2;}
           else if(kodenode1B.equals("Sale")){n2=B2;}
           else if(kodenode1B.equals("Sale2")){n2=C2;}
           else if(kodenode1B.equals("Jl. Kragan")){n2=D2;}
           else if(kodenode1B.equals("Bonang")){n2=E2;}
           else if(kodenode1B.equals("Jatisari")){n2=F2;}
           else if(kodenode1B.equals("Jl. Baidhowi")){n2=G2;}
           else if(kodenode1B.equals("Jl. Baidhowi2")){n2=H2;}
           else if(kodenode1B.equals("Kajar")){n2=I2;}
           else if(kodenode1B.equals("Selopuro")){n2=J2;}
           else if(kodenode1B.equals("Vihara")){n2=K2;}
       
         
           //=================================================
        AStarSearchApp astar = new AStarSearchApp();
        //String gab=astar.Astarsearch(n1, n2);//astar.Astarsearch(A, L);
        String gab=astar.Astarsearch(A, L);//astar.Astarsearch(A, L);
        double total=astar.getCosttotal();


String[]ar=gab.split("#");
int p=ar.length;
String mrute="https://www.google.co.id/maps/dir/"+myLati+","+myLongi;
for(int i=0;i<p;i++){
    String kota=ar[i];
    for(int ii=0;ii<jd;ii++){
            if(kota.equalsIgnoreCase(arNama[ii])){
                mrute+="/"+String.valueOf(arLati[ii])+","+String.valueOf(arLongi[ii]);
            }
        }
}//i


gab=myPosisi+" -> "+ gab.replaceAll("#", " -> ")+myPosisi2;
cetak("MRUTE:"+gab);
cetak("MRUTE:"+mrute);
  cetak("MRUTE:"+String.valueOf(total)+" KM");


  txt1.setText(gab);
  txt2.setText(String.valueOf(total)+" KM");
  txt3.setText(mrute);




 }
   

 void cetak(String info){
Log.d("Info",info);
 }
void init(){
 
    jd=70;
    arKode = new String[jd];
    arNama = new String[jd];
 
    arLati = new double[jd];
    arLongi = new double[jd];
    arJarak = new double[jd];

arKode[1]="A";
arNama[1]="Wates"; //Pantai Wates
arLati[1]=-6.690439;
arLongi[1]=111.282741;

arKode[2]="B";
arNama[2]="Jl. Nasional 1";
arLati[2]=-6.694965;
arLongi[2]=111.282782;

arKode[3]="C";
arNama[3]="Jl. Nasional 2";//Hotel pantura&hotel kartini
arLati[3]=-6.699873;
arLongi[3]=111.312078;

arKode[4]="D";
arNama[4]="Jl. Nasional 3";//hotel spbu gajah mada
arLati[4]=-6.700048;
arLongi[4]=111.313894;

arKode[5]="E";
arNama[5]="Magersari";//RM Bu Joyo
arLati[5]=-6.700715;
arLongi[5]=111.324093;

arKode[6]="F";
arNama[6]="Jl. Diponegoro";
arLati[6]=-6.704120;
arLongi[6]=111.332566;

arKode[7]="G";
arNama[7]="Jl. Dr. Wahidin";
arLati[7]=-6.705046;
arLongi[7]=111.335064;

arKode[8]="H";
arNama[8]="Jl. KS Tubun";//Sate serepeh, Sayur Mangut
arLati[8]=-6.706513;
arLongi[8]=111.334286;

arKode[9]="I";
arNama[9]="Jl. KS Tubun2";
arLati[9]=-6.708302;
arLongi[9]=111.333495;

arKode[10]="J";
arNama[10]="Jl. KS Tubun3";//De Kampoeng
arLati[10]=-6.714509;
arLongi[10]=111.333520;

arKode[11]="K";
arNama[11]="Jl. Diponegoro2";//dewa Burung
arLati[11]=-6.704043;
arLongi[11]=111.337096;

arKode[12]="L";
arNama[12]="JL. Airlangga";//Hotel antika & RM Hien
arLati[12]=-6.706450;
arLongi[12]=111.336425;

arKode[13]="M";
arNama[13]="Jl. Yos Sudarso";
arLati[13]=-708508;
arLongi[13]=111.338253;

arKode[14]="N";
arNama[14]="Jl. Yos Sudarso2";
arLati[14]=-6.709575;
arLongi[14]=111.337968;

arKode[15]="O";
arNama[15]="Jl. MH Tamrin";
arLati[15]=-6.707244;
arLongi[15]=111.338596;

arKode[16]="P";
arNama[16]="Jl. Dr. Wahidin2";
arLati[16]=-6.705447;
arLongi[16]=111.336721;

arKode[17]="Q";
arNama[17]="Jl. Diponegoro3";
arLati[17]=-6.704114;
arLongi[17]=111.339238;

arKode[18]="R";
arNama[18]="Jl. Diponegoro4";//Pantai Dampo awang, Hotel Kencana
arLati[18]=-6.704311;
arLongi[18]=111.341970;

arKode[19]="S";
arNama[19]="Jl. RA Kartini";//Hotel Sumber agung
arLati[19]=-6.706690;
arLongi[19]=111.341678;

arKode[20]="T";
arNama[20]="Jl. RA Kartini2";
arLati[20]=-6.709280;
arLongi[20]=111.341222;

arKode[21]="U";
arNama[21]="Jl. Pemuda";//Dokar, Angkutan Umum
arLati[21]=-6.710267;
arLongi[21]=111.341498;

arKode[22]="V";
arNama[22]="Jl. Slamet Riyadi";
arLati[22]=-6.712732;
arLongi[22]=111.340963;

arKode[23]="W";
arNama[23]="Jl. Slamet Riyadi2";
arLati[23]=-6.731945;
arLongi[23]=111.344583;

arKode[24]="X";
arNama[24]="Jl. Lingkar";//Kelo Mrico, Hotel Puri Indah
arLati[24]=-6.732869;
arLongi[24]=111.353741;

arKode[25]="Y";
arNama[25]="Jl. Landoh";
arLati[25]=-6.772813;
arLongi[25]=111.366723;

arKode[26]="Z";
arNama[26]="Jl. Landoh2";
arLati[26]=-6.754856;
arLongi[26]=111.332349;

arKode[27]="A1";
arNama[27]="Seren";//Karangsari Park
arLati[27]=-6.781280;
arLongi[27]=111.329724;

arKode[28]="B1";
arNama[28]="Jl. Blora";
arLati[28]=-6.859778;
arLongi[28]=111.407221;

arKode[29]="C1";
arNama[29]="Panohan";//Waduk Panohan
arLati[29]=-6.820164;
arLongi[29]=111.433418;

arKode[30]="D1";
arNama[30]="Jl. Blora2";
arLati[30]=-6.859778;
arLongi[30]=111.407221;

arKode[31]="E1";
arNama[31]="Jl. Blora3";
arLati[31]=-6.862718;
arLongi[31]=111.429381;

arKode[32]="F1";
arNama[32]="Jl. Blora4";
arLati[32]=-6.869155;
arLongi[32]=111.433124;

arKode[33]="G1";
arNama[33]="Pasucen";//Air Terjun Pasucen
arLati[33]=-6.854362;
arLongi[33]=111.482053;

arKode[34]="H1";
arNama[34]="Kutoharjo";//Terminal & Fave Hotel
arLati[34]=-6.704975;
arLongi[34]=111.348207;

arKode[35]="I1";
arNama[35]="Kutoharjo2";
arLati[35]=-6.705105;
arLongi[35]=111.350210;

arKode[36]="J1";
arNama[36]="Kutoharjo3";//Hotel Rantina&Museum RA Kartini
arLati[36]=-6.705997;
arLongi[36]=111.350212;

arKode[37]="K1";
arNama[37]="Kabongan";
arLati[37]=-6.705891;
arLongi[37]=111.359987;

arKode[39]="L1";
arNama[39]="Pasarbanggi";//Hutan Mangrove
arLati[39]=-6.703869;
arLongi[39]=111.387430;

arKode[40]="M1";
arNama[40]="Tritunggal";//Pantai Nyamplung
arLati[40]=-6.699548;
arLongi[40]=111.399279;

arKode[41]="N1";
arNama[41]="Tritunggal2";
arLati[41]=-6.692636;
arLongi[41]=111.398583;

arKode[42]="O1";
arNama[42]="Punjulharjo";//Karangjahe
arLati[42]=-6.692892;
arLongi[42]=111.415755;

arKode[43]="P1";
arNama[43]="Punjulharjo2";
arLati[43]=-6.687502;
arLongi[43]=111.412037;

arKode[44]="Q1";
arNama[44]="Karangpelem";//Caruban
arLati[44]=-6.691681;
arLongi[44]=111.433867;

arKode[45]="R1";
arNama[45]="Karangpelem2";
arLati[45]=-6.677958;
arLongi[45]=111.429700;

arKode[46]="S1";
arNama[46]="Gedongmulyo";//Hotel Surya
arLati[46]=-6.693650;
arLongi[46]=111.437478;

arKode[47]="T1";
arNama[47]="Karangturi";
arLati[47]=-6.696878;
arLongi[47]=111.443270;

arKode[48]="U1";
arNama[48]="Karangturi2";//Klenteng Cu An kiong
arLati[48]=-6.694234;
arLongi[48]=111.443622;

arKode[49]="V1";
arNama[49]="Karangturi3";
arLati[49]=-6.697798;
arLongi[49]=111.447777;

arKode[50]="W1";
arNama[50]="Jl. Provinsi";
arLati[50]=-6.701752;
arLongi[50]=111.446991;

arKode[51]="X1";
arNama[51]="Jl. Provinsi2";//Po. Madu Kismo & RM Pondok Hijau
arLati[51]=-6.708644;
arLongi[51]=111.448825;

arKode[52]="Y1";
arNama[52]="Jl. Japerejo";//Kuliner Tuyuhan
arLati[52]=-6.723273;
arLongi[52]=111.448201;

arKode[53]="Z1";
arNama[53]="Jl. Gunem";
arLati[53]=-6.765561;
arLongi[53]=111.489853;

arKode[54]="A2";
arNama[54]="Jl. Pamotan";
arLati[54]=-6.779295;
arLongi[54]=111.555938;

arKode[55]="B2";
arNama[55]="Sale";
arLati[55]=-6.850729;
arLongi[55]=111.580354;

arKode[56]="C2";
arNama[56]="Sale2";//wana wisata sumber semen
arLati[56]=-6.877441;
arLongi[56]=111.553843;

arKode[57]="D2";
arNama[57]="Jl. Kragan";
arLati[57]=-6.697848;
arLongi[57]=111.450681;

arKode[58]="E2";
arNama[58]="Bonang";//Petilasan sunan bonang
arLati[58]=-6.660531;
arLongi[58]=111.467079;

arKode[59]="F2";
arNama[59]="Jatisari";//pantai jatisari
arLati[59]=-6.633136;
arLongi[59]=111.514556;

arKode[60]="G2";
arNama[60]="Jl. Baidhowi";//makam RA Kartini
arLati[60]=-6.698207;
arLongi[60]=111.455833;

arKode[61]="H2";
arNama[61]="Jl. Baidhowi2";
arLati[61]=-6.694235;
arLongi[61]=111.465436;

arKode[62]="I2";
arNama[62]="Kajar";//Gunung Kajar
arLati[62]=-6.688457;
arLongi[62]=111.479835;

arKode[63]="J2";
arNama[63]="Selopuro";//Watu congol
arLati[63]=-6.697746;
arLongi[63]=111.471489;

arKode[64]="K2";
arNama[64]="Vihara";//vihara ratanavana
arLati[64]=-6.705893;
arLongi[64]=111.472934;

     
     

     
}


 public static double getJarak(double lat1, double lng1, double lat2, double lng2) {
           double earthRadius = 3958.75;
           double dLat = Math.toRadians(lat2-lat1);
           double dLng = Math.toRadians(lng2-lng1);
           double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
                      Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
                      Math.sin(dLng/2) * Math.sin(dLng/2);
           double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
           double dist = earthRadius * c;

           int meterConversion = 1609;
           double myjr=dist * meterConversion;
           return Math.floor(myjr/1000);

}
}
+++++++++++

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     android:background="#fff"  >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="10dip" >

        <ImageView
            android:id="@+id/myGambar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:src="@drawable/icon2" />
      <TextView
          android:id="@+id/djarak"
          android:layout_width="50dp"
          android:layout_height="wrap_content"
          android:layout_gravity="right"
          android:background="#F58634"
          android:textColor="#000000" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Nama"
            android:textColor="#0e3168" />

        <TextView
            android:id="@+id/dnama_wisata"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
        
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Kategori"
            android:textColor="#0e3168" />
        
        <TextView
            android:id="@+id/dkategori"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
        
   <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Alamat"
            android:textColor="#0e3168" />
        
        <TextView
            android:id="@+id/dalamat"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
        
        
         <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Deskripsi"
            android:textColor="#0e3168" />
        
        <TextView
            android:id="@+id/ddeskripsi"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
       

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Posisi Anda"
            android:textColor="#0e3168" />
        
         <TextView
            android:id="@+id/dposisi"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />

      
        <Button
            android:id="@+id/btnarah"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Lihat rute"
            android:textColor="#000000"
            android:textStyle="bold" />
   
        
                <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Lintasan :"
            android:textColor="#0e3168" />
        
         <TextView
            android:id="@+id/dlintasan"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
         
         
                <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Jarak Tempuh"
            android:textColor="#0e3168" />
        
         <TextView
            android:id="@+id/djaraknya"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
        
            <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Keterangan"
            android:textColor="#0e3168" />
        
         <TextView
            android:id="@+id/dketerangan"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000" />
    </LinearLayout>
</ScrollView>