Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
# This is a testcase to obtain the location from an image on Server side
|
||||
#
|
||||
# The idea is to use the ImageMetadataReader Java Class :
|
||||
# https://drewnoakes.com/code/exif/
|
||||
#
|
||||
# Downloads from:
|
||||
# https://github.com/drewnoakes/metadata-extractor/releases
|
||||
# Release 2.9.1 was used for this testcase
|
||||
#
|
||||
# Testcase based on example :
|
||||
# https://github.com/drewnoakes/metadata-extractor/blob/master/Samples/com/drew/metadata/GeoTagMapBuilder.java
|
||||
|
||||
IMPORT JAVA com.drew.metadata.Metadata
|
||||
IMPORT JAVA com.drew.metadata.exif.GpsDirectory
|
||||
IMPORT JAVA com.drew.metadata.Directory
|
||||
IMPORT JAVA com.drew.imaging.ImageMetadataReader
|
||||
IMPORT JAVA com.drew.imaging.ImageProcessingException
|
||||
IMPORT JAVA com.drew.lang.GeoLocation
|
||||
IMPORT JAVA java.io.File
|
||||
|
||||
|
||||
FUNCTION get_exif_latlong_bdl(filename)
|
||||
|
||||
DEFINE filename STRING
|
||||
DEFINE msg STRING
|
||||
DEFINE stat SMALLINT
|
||||
DEFINE mdata com.drew.metadata.Metadata
|
||||
DEFINE jfile java.io.File
|
||||
DEFINE gpsdir com.drew.metadata.exif.GpsDirectory
|
||||
DEFINE thedir com.drew.metadata.Directory
|
||||
DEFINE latlong com.drew.lang.GeoLocation
|
||||
DEFINE lat,lon FLOAT
|
||||
|
||||
LET lat=NULL
|
||||
LET lon=NULL
|
||||
DISPLAY "FILE ",filename
|
||||
TRY
|
||||
LET jfile = java.io.File.create(filename)
|
||||
LET mdata = com.drew.imaging.ImageMetadataReader.readMetadata(jfile)
|
||||
CATCH
|
||||
LET stat=STATUS
|
||||
LET msg=SFMT("Unable to create ImageMetadataReader for image file '%1'\nError code=%2\n%3",
|
||||
filename, stat, err_get(stat))
|
||||
CALL fgl_winmessage("Error",msg,"stop")
|
||||
RETURN lat,lon
|
||||
END TRY
|
||||
|
||||
TRY
|
||||
LET gpsdir = com.drew.metadata.exif.GpsDirectory.create()
|
||||
LET thedir = mdata.getFirstDirectoryOfType(gpsdir.getClass())
|
||||
CATCH
|
||||
LET stat=STATUS
|
||||
LET msg=SFMT("Unable to obtain Gps information from image file '%1'\nError code=%2\n%3",
|
||||
filename, stat, err_get(stat))
|
||||
CALL fgl_winmessage("Error",msg,"stop")
|
||||
RETURN lat,lon
|
||||
END TRY
|
||||
|
||||
LET gpsdir = CAST(thedir AS com.drew.metadata.exif.GpsDirectory)
|
||||
|
||||
IF gpsdir IS NOT NULL THEN
|
||||
LET latlong = gpsdir.getGeoLocation()
|
||||
LET lat = latlong.getLatitude()
|
||||
LET lon = latlong.getLongitude()
|
||||
ELSE
|
||||
LET lat = 0
|
||||
LET lon = 0
|
||||
END IF
|
||||
|
||||
RETURN lat,lon
|
||||
|
||||
END FUNCTION
|
||||
Reference in New Issue
Block a user