Commit 1b8504da authored by jaehyu's avatar jaehyu

restructuring

parent 8d33d5d1
...@@ -31,12 +31,4 @@ public class Configure { ...@@ -31,12 +31,4 @@ public class Configure {
// TODO : 파일을 로딩해야 합니다. // TODO : 파일을 로딩해야 합니다.
// TODO : 로딩한 값을 변수에 설정해 주어야 합니다. // TODO : 로딩한 값을 변수에 설정해 주어야 합니다.
} }
public static final double CELL_SIZE_BLE = 300;
public static final double CELL_SIZE_MAG = 50;
public static final double LENGTH_PIXEL_X = 350; // 층의 X축방향 길이
public static final double WIDTH_PIXEL_Y = 200; // 폭
} }
...@@ -5,15 +5,18 @@ package com.skt.ehs.mbs.fpbuilder; ...@@ -5,15 +5,18 @@ package com.skt.ehs.mbs.fpbuilder;
*/ */
public class BLECell { public class BLECell {
int ble_cell_id; private int ble_cell_id;
double location_x; private double location_x;
double location_y; // 실거리 ?? private double location_y; // 실거리 ??
double rssi_min; private double rssi_min;
double rssi_max; private double rssi_max;
double rssi_avg; private double rssi_avg;
double rssi_std_dev; private double rssi_std_dev;
int rssi_dir; private int rssi_dir;
BLECell(int id) {
ble_cell_id = id;
}
double mag_angle; // 해당 cell의 각 수집방향에 대하여 수집된 지자기방향의 평균값으로 대표 double mag_angle; // 해당 cell의 각 수집방향에 대하여 수집된 지자기방향의 평균값으로 대표
public int getBle_cell_id() { public int getBle_cell_id() {
......
package com.skt.ehs.mbs.fpbuilder; package com.skt.ehs.mbs.fpbuilder;
import com.skt.ehs.mbs.conf.Configure;
import com.skt.ehs.mbs.db.maria.DBManager; import com.skt.ehs.mbs.db.maria.DBManager;
import com.skt.ehs.mbs.db.maria.MariaConnectionManager; import com.skt.ehs.mbs.db.maria.MariaConnectionManager;
import com.skt.ehs.mbs.db.maria.vo.RawDataTag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/*
이 class 는 Java 8 의 stream API 와 lambda expression 을 사용함으로,
intellj 컴파일에 문제가 있으면 ,
메뉴중, 'Project Structure' -> 'Project' -> 'project language level' 이
'8 - lambda' 로 세팅되어야 합니다.
by jaehyu 2016-11-28
*/
public class BLEFPBuilder { public class BLEFPBuilder {
private Floor mFloor; public static final int CELL_SIZE_BLE = 300;
public static final int LENGTH_X = 8000;
public static final int WIDTH_Y = 4000;
boolean build_FP_BLE_CELL() { Floor mFloor;
int mag_per_ble = (int)(Configure.CELL_SIZE_BLE / Configure.CELL_SIZE_MAG);
return false; public BLEFPBuilder(int M,int N) {
mFloor = new Floor(M,N);
} }
/* Todo
층(floor) 단면에 대하여 x축방향 길이 (Configure.LENGTH_X) 와
폭 (Configure.WIDTH_Y) 을 성분으로 하는 가상 Matrix를 구성한다.
*/
public void LoadCellLocation() {
int location_x = 0;
int location_y = 0;
for (int x = 1 ; x <= mFloor.getM(); x++) {
location_x = CELL_SIZE_BLE * x - CELL_SIZE_BLE / 2;
for (int y = 1; y <= mFloor.getN(); y++) {
location_y = CELL_SIZE_BLE * y - CELL_SIZE_BLE / 2;
// Todo calculate x,y
mFloor.setBLECellLocation(x-1,y-1,location_x,location_y);
}
}
mFloor.showCellLocation();
}
public void LoadCellID() {
for (int x = 1 ; x <= mFloor.getM(); x++) {
int id = 0;
int id_x = 1000 * x;
for (int y = 1; y <= mFloor.getN(); y++) {
id = id_x + y;
BLECell bleCell= new BLECell(id);
mFloor.setBLECell(x-1,y-1,bleCell);
}
}
mFloor.showCellID();
}
public boolean LoadDBConnectionPool() {
if (!MariaConnectionManager.getInstance().makeConnectionPool()) return false;
return true;
}
static boolean processor() { private static double readMapScale() {
System.out.println("Hello processor"); int iCampusID = 1; // Todo console 에서 받아옴
int iBuildingID = 1; // Todo console 에서 받아옴
int iFloorID = 1; // Todo console 에서 받아옴
double ret = 0;
// package-only-list from raw_data_tag
List<RawDataTag> rawdata = Collections.emptyList();
List<RawDataTag> packNameList = Collections.emptyList();
try { try {
rawdata = DBManager.getRawDataTag(DBManager.COMMAND_OPTION_GETRAWDATATAG,1,1,1); ret = DBManager.getMapScale (iCampusID,iBuildingID,iFloorID);
// packNameList = DBManager.getRawDataTag(DBManager.COMMAND_OPTION_GETPACKAGE,1,1,1);
} catch (Throwable throwable) { } catch (Throwable throwable) {
throwable.printStackTrace(); throwable.printStackTrace();
} }
System.out.println(rawdata.size()); return ret;
/* }
try {
// 스케일값을 DB에 넣기 위한 임시코드
DBManager.updateMapImage(DBManager.COMMAND_OPTION_UPDATESCALEPIXEL,10.00,2);
} catch (Throwable throwable) {
throwable.printStackTrace();
}*/
public boolean build() {
double scale_pixel = readMapScale();
System.out.println("scale_pixel : "+scale_pixel);
// Todo access DB & calculate factor & build fp.
return true; return true;
} }
public static void main(String[] args) { public static void main(String[] args) {
Initializer.compose(); BLEFPBuilder blefpBuilder = new BLEFPBuilder((LENGTH_X % CELL_SIZE_BLE == 0)? LENGTH_X/CELL_SIZE_BLE : LENGTH_X/CELL_SIZE_BLE + 1,(WIDTH_Y % CELL_SIZE_BLE == 0)? WIDTH_Y/CELL_SIZE_BLE : WIDTH_Y/CELL_SIZE_BLE + 1); // mFloor
blefpBuilder.LoadCellID();
//processor(); blefpBuilder.LoadCellLocation();
if (!blefpBuilder.LoadDBConnectionPool()) {
//exit
}
blefpBuilder.build();
} }
} }
...@@ -6,13 +6,50 @@ package com.skt.ehs.mbs.fpbuilder; ...@@ -6,13 +6,50 @@ package com.skt.ehs.mbs.fpbuilder;
* Matrix의 각 element는 값으로 BLECell 타입의 Object를 가지게 된다 * Matrix의 각 element는 값으로 BLECell 타입의 Object를 가지게 된다
*/ */
class Floor { class Floor {
private int M;
BLECell[][] fp; // FingerPrint private int N;
private BLECell[][] fp; // FingerPrint
public Floor(int M, int N) { public Floor(int M, int N) {
this.M = M;
this.N = N;
fp = new BLECell[M][N]; fp = new BLECell[M][N];
} }
public void showCellID() {
for(int j=0;j< N;j++) {
for(int i=0;i< M; i++) {
System.out.printf("%9d ", fp[i][j].getBle_cell_id());
}
System.out.println();
}
}
public void showCellLocation() {
for(int j=0;j< N;j++) {
for(int i=0;i< M; i++) {
System.out.printf("("+fp[i][j].getLocation_x()+","+fp[i][j].getLocation_y()+")");
}
System.out.println();
}
}
public int getM() {
return M;
}
public void setM(int m) {
M = m;
}
public int getN() {
return N;
}
public void setN(int n) {
N = n;
}
public BLECell getBLECell(int M, int N) { public BLECell getBLECell(int M, int N) {
return fp[M][N]; return fp[M][N];
} }
...@@ -20,6 +57,10 @@ class Floor { ...@@ -20,6 +57,10 @@ class Floor {
public void setBLECell(int M, int N, BLECell bleCell) { public void setBLECell(int M, int N, BLECell bleCell) {
fp[M][N] = bleCell; fp[M][N] = bleCell;
} }
public void setBLECellLocation(int M, int N, int x, int y) {
fp[M][N].setLocation_x(x);
fp[M][N].setLocation_y(y);
}
double map_scale_pixel; double map_scale_pixel;
......
package com.skt.ehs.mbs.fpbuilder;
import com.skt.ehs.mbs.conf.Configure;
import com.skt.ehs.mbs.db.maria.DBManager;
import com.skt.ehs.mbs.db.maria.MariaConnectionManager;
import com.skt.ehs.mbs.db.maria.dao.RawDataAPDAO;
import org.apache.ibatis.session.SqlSession;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by user on 2016-12-01.
*/
public class Initializer {
// Todo BLECell 을 최소한의 필수 정보로 구성하여
// Floor Matrix 를 만든다
private static boolean generateCellid() {
// compose ble-cell-matrix
int M = (int) (Configure.LENGTH_PIXEL_X / Configure.CELL_SIZE_BLE);
int N = (int) (Configure.WIDTH_PIXEL_Y / Configure.CELL_SIZE_BLE);
System.out.println( "X : "+M+" Y : "+N);
if (((int)Configure.LENGTH_PIXEL_X % (int)Configure.CELL_SIZE_BLE) != 0 ) M++;
if (((int)Configure.WIDTH_PIXEL_Y % (int)Configure.CELL_SIZE_BLE) != 0 ) N++;
System.out.println( "M : "+M+" N : "+N);
// gen cell_id
int[][] ble_cell_ids = new int[M][N];
for (int x = 1; x <= M; x++) {
int idx = 0;
int id = 0;
int id_x = 1000 * x; // id는 6자리, 이 중 앞 3자리는 x(index) 성분 , 뒤 세자리는 y(index) 성분
// index 란 , ble cell 격자에서 좌상 element 에서 1 로 시작해서 오른쪽방향 그리고
// 아래방향(폭, y 방향) 으로 1씩 증가하는 수를 말한다
for (int y = 1; y <= N; y++) {
id = id_x + y;
ble_cell_ids[x-1][y-1] = id;
}
}
// assign Floor
CellMatrix ble_cells = new CellMatrix(ble_cell_ids);
ble_cells.show();
return true;
}
private static double readMapScale() {
int iCampusID = 1; // Todo console 에서 받아옴
int iBuildingID = 1; // Todo console 에서 받아옴
int iFloorID = 1; // Todo console 에서 받아옴
double ret = 0;
try {
ret = DBManager.getMapScale (iCampusID,iBuildingID,iFloorID);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
return ret;
}
private static void initFloor() {
double scale = readMapScale();
System.out.printf("scale_pixel : %9.4f",scale);
//Floor floor = new Floor();
}
public static boolean compose() {
if (MariaConnectionManager.getInstance().makeConnectionPool() == false) {
return false;
}
initFloor();
//boolean t = generateCellid();
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment