【開源GPS追蹤】 之 服務器端opengts安裝


國內大多數GPS追蹤/定位 平台都是基於opengts 二次開發的,opengts 是一款開源的gps 跟蹤軟件。

下面摘自百度百科:

OpenGTS ™(“GPS跟蹤系統”)是第一個可用的開源項目,專門提供基於網絡的 GPS 跟蹤服務。 迄今為止,OpenGTS™已被下載並投入了使用於95個國家。車輛和跟蹤資產類型包括出租車,送貨面包車,卡車/拖車,農用設備,個人車輛,服務車輛,集裝箱,船舶,全地形車,專人跟蹤,手機等。 雖然OpenGTS ™設計以填補需求入門級船隊跟蹤系統為主,它也是非常高度可配置和可擴展性以及規模較大的框架。

====================================================================================================

安裝opengts:

需求:一台具有公網ip 的電腦,這里我使用的virtwire 的廉價VPS。 系統采用的是Ubuntu,嘗試在centos上安裝,在安裝jave jdk 的時候遇到點問題,由於對Centos 和Java 都不是很熟悉,就在網上查找,發現一篇在Ubuntu上安裝的教程,按部就班安裝,一切OK。

最小配置:硬盤 2GB ,內存64MB

下面是具體教程步驟:

 

install opengts in ubuntu system: 

# sudo apt-get update

Install required software packages:

$ sudo apt-get install apache2 php5 mysql-server libmysql-java wget curl unzip ant

Provide mysql password during installation.

Start Mysql and apache2 services:

$ sudo /etc/init.d/mysql start

 

 如果上面安裝遇到一些奇怪的問題,請安裝下面的工具

 

Had the same issue with mysql-server-5.6 and this solution hs helped me:

launchpad: Bug #392051: [Karmic] logger command not found

Basically, the program logger got messed up;

It can be recreated by reinstalling the package bsdutils:

apt-get --reinstall install bsdutils

or

aptitude reinstall bsdutils

$ sudo /etc/init.d/apache2 start

Install openjdk: 安裝jdk6 為好,后面對應7的需要修改成6

$ sudo apt-get install openjdk-6-jdk

openjdk-7-jdk

Download and install Apache Tomcat version 7-x-x.

$ wget -c http://apache.mirror.uber.com.au/tomcat/tomcat-7/v7.0.65/bin/apache-tomcat-7.0.65.zip

上面這個鏈接已經失效了,請到 http://download.csdn.net/detail/duanfei255/9572008

Extract tomcat package and copy everything to /usr/local/ directory.

$ sudo unzip apache-tomcat-7.0.65.zip

$ sudo cp -av apache-tomcat-7.0.65 /usr/local/

Define CATALINA_HOME environment and run the startup script.

$ export CATALINA_HOME=/usr/local/apache-tomcat-7.0.65/

 

echo "export CATALINA_HOME=/usr/local/apache-tomcat-7.0.65/" >> ~/.bashrc

$ cd /usr/local

$ sudo ln -s $CATALINA_HOME tomcat

$ cd /usr/local/apache-tomcat-7.0.65/bin

$ chmod a+x *.sh

$ ./startup.sh

$ sudo ln -s $CATALINA_HOME /usr/local/tomcat

Define JAVA_HOME environment:

$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

$ echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bashrc

$ sudo ln -s $JAVA_HOME /usr/local/java

Configure JAVA mail setup and Java Connector:

First Download and setup mysql Java connector, extract package and copy mysql java connector to $JAVA_HOME/jre/lib/ext folder

$ cd /tmp/ && wget http://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.37.tar.gz

上面這個鏈接也有問題,下載地址http://download.csdn.net/detail/duanfei255/9572009

$ tar -xvf mysql-connector-java-5.1.37.tar.gz

$ cd mysql-connector-java-5.1.37

$ sudo cp mysql-connector-java-5.1.37-bin.jar $JAVA_HOME/jre/lib/ext

 

Now download and configure Java mail setup and copy that downloaded .jar file to $JAVA_HOME/jre/lib/ext folder.

$ cd /tmp/ && wget https://maven.java.net/content/repositories/releases/com/sun/mail/javax.mail/1.5.4/javax.mail-1.5.4.jar

$sudo cp javax.mail-1.5.4.jar $JAVA_HOME/jre/lib/ext/

Rename javax.mail-1.5.4.jar to javax.mail.jar:

$ mv $JAVA_HOME/jre/lib/ext/javax.mail-1.5.4.jar $JAVA_HOME/jre/lib/ext/javax.mail.jar

Download OpenGTS:

$ cd /tmp && wget http://ncu.dl.sourceforge.net/project/opengts/server-base/2.6.0/OpenGTS_2.6.0.zip

Extract package to /usr/local folder:

$ sudo unzip OpenGTS_2.6.0.zip -d /usr/local/

Set up GTS_HOME environment:

$ export GTS_HOME=/usr/local/OpenGTS_2.6.0/

$ echo "export GTS_HOME=/usr/local/OpenGTS_2.6.0" >> ~/.bashrc

$ sudo ln -s $GTS_HOME /usr/local/gts

 

Change ownership for user currently logged in before running next command:

$ sudo chown -R unixmen:sudo /usr/local/OpenGTS_2.6.0/

Now change directory to $GTS_HOME and run following command:

&& ant all

If everything goes smooth, output will be something like below.

Define database user name and password (Note that we are still in $GTS_HOME).

$ bin/initdb.sh -rootUser=root -rootPass=password

Sample output:

Run ant track command which will create a file named track.war, we have to copy that file to $CATALINA_HOME/webapps folder.

$ ant track

Sample output:

$ cp $GTS_HOME/build/track.war /usr/local/apache-tomcat-7.0.65/webapps/ Before moving ahead stop and restart apache tomcat again $ $CATALINA_HOME/bin/startup.sh$ $CATALINA_HOME/bin/startup.sh

Open browser and type http://<ip_address>:8080/track/Track

Oops, we have not create a sysadmin account required to login the server, let us create it first.

$ cd $GTS_HOME/bin$ ./admin.sh Account -account=unixmen -pass=unixmen -create

Sample output

Now Provide these credentials and login

A welcome screen will appear:

Now installation and configuration part is over at this stage, configure your GPS tracking devices and you can use them with Open GTS.

 Conclusion

Track application configuration

  • Login to track application as sysadmin
  • Use System Admin – System Accounts to create new account ‘acct’ with a password of your choice
  • Logout and login as user ‘acct’
  • In Administration – Vehicle Admin add new device ‘dev’. Optionally edit it and set Unique ID to ‘dev’.
  • You should see your device location on the map in Mapping – Vehicle Map right after the first packet from your phone is sent in and accepted.

In the command line edit $GTS_HOME/webapp.conf. There is a section ‘GPS2OpenGTS configuration’ there. Set or uncomment these 2 lines:

#gprmc.parm.account=acct                                                                                                                                            
#gprmc.parm.device=dev

Rebuild and redeploy track and gprmc applications:

cd $GTS_HOME
ant track && ant track.deploy && ant gprmc && ant gprmc.deploy
or
ant track
ant gprmc
cp those two in ...(add later)

For debugging purposes you may also try calling the URL with a browser or curl like:

http://username.jvmhost.net:YOUR_TOMCAT_HTTP_PORT/gprmc/Data?acct=acct&dev=dev&gprmc=$GPRMC,172413,A,3848.8028,N,08957.3521,W,0,000.0,171111,,*16


 

 

As per my knowledge very fewer documentations related to OpenGTS installation are available, but official documentation will be sufficient to configure it. One problem which was faced by me during installation process is that OpenGTS show error when it was configured with latest version of Apache Tomcat.

It is recommended that you should use Apache tomcat version 7.0.x for that purpose. Although this practical guide was tested in Mint Linux 17 , but I believe that it will also work with Ubuntu 14.04/15.10.

 

change the map provider(recomand google map)

cd $GTS_HOME

vi private.xml

than ant track

ant track

everything ok, ant pass, copy track.war to tomacat/webapps

sudo cp $GTS_HOME/build/track.war /usr/local/apache-tomcat-7.0.65/webapps/

reboot computer...

start tomacat

$CATALINA_HOME/bin/startup.sh

if use google map, should change the map.google.com to map.google.cn in code base(google.com is blocked by greet wall)

fix gprmc.war bug(may better ways)

when i use gprmc.war, sometime there is a error location in the map with wrong time and location!

this may be a error caused by gprmc.war interpreted error,this error occur very random.

fixed method:

add a line in gprmc  only accept the point in china!--this can not eliminate the random error,but can reduce remarkable!

if(latitude >54 || latitude <3 || longitude >136 ||longitude <73)

   return; // not in china

*****before**

/*create/insert new event record*/

 

 

 

  • 重新編譯

    ant clean 
    ant all

  • 安裝

    • 復制 track.war 到tomat目錄下的 webapps 下

      cd $GTS_HOME

      cp build/gprmc.war $CATALINA_HOME/webapps/.

    • 或者用 ant 安裝

      cd $GTS_HOME 
      ant gprmc.deploy

  • 設備端軟件 
    我們這里設備端是Android系統的手機。軟件用的是GPSLogger。位於: 
    https://github.com/mendhak/gpslogger。它支持OPENGTS的GPRMC上傳。

修改地圖提供者

默認地圖提供者是:openLayers 。現在需要改成 google 。需要修改配置文件 $GTS_HOME/private.xml 。

vim $GTS_HOME/private.xml

找到包含 google 的標簽 MapProvider。修改:

<MapProvider name="googleMaps" 
    active="${Domain.MapProvider.active=false}"
    class="org.opengts.war.maps.jsmap.GoogleMaps"
    key="${Domain.MapProvider.key=***PLACE_AUTHORIZATION_KEY_HERE***}"
    rtPropPrefix="Domain.MapProvider.">

把 active=”${Domain.MapProvider.active=false}” 改成:active=”${Domain.MapProvider.active=true}” 
注意,原代碼中用的是 maps.google.com 域名,被天朝限制了。需要把它替換成: www.google.cn

vim $GTS_HOME\src\org\opengts\war\maps\jsmap\GoogleMaps.java 

把其中的 maps.google.com 替換成 www.google.cn

 

Have fun!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM