레이블이 gps인 게시물을 표시합니다. 모든 게시물 표시
레이블이 gps인 게시물을 표시합니다. 모든 게시물 표시

2015년 7월 12일 일요일

GPS 기반 앱 개발 시 위치 정보 사용을 위해 참고해야 할 내용들

위치정보 좀 사용해서 앱 좀 만들어 보려 했는데
정말 쉽지 않구나..

[앱 개발자를 위한 개인정보 보호 안내서]
: http://www.wku.ac.kr/image/wku/01/privacy/privacy_learn_3.pdf


[연구보고서, 위치정보 관련 법,제도 개선방안]

: https://www.kisa.or.kr/public/library/report_View.jsp?regno=011549&pageIndex=1&searchType=&searchKeyword=%EC%9C%84%EC%B9%98


위치정보의 개념 (위 링크 발췌)

  • 개인위치정보는 개인정보이다.
  • 개인위치정보는 특정 개인의 위치정보이다.
  • 개인위치정보는 위치정보이다.
  • 위치정보는 이동성이 있는 물건 또는 개인에 관한 정보이다.
  • 위치정보는 시간에 관한 정보이다.
    • 특정한 시간에 존재하거나(현재) 존재하였던(과거) 장소에 관한 정보
    • 위도, 경도, 고도 뿐 아니라 지리적 위치가 수집된 시점을 구성요소로 함.
  • 6.위치정보는 장소에 관한 정보이다.a.좌표 뿐만아니라 '영통구청'과 같이 장소로 표현될 수도 있다.
  • 7. 위치정보는 수집된 정보이다.
    • '수집' 이란 최초로 위치정보를 제작하여 획득하거나 이용자로부터 위치정보를 제공받는 것을 말한다.
    • '이용'은 위치 정보를 기반으로 CRM 또는 마케팅 분석 등의 목적으로 활용하는 것을 말하며
    • '제공'은 위치정보를 제3자에게 공급하거나 위치정보에 부가서비스를 덧붙여 본인 또는 제3자에게 공급하는 것을 말한다.


[생활 법령 > 위치정보사업자 등의 개인위치정보 보호의무]

http://oneclick.law.go.kr/CSP/CnpClsMain.laf?popMenu=ov&csmSeq=615&ccfNo=4&cciNo=2&cnpClsNo=3


[위치정보사업 인허가 - 방통위]

: http://www.kcc.go.kr/user.do?page=A08010500&dc=K08010500


  • 위치정보사업과 위치기반서비스사업 구분
  • 위치정보사업
    • 위치 측위 기술을 활용하여 위치정보를 수집하여 이를 위치기반서비스사업자에게 제공하는 사업으로 이동통신사 등이 해당
    • 위치정보의 보호 및 이용 등에 관한 법률 제2조제6호
  • 위치기반서비스사업
    • 위치정보사업자로부터 받은 위치정보를 이용하여 친구찾기, 물류, 차량관제 등의 서비스를 제공하는 사업으로 스마트폰 앱 개발·운영사 등이 해당
    • 위치정보의 보호 및 이용 등에 관한 법률 제2조제7호



[위치정보사업 허가 신고 상담 - LBS 비지니스센터]

: http://www.lbsc.kr/jsp/content/report.jsp

표준 약관 : http://www.lbsc.kr/jsp/agreement/agreement.jsp
표준 관리 지침 : http://www.lbsc.kr/jsp/agreement/management.jsp

위치기반서비스사업 신고 서류 제출

  • 1. 위치기반서비스사업 신고 서식 1부 <첨부2 참조>
  • 2. 사업계획서 1부(Ⅰ. 사업자 현황, Ⅱ.서비스 내용, Ⅲ.위치정보보호법 시행령 제20조의 위치정보 보호조치에 대한 내용을 중점적으로 기입)
  • 3. 사업용 주요 설비의 내역 및 설치장소를 확인할 수 있는 서류 (설치장소 : IDC와 계약 서류, 자사에 서버 등을 설치한 경우 설치된 장비의 사진 등)
  • 4. 위치정보의 보호조치를 증명하는 서류 ==> S/W구입서류, IDC와 방화벽, 백신 등 계약 서류 내역서 등
  • 5. 법인등기부등본 또는 사업자등록증 1부
  • 6. 이용약관 1부(사업신고와 동시 신고시)
