Blog from a software professional, Passionate to work in latest cutting edge technologies in order to get better results in business.
Sunday, June 19, 2011
Sample to find Area and perimeter of a Polygon
Today tried a sample to fetch Area and perimeter of a surface using ArcGIS API with Google maps. It is easy to use, we just need to join the points for the respective surface for which we need to find the Area & perimeter and double click. I always like Central park in Newyork, Thought let us try the tool there... It works perfect... please find the link & screen shot below.
Live Sample: http://www.kuwaitfresh.com/find_area.html
Saturday, June 18, 2011
Terrain Analysis in ArcGIS Explorer
Tried installing the Terrain Profile plug-in for ArcGIS explorer. Found it interesting because, I came to know that Terrain analysis & calculations are done through ArcGIS web-servers in real-time. The location striked on my Mind was Mt. Everest from Himalayas. Just searched for Mt. Everest and landed in the location. I just enabled Terrain Analysis, drew a straight line and double clicked in order to start calculation. In few seconds it was done! The values are almost close... Its fun working with this tool & much more to explore...
Fauzi
Friday, May 27, 2011
Salmiya Garden Distance
Today, i thought we need to find the distance we walk in the salmiya garden situated in 10th Block. We usually go for two rounds and some times more, based on the energy level :). Thanks to ArcGIS explorer which made our quest simple. its easy to do as well... Please see the screen shot below which shows a clear picture.
Answer: 1.048 Kms
Sunday, May 22, 2011
Where Am I ! A sample on Geo location using ArcGIS API
Hi
I have created a Geo location finder page using ArcGIS api. It is a test page to display the current location of the browser. I am sending to friends across the globe to evaluate. Please try from your end and reply whether it works fine or not & your browser version. mostly it is supported in all latest versions.
Live Sample : http://www.kuwaitfresh.com/WhereAmI.htm
We have used the following web-service in this sample:
http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer
Observation as on 1 July: For some friends in IE 8 it didn't work. Rest for Firefox version greater than 3.5,Chrome, IE9, It worked once the user allowed "share my location" option. and we have also tested in Iphone which is upgraded with version 4.3.
ArcGIS JavaScript API sample to display the current latitude and longitude
Here is a sample of ArcGIS Javascript API using google maps web services. To use google web services we need to register with them. After registration with google, they provide a API Key specifically for our domain, say for example in our case it is KuwaitFresh.com.
About the Sample, it helps us to fetch exactly the current Latitude and longitude on mouse click on the respective position. Please click the link below to navigate to the live sample. Thanks
Live Sample
Thursday, May 19, 2011
Sample of ArcGIS online Viewer using Javascript API
Created a sample Map from API viewer in ArcGIS to display some cities in kuwait. Embedded the code in a page in my website as well... click the image below to view the page below.
http://www.kuwaitfresh.com/ArcGIS_MapViewer_sample.html
ArcGIS Explorer online : Oil spill in Gulf of Mexico over time
Wednesday, May 11, 2011
Searh for a text in whole database SQL
There was a requirement to search for a text in the whole SQL database. found this Stored procedure very useful. though it is worth sharing...
Resource: http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
-- SearchAllTables ''
CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
)
WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)
IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
ENDThursday, April 14, 2011
SQL to generate Script for All stored procedures in a Database
I had a requirment to create a local copy of a MS SQL Database hosted on remote environment(Godaddy Hosting). With the help for Import Data option in SQL Server Managment studio, I was able to replicate both the Tables & their respective Data. Since there no option to import Stored procedures. I was looking in google to generate SQL script for all the stored procedures from a Database.
List All Stored Procedure in Database: select * from sys.procedures
Fortunate to find this post: http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/how-to-script-all-stored-procedures-in-a
set nocount on
DECLARE @Test TABLE (Id INT IDENTITY(1,1), Code varchar(max))
INSERT INTO @Test (Code)
SELECT 'IF object_ID(N''[' + schema_name(schema_id) + '].[' + Name + ']'') IS NOT NULL
DROP PROCEDURE ['+ schema_name(schema_id) +' ].[' + Name + ']' + char(13) + char(10) + 'GO' +
OBJECT_DEFINITION(OBJECT_ID) + char(13) +char(10) + 'GO' + char(13) + char(10)
from sys.procedures
where is_ms_shipped = 0
DECLARE @lnCurrent int, @lnMax int
DECLARE @LongName varchar(max)
SELECT @lnMax = MAX(Id) FROM @Test
SET @lnCurrent = 1
WHILE @lnCurrent <= @lnMax BEGIN SELECT @LongName = Code FROM @Test WHERE Id = @lnCurrent WHILE @LongName <> ''
BEGIN
print LEFT(@LongName,8000)
SET @LongName = SUBSTRING(@LongName, 8001, LEN(@LongName))
END
SET @lnCurrent = @lnCurrent + 1
END
Hope it Helps
4Z
Tuesday, February 8, 2011
UNZIP a zip file through C#
We had a FTP location where our vendors place a ZIP file. The idea is to process file once it is placed through a listner application. So we need to unzip the placed file through an application. The API: ICSharpCode.SharpZipLib.Zip was very much helpful to achieve the same.
Sample source code is below:
using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;
namespace unzipper
{
class Program
{
static void Main(string[] args)
{
UnZipFiles("C:\\TEST\\SharpZipLib_0860_Bin.zip", "C:\\TEST\\", "", false);
}
public static void UnZipFiles(string zipPathAndFile, string outputFolder, string password, bool deleteZipFile)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));
if (password != null && password != String.Empty)
s.Password = password;
ZipEntry theEntry;
string tmpEntry = String.Empty;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = outputFolder;
string fileName = Path.GetFileName(theEntry.Name);
// create directory
if (directoryName != "")
{
Directory.CreateDirectory(directoryName);
}
if (fileName != String.Empty)
{
if (theEntry.Name.IndexOf(".ini") < fullpath =" directoryName" fullpath =" fullPath.Replace(" fulldirpath =" Path.GetDirectoryName(fullPath);" streamwriter =" File.Create(fullPath);" size =" 2048;" data =" new" size =" s.Read(data,"> 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
}
s.Close();
if (deleteZipFile)
File.Delete(zipPathAndFile);
}
}
}
Hope it Helpz...
Reference: http://www.eggheadcafe.com/tutorials/aspnet/9ce6c242-c14c-4969-9251-af95e4cf320f/zip--unzip-folders-and-files-with-c.aspx
Regards
Fauzi
Sunday, January 9, 2011
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561
We had a requirement to generate a PDF report in a table with all items for the selected vendor with their respective images. Thanks to ItextSharp for the wonderful utility to generate PDF's. Since we embed image in run time, while executing the part,
table.AddCell(image.Getinstance(
"Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Googled for the message and found that the solution is that we need to set trust level as full in web.config. Since it is an internal application for us it is not a big deal in our case. Any ways planning to encrypt the PDFs as password protected.
Solution: trust level="Full" in web.config
Resource: http://forums.asp.net/p/1422162/3433380.aspx
Hope It Helps :)
Regards
Fauzi