понедельник, 4 ноября 2013 г.

Ошибка "Библиотека не зарегистрирована" в ИнГео.

Решение

1.Включить VBScript (команды для 64 битной системы):

Нажмите кнопку Пуск, выберите пункт выполнить, введите cmdи нажмите кнопку ОК.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\vbscript.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\jscript.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\dispex.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\scrobj.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\scrrun.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\wshext.dllи нажмите клавишу ВВОД.
Введите %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\wshom.ocxи нажмите клавишу ВВОД.

Листинг взят с сайте Майкрософта.
Мне это не помогло.

2.Запуск ИнГео с правами Администратора:

Как ни странно это решило проблему.


среда, 2 октября 2013 г.

Insert Shape file into MS SQL-Server data base.

It's how to use ogr2ogr to insert Shape file into MS SQL-Server data base.
ogr2ogr -overwrite -f MSSQLSpatial "MSSQL:server=MY-PC-NAME;database=mydatabase;trusted_connection=yes" "D:\data\test_shape.shp"
It's create or overwrite table with name - test_shape.

четверг, 18 июля 2013 г.

Install LifeRay 6.1 on Ubuntu and CentOS

Today i will install LifeRay 6.1 GA2 on Ubuntu 13.04 with 1Gb memory.

1. Installing.
At first create new user for Liferay:

sudo adduser --home /home/liferay liferay
Install Java:

sudo apt-get install default-jre
For me it was installed into /usr/lib/jvm/java-7-openjdk-amd64
On CentOS path was:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64
Get a LifeRay:

http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.1.1%20GA2/liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558.zip
unzip liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558.zip -d /home/liferay
Change user to liferay and go to Liferay folder. There i have a problem becouse when i try to start Tomcat it was not work. So all operations i do as administrator.

2. Tomcat configuration.
How we need to set JAVA_HOME variable. And we do it in bash. Go to file /etc/bash.bashrc and add:

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
For CentOS JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/jre
Next you need give a permissions to Tomcat log file. Only heavy artillery helps me:

chmod 777 /home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/logs/catalina.out
Okey, now you can start LifeRay

sh /home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/startup.sh
In console you'll get list of variables. And when in catalina.log appears line
INFO: Server startup in 24802 ms
server is start.

3. Add Liferay in autoload
At first create script /etc/init.d/liferay6

#!/bin/bash
# LifeRay Startup Service script v1.0 by Faraz Haider 6 May 2012
# acts as startup service script for LifeRay Portal.
# USAGE: start|stop|status|logs
#
case "$1" in
start)
echo "Starting LifeRay Web Portal."
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
/home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/startup.sh
;;
stop)
echo "Stopping LifeRay Web Portal."
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
/home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/shutdown.sh
;;
logs)
echo "See the logs of the LifeRay Web Portal."
tail -f /home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/logs/catalina.out
;;
status)
# Check to see if the process is running
ps aux|grep -i liferay
;;
 
*)
echo “LifeRay Web Portal Service”
echo $”Usage: $0 {start|stop|status|logs}”
exit 1
esac
exit 0
For CentOS:

#!/bin/bash
# chkconfig: 2345 90 10
# description: Liferay Service
# LifeRay Startup Service script v1.0 by Faraz Haider 6 May 2012
# acts as startup service script for LifeRay Portal.
# USAGE: start|stop|status|logs
#
case "$1" in
start)
echo "Starting LifeRay Web Portal."
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/jre
#export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
/home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/startup.sh
;;
stop)
echo "Stopping LifeRay Web Portal."
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/jre
#export JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
/home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/bin/shutdown.sh
;;
logs)
echo "See the logs of the LifeRay Web Portal."
tail -f /home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/logs/catalina.out
;;
status)
# Check to see if the process is running
ps aux|grep -i liferay
;;
 
*)
echo “LifeRay Web Portal Service”
echo $”Usage: $0 {start|stop|status|logs}”
exit 1
esac
exit 0
First two comments real important.
Make file executable:

chmod 755 /etc/init.d/liferay6
update-rc.d tomcat7 defaults
For CentOS:
chmod 755 /etc/init.d/liferay6
chkconfig liferay6 on

PS: only start,stop and status works
Reboot and be happy.

Change Tomcat port

Default port is 8080 but in not prety good becouse link www.example.com:8080 looks like a hell.
So go to home/liferay/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/conf/server.xml. Find part:

 
And change port 8080 to what you want. I use 80 port for my site address www.example.com.

понедельник, 15 июля 2013 г.

Install php+FastCGI+nginx on Ubuntu.

Im continue create my super-amazing-web-GIS-application. I have a weak hardware so i have choice between 2 server side languages php and node.js. With php i can work now and there but for using node.js i have to read tons of books and miles of forums. So i have php i choose you!


