Saturday, March 16, 2013

iMapIt Pro 2.0 – How the Transferring of a File Exported to a Web Site Works

One of the main functionalities of the version iMapIt Pro 2.0 is to allow the file to be exported, available now on formats DXF, KML or GPX. Besides being able to be extracted through cable, by USB Port and sent by e-mail, it can also be sent through internet to an internet server.

The main goal of this article is to explain how the functionality of  sending the file through internet can be used.

When tapping on option "Web" under "Send to:" a field will be shown right under it and which will allow you to type the internet address to where the file must be sent.


When tapping on Export button, the file will be sent to the address informed and a screen will be shown with the answer from the server.


Notice that to apply it correctly, the server indicated on the internet address, must be ready to receive the file. Then, you must have access to this server, so that you can configure it and receive the file and save it where you find it appropriated on the server.
How do I configure the server to receive the file?
I developed two examples of scripts to internet servers that may be used to receive the file sent by iMapIt Pro.
The first example is a script PHP. PHP is one of the programming languages for internet servers. This type of file works on Apache servers.
See the example below, the file must be saved under the name "imapit_uploader.php".


------------------------------------------------------------- Beginning of PHP file (do not include this line)


<?php

// iMapIt Uploader
// Example of PHP script to upload the export file sent by iMapIt

// Folder where the file will be saved
$_UP['pasta'] = 'uploads/';

// File maximum size (in Bytes)
$_UP['tamanho'] = 1024 * 1024 * 2; // 2Mb

// Array with allowed file extensions
$_UP['extensoes'] = array('dxf', 'kml', 'gpx');

// Rename file? (If true, file will be saved with a unique name.jpg)
$_UP['renomeia'] = false;

// Array with PHP upload common error description
$_UP['erros'][0] = 'Successful upload';
$_UP['erros'][1] = 'File size is greater than PHP limit';
$_UP['erros'][2] = 'File size is greater than the limit specified in HTML';
$_UP['erros'][3] = 'Partial file upload';
$_UP['erros'][4] = 'File not uploaded';

// Return html header
echo "<br><br><br>--- iMapIt Uploader ---<br>File: " . $_FILES['iMapIt_File']['name'] . "<br><br>";

// Check if there were any upload error. If yes, show error message.
if ($_FILES['iMapIt_File']['error'] != 0) {
die("It was not possible to upload the file, error:<br />" . $_UP['erros'][$_FILES['iMapIt_File']['error']]);
exit; // Stop script execution
}

// If the script got to this point there was no upload error and the PHP script can continue

// Check if it is a allowed file extension
$extensao = strtolower(end(explode('.', $_FILES['iMapIt_File']['name'])));
if (array_search($extensao, $_UP['extensoes']) === false) {
    echo "Please, the only allowed file extensions are: dxf, kml ou gpx";
}

// Check file size
else if ($_UP['tamanho'] < $_FILES['iMapIt_File']['size']) {
echo "Uploaded file is to big. Send only files up to 2Mb.";
}

// File passed all checks. Time to move it to the destination folder.
else {
// First, change the file name, if needed.
if ($_UP['renomeia'] == true) {
    // File name with UNIX TIMESTAMP plus .jpg extension
    $nome_final = time().'.jpg';
} else {
    // Keep the original file name
    $nome_final = $_FILES['iMapIt_File']['name'];
}

// Check if it is possible to move the file to the destination folder
if (move_uploaded_file($_FILES['iMapIt_File']['tmp_name'], $_UP['pasta'] . $nome_final)) {
    // File successfuly uploaded
    echo "Upload successful!";
    } else {
        // It was not possible to upload the file, may be some issue with destination folder
        echo "It was not possible to upload the file, please try again";
    }
}
?>
---------------------------------------------------------------- End of PHP file (do not include this line)

You will only need one type of script on the internet server, let us show you another example, now in JSP. JSP is another type of programming language for internet servers and works on Apache Tomcat Servers.
See the example below, the file must be saved under the name "imapit_uploader.jsp".

------------------------------------------------------------- Beginning of JSP file (do not include this line)

<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");%>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="org.apache.commons.io.output.*" %>
<%
File file;
int MAX_FILE_SIZE = 5 * 1024 * 1024;
int MAX_MEM_SIZE = 1 *1024 * 1024;
ServletContext context = pageContext.getServletContext();
String tempFolder = context.getInitParameter("temp-folder");
String IMEI="", method="", msg="";
boolean isMultipart;
method = request.getMethod();
isMultipart = ServletFileUpload.isMultipartContent(request);

if (isMultipart && method.equalsIgnoreCase("POST")) {
DiskFileItemFactory factory = new DiskFileItemFactory();
// maximum size that will be stored in memory
factory.setSizeThreshold(MAX_MEM_SIZE);
// Location to save data that is larger than maxMemSize.
factory.setRepository(new File(tempFolder));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(MAX_FILE_SIZE);
List items = null, fileItems = null;
FileItem item;
String fileName="";
try {
items = upload.parseRequest(request);
Iterator itr = items.iterator();
int idx;
while (itr.hasNext()) {
item = (FileItem) itr.next();
if (item.isFormField()) {
if (item.getFieldName().equalsIgnoreCase("IMEI")) 
IMEI = item.getString() + "";
} else {
if (fileItems==null) fileItems = new ArrayList<FileItem>();
fileItems.add(item);
}
}
//if (IMEI.equals("") || IMEI.equals("null")) {
// msg = "Invalid source";
//}
if (fileItems!=null && !fileItems.isEmpty()) {
msg = "You have uploaded following file(s): ";
for (int i=0; i<fileItems.size(); i++) {
item = (FileItem) fileItems.get(i);
fileName = item.getName();
idx = fileName.lastIndexOf("\\");
if (idx == -1) idx = fileName.lastIndexOf("/");
if (idx >= 0) {
fileName = fileName.substring(idx);
}
fileName = fileName;
item.write(new File(tempFolder + fileName));
msg += "<br><a href=\"/upload/temp/" + fileName + "\">" + fileName + "</a>";
}
}
} catch (Exception e) {
msg = e.getMessage();
}
} else {
msg += "Upload is not accepted.<br>";
msg += "Please upload file using multipart/form-data and POST method<br>";
}
%>
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>KML Loader</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</HEAD>
<BODY>
<%=msg%>
</BODY>
</HTML>

---------------------------------------------------------------- End of JSP file (do not include this line)


If someone has more script examples to share, they will be more than welcome.

Well, in order to test if your upload script is working properly, you can use the HTML code; you can see as an example below. This code can be saved under the name "teste_upload.html".


---------------------------------------------------------------- Beginning of HTML file (do not include this line)

<!DOCTYPE HTML>
<HTML>
    <HEAD>
            <TITLE>iMapIt Loader Test</TITLE>
            <META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </HEAD>
    <BODY>
            <FORM id="frm" name="iMapIt_Form" action="imapit_uploader.php" method="POST" enctype="multipart/form-data">
                Select a file to upload<br>
                <INPUT id="iMapIt_File" name="iMapIt_File" type="file" style="width:100%;"/><br>
                <INPUT id="submit" type="submit" value="Submit" />
                </FORM>
    </BODY>
</HTML>

---------------------------------------------------------------- End of HTML file (do not include this line)


The HTML file example above is how the iMapIt Pro from your iPhone or iPad will transfer the exported file. If the test file above works calling the PHP script "imapit_uploader.php" and transfer a file properly; the iMapIt Pro will also work.

Feel free to send questions and suggestions.

Monday, January 14, 2013

In version 1.4 of PRO iMapIt new features were introduced on screen Export Project.
See below.


The choice of file format existed, there you can choose from:

  • DXF - is a format read by most CAD software
  • KML - Is the presentation format Google Maps
The choice of coordinates type to be exported is a new feature. Now you can select the following options:
  • Geographic - geographical coordinates are collected directly from the iPhone or iPad's GPS, latitude and longitude. Geographical coordinates are coordinates that represent a point on the globe and are represented in degrees, minutes and seconds. In iMapIt geographical coordinates are represented in degrees and decimal fractions of a degree;
  • UTM - is a type of projection flat, converted from geographic coordinates. UTM is the abbreviation for Universal Transverse Mercator;
The Ellipsoid option offers different ways of calculating the projection as UTM following the Brazilian Coordinate Reference System.

In Axis option:
  • Latitude in X - Export coordinates with latitude on the X axis and longitude on the Y axis;
  • Latitude in Y - Export coordinates with latitude on the Y axis and longitude on the X axis;
The Send To option already existed and there you can choose from:
  • USB - Allows the exported file to be extracted from the iPhone / iPad through USB port, through iTunes file sharing option in the application iMapIt;
  • eMail - Allows the exported file to be sent via eMail;
The File Name option displays the default file name that is automatically generated by the application and allows it to be changed. The exported file will have that name.

These are the current export options. Any suggestions for improving the application are welcome.

Thursday, January 10, 2013

iMapIt – Features and Comparison Between Versions

Features: iMapIt PRO iMapIt LITE
Available to:
   iPhone x x
   iPad x x
