Hello I'm shocked. You, Philip, were absolutely right. When I moved poins collection into new variable working time decreased to less than minute for 4000 objects. I can't understand such a logic... very strange. I'm so gratefull to you.Thanks so much. Now i'll try to remake all the code depending on such logic
Katrin, I'll have a closer look tomorrow, but other things to think about: 1. Possibly the same logic applies to the parts object, so frequent refs to ftr1.parts might be summarised as a parts object. 2. Then it gets down to geometry checks. MBR checks are much quicker than INTERSECT, so if you can filter some of your data by checking if the MBR's dont overlap, it might help (see MBR fn). Regards, Phil. ----- Original Message ----- From: Katrin To: Philip Waight Sent: Wednesday, November 19, 2003 6:43 PM Subject: [EMAIL PROTECTED] Thanks a lot, Philip, for your answer It gives me an advantage about 15%. I'm surprized. :) Is there anything more here to correct? What about the second question - it bothers me mostly. I'm fairly sure this will help ... In the lines ... For iCount = 1 To CurLayer.AllFeatures.Count Set ftr1 = CurLayer.AllFeatures.Item(iCount) especially the second line, Mapx will extract all features from the layer on each call. So i think a previous line of: set allftrs = Curlyr.Allfeatures For iCount = 1 To allftrs.Count Set ftr1 = allftrs.Item(iCount) ... Regards. ----- Original Message ----- From: "Katrin" To: Sent: Tuesday, November 18, 2003 11:32 PM Subject: MI-L Defining cross-roads MapX > Hello All > Could you help me with my problem. I'm using MapX 4.5, work with road network. My aim is to define point of crossings, where roads intersect in such a way that for at least one road intersection point is not the end or start point of this line. I'll try to show this as an example: > > \ / or ======= > X | > / \ | > > > 1. Define such intersection points > 2. Divide each line into two at this intersection point > > 1. problem I've already solved but it's quite slow - 20 minutes for 4000 objects. May be I do something wrong. Below is my code. Have you some ideas for optimizing it? > > Map1.DisplayCoordSys = CurLayer.CoordSys > Map1.NumericCoordSys = CurLayer.CoordSys > > CurLayer.BeginAccess miAccessRead > Clayer.BeginAccess miAccessReadWrite > > For iCount = 1 To CurLayer.AllFeatures.Count > Set ftr1 = CurLayer.AllFeatures.Item(iCount) > > StartPtX = ftr1.Parts.Item(1).Item(1).X > STartPtY = ftr1.Parts.Item(1).Item(1).Y > EndPtX = ftr1.Parts.Item(ftr1.Parts.Count).Item(ftr1.Parts.Item(ftr1.Parts.Count).Cou nt).X > EndPtY = ftr1.Parts.Item(ftr1.Parts.Count).Item(ftr1.Parts.Item(ftr1.Parts.Count).Cou nt).Y > > Set ftrs = CurLayer.SearchWithinFeature(ftr1, miSearchTypePartiallyWithin) > For i = 1 To ftrs.Count > Set ftr2 = ftrs.Item(i) > If ftr2.FeatureKey <> ftr1.FeatureKey Then > > Set pts = Map1.FeatureFactory.IntersectionPoints(ftr1, ftr2, miIntersectAll) > For j = 1 To pts.Count > If Not (pts.Item(j).X = StartPtX And pts.Item(j).Y = STartPtY) And Not (pts.Item(j).X = EndPtX And pts.Item(j).Y = EndPtY) Then > Set AddFtr = Map1.FeatureFactory.CreateSymbol(pts.Item(j)) > AddFtr.Attach Map1 > Clayer.AddFeature AddFtr, RVals2 > End If > Next > End If > Next > Next > CurLayer.EndAccess miAccessEnd > Clayer.EndAccess miAccessEnd > > 2. I can't imagine how to do this more effective than define (while loop through the whole polyline segment) where the intersection point lies and create two polylines. I doubt it won't take much time. May be there's another, more simple way to make two polylines from one dividing them at definite point. > > I'll be very gratefull for any answers > > > Best Regards, > Katerinka > > --------------------------------- > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard Best Regards, Katerinka --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard Best Regards, Katerinka --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
