Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to convert a Google Maps polygon object (can has multi paths and holes) to wkt string (multipolygon) at client. Then i'll able to save polygon as geography in Sql Server 2012.

I tried Wicket (https://github.com/arthur-e/Wicket) but it has a bug converting multipolygons.

Is there any ready to use library? Any ideas, please?

Thanks.

share|improve this question
    
Can you share the code of the object or a sample object? –  johanvdw Jun 17 '13 at 13:47

2 Answers 2

I just enabled multipolygon support (Arrays of google.maps.Polygon instances) in Wicket, version 1.0. Clone the "master" branch or download the 1.0 release.

share|improve this answer

If you can iterate the rings and holes you can do this yourself. Format is pretty simple. Pseudocode:

emit 'MULTIPOLYGON('

for each ring

  if it's not the first ring emit ','

  emit '(' 

  emit '('


    for each point in ring
     if it's not the first point emit ','

     emit X

     emit ' '

     emit Y

     end point loop
  emit ')'


  for each hole in ring

   emit ',('

     for each point in hole

      if it's not the first point emit ','

      emit X

      emit ' '

      emit Y

   end point loop

  emit ')'

  end hole loop

emit ')'

end ring loop

emit ')'
share|improve this answer
    
Tomislav, thanks for the formatting. –  Russell at ISC Jun 17 '13 at 14:36
    
I'm curious why the thumbs down. I don't believe there is any error, is there a disliking for pseudocode in general in this forum? –  Russell at ISC Jun 17 '13 at 14:37
1  
thanks for the answer, but there is no way to get rings and it's inner rings from google maps polygon object. it contains all paths but no containment information. –  evren Jun 17 '13 at 17:30
    
-1 because the pseudo-code cannot be applied with google map api –  Below the Radar Jun 17 '13 at 19:19
    
Ah. Bummer. Appreciate the explanation. –  Russell at ISC Jun 18 '13 at 17:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.