ArcObjects Tutorial Part 1

May 21, 2008 by iamlaksh1

This walkthrough from ESRI teaches how to create a custom command by inheriting from the ESRI BaseCommand class. Inheriting the BaseCommand allows you to create commands more quickly and simple than directly implementing the ICommand interface in ESRI.ArcGIS.SystemUI.

Here is a link to start with. If you are new to application development in .NET environment, you can take this sample as your first step. The walkthrough explains in both VB.NET and C# languages.

If anyone has any doubts or require help on this, please do write me.

Create a Commad by Inheriting from Base Command 

You may ask wheather we can create ESRI command/tool using Java?. The answer is YES, but not in a direct way. We have to compile jar to dll using other tools (eg. J-Integra). If you are serious java developer you can watch this ESRI thread for the possible approach.

10000 Requests!

May 16, 2008 by iamlaksh1

Folks,

My blog crossed 10,000 mark today.  I’m surprised with in four months (started on Jan 21,2008) 10,000 server requests (hits) has been made through my blog.  Here is simple stat for you

Feb: 2329 Views

March: 2439 Views

April: 3278 Views

I wish to write more on some interesting topics and basics. I assure you that every reader who cross my blog will find something useful. This journey will be continued. 

 

 

Best Topics from Coding Horror

May 9, 2008 by iamlaksh1

HTTP Status/Error Code: Quick Reference

May 6, 2008 by iamlaksh1

 

During your HTTP sessions, you’ll receive various numbered codes from Web servers.  When connected via HTTP, displays these codes in the log window.  Some codes represent errors.  Most others simply communicate the status of the connection. Here are brief explanations for the most common status and error codes.

 

 

Error or Status Code

Description

100 Series

Informational - These status codes indicate a provisional response. The client should be prepared to receive one or more 1xx responses before receiving a regular response.

100

Continue.

101

Switching protocols.

200 Series

Success - This class of status codes indicates that the server successfully accepted the client request.

200

Okay - The client request has succeeded  This status code indicates that the Web server has successfully processed the request

201

Created.

202

Accepted.

203

Non-authoritative information.

204

No content.

205

Reset content.

206

Partial content.

300 Series

Redirection - The client browser must take more action to fulfill the request. For example, the browser may have to request a different page on the server or repeat the request by using a proxy server.

302

Object moved.

304

Not modified. The client requests a document that is already in its cache and the document has not been modified since it was cached. The client uses the cached copy of the document, instead of downloading it from the server

307

Temporary redirect.

400 Series

Client Error - An error occurs, and the client appears to be at fault. For example, the client may request a page that does not exist, or the client may not provide valid authentication information.

400

Bad request.

401

Access denied.

403

Forbidden.

404

Not found. This error may occur if the file that you are trying to access has been moved or deleted.

404.0

File or directory not found.

404.1

Web site not accessible on the requested port.

405

HTTP verb used to access this page is not allowed (method not allowed).

406

Client browser does not accept the MIME type of the requested page.

407

Proxy authentication required.

412

Precondition failed.

413

Request entity too large.

414

Request-URL too long.

415

Unsupported media type.

416

Requested range not satisfiable.

417

Execution failed.

423

Locked error.

500 Series

Server Error - The server cannot complete the request because it encounters an error.

500

Internal server error.  You see this error message for a wide variety of server-side errors.

500.12

Application is busy restarting on the Web server. Indicates that you tried to load an ASP page while IIS was in the process of restarting the application. This message should disappear when you refresh the page. If you refresh the page and the message appears again, it may be caused by antivirus software that is scanning your Global.asa file.

500.13

Web server is too busy.

500.15

Direct requests for Global.asa are not allowed.

500.16

UNC authorization credentials incorrect. This error code is specific to IIS 6.0.

500.18

URL authorization store cannot be opened. This error code is specific to IIS 6.0.

500.100

Internal ASP error. You receive this error message when you try to load an ASP page that has errors in the code.

501

Header values specify a configuration that is not implemented.

502

Bad Gateway.  Web server received an invalid response while acting as a gateway or proxy. You receive this error message when you try to run a CGI script that does not return a valid set of HTTP headers.

503

Service unavailable. This error code is specific to IIS 6.0.

504

Gateway timeout.

505

HTTP version not supported.

 

 

 

 

ESRI MVP

May 5, 2008 by iamlaksh1

Dear Folks,
This is second consecutive time being Most Valuable Professional (MVP) on ESRI Forums. I take this opportunity to thank all those who have clicked ‘this post answered my question’ .


Thanks to all my team members, collegues, friends and organisation , for their support and encouragment  throughout.

 

MVP

Google Code Search

May 2, 2008 by iamlaksh1

Here is another interesting stuff from Google.

Google Code Search

http://www.google.com/codesearch

You can get some sample codes/links on topic searched. Another cool app from Google.

Tips for good presentation

May 2, 2008 by iamlaksh1
This post is taken from VenkatRangan Blog . 
 
There are 3 basic ways to learn this art:
  1. Listen to great speakers: Attend as many programs of great speakers as possible. Subject spoken is immaterial here, what you are learning is the “Master’s” way of doing it.
  2. Read about doing presentations: There are now plenty of books on doing effective presentations and Internet has numerous pages on this. Read them.
  3. Keep Doing it: Get on stage as many times as you can and just do it. As they say, your mistakes teach you more than anyone. So as you keep doing more and more presentations, you will learn on your mistakes and improve.

Apart from the above 3 tenants, following is what I learned over the years.

General Tips:
  1. Know your audience well – try to get before-hand, the profile and the number of audiences. It is also a good idea to ask the event organizers, what they consider as the success of the event. 
  2. Prepare on the subject - a time honoured tip!
  3. Before the start of the presentation, try to get into the hall and spend few minutes looking around it. This is to make yourself comfortable with the place and ease your anxiety.
  4. Before your presentation, if you get a chance to sit on the stage with other speakers, use the opportunity. Try to sweep the hall with your eyes and make few eye-contacts with the audiences. Don’t take the eye-contact to extreme and stare at one person for long time, they will get nervous. Just do it for a second with one person and then keep moving. This will boost your confidence.
  5. Start with a “Joke” or “Tidbit” or “Exciting News” relevant which is related to the day’s topic but not part of the topic directly.
  6. Introduce yourself – You have worked for it, you have put in effort, you deserve your limelight. Speak your name, loud & clear in a way you will like to hear it to being pronounced by others. Tell about your background especially relevant experiences to today’s topic. Having said that, If the host already has introduced you, don’t repeat your “Profile” all again. Always keep the introduction short.
  7. Learn to study the body language of your audience. Most of the time, when they are bored or if they think you are lying, you can read that from their body language.
  8. Deliver your presentation in clear voice, don’t use any accents.
  9. During your presentation, don’t keep looking at your laptop or the screen all the time. Stand Straight, make frequent eye contacts with the audience. Sweep the hall (across all the four corners) with your eye.
  10. If you can walk during the presentation walk but don’t run on stage. Make small and firm strides. If you keep walking left-and-right across the stage too fast, audiences will get a stiff neck. Remember, they are not watching a tennis-match!
  11. Never overshoot your time. Always keep a tab on time. Rehearsing your timing beforehand really helps here. {I normally keep my wrist watch in a comfortable viewing position for me to check the timing}.
  12. More than overshooting the time, it is very embarrassing if you finish well in advance. If you do it, you will appear to your audience as someone who doesn’t know enough on the topic.
  13. Finally once the presentation is over, speak to your friends (if they were present) or to the hosts and ask them for a honest/frank feedback. This is super critical for you to improve in future. Also speak to few of the audience, and casually ask them questions with an objective to understand how much of your topic has reached them.
  14. If the event was recorded (Video or Audio) asks your hosts to give you a copy of it. It is a good idea to carry a blank CD or Mini-DV cassette and give it to them along with your business card. This way they will remember to do the favour for you. 
  15. If there was a feedback form, take time after the event, talk to event organizers and go through atleast few tens of completed feedback forms in person. This is important, even if they promise to send an excellent report with all statistics and chart after the event. Reason being, by the time the well-prepared report comes, it will be couple of days/weeks and you would have gone to a different job/forgotten about the specifics of the presentation. So when the event is fresh in your mind, try to gather first-hand opinion.
  16. Presentations and Speaking are good oppurtunities to network. So carry good number of your business cards and give it to people whoever asks for it. If it is a product selling presentation you are doing, then it is a good idea to even keep some of the cards on the podium/dias for people to self-service. Also remember to talk to walk around with people if there is a lunch/dinner happening after the dinner.
  17. How irritating it is to hear a mobile phone ring during a presentation. Before you asking the audience, please remember to switch off your mobile and put it in away (say in your laptop bag). At times it will be a good idea to do it on stage while you start talking, this way you will set an example and reminder to others’ to do it, rather than asking them to do it.
  18. Finally, don’t leave your mobile or wallet or other valuables on podium/dias. There is every likelyhood, that after the presentation you will be preoccupied with questions from audience and you will forget to collect your items back.  