위치정보보호법 시행령 제20조 관련 확인 필요 사항들
  • 제20조(위치정보의 관리적,기술적 보호조치)
  • ①법 제16조제1항에 따른 관리적 조치에는 다음 각 호의 내용이 포함되어야 한다.
    • 1.위치정보관리책임자의 지정
    • 2.위치정보의 수집, 이용, 제공, 파기 등 각 단계별 접근 권한자 지정 및 권한의 제한
    • 3.위치정보 취급자의 의무와 책임을 규정한 취급, 관리 절차 및 지침 마련
  • ②법 제16조제1항에 따른 기술적 조치에는 다음 각 호의 내용이 포함되어야 한다.
    • 1.위치정보 및 위치정보시스템의 접근권한을 확인할 수 있는 식별 및 인증 실시 
      • ==> 서버 로그인 기능 화면캡쳐 등
    • 2.위치정보시스템에의 권한없는 접근을 차단하기 위한 암호화,방화벽 설치 등의 조치 
      • ==> SSL인증서, DB암호화 화면캡쳐, 방화벽 등
    • 3.위치정보시스템에 대한 접근사실의 전자적 자동 기록,보존장치의 운영 
      • ==> DBMS를 이용하고 있는 로그기록 화면 캡쳐
    • 4.위치정보시스템의 침해사고 방지를 위한 보안프로그램 설치 및 운영 
      • ==> 백신을 사용하고 있는 화면 캡쳐

2015년 6월 24일 수요일

Android Webview, Gear 상에서의 GPS 개발 관련 정리

[Geolocation API 사용을 위한 Android Webview 설정]


Android Webview 내에서 Geolocation API를 사용하려면 아래와 같은 설정이 필요하다.

참고
http://stackoverflow.com/questions/5329662/android-webview-geolocation


1. Android app에서 location 관련 permission 명시

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


2. Geolocation API 사용을 위한 Webview 설정

: JavaScript enable, Geolocation enable, Geolocation caching을 위한 DB path 설정
http://developer.android.com/reference/android/webkit/WebSettings.html

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setGeolocationEnabled(true);
webView.getSettings().setGeolocationDatabasePath(Context.getFilesDir().getPath());


아래 HTML5 관련 설정들은 실제 Geolocation API에 영향을 주는지 확인은 안했지만
사용하는 webview에서 사용하고 있었던 것이라 혹시나 안된다면 아래 것도 추가를..

webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);


3. 위치 정보 접근 허용을 위한 알림 및 허용 처리

: 위치정보 접근 허용을 위한 WebChromeClient.onGeolocationPermissionsShowPrompt() 구현
http://developer.android.com/reference/android/webkit/WebChromeClient.html#onGeolocationPermissionsShowPrompt(java.lang.String, android.webkit.GeolocationPermissions.Callback)

아래 예제에서는 그냥 사용자에게 prompt를 보여주지 않고 자동으로 위치정보를 접근하게 한예제이니 사용자에게 알릴 필요가 있다면 여기서 알려야함.

webView.setWebChromeClient(new WebChromeClient() {
 public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
    callback.invoke(origin, true, false);
 }
});


위 방법들을 사용하면 Android webview 내에서 Geolocation API를 사용할 수 있다.


[Geolocation APIs - getCurrentPosition, watchPosition]

: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation

getCurrentPosition, watchPosition에 대한 설명이다.