1. Installing.

In previous part we already install nginx and fastCGI. So now we need only php. I will make php+fastCGI not php+php-rgm just becouse im already have fastcgi. If someone will write in comments why i have to use php-rgm i will glad.


Install php:


apt-get install php5 nginx php5-cgi

I was not install mySQL becouse i will use PostgreSQL+PostGIS for spatial data.


2. FastCGI configuration.

Create file /usr/bin/php-fastcgi and put into:


#! /bin/sh
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=1000
exec /usr/bin/php5-cgi

Create file /etc/init.d/init-fastcgi and put into:


#!/bin/bash
PHP_SCRIPT="/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php-fastcgi"
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php5-cgi
RETVAL=$?
;;
restart)
killall -9 php5-cgi
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: sudo /etc/init.d/init-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL

Make files executable:


chmod 755 /usr/bin/php-fastcgi
chmod 755 /etc/init.d/init-fastcgi 
3. nginx configuration.

You can create new file /etc/nginx/sites-enabled/your-file-name for server configuration:


server {
 listen 80;
 listen [::]:80 default_server ipv6only=on;

 root /srv/www/localhost/public_html;
 access_log /srv/www/localhost/logs/access.log;
 error_log /srv/www/localhost/logs/error.log;
 #index index.html index.htm;

 # Make site accessible from http://localhost/
 server_name localhost;

 location / {
  # First attempt to serve request as file, then
  # as directory, then fall back to displaying a 404.
  try_files $uri $uri/ /index.html;
  # Uncomment to enable naxsi on this location
  # include /etc/nginx/naxsi.rules
 }

 location /doc/ {
  alias /usr/share/doc/;
  autoindex on;
  allow 127.0.0.1;
  allow ::1;
  deny all;
 }
 location ~\.php$ {
  root /srv/www/localhost/public_html;
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param QUERY_STRING $query_string;
  fastcgi_param SCRIPT_FILENAME /srv/www/localhost/public_html$fastcgi_script_name;
 }

}

But i use default file so i just add:


 location ~\.php$ {
  root /srv/www/localhost/public_html;
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param QUERY_STRING $query_string;
  fastcgi_param SCRIPT_FILENAME /srv/www/localhost/public_html$fastcgi_script_name;
 }

into /etc/nginx/sites-enabled/default.


4. Site directory.

Its all with configurations. Now you can start FastCGI script:


Now we need to create directory for our site and log directory:


/srv/www/localhost/public_html
/srv/www/localhost/logs

In public_html keeped all site content.


5. Results.

Its all with configurations. Now you can start FastCGI script:


sudo /etc/init.d/init-fastcgi start

And start nginx:


/etc/init.d/nginx start

Create file test.php in our site directory with:



Go to the localhost/test.php and if you do all right you'll see standart phpinfo() output:


Its mean that php+nginx work fine.


In my case i get a 404 error becouse nginx tried to find test.php in standart nginx directory /var/www. Restart of nginx and fastcgi not help me, i was forced to reboot machine. But after all work fine.
Another problem was with permissions. So dont forget set to site directory:


 
sudo chmod -R 755 /srv/www/localhost/public_html
6. Enable PostgreSQL.

Its all nice but i will need PostgreSQL support in php. Now we need to install PostgreSQL module.


 
sudo apt-get install php5-pgsql

Restart fastCGI


 
sudo /etc/init.d/init-fastcgi restart

And go to localhost/test.php again to make sure that PostgreSQL enabled. You gonna see that part:


Its mean all works fine.


среда, 26 июня 2013 г.

MapServer+nginx+FastCGI on Ubuntu.

Hi.

Im new with Linux. But try to tell how to start with Mapserver on Ubuntu.


1. Installing

Add UbuntuGis repository:


sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update

Before install MapServer dont forget that its needed in some libraries: curl, gdal,org, agg. Here more inforamtion about this - MapServer Site


Install MapServer, nginx,FastCGI and libgd:


sudo apt-get install libgd2-xpm-dev
sudo apt-get install cgi-mapserver mapserver-bin
sudo apt-get install nginx
sudo apt-get install spawn-fcgi
2. FastCGI config

Create file /etc/init.d/mapserv/ and put into:


#! /bin/sh
#
# description: Mapserver Service Manager
# processname: lt-mapserv
# pidfile: /var/run/mapserv.pid
# Source function library.
#. /etc/init.d/functions
# Check that networking is up.
#. /etc/sysconfig/network
if [ "$NETWORKING" = "no" ]
then
        exit 0