Allow creating multiple projects x x
Use device maximum GPS precision x x
Collect Points x x
Collect Lines x x
Collect Polygons x x
Calculates lines extension x 1
Calculates polygons area x 1
Available space to describe the project x x
Available space to describe each measurement x x
Measures in metric units x 1
Measures in imperial units x 1
Shows GPS precision while collecting points x x
Shows coordinates in real time x x
Exporting features:
   Exports file in DXF format x
   Exports file in KML format x
   Allows extracting exported file through USB x
   Sends exported file through e-mail x
   Exports geographical coordinates x
   Exports coordinates in UTM projection x
  Alternates coordinates between aixes X and Y in exported file x
  Allows to change the exported file name x

1 - Feature available only once

Tuesday, November 6, 2012

iMapIt Pro Version 1.4 Crashes in iOS 6.0

A iMapIt user wrote me complaining that the new version he had just installed crashed when he tapped the Export button.
He use a iPhone 4.
After investigating we've got a solution for that:

  • Upgrade the device's iOS to 6.0.1;
  • Test iMapIt using the Export function. If the Export screen appears we're done. If not continue below;
  • Delete the iMapIt Pro app from your device, download and install it again from AppStore.
Should you have any questions feel free to contact us.

Friday, January 27, 2012

User question: Bad surveys


An user sent me the following e-mail:

"Hi ...,


I've tested the application in the farm on Wednesday to measure a known area in the farm and the result was very good. Today I showed it to a customer in Independência Stadium, inside Belo Horizonte, and it was a complete disaster. What could have happened? I tested it twice, I'd like to send you the generated file, a disaster.
"

Answer:
Usually a GPS device works in the following way, quite briefly: There is a constellation of GPS satellites (Global Positioning System) in Earth orbit. The device looks for a minimum of three visible 
and closer satellites, performs a triangulation calculation and gives the coordinates of your position in latitude, longitude and altitude.
The iPhone, iPad or iPod Touch GPS uses the same type of calculation, but it is necessary that the satellites are visible. If the minimum number of satellites is not visible, it seeks a Wi-Fi network or use the mobile antenna network to give you a position.
However, the accuracy of the coordinates reported falls a lot if it does not use the satellites.
The application iMapIt has no way of knowing whether satellites are being used or not, but has the accuracy and the error that is being used at this time.

When you use the positioning indication button, as illustrated above, the application will zoom in to your current location and display a blue dot with a circle around it. The blue dot is your position, the circle is the current GPS accuracy.
See the image below.


See that the circle of precision occupies several city blocks.
This is one of the worst possible precision... I was not placed where the blue dot is centered, but I was certainly within the circle.
It's not worth to measure anything with such accuracy. The result will be disastrous.

Please note this new image. I stood waiting at the same point ...
The circle and diminished and the blue dot was almost exactly where I was ...
But to survey an area the accuracy is not good yet.
Notice that the blue circle still occupies two city blocks.

He was in the middle of town, so not always the GPS signal is the best. I walked a little, reached out, separated the phone from the body, turned to one side and to another. The accuracy increases, decreases, and ends up putting you in the right spot.
The best accuracy will be seeing when the blue circle disappear. When you get only the blue dot and a pulsing circle around it.
This way your surveys will be "perfect" ...
One tip: get to the point where you want to mark, before taping the MapIt button, wait a few seconds ... You will see the blue dot will gradually positioning itself to get exactly where you are.
If you prefer, use the satellite image map view.
Use this button for that, which is in the upper right corner of the screen. So you know exactly if the blue dot is on your actual physical location.

I hope this helps.
Do not hesitate to ask.

Tuesday, November 29, 2011

iMapIt First User Guide

This is a guide to help you on how to use the function of
surveying areas, paths or points information, using the
iMapIt application, and better explorer its characteristics.

This screen is used to collect and save the geographic
coordinates of your real global position. These coordinates
can be save as a sequence of points, but also they can be
connected and organized as a line, or path, or also can be
connected to build the limits of an area or terrain.


How each button works

This is the mapping screen.

























Where:


Alternates the map presentation between the standard and satellite
modes.



Turns on or off the position identification mode. When this button
is pressed a blue dot is shown indicating where is your actual
global position.


This button toggles the coordinates surveying between the types:
points, path or area.



This button shows up a setup screen. In this new screen you'll
be able to:

  • Toggle the surveying between points, path or area
  • Enable or disable sounds
  • Change the iMapIt button transparency

Begins the coordinates collection. When pressed this button has
its text changed to STOP, to stop the coordinates collection when
needed. When you start collecting coordinates the MapIt button
is displayed and some configuration buttons are disabled.



This is the MapIt button.
Every time it is pressed is collected a geographic coordinate from
your actual global position. This coordinates come from the GPS
built in your device. Each coordinate collected is saved as a single
point, or a point of a path, or a polygon vertex to build the boundaries
of an area or terrain, depending on how this function is setup to.