둘다 위치 정보를 얻기 위해 hardware를 사용하므로 비동기적(asynchronous)으로 callback을 통해 결과를 전달하는 것은 동일하지만 getCurrentPosition은 일회적으로 현재 위치를 제공하는 것이고 watchPosition은 위치의 변화가 있을 경우 변경된 좌표를 제공한다는 것이 다른 점이다.
또한 아래 설명의 굵은 글씨들을 참고하면 watchPosition이 이전 좌표를 기반하여 별도의 기술을 사용하여 좀 더 정확한 좌표를 제공하려 하는 것 같다. 아마도 Android webview에서 database path를 설정하는 것도 이런 연유에서일 것으로 추측..
하지만 watchPosition은 위치 변화 뿐만아니라 좀 더 정확한 위치가 설정 되어도 알려줘서 모르겠지만 수신 받은 위치를 좀 걸러내야 할 필요성이 있는 것 같다. 특히 GPS + 네트워크 둘다 사용할 경우 종종 부정확한 위치가 전달 된다.

(발췌, MDN Using Geolocation )

Getting the current position

To obtain the user's current location, you can call the getCurrentPosition() method. This initiates an asynchronous request to detect the user's position, and queries the positioning hardware to get up-to-date information. When the position is determined, the defined callback function is executed. You can optionally provide a second callback function to be executed if an error occurs. A third, optional, parameter is an options object where you can set the maximum age of the position returned, the time to wait for a request, and if you want high accuracy for the position.


Watching the current position

If the position data changes (either by device movement or if more accurate geo information arrives), you can set up a callback function that is called with that updated position information. This is done using the watchPosition() function, which has the same input parameters as getCurrentPosition(). The callback function is called multiple times, allowing the browser to either update your location as you move, or provide a more accurate location as different techniques are used to geolocate you. The error callback function, which is optional just as it is for getCurrentPosition(), can be called repeatedly.


이와 비슷한 내용의 Answer와 예제 샘플은 다음과 같다.

watchPosition API 사용 샘플
watchPosition을 계속 실행하면 아무래도 GPS 관련 hardware를 계속 사용하게 되므로 일정시간 watchPosition을 사용하되 몇초 단위로 끊어서 사용하고 있음.
: http://stackoverflow.com/questions/8552186/how-to-get-html5-position-in-webview-updated-at-a-regular-interval-with-fine-ac


Platform, OS 별 Geolocation 사용 예제
: http://docs.phonegap.com/en/edge/cordova_geolocation_geolocation.md.html

HTML5 Geolocation API 표준 문서
: http://www.w3.org/TR/geolocation-API/#geolocation_interface

이것도 참고하시라...
: http://www.andygup.net/how-accurate-is-html5-geolocation-really-part-2-mobile-web/


[Gear에서의 GPS 사용]



- GPS feature를 제공하는 제품들은 Gear2 neo, GearS가 있는 것으로 알고 있지만
   Gear 2에서는 Geolocation API를 사용할 수 없다. (Tizen 2.3 기준)

 . 그래서 GPS 센서가 없는 모델들은 SAP(Samsung Accessory Protocol)을 사용해서 mobile의 GPS 좌표를 사용하더라..
 (http://www.codeproject.com/Articles/830305/Speedometer-for-Galaxy-Gear-Tizen-Based)


- GearS는 GPS 센서가 있지만 GPS 센서, 네트워크 위치를 사용해서 위치를 파악한다.
 . GPS 센서만 사용하고자 한다면 설정 > 연결 > GPS만 사용 에 체크

 . FakeGPS를 사용하여 GearS GPS app디버깅 방법
  : SIM 카드가 없는 상태에서 설정 > 연결 > GPS만 사용 체크 해제
    GearS와 연결된 mobile의 GPS 끄고 fake GPS로 GPS 좌표 설정
    다만 Gear GPS센서가 동작이 안되는 상태에서 가능하므로 실내에서 가능하다..


[T map OpenAPIs]



https://developers.skplanetx.com/apidoc/kor/tmap/

타 통신사에서는 그림의 떡같은 T map인 관계로 별로 좋아하지 않았지만
이번에 Geolocation 관련 API을 찾다 보니 감사하게도 Open API들을 제공하고 있었다.
제공되는 API들도 꽤나 다양해서 GPS app 개발 시 상당히 유용할 것으로 보인다.

REST API를 사용해서 몇개를 사용해 봤는데 아래 사항은 지켜야 정상 응답을 하더라.

- url에서 callback, gizAppId는 값이 없어도 파라미터로 존재해야 한다.

예를 들어 경로 안내 API를 사용하려면
: https://developers.skplanetx.com/apidoc/kor/t-map/course-guide/geojson/

https://apis.skplanetx.com/tmap/routes?version=1&bizAppId={bizAppId}&callback={callback}

위와 같은 URL을 사용해야 하는데 bizAppId와 callback은 optional 항목이다.
하지만 bizAppid와 callback을 생략하고 ?version=1 만 적으면 정상 응답이 오지 않더라.
?bizAppId=&callback=&version=1 이렇게 적어 호출하니 정상응답.


- content type 설정

REST API 호출(HTTP request시) content type을 "Content-Type: application/x-www-form-urlencoded"로 설정해야 해서 jquery의 $.ajax()를 사용 시 header param으로 명시해야 한다.

2015년 6월 22일 월요일

[Links] GPS 관련 정보들 모음. 위도, 경도 등등

GPS 관련 앱 개발로 관련 내용 좀 찾아봄.

[Geographic coordinate system]

: http://en.wikipedia.org/wiki/Geographic_coordinate_system

  . Latitude(위도), Longitude(경도)
  . 완전한 구형이 아닌 지구의 형태로 인해 여러가지 좌표계에 대한 설명을 확인 필요.



중고등학교에서 배운 내용이지만
위도는 적도(0)를 기준으로 위아래를 각 90도로 나눈 것이고 대체적으로 간격이 비슷하지만 경도는 Greenwich를 기준으로 지구를 각 360도 방향으로 세로로 나눈것이라 위도에 따라서 간격이 다르다.
그래서 경위도 기준으로 거리를 거리를 계산할 경우 경도와 위도의 특징을 생각해서 계산해야 하므로 다소 수식을 써서 계산이 필요하다.


경위도 좌표 표시의 다양한 방법 by 이마운틴
: http://www.emountain.co.kr/atl/view.asp?a_id=4054


경도와 위도로 거리와 위치를 알아보는 방법
상세한 수치는 좀 다르지만 대략적으로 쉽게 설명한 글
: http://m.blog.daum.net/esikhong/17163754


T map API 가이트 by SK 플래닛
https://developers.skplanetx.com/apidoc/kor/tmap/reference/

(T map API 가이드에서 발췌)
지도상에 위치를 표현 하기 위해 좌표를 사용 합니다.
우리가 많이 들어본 “동경132 북위 37”은 경위도 좌표계이며 용도에 따라 수 많은 좌표계가 존재 합니다.
T map Open API에서 제공하는 주요 좌표계는 다음과 같습니다.
① EPSG:3857 : Google Mercator 좌표계. EPSG:900913으로 사용되기도 합니다. 900913은 알파벳 GOOGLE과 비슷한 숫자의 조합으로 특별한 뜻을 가지고 있지는 않습니다.
② EPSG:4326 : WGS84 좌표계. 구글 Earth가 사용하고 있는 좌표입니다.
③ KATECH : 국내에서 자동차 내비게이션 시스템 용으로 개발된 좌표계로 KATEC 또는 KATECH 으로 표기하고 있습니다. 과거 국내 포탈 지도 서비스에서 대부분 이 좌표계를 사용했으며 현재의 지도 서비스는 EPSG:3857또는 EPSG:4326을 기본으로 하는 추세 입니다.
서울 광장의 위치를 각각의 좌표계로 나타내면 다음과 같습니다.
- EPSG3857 : Lat: "4518258.6620310" , Lon: "14135199.7637174"
- WGS84 : Lat: "37.5657321", Lon: "126.9786599"
- KATECH : Lat: "551988.4373341", Lon: "309969.0505621"


[GPS]


GPS 개요 by 국토지리정보원
http://sd.ngii.go.kr/sub/gps/gps_outl.jsp?serv_cd=5&mmenu=1&smenu=1

Global Positioning System

간단히 보면 24개의 위성들을 통해서 측위와 시간 정보를 얻기 위한 시스템이며 군사목적으로 개발되었으나 대한항공 007편 격추사건을 통해서 민간에 개방되었음. GPS는 미국에서 운용되는 시스템이고 그외 러시아, 유럽에서 운용되는 시스템이 있다고 함.


대한항공 007편 격추 사건 (보면 볼수록 안타깝다.)
https://ko.wikipedia.org/wiki/%EB%8C%80%ED%95%9C%ED%95%AD%EA%B3%B5_007%ED%8E%B8_%EA%B2%A9%EC%B6%94_%EC%82%AC%EA%B1%B4
https://www.youtube.com/watch?v=10O3fKZBxz0

After Korean Air Lines Flight 007, a Boeing 747 carrying 269 people, was shot down in 1983 after straying into the USSR's prohibited airspace,[22] in the vicinity of Sakhalin and Moneron Islands, President Ronald Reagan issued a directive making GPS freely available for civilian use, once it was sufficiently developed, as a common good.[23]

그외 러시아, 유럽 시스템 소개
This article is about the American system. For the Russian equivalent, see GLONASS. For the European equivalent, see GALILEO. For other similar systems, see GNSS.


[좌표 기반 계산 방법들]


좌표 주변 반경을 계산 하는 방법에 대한 설명
보통 GPS 좌표를 기반해서 두 위치간 거리 측정, 좌표 주위 m 반경 내 있는 좌표들 확인등을 많이 하게 되는데 이를 위한 계산 방법 및 소스코드를 제공한다.
특히나 경도의 특성에 따라 제대로된 계산식을 구성하는 설명이 아주 잘 되어 있어 필독!
: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates

3.3 Computing the Minimum and Maximum Longitude – the Correct Way

Figure 1: Tangent meridians to the query circle [1]
Moving along a circle of latitude in order to find the minimum and maximum longitude does not work at all as you can see in figure 1: The points on the query circle having the minimum/maximum longitude, T1 and T2, are not on the same circle of latitude as M but closer to the pole. The formulae for the coordinates of these points can be found in a good math handbook like [1]. They are:
latT = arcsin(sin(lat)/cos(r)) = 1.4942(5)
lonmin = lonT1 = lon - Δlon = -1.8184(6)
lonmax = lonT2 = lon + Δlon = 0.4221(7)
where
Δlon = arccos( ( cos(r) - sin(latT) · sin(lat) ) / ( cos(latT) · cos(lat) ) )
      = arcsin(sin(r)/cos(lat)) = 1.1202(8)
Note that special care must be taken if the 180th meridian is within the query circle. See section 3.4 for details.


좌표 기반 계산 방법들을 설명하고 구현한 JavaScript 기반 코드
용도에 따라 참고해서 사용하면 될 듯 함.
: http://www.movable-type.co.uk/scripts/latlong.html

GPS좌표 <-> 도분초 변환방법
: http://en.wikipedia.org/wiki/Geographic_coordinate_conversion

(Wikipedia 발췌)
Informally, specifying a geographic location usually means giving the location's latitude and longitude. The numerical values for latitude and longitude can occur in a number of different formats:[2]
  • degrees minutes seconds: 40° 26′ 46″ N 79° 58′ 56″ W
  • degrees decimal minutes: 40° 26.767′ N 79° 58.933′ W
  • decimal degrees: 40.446° N 79.982° W
There are 60 minutes in a degree and 60 seconds in a minute. Then to convert from a degrees minutes seconds format to a decimal degrees format, one may use the formula
 \rm{decimal\  degrees} = \rm{degrees} + \rm{minutes}/60 + \rm{seconds}/3600.
To convert back from decimal degree format to degrees minutes seconds format,
 \begin{align}
  \rm{degrees} & = \lfloor\rm{decimal\  degrees}\rfloor \\
  \rm{minutes} & = \lfloor 60*(\rm{decimal\  degrees} - \rm{degrees})\rfloor  \\
  \rm{seconds} & = \lfloor 3600*(\rm{decimal\  degrees} - \rm{degrees} - \rm{minutes}/60)\rfloor \\
  \end{align}
where the notation \lfloor x \rfloor means take the integer part of x and is called a floor function.