package com.example.mountaintravel.kind;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class FindDbData {
	private Context context;
	private SQLdm s;
	public SQLiteDatabase db ;
	public FindDbData(Context context) {
		super();
		this.context = context;
		s = new SQLdm();
		db =s.openDatabase(context);
	}
/**
 * 得到所有规划线路起点名称及线路编号
 * @param a
 * @return
 */
	public List<Map<String,String>> findRoad(String a){
		List <Map<String,String>>list =new ArrayList<Map<String,String>>();
	    Cursor cursor = db.rawQuery("select * from allRoad where RuKouId=?", new String[]{a});
	    while(cursor.moveToNext()){
	    	 Map <String,String>aa=new HashMap<String,String>();
	    	 String RuKouIdAllRoadIndex = cursor.getString(cursor.getColumnIndex("RuKouIdAllRoadIndex"));
	    	 String RuKouIdAllRoad = cursor.getString(cursor.getColumnIndex("RuKouIdAllRoad"));
	    	 String RuKou = cursor.getString(cursor.getColumnIndex("RuKou"));
	    	 String RuKouId = cursor.getString(cursor.getColumnIndex("RuKouId"));
	    	 aa.put("RuKouIdAllRoadIndex", RuKouIdAllRoadIndex);
	    	 aa.put("RuKouIdAllRoad", RuKouIdAllRoad);
	    	 aa.put("RuKou", RuKou);
	    	 aa.put("RuKouId", RuKouId);
	    	list.add(aa);
	     }
		return list;
	}
/**
 * 查询线路对应的路段
 * @param a
 * @return
 */
	public ArrayList<String> duan(String a){
		ArrayList<String>list =new ArrayList<String>();
	    Cursor cursor = db.rawQuery("select * from road where count=?", new String[]{a});
	    while(cursor.moveToNext()){
	    	 String indexs = cursor.getString(cursor.getColumnIndex("indexs"));
	    //	 System.out.println("indexs=: "+indexs);
	    	list.add(indexs);
	     }
		return list;
	}
}