Health/Life Style Tips:
  1. Try to get a good-night sleep. For the audience, your eyes are the window to you, so a well-rested body has relaxed good-looking eyes. {Having said it, most of the times, I prepare my slide-decks the day before, but everytime when I practiced this, I felt my presentations to be much better}.
  2. Be in Rome as “Romans” do. So check with your host/event organizers on the dress code they are expect you. I normally stick to formals (no-tie or suit) for technical presentations, Suits for Business Presentations and Relaxed-formals for other presentations.
  3. Keep a bottle of water handy in the podium. When you are speaking, especially in an Air-Conditioned halls, your mouth gets dry very quickly.
  4. After a long presentation (60 - 90 minutes) when you are back home, a good mouth-gargle (with water/glycerin or salt-water) has a soothing effect.
Doing Technical Presentations:
  1. Learn the subject you are going to be presenting thoroughly. Today audiences have access to nearly all the information (or at times more) on the subject through Internet and if it is Microsoft Technologies through MSDN Online and various blogs.
  2. If you are stepping-in last minute for a different speaker, and you don’t have time to prepare fully on the subject, at-least take the effort of preparing a map of land-mines. These are list of topics/areas on the subject that you are not fully-aware, this way you can stay clear off (or atleast step on as gently as possible) of the land-mines.
  3. On an average for every slide you should budget 3 to 5 minutes, depending on the complexity. So a 90 minutes presentation, maximum you should have is 30 Slides. If you have demos, this number should come down.
  4. If you are talking about a particular product Never Criticize or Attack competition directly. If you have to do it, do it only after presenting strong data and statistics supporting your product. If you do it without data, it will result in a blood bath in the hall (needless to say most of the blood, would have come from your body). Always, try to remain factual in the presentation. At the same time, don’t hesitate to point out errors/omissions/defects in competition’s argument.
  5. During the presentation or especially during the demos, if you forget a particular step or point that you rehearsed don’t try yourself hard to remember it. Simply ignore it and move on.
  6. Don’t pause for undue duration in between, even if you are waiting for something else to happen (like application to load, compilation, etc). Continue talking during that time. This gap is useful for throwing some jokes & interesting points. In a way this will shake-up the audience and wake those you are sleeping.
Authoring Power Point Slide-Decks:
  1. Slides should be brief: Typically a single Power Point Slide shouldn’t contain more than 1 or 2 images and not more than 5 to 6 points. Remember MS Word is a better tool to write pages and essays and Power Point is a bad tool to write long paragraphs.
  2. Slides are only pointers: Continuing on the previous point, remember that the slides are only pointers for you to recollect and speak. The slides shouldn’t communicate the entirety to audience – if that is the case, you have no role to play in the hall, the audience can read it for themselves.
  3. Generally keep your slide background to a solid, light colour. Remember that projectors don’t show colour as great as your monitor and from a distance dark colour fonts appear on a light background appear clearer. {This is the reason why Cars around the world have their Numberplates in White or Yellow background and with Black colour lettering}.
  4. Avoid cliparts or cartoons unless they are absolutely necessary. Even if you use them, use sparingly. Remember, everyone in the audience would have for sure, seen the MS Office cliparts hundreds of time. I have seen in many PPTs, where the presenter has used almost all the Cliparts that Microsoft manages to ship with MS Office CD.
  5. Spend the time to learn Power Points powerful (less-used) feature of Master Slides (View-Master-Slide Master Menu).
  6. Reduce the number of times, you do changes to fonts and colours on individual slides. Continuing on previous point, try to make tweaking only to your Slide Master and let it run across your slide-deck.
  7. Reduce the usage of Serif Fonts. Try to use only Sans-Serif fonts for everything in your slides. Typefaces generally fall into two broad categories: serif and sans serif. Serif fonts, such as Times New Roman have little “tails” at the ends of each character stroke that lead a reader’s eye from character to character, increasing reading speed. Sans serif fonts, such as Arial and Verdana, don’t have these tails; as a result, reading is difficult for long passages of text because the eye isn’t moved from character to character.
  8. Don’t create Power Point templates from scratch. Use the templates that ship out-of-box with Power Point and then start tweaking them. For example if the background image you want use across all your slides is White-based, start with one of the standard templates that have white background, replace your background image and go from there. This way you will get best practices on fonts, colours and alignments for free and you only need to change things you don’t like.
  9. Most of the projectors are capable of doing only 1024×768 resolution, so make your slides/demos look good at that resolution.
Laptops, Audio-Video & Systems:
  1. Even if you are carrying your own laptop with the presentation loaded, have backups. Always have a copy of your PPT in a USB Thumb drive (and remember to carry it) or email it beforehand to the host of the event and request them to have it loaded on an alternate system.
  2. Check/Double-check all your hardware, cables, power-supply and software.
  3. Always run your laptop from Power-Supply. Even if your laptop can run for more time without power, than the length of the presentation, don’t use battery. Modern day laptops, reduce the speed of CPU if you are running with battery.
  4. Keep all the applications that you are demo’ing open before the start of the presentations. Most of the times applications tend to take more time when you are on stage.
  5. Increase your font size to say “20” in Notepad/VS.NET/IDE if you are showing Code.
  6. Stick to simpler font-faces like Courier or Tahoma, I believe source code looks good with these fonts.
  7. If this is the first time, you are doing a demo with this laptop – then connect your laptop to an external monitor and check the day(s) before.
  8. If you are going to be using a laptop for the first time during the presentation, then practice using a laptop before the presentation. The usage of touch-pad/pointer is completely a different feel from a mouse. Better still, request/carry a mouse and connect it before the presentation.
  9. Go 20-30 minutes early to hall/stage before the audiences comes in, then wire your laptop and check with the projectors. Try to build a “Rapo” with the A/V assistant there, remember he is your best friend in the entire hall during the presentation.
  10. If you need Internet connection, inform the Event Organizers well in advance (A week really helps). I have learned the hard-way that the grander the hall (the more stars if it is a Hotel) greater the difficulty for them to give you Internet Connection or Phone Connections. This pain is now relatively eased due to Internet connection through Mobile phones and WI-FI. Here again, on most halls for some reason (because they tend to be below ground) have poorest signal strength near the stages. So test it before hand.
  11. Remember that the Murphy’s law works at its best during technical presentations and especially during beta demos.
Sharing the stage:
  1. If you are doing the presentation with another speaker, remember to get the story-board discussed well in advance. Apart from doing this, you need to definitely rehearse once or twice. Because the chemistry on stage between you two is very important – and it doesn’t come that easily unless you know the other person very well and have worked/spoken with him before.
  2. If story board is not discussed before hand, then do “Divide and Conquer”. {If I am sharing a stage with a speaker who I haven’t met before – I normally do “divide and conquer”, meaning I clearly divide the portions between us. For example, it will be first “10” slides by me and the next “10” by the other speaker or it will be that I do all the Slides and the other person does all the demos. This way I avoid stepping on his/her shoes}.
  3. In the introduction slide, the hierarchy of names is important. Generally have the first name on the slide to be of the person who is going to do the major portion. If you are doing the presentation along with your superior/boss/client then it is etiquette to have their name first, even though you may be doing the major talking.
  4. If you are presenting along with your colleague, remember to give him/her adequate time to introduce and talk.
  5. If you finished a portion, the other speaker is starting, it is OK to say “Thank you” to you for the first time, but it shouldn’t be repeated at every switch.
  6. Divide the total time between you and have a pre-agreement on who is going to reduce their portion when time becomes short.
  7. When the other speaker is speaking, please don’t keep typing on your laptop or keep gesturing at your friend in the first row. Focus your attention, just like the audience on the speaker. If you do otherwise, it shows your disrespect for the speaker.
  8. Similarly, when the other speaker is doing a demo and forgets a step, don’t go bullish and help immediately. Give some time and after that try to convey the idea as discreetly as possible.
  9. Finally there can be only one captain to the ship, so agree between you that for the duration of the presentation, who is that captain. This basically means who can call the shots, when an emergency like demos not working, embarrassing question comes in, short of time, etc. Having a captain makes it easy and avoids conflicting fire-fighting decisions on stage. Remember, in situation like this, you have to think on your feet (sometimes it may not be logical/correct) and two people can never think the same quick-fix.
Answering Questions – Q & A:
  1. If you are new to doing presentations, don’t encourage taking questions during the talk. Announce to audience at the start, that you will take all questions at the end. Taking questions in-between, normally interrupts your flow and regaining your position is very difficult – you can very easily drift from your main message. Change this rule, once you have become an “Ace” in presentations. This is because, taking questions in-between creates a good ambience – somekind of positive interaction.
  2. Never get into an argument or a lengthy discussion – cut them after 60 seconds and take it offline.
  3. There are sections of people in the audience who ask questions – simply to say something they know or advertise about their company or announce to everyone that the food was bad or to say that they know the subject more than you do. If you suspect the question to be on these lines, interrupt the person immediately and request them to ask the “Actual” question they have in mind.
  4. Never let a question be answered by a member of audience. If you do it, then you will completely loose the audience and it will become a discussion session. You are the boss during your presentation, so ascertain your rights.
  5. If you get a question for which you are unsure of, politely say that you need to check on the facts before answering. Ask them to speak to you after session or tell them that you will check and email them back.
Finally relax, take your first presentation easy. Either good or bad, you will remember it for your life!!!

GIS-SAP Integration

May 2, 2008 by iamlaksh1

There are some active discussion going on some of social network sites on SAP-GIS Integration. I am also one who look for some specific information on integration of these two systems. I have searched continously and got some information which are useful for someone like me.  The GIS group in Larsen and Toubro (LNT) Infotech, Mumbai and TCS working on this integration. You can download their paper (won prize in ESRI) titled “DEVELOPMENT OF GIS-SAP INTERFACE FOR VALIDATION OF GEO-CODED ADDRESS” explains about application developed for electric utility company. “The GIS application was developed as a multi-threaded component implemented in the COM Model. The Arcobjects toolkit from ESRI forms the core of the component. SAP’s COM4ABAP software has been used as the middleware”. This is one example. ESRI has provided some docs on integration.  Here is list of some documents/paper for getting started.

1. GIS Best Practices : Using GIS and SAP , June 2007, ESRI

2. Technology Update : ESRI Internation User Conf 2005, ESRI SAP User group meeting

3. SAP/GIS Integration: Observation and practices by Stever Burner of ESRI

4. SAP Netweaver: ESRI-SAP competency centre, Europe (Good Document)

5. SAP Exchange Infrastructure (XI) by Carsten Pipel (Good document)

6. SAP Business data visualization with Map Objects (Year, 1999: Outdated one)

7.  GIS and beyond Looking to SAP through the Ge0-Window: Belgian water Utility, Pidpa

8 . Tacoma Economic Development: GIS Diversity, Address and 3D visualization (2004 paper)

9. MDM for SAP-GIS Integration: from SAP Labs (Good doc)

10. Map4SAP: An ArcGIS Solution for SAP : Peter Wikinson , ESRI (UC 2007)

11.  Mapping Data in SAP-Business Ware House: Mark T.Schnur, M.S.

12.  Mapping SAP-BW Data

and many more documents available in internet for further reading.

In general, SAP systems are very costly and resources are also scarce. Most of pure GIS companies in India are medium level companies hence affordablity to SAP system is  void. Big gaints can make use of GIS (Mapping) potentials to their existing system(SAP).Most of integration has been taken place with respect to ESRI Products. Open source GIS integration with SAP is also another viable option.

Any comments/suggestions are welcome!.

.NET Performance tips on using Strings

April 30, 2008 by iamlaksh1

Here is an interesting tech analysis on String in .NET.    Rico Marains .NET Blog gives wonderful analysis of internal process. Excerpt is copied from his blog for first reading. I suggest you to read his blog worths lot. 

“Recently there was a discussion on one of our internal email aliases in which this problem came up. I though it was an interesting problem so I posed this Quiz to assorted people I work with to see what kinds of things they would say.

Considering these three options:

Option 1:

sw.WriteLine(subject + “: ” + message);

Option 2:

sw.WriteLine(”{0}: {1}”, subject, message);

Option 3:

sw.Write(subject);
sw.Write(”: “);
sw.WriteLine(message);

Answer these questions:

Q1. Which of these choices offers the best performance?
Q2: Can you characterize the memory usage of each of these?
Q3: Which would the performance team generally recommend, and why?
Q4: What special factors might alter this recommendation?
Q5: What did you have do assume about “sw” to answer the question?

I encourage you to think about this for a few minutes (more is good too) before reading past the line. SPOILERS/ANSWERS follow.


For everyone that took the time to think about this at all, thank you very much.In the course of my job I’m often asked to comment of the probable performance of an assortment of solutions to give guidance, or at least suggest what measurements should be made. So I approached this quiz the same way and made my best guesses/recomendations as I would if I could not do the measurements. Then I went back and did the actual measurements.

Here are my own answers:

Q1. Which of these choices offers the best performance?

  • Only thing I can say for sure is that #2 will lose to #1 in all cases
  • #3 is going to be best if the output is buffered
  • #1 is going to be best if the output is unbuffered
  • In any case, a typical program’s overall performance will be unaffected by the choice

Q2: Can you characterize the memory usage of each of these?

(These answers all proved to be “close but no cigar” due to the unusual WriteLine behavior discussed in the real analysis, see below)

All three probably have allocations associated with buffering the stream, ignoring those as invariant, the allocations unique to each choice are:

#1 single concat operation, one temporary string
#2 assorted allocations, including string builder, underlying string buffer, vararg array (I was close)
#3 no allocations

Q3: Which would the performance team generally recommend, and why?

Even though it’s the worst performing, and we knew that much in advance, both of your CLR Performance Architects concur that #2 should be the default choice. In the highly unlikely event that it becomes a perf problem the issue is readily addressable with only modest local changes. Normally you’re just cashing-in on some nice maintainability. We do not alter our choice given the data below.

Q4: What special factors might alter this recommendation?

Specific measurements indicating that the code path had become a hotspot.

Q5: What did you have do assume about “sw” to answer the question?

Only that the stream did not have exotic behavior (such as weird cryptographic features that make the cost model very complex) and that it was buffered. In the event of an unbuffered stream of one type or another there are signficant semantic differences between (1 or 2) and (3) and potentially huge perf differences too.

OK, time to see how we did.

To do the analysis below I used the following benchmark program and CLR Profiler, which is one way to look at this data.

namespace Test
{
    using System;
    using System.IO;
 
    class Test
    {
        static private String s1 = “Hello”;
        static private String s2 = “Good bye”;
        static private int iterations = 5;
        static private volatile int foo = 0;
 
        static private MemoryStream ms = new MemoryStream(100000);
        static private StreamWriter sw = new StreamWriter(ms);
 
        public static void Main(string[] args)
        {
            int i;
 
            for (i=0;i<iterations;i++) Test1();
            for (i=0;i<iterations;i++) Test2();
            for (i=0;i<iterations;i++) Test3();
        }
 
        public static void Test1()
        {
            sw.WriteLine(s1+”: “+s2);
            foo++;
        }
 
        public static void Test2()
        {
            sw.WriteLine(”{0}: {1}”, s1,s2);
            foo++;
        }
 
        public static void Test3()
        {
            sw.Write(s1);
            sw.Write(”: “);
            sw.WriteLine(s2);
            foo++;
        }
    }
}

The results below are in the form of an execution trace showing functions and allocations for each of the three options as reported by CLRProfiler”. Continued here

ASP.NET state management

April 30, 2008 by iamlaksh1

ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it’s difficult to decide where you should put things and how to make that decision.

You choices for state management include:

  • Application - Stored on the server and shared for all users. Does not expire.  Deprecated by Cache (below).
  • Cache - Stored on the server and shared for all users. Can expire.
  • Session - Stored on the server.  Unique for each user.  Can expire.
  • ViewState - Stored in a hidden page input (by default).  Does not expire.
  • Cookies - Stored at the client. Can expire.
  • QueryString - Passed in the URL.  Must be maintained with each request.
  • Context.Items - Only lasts for one request’s lifetime.