fi
PREFIX=/usr
NAME=mapserv
PID=/var/run/mapserv.pid
DAEMON=$PREFIX/bin/spawn-fcgi
DAEMON_OPTS=" -a 127.0.0.1 -p 9999 -F 4 -u user -U user -P $PID $PREFIX/lib/cgi-bin/mapserv"
start () {
    echo -n $"Starting $NAME "
        exec $DAEMON $DAEMON_OPTS >> /dev/null
        daemon --pidfile $PID
        RETVAL=$?
        echo
    [ $RETVAL -eq 0 ]
}
stop () {
    echo -n $"Stopping $NAME "
        killproc -p $PID
        #make sure all mapservers are closed
        pkill -f lt-mapserv
        RETVAL=$?
        echo
    if [ $RETVAL -eq 0 ] ; then
                rm -f $PID
        fi
}
restart () {
    stop
    start
}
# See how we were called.
case "$1" in
  start)
        start
    ;;
  stop)
        stop
    ;;
  status)
    status lt-mapserv
        RETVAL=$?
        ;;
  restart)
    restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        RETVAL=2
        ;;
esac
exit $RETVAL

Make this file executable:


chmod +x /etc/init.d/mapserv
3. nginx config

Create file /etc/nginx/sites-enabled/your-file-name


server {
    ##another server config
    listen   80;
    server_name  your_server.name www.mapserver.your_server.name;
    #MapServer
        location / {
                fastcgi_pass   127.0.0.1:9999;
                fastcgi_index  mapserv?*;
                fastcgi_param  SCRIPT_FILENAME  /usr/lib/cgi-bin/mapserv$fastcgi_script_name;
                include fastcgi_params;

    }
}

I was make all thing on localhost. So i not create new file, but just add lines with:


        location /map/ {
                fastcgi_pass   127.0.0.1:9999;
                fastcgi_index  mapserv?*;
                fastcgi_param  SCRIPT_FILENAME  /usr/lib/cgi-bin/mapserv$fastcgi_script_name;
                include fastcgi_params;

    }
into /etc/nginx/sites-enabled/default.

Its all with configurations. Now you can start FastCGI script:


service mapserv start 
And start nginx:
/etc/init.d/nginx start

Go to the localhost/map/ and if you do all right you'll see:


No query information to decode. QUERY_STRING is set, but empty.

Its mean that MapServer+nginx work fine.


4. Create map.

Now lets do your first map.For this we need some data. I take Shape files: http://gis-lab.info/other/mapserver-begin-example.zip. Extract it everywhere you want, i do it into /home/my-user/example.


MapServer have no admin panel like Geoserver. For make map you gonna create *.map files. In zip already contain some. We'll use file polt.map:


 
# Аннотированный map-файл (за основу взят файл из учебника 
# http://biometry.gis.umn.edu/tutorial/) 
#
# Все, что идет за символом решетки - комментарий и программой не обрабатывается 
# 
# Map-файлы начинаются с ключевого слова MAP, обозначающего начало 
# "map"-объекта. Закрывает map-объект ключевое слово END в конце файла. Вся 
# карта, которая будет отображаться пользователю описывается внутри.

MAP
  IMAGETYPE      GIF
  EXTENT         34.59 49.58 34.63 49.6
  SIZE           400 300
  SHAPEPATH      "/home/user/example/shp/"
  IMAGECOLOR     255 255 255

#   Внутри MAP-объекта определяются новые объекты - слои (LAYER). 
#   Обязательно нужно определить по крайней мере один слой.
#   Количество слоев ограничено сверху (по умолчанию - не больше 100 слоев), 
#   если нужно большее количество слоев, придется перекомпилировать 
#   MapServer (см. map.h)


  LAYER # Определяем полигональный слой
    NAME         veget
    DATA         Poltava10_Vegetation_region
    STATUS       ON
    TYPE         POLYGON

#     Внутри слоя нужно определить как минимум один класс. Классов может быть
#     несколько, но не больше 10 (иначе опять придется перекомпилировать MapServer) 

    CLASS
      NAME       "Растительность"

#       Внутри класса определяются стили: как именно данный класс отобразить
#       на карте.
      STYLE
        COLOR        232 232 232
        OUTLINECOLOR 32 32 32
      END
    END
  END # Конец определения слоя

END # Конец определения карты

There much comments on russian, but don't worry this files works fine. This map contains only one layer veget There you gonna change only SHAPEPATH parameter if you extract your zip archive in another place.


For see this map add in your address line:


 
http://localhost/map/?map=/home/user/example/polt.map&layer=veget&mode=map

If you see map image:


Its mean all works fine.


Thanks for Yodeski Rodríguez Álvarez for nginx and FasrCGI configuration files. Part with map creating takes from gis-lab.